akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

signed main(){

  int h,w;
  cin>>h>>w;

  auto a = vec<int>(h,w);
  auto b = a;
  auto dif = a;

  cin>>a>>b;

  rep(i,h)rep(j,w){
    dif[i][j] = abs(a[i][j]-b[i][j]);
  }

  constexpr int bias = 80*80;
  auto dp = vec<bitset<bias*2+1>>(h,w);
  dp[0][0][bias+dif[0][0]] = 1;
  dp[0][0][bias-dif[0][0]] = 1;

  rep(i,h)rep(j,w){
    if(i>0){
      dp[i][j] |= (dp[i-1][j]<<dif[i][j]);
      dp[i][j] |= (dp[i-1][j]>>dif[i][j]);
    }
    if(j>0){
      dp[i][j] |= (dp[i][j-1]<<dif[i][j]);
      dp[i][j] |= (dp[i][j-1]>>dif[i][j]);
    }
  }

  ll ans = INF;
  rep(i,bias*2+1){
    if(dp[h-1][w-1][i])ans = min(ans,(ll)abs(bias-i));
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 10496
#include <stdio.h>
int m[100][100];
int p[100];
int n;

void matrix();
int min(int, int);

int main(){
  int i,j;

  scanf("%d",&n);

  for(i=1;i<=n;i++) scanf("%d%d",&p[i-1],&p[i]);

  matrix();


  printf("%d\n",m[1][n]);


  return 0;
}

void matrix(){
  int i,j,k,l,a;
  for(i=1;i<=n;i++) m[i][i] = 0;

  for(l=2;l<=n;l++) {
    for(i=1;i<=n-l+1;i++) {
      j = i + l - 1;
      m[i][j] = 100000000;
      for(k=i;k<j;k++){
        a = min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
        m[i][j] = a;
      }
    }
  }
}

int min(int a, int b){
  if(a>b) return b;
  else return a;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod =1e9+7;
ll qui(ll n,ll m){
    ll ans =1;
    while(m){
        if(m&1){
            ans *=n;
            ans %=mod;
        }
        m >>=1;
        n *=n;
        n %=mod;
    }
    return ans;
}
int main(){
    ll n;
    cin>>n;
    ll res =qui(10,n)-qui(9,n)*2+qui(8,n);
    res =(res%mod+mod)%mod;
    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 3620
from heapq import heappush, heappop
def main():
    N=int(input())
    road=[[float("inf") for _ in range(N)]for _ in range(N)]
    pq=[]
    ans=0
    for i in range(N):
        road[i][i]=0
        tmp=list(map(int,input().split()))
        for j in range(i+1,N):
            heappush(pq,(tmp[j],i,j))

    while pq:
        v=heappop(pq)
        d,i,j=v[0],v[1],v[2]
        tmp=road[i][j]
        for k in range(N):
            tmp=min(tmp,road[i][k]+road[k][j])
            if tmp==d:
                break
        if tmp>d:
            road[i][j]=d
            road[j][i]=d
            ans+=d
        elif tmp==d:
            road[i][j]=d
            road[j][i]=d
        else:
            print(-1)
            exit()
    print(ans)
main()

Measured memory_bytes: 62172
#include <stdio.h>

int main(void)
{
	int H, W, i, j;
	
	do {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
			break;
		
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1)
					putchar('#');
				else
					putchar('.');
			}
			putchar('\n');
		}
		putchar('\n');
	} while (1);
	
	return 0;
}

Measured memory_bytes: 572
N, T = map(int, input().split())
ct = []
for i in range(N):
    ct.append(list(map(int, input().split())))

ct_1 = sorted(ct, key=lambda h: (h[0], h[1]))
ct_2 = sorted(ct, key=lambda h: (h[1], h[0]))

for i in range(N):
    if ct_1[i][1]<=T:
        print(ct_1[i][0])
        break

if ct_2[0][1]>T:
    print('TLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;


int main(){
    int A, B, C, K;
    scanf("%d %d %d %d", &A, &B, &C, &K);

    int sum;
    if (K <= A){
        sum = K;
    }else if (K <= A + B){
        sum = A;
    }else{
        sum = A - (K - A - B);
    }
    
    cout << sum << endl;
    
    
}

Measured memory_bytes: 3756
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int cnt = s.nextInt();
		int[] values = new int[cnt];
		for(int i=0 ; i<cnt ; i++) {
			values[i] = s.nextInt();
		}
		solve(values);
	}

	public static void solve(int[] values) {
		int change = 0;
		for(int i=0 ; i<values.length ; i++) {
			int min = i;
			for(int j=i ; j<values.length ; j++) {
				if(values[min] > values[j]) {
					min = j;
				}
			}
			if(min != i) {
				int tmp = values[min];
				values[min] = values[i];
				values[i] = tmp;
				change++;
			}
		}
		String sortedStr = "";
		for(int k=0 ; k<values.length ; k++) {
			if(k != values.length - 1)
				sortedStr += values[k] + " ";
			else
				sortedStr += values[k];
		}
		System.out.print(sortedStr + "\n");
		System.out.println(change);
	}
}

Measured memory_bytes: 18272
#include<cstdio>
#include<map>
#define LL long long
#define mod 1000000007
using namespace std;
map<LL,LL> mp;
LL p(LL x)
{
	if(mp.count(x)) return mp[x];
	if(x==1) return 1;
	if(x%2ll) return mp[x]=(p((x-1)/2ll)+p((x+1)/2ll))%mod;
	return mp[x]=p(x/2ll);
}
LL calc(LL x)
{
	if(x==1) return 1;
	if(x%2ll) return (calc(x/2ll)*3ll+p(x/2ll+1))%mod;
	return (calc(x/2ll)*3ll-p(x/2ll)+mod)%mod;
}
int main()
{
	LL n;
	scanf("%lld",&n);
	printf("%lld\n",calc(n+1));
}

Measured memory_bytes: 256
[<EntryPoint>]
let main argv =
    //printfn "Gokigenyou!" 
    let s = System.Console.ReadLine()
    let ans =
        match s with
        | "Sunny" -> "Cloudy"
        | "Cloudy" -> "Rainy"
        | "Rainy" -> "Sunny"
        | _ -> failwith "error."
    System.Console.WriteLine(ans)
    0


Measured memory_bytes: 11092
import java.io.*;
import java.util.*;

public class Main {

	
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
	//	int t=in.nextInt();
	//	while(t-->0)
		solve(in,out);
		out.close();
	}

    static void solve(FastScanner in,PrintWriter out){
     int n=in.nextInt();
     char s[]=in.next().toCharArray();
     char t[]=in.next().toCharArray();
     for(int i=0;i<n;i++){
         out.print(s[i]); out.print(t[i]);
     }out.println();
    }    
	


	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 32960
D = {0: 1}
N = int(input())
A = list(map(int, input().split()))
S = 0
for i in range(N):
  S += A[i]
  if S in D:
    D[S] += 1
  else:
    D[S] = 1
p = 0
for i in D:
  p += (D[i] * (D[i] - 1)) // 2
print(p)

Measured memory_bytes: 38644
#include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    cout << N/3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    string s,t;
    cin >> s;
    cin >> t;

    sort(s.begin(),s.end());
    sort(t.begin(),t.end());

    reverse(t.begin(),t.end());

    if (s < t) {
        cout << "Yes" << endl;
    }else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
constexpr int mod = 1e9 + 7;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  for(int i = 0; i < n; ++i) cin >> A[i];
  vector< vector<long long int> > DP(n+1, vector<long long int>(1<<8, 0));
  DP[0][0] = 1;
  for(int i = 0; i < n; ++i){
    vector< vector<long long int> > DP_ = DP;
    for(int j = 0; j < n; ++j){
      for(int k = 0; k < (1<<8); ++k){
        DP_[j+1][k^A[i]] += (DP[j][k]*(j+1))%mod;
        DP_[j+1][k^A[i]] %= mod;
      }
    }
    DP = DP_;
  }
  int ans = 0;
  for(int i = 0; i <= n; ++i){
    ans += DP[i][k];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 712
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }
long long int knapSack(long long int W,long long  int wt[],long long  int val[],long long  int n)
{
   long long int i, w;
   long long int K[n+1][W+1];
 
   // Build table K[][] in bottom up manner
   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }
 
   return K[n][W];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif   
    int n,tot;
    cin>>n>>tot;
    int t[n];
    long long int end = 0;
    long long int ans = 0;
    for(int i=0;i<n;i++)
    {
        cin>>t[i];
    }
    ans = ans+tot;
    for(int i=n-1;i>=0;i--)
    {
        if(i!=0)
            if(t[i]-t[i-1]>=tot)
                ans=ans+tot;
            else
            {
                ans=ans+(t[i]-t[i-1]);
            }
    }
    cout<<ans<<endl;

    // long long int n,w;
    // cin>>n>>w;
    // long long int wt[n],val[n];
    // for(int i=0;i<n;i++)
    // {
    //     cin>>wt[i]>>val[i];
    // }
    // long long int ans = knapSack(w,wt,val,n);
    // cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	vi A(3); cin>>A[0]>>A[1]>>A[2];
	sort(all(A));
	int ans = A[2] - A[0];
	ote(ans);
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
ans1 = 0
ans2 = 0
index = N
for i in range(N-1):
    if A[i] == A[i + 1]:
        ans1 = A[i]
        index = i + 2
        break
for j in range(index, N - 1):
    if A[j] == A[j + 1]:
        ans2 = A[j]
        flag = 1
        break

print(ans1*ans2)


Measured memory_bytes: 14252
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int k,t;cin>>k>>t;
    vector<int> vec(t);
    if(t==1){cin>>k;cout<<k-1<<endl;return 0;}
    for(int i=0;i<t;i++)cin>>vec[i];
    sort(all(vec),greater<int>());
    int ans;
    if(vec[0]==vec[1])ans=0;
    else{
        int tmp=0;
        for(int i=1;i<t;i++)tmp+=vec[i];
        if(tmp<vec[0])ans=vec[0]-tmp-1;
        else ans=0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
import sys
N,A,B = [int(n) for n in input().split()]
#  = int(input())
ans = 0
for i in range(N+1):
    s = [int(s) for s in str(i)]
    if(sum(s)>=A and sum(s)<=B):
        ans+=i
print(ans)
# print(sum([1,2,3]))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int M = 1e9 + 7;

ll mul(ll a, ll b) {
    return a * b % M;
}

int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    vector<ll> arr(N);
    for (auto& v : arr) {
        cin >> v;
    }
    ll res = 0;
    for (int b = 0; b < 60; b++) {
        ll v = 1LL << b;
        ll n = 0;
        for (int i = 0; i < N; i++) {
            if (arr[i] & v) {
                n++;
            }
        }
        res += mul(mul(n, N - n), v % M);
        res %= M;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000




int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> a(M),b(M);
	
	for(int i=0;i<M;i++){
		cin>>a[i];
		int k;
		cin>>k;
		int mask = 0;
		for(int j=0;j<k;j++){
			int bb;
			cin>>bb;
			bb--;
			mask |= (1<<bb);
		}
		b[i] = mask;
	}
	
	vector<vector<long long>> dp(M+1,vector<long long>((1<<N),Inf));
	dp[0][0] = 0;
	
	for(int i=0;i<M;i++){
		for(int j=0;j<(1<<N);j++){
			if(dp[i][j]==Inf)continue;
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
			int mask = (j|b[i]);
			dp[i+1][mask] = min(dp[i+1][mask],dp[i][j]+a[i]);
		}
	}
	/*
	for(int i=0;i<=M;i++){
		for(int j=0;j<(1<<N);j++){
			cout<<dp[i][j]<<',';
		}
		cout<<endl;
	}*/
	
	if(dp[M][(1<<N)-1]!=Inf){
		cout<<dp[M][(1<<N)-1]<<endl;
	}
	else{
		cout<<-1<<endl;
	}
		
	
	return 0;
}



Measured memory_bytes: 32384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        while(n%7!=0){
            n-=4;
            if(n<4&&n!=0){
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 24020
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
    int A,B,C,K; cin >> A >> B >> C >> K;

    int a = 0, b = 0, c = 0; //それぞれの枚数

    // Aをとる
    while(A > 0 && K > 0){
        A -= 1; K -= 1 ;
        a++;
        
    }

    while(B > 0 && K > 0){
        B -= 1; K -= 1 ;
        b++;
    }

    while(C > 0 && K > 0){
        C -= 1; K -= 1 ;
        c++;
    }

    cout << a - c << endl;

    

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    bool n = false;
    bool e = false;
    bool s = false;
    bool w = false;

    string a;
    cin >> a;

    rep(i, a.length()) {
        if (a[i] == 'N') n = true;
        else if (a[i] == 'W') w = true;
        else if (a[i] == 'E') e = true;
        else if (a[i] == 'S') s = true;
    }

    bool can = false;

    if (n && w && e && s) can = true;
    else if (n && !w && !e && s) can = true;
    else if (!n && w && e && !s) can = true;

    Yes(can);

    return 0;
}



Measured memory_bytes: 256
function main(input: string) {
  const [N, hs] = input.split("\n").map((v,i) => i % 2 === 0 ? parseInt(v) : v.split(" ").map(vv=>parseInt(vv)));
  const arr = new Array(N);
  arr.fill(Infinity);
  arr[0] = 0 // 初期値
  for (let i = 1; i < N; i++) {
    // 2個前から
    if (i - 2 >= 0) {
      arr[i] = Math.min(arr[i], arr[i-2] + Math.abs(hs[i] - hs[i-2]));
    }
    // 1個前から
    if (i - 1 >= 0) {
      arr[i] = Math.min(arr[i], arr[i-1] + Math.abs(hs[i] - hs[i-1]));
    }
  }
  console.log(arr[N-1]);
}

main(
  require("fs")
    .readFileSync("/dev/stdin", "utf8")
    .trim()
);


Measured memory_bytes: 27808
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        A: usize,
        B: usize,
        C: usize,
        D: usize
    }
    let s = std::cmp::max(A,C);
    let e = std::cmp::min(B,D);

    if e < s {
        println!("0");
    }else{
        println!("{}",e - s);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N %2 == 0){
    cout << (N*(N-1) - (N-1))/2 << endl;
    for(int i=1; i<=N; i++){
      for(int j=i+1; j<=N; j++){
        if(j != N - i + 1){
          cout << i << " " << j << endl;
        }
      }
    }
  }
  else{
    cout << (N*(N-1) - (N-1))/2 << endl;
    for(int i=1; i<=N; i++){
      for(int j=i+1; j<=N; j++){
        if(j != N - i){
          cout << i << " " << j << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 256
function Main() {
  var input = require("fs").readFileSync("/dev/stdin", "utf-8").trim();
  var items = input.split(" ").map(function(item) { return parseInt(item); });
  items.sort();
  var target = [5, 5, 7];
  var flag = true;
  for (var i = 0; i < 3; ++i) {
    if (items[i] != target[i]) {
      flag = false;
      break;
    }  
  }
  console.log(flag ? "YES" : "NO");
}

Main();


Measured memory_bytes: 21192
import sys
S = list(input())
N = len(S)
S_r = list(reversed(S))
if S == S_r:
    # (N-1)/2を抜き出す
    S_2 = S[:int((N-1)/2)]
    S_2_r = list(reversed(S_2))
    if S_2 == S_2_r:
        S_3 = S[int((N+3/2)):N]
        S_3_r = list(reversed(S_3))
        if S_3 == S_3_r:
            print('Yes')
            sys.exit()
print('No')



Measured memory_bytes: 3060
#include<cstdio>
#define ll long long
int main(){
	ll l,r;scanf("%lld%lld",&l,&r);
	int p=0,q;while(l>>p+1!=r>>p+1)p++;
	ll v=r>>p<<p;for(q=p;q&&!(r>>q-1&1);q--);
	printf("%lld\n",v+(1ll<<q)<l+(1ll<<p)?v-l+v+(1ll<<q)-l:v+(1ll<<p)-l);
}

Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc a1s a2s 0 m = m
calc a1s a2s n m = calc a1s a2s (n -1) m''
  where
    m' = sum (take n a1s) + sum (drop (n -1) a2s)
    m'' = if m' > m then m' else m

main = do
  n <- getInt
  a1s <- getIntList
  a2s <- getIntList
  print $ calc a1s a2s n 0


Measured memory_bytes: 3760
#include <iostream>
#include <string>
using namespace std;

int main(){
    int n,i,maxi=0,sum=0;
    cin >> n;
    int p[n];
    for (i=0;i<n;i++){
        cin >> p[i];
        sum += p[i];
        if (p[i] > maxi){
            maxi = p[i];
        }
    }
    sum -= maxi/2;
    cout << sum;
}





Measured memory_bytes: 892
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 100100
using namespace std;

int main()
{
	long long n, a = 0, b; 
	scanf("%lld", &n);
	if (n % 2) printf("0");
	else {
		for (b = 5; b < n; b *= 5) {
			a += (n / b) / 2;
		}
		printf("%lld", a);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
  int n,x,y,z,i,j;

  scanf("%d",&n);
  int A[n][n];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      A[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&x,&y);
    for(j=0;j<y;j++)
      {scanf("%d",&z);
	A[x-1][z-1]=1;}
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",A[i][j]);
      if(j==n-1)printf("\n");
      else printf(" ");
    }
  }
  return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;

int main(){
    while(1) {
        int n;
        cin >> n;
        if (n == 0) break;

        vector<char> ope(n);
        vector<vector<int>> num(n);

        int cnt = 0;
        int pre_cnt = 0;
        for (int i = 0; i < n; i++){

            string s;
            cin >> s;
            cnt = 0;
            int k = (int)s.size();

            for (int j = 0; j < k; j++) {
                if (s[j] == '.') cnt++;
                else {
                    if (pre_cnt > cnt){
                        for (int p = n - 1; p > cnt; p--){
                            if (num[p].size() == 0) continue;
                            int tmp = num[p][0];
                            for (int q = 1; q < num[p].size(); q++){
                                if (ope[p-1] == '*') tmp *= num[p][q];
                                else tmp += num[p][q];
                            }
                            num[p].clear();
                            num[p-1].push_back(tmp);
                        }
                    }

                    if (s[j] == '+' || s[j] == '*'){
                        ope[cnt] = s[j];
                    }
                    else num[cnt].push_back(s[j] - '0');
                }
            }

            pre_cnt = cnt;
        }

        for (int i = n - 1; i > 0; i--){
            if (num[i].size() == 0) continue;
            int tmp = num[i][0];
            for (int j = 1; j < num[i].size(); j++){
                if (ope[i-1] == '*') tmp *= num[i][j];
                else tmp += num[i][j];
            }
            num[i-1].push_back(tmp);
        }
        cout << num[0][0] << endl;
    }
}


Measured memory_bytes: 3124
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char c[55][55];
int main() {
	int h, w;
	cin >> h >> w;
	ll count = 0;
	vector<P>p;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
			if (c[i][j] == '#') {
				p.push_back(make_pair(i, j));
				count++;
			}
		}
	}

	bool ok = true;
	for (int i = 0; i < count; i++) {
		if (i != count - 1) {
			if (p[i].first == p[i + 1].first) {
				for (int j = p[i].second; j <= p[i].second; j++) {
					if (c[p[i].first][j] == '.') {
						ok = false;
					}
				}
			}

			else {
				if (p[i].second != p[i + 1].second) {
					ok = false;
				}
			}
		}
	}
	if (ok) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<string.h>
#include<cmath>

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	int pos;
	for (int i = 0; i < n; i++) {
		cin >> pos;
		ans += 2 * min(abs(pos), abs(pos - k));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
using namespace std;

int main() {
    int N;
    cin >> N;

    bool ok = true;
    rep(i, N) {
        int A;
        cin >> A;
        if (A % 2 != 0) continue;
        if (A % 3 != 0 && A % 5 != 0) ok = false;
    }

    if (ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
dp = Array.new(n+10){Array.new(3, 0)}
happy = []
n.times do |i|
  happy << gets.split.map(&:to_i) 
end

n.times do |i|
  3.times do |k|
    dp[i+1][0] = [dp[i+1][0], dp[i][k]+happy[i][0]].max if k != 0 # k -> 0への遷移
    dp[i+1][1] = [dp[i+1][1], dp[i][k]+happy[i][1]].max if k != 1
    dp[i+1][2] = [dp[i+1][2], dp[i][k]+happy[i][2]].max if k != 2
  end
end

#p happy
#p dp
p dp[n].max

Measured memory_bytes: 25596
#include <bits/stdc++.h>

using namespace std;
#define BUF (100005)
#define ll long long 

int n, k;
long long a[BUF];
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
	cin >> n >> k;
	for(int i=1;i<=n;i++) cin >> a[i];
	COMinit(); //init table

	sort(a+1,a+n+1);
	long long ans = 0;

	//calc max
	for(int i=n;i>=k;i--){
		ans = ans + a[i]*COM(i-1, k-1)%MOD;
	}

	//calc min
	for(int i=1;i<=n-k+1;i++){
		ans = ans - a[i]*COM(n-i, k-1)%MOD;
	}

	cout << (ans+MOD)%MOD << endl;
	return 0;
}


Measured memory_bytes: 12928
#include <iostream>

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b % MOD;
    if (n % 2 == 0) {
        return mypow(b * b % MOD, n / 2);
    } else {
        return mypow(b, n - 1) * b % MOD;
    }
}

int main() {
    int S;
    cin >> S;

    ll ans = 0;
    int r = 0, sum = 0;
    int ldig = 0, rdig = 0, lten = 1, rten = 1;

    // l<10^8
    for (int l = 1; l < 100000000; ++l) {
        if (l == lten) ++ldig, lten *= 10;

        while (sum < S) {
            ++r;
            if (r == rten) ++rdig, rten *= 10;
            sum += rdig;
        }

        if (sum == S) ++ans;
        sum -= ldig;
    }

    // 以降、区間長で総当たり
    for (int t = 1; t * 9 <= S; ++t) {
        int d = S / t;

        if (S % t == 0) {  // f(l)=f(r)=dの場合
            ans += mypow(10LL, d - 1) * 9 - t + 1 + MOD;
        } else {  // f(l)=f(r)-1=dの場合
            ++ans;
        }
    }

    cout << ans % MOD << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
#include <set>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

struct RollingHash {
    vector<unsigned long long> hash, power;
    const unsigned int seed = 10007, mod  = 1e9 + 7;

    RollingHash(const string &s) {
        int n = (int)s.size();
        hash.assign( n + 1, 0);
        power.assign(n + 1, 1);
        for(int i = 0; i < n; ++i) power[i+1] = power[i] * seed % mod;

        for(int i = 0; i < n; ++i) {
            hash[i+1]  = (hash[i] * seed + s[i]) % mod;
            power[i+1] = power[i] * seed % mod;
        }
    }

    // [l, r)
    unsigned long long get_hash(int l, int r) {
        unsigned long long ret = (hash[r] - hash[l] * power[r-l] % mod + mod) % mod;
        return ret;
    }
};

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    RollingHash rh1(s), rh2(t);
    unsigned long long thash = rh2.get_hash(0, t.size());
    for(int i=0; i < s.size(); ++i) 
        if(rh1.get_hash(i, i + t.size()) == thash) cout << i << '\n';
    return 0;
}



Measured memory_bytes: 19764
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(2e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    
    int n;
    cin>>n;
    vector<pair<int,int>> v[n+1];
    for(int i=0;i<n;i++){
    	int a;
    	cin>>a;
    	for(int j=0;j<a;j++)
		{
			int x,y;
			cin>>x>>y;
			v[i+1].pb({x,y});
		}
    }
    int ans =0;
    for(int i=1;i<(1<<n);i++){
    	int flag = 1;
    	int tmp[n+1]={0};
    	for(int j=0;j<n;j++)
    		tmp[j+1] = ((i&(1<<j))>=1);
    	// cout<<i<<tmp[1]<<tmp[2]<<endl;
    	for(int in=0;in<n;in++){
    		if(!tmp[in+1])
    			continue;
    		for(auto it:v[in+1]){
    			int x = it.ff,y = it.ss;
    			if(tmp[x]!=y){
    				// cout<<tmp[x]<<" "<<x<<" "<<i<<endl;
    				flag = 0;
    			}
    		}
    	}
    	if(flag)
    		ans = max(ans,setbits(i)*1LL);
    }     
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int inf = ( 1 << 28);

int dp[20001][256];
int solve(int n,int m,int *cbook,int *in){
  rep(i,n+1)rep(j,256)dp[i][j]=inf;
  dp[0][128]=0;

  rep(i,n){
    rep(j,256){
      rep(k,m){
	int next=j+cbook[k];
	if (next<0)next=0;
	else if (next>255)next=255;
	dp[i+1][next]=min(dp[i+1][next],dp[i][j]+(next-in[i])*(next-in[i]));
      }
    }
  }
  
  int ans = inf;
  rep(i,256)ans=min(ans,dp[n][i]);
  return ans;
}


main(){
  int n,m;
  int in[20000],cbook[200];
  while(cin>>n>>m && n){
    rep(i,m)cin>>cbook[i];
    rep(i,n)cin>>in[i];
    cout << solve(n,m,cbook,in) << endl;
  }
}

Measured memory_bytes: 20000
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[2]);
            Console.WriteLine(line[1] == "+" ? A + B : A - B);
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int r = 0;
		int l = 0;
		for(int i=0;i<S.length()-1;i++) {

			if(S.charAt(i) == 'R') {
				r++;
			}else {
				l++;
			}

			if(i == S.length()-2) l++;

			if((S.charAt(i) == 'L' && S.charAt(i+1) == 'R') || i == S.length()-2) {
				calclist(r,l);
				r=0;
				l=0;
			}
		}


	}

	public static void calclist(int r,int l){

		int left =  (int) Math.ceil((double)r/(double)2) + (int) Math.floor((double)l/(double)2);
		int right = (int) Math.ceil((double)l/(double)2) + (int) Math.floor((double)r/(double)2);
		for(int i=1;i<r;i++) {
			System.out.print(0 + " ");
		}
		System.out.print(left + " ");
		System.out.print(right + " ");
		for(int i=1;i<l;i++) {
			System.out.print(0 + " ");
		}
	}

}


Measured memory_bytes: 36860
while true
    n, s = gets.chomp.split.map(&:to_i)
    break if [n, s] == [0, 0]
    arr = Array.new(101, 0)
    n.times{arr[gets.to_i] += 1}
    cum = [n]
    1.upto(100){|i| cum[i] = cum[i - 1] - arr[i - 1]}
    sum = 0
    arr.each_with_index{|x, i| sum += x * (cum[[s - i + 1, 0].max] - ((s - i + 1 <= i) ? 1 : 0)) if x > 0}
    puts sum / 2
end


Measured memory_bytes: 6896
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int Maxn = 200005;
const ll Inf = 4000000000000000000ll;

int n;
ll sum[Maxn];
ll res = Inf;

void Get(int l, int r, ll &fir, ll &sec)
{
	ll res = Inf;
	int lef = l, rig = r - 1;
	while (lef <= rig) {
		int mid = lef + rig >> 1;
		ll a = sum[mid] - sum[l - 1];
		ll b = sum[r] - sum[mid];
		if (abs(a - b) < res) {
			res = abs(a - b);
			fir = a; sec = b;
		}
		if (a <= b) lef = mid + 1;
		else rig = mid - 1;
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		sum[i] = a + sum[i - 1];
	}
	for (int i = 2; i <= n - 2; i++) {
		ll a, b; Get(1, i, a, b);
		ll c, d; Get(i + 1, n, c, d);
		ll cand = max(max(a, b), max(c, d)) - min(min(a, b), min(c, d));
		res = min(res, cand);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin>>n;
	getline(cin,s);
	getline(cin,s);
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		s[i]=s[i]+n;
		if(s[i]>'Z')
			s[i]=s[i]-'Z'+'A'-1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int,input().split()))
a = []
flag = 0

for i in range(n):
    tmp = []
    for j in range(len(b)):
        if j+1 == b[j]:
            tmp.append(b[j])
    if len(tmp) == 0:
        flag= 1
        break
    a.append(b.pop(tmp[-1]-1))

if flag == 0:
    for i in range(len(a)):
        print(a[-1-i])
else:
    print(-1)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;

bool vector_finder(vector<int> vec, int number)
{
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size())
  {
    return 1;
  }
  else
  {
    return 0;
  }
}
int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<int>> data(200000);
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    data[a].push_back(b);
  }
  bool can = false;
  for (auto v : data[0])
  {
    if (vector_finder(data[v], N - 1))
    {
      can = true;
      break;
    }
  }
  if (can)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 8576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int S[1000];
int top;
int pop();
void push(int);
int main(){

  int top=0;
  int a,b;
  char anos[1000];
  
  while(scanf("%s",anos)!=EOF){

      
   

    if(anos[0]=='+'){
      a=pop();
      b=pop();      
      push(a+b);
    }

    else if(anos[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }

    else if(anos[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else {
      push(atoi(anos));
    }
  }


  printf("%d\n",pop());

  return 0;

}

int pop(){

  return S[top--];

}

void push(int x){

   top++;
   S[top]=x;

 }

Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    int ac=0,wa=0,tle=0,re=0;
    while(t--){
        string s;
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="WA")wa++;
        else if(s=="TLE")tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl;
    
    cout<<"WA x "<<wa<<endl;
    
    cout<<"TLE x "<<tle<<endl;
    
    cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3596
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, m, k; cin >> n >> m >> k;
    vector<int> a(n), b(m);
    vector<int> suma(n + 1, 0), sumb(m + 1, 0);
    rep(i, n) {
        cin >> a[i];
        suma[i + 1] = suma[i] + a[i];
    }
    rep(i, m) {
        cin >> b[i];
        sumb[i + 1] = sumb[i] + b[i];
    }
    int ans = 0;
    for(int i = 0; i <= n; ++ i) {
        if(k >= suma[i]) {
            int res = k - suma[i];
            auto ite = lower_bound(all(sumb), res);
            int j = ite - sumb.begin();
            if(j - 1 >= 0) {
                if(sumb[j - 1] <= res) {
                    chmax(ans, i + j - 1);
                }
            }
            if(j <= m) {
                if(sumb[j] <= res) {
                    chmax(ans, i + j);
                }
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 9524
#include <stdio.h>

int main(void)
{
	int n;
	int pm, pe, pj;
	int i;

	scanf("%d", &n);
	while (n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &pm, &pe, &pj);

			if (pm == 100 || pe == 100 || pj == 100){
				printf("A");
			}
			else if ((pm + pe) / 2 >= 90){
				printf("A");
			}
			else if ((pm + pe + pj) / 3 >= 80){
				printf("A");
			}
			else if ((pm + pe + pj) / 3 >= 70){
				printf("B");
			}
			else if ((pm + pe + pj) / 3 >= 50 && (pm >= 80 || pe >= 80)){
				printf("B");
			}
			else {
				printf("C");
			}
			printf("\n");
		}
		scanf("%d", &n);
	}

	return (0);
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool solve(vector<int> &a, int k, int l){
  ll r = 0;
  for(int i : a) r += (i - 1) / l;
  return r <= k;
}
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0;i < n;i++) cin >> a[i];
  int x = 1, y = 1 << 30;
  while(x < y){
    int sr = (x + y) / 2;
    if(solve(a, k, sr)) y = sr;
    else x = sr + 1;
  }
  cout << x << endl;
}


Measured memory_bytes: 3988
def main():
    flag = True
    while flag:
        s1, tr, s2 = input().split()
        s1, s2 = int(s1), int(s2)
        if tr == "+":
            print(s1 + s2)
        elif tr == "-":
            print(s1 - s2)
        elif tr == "*":
            print(s1 * s2)
        elif tr == "/":
            print(s1 // s2)
        else:
            flag = False
            break


if __name__=="__main__":
    main()

Measured memory_bytes: 6724
import sys 
X,Y = map(int, input().split())
for i in range(X+1):
    for j in range(X+1):
        if (((2*i) + (4*j)) == Y) or (((2*j) + (4*i)) == Y):
            if (i+j == X):
                print("Yes")
                sys.exit()
print("No")


Measured memory_bytes: 9032
// AOJ 2097: Triangles
// 2017.11.7 bal4u@uu

#include <stdio.h>
#include <math.h>

#define PI    3.1415926535897932384626433832795
#define ROOT3 1.7320508075688772935274463415059

int main()
{
	int n;

	while (scanf("%d", &n) && n > 0) {
		if (n % 3 == 0) n /= 3;
		printf("%lf\n", n/(1/tan(PI/(3*n))+ROOT3));
	}
	return 0;
}

Measured memory_bytes: 1980
#include <iostream>
#include<cctype>
using namespace std;
 
int main()
{
	char ch;
	int count[26]={};

	while( cin >> ch){
		if(islower(ch)){//islower???ch????°?????????????ture?????????
			count[ch-'a']++;//??¢?????????????????????a???z????????£?¶?????????¢?????????????????????????????????????????????????????§???????????????'a'???????????¨?????????????????????????????????
		}else if(isupper(ch)){
			count[ch-'A']++;
		}
	}

	for(int i = 0;i < 26;i++){
        cout << char(i +'a') << " : " << count[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  while(true){
    string s = to_string(n);
    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){
      cout << s << endl;
      break;
    }
    n++;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,t[100001],maxx,f[100001];
vector<int>v[100001],w[100001];
int ans[100001];
void dfs(int x,int y)
{
	int n1,t=1;
	for(int i=0;i<v[x].size();i++)
	{
		n1=v[x][i];
		if(f[x]==n1)
		continue;
		f[n1]=x;
		while(t==y)
		t++;
		ans[w[x][i]]=t;
		dfs(n1,t);
		t++;
	}
}
int main()
{
	int x,y;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
		w[x].push_back(i);
		w[y].push_back(i);
		t[x]++;
		t[y]++;
		maxx=max(maxx,max(t[x],t[y]));
	}
	printf("%d\n",maxx);
	f[1]=1;
	dfs(1,0);
	for(int i=1;i<n;i++)
	printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }

  int dp[n+1];
  for(int i=0;i<=n;i++){
    dp[i]=1e9;
  }
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;i++){
    for(int j=1;j<=min(i,k);j++){
      dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }



signed main() {
	int n ; cin >> n;
	long double x = n;
	x /= 3.0;
	x = x * x * x;
	w << fixed << setprecision(10) <<x;
}


Measured memory_bytes: 256
N=int(input())
A=[0]+list(map(int,input().split()))+[0]
S=sum(abs(x-y)for x,y in zip(A,A[1:]))
for i in range(1,N+1):
    print(S-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]))


Measured memory_bytes: 14048