akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
 
 
int main(){
    ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
int n,k;cin>>n>>k;
  int p[n];
  rep(i,0,n)cin>>p[i];
  sort(p,p+n);
  int ans=0;
  rep(i,0,k)ans+=p[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
import kotlin.math.pow

fun main() {
    val (d, n) = nextIntList()
    val m = if (n == 100) {
        n + 1
    } else {
        n
    }
    println(m * 100.toDouble().pow(d).toInt())
}
// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)
// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }
// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

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

int main() {
    int n;cin >> n;
    int p[n];
    for (int i = 0; i < n; i++)cin >> p[i];
    int minp = p[0];
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i] <= minp) {
            ans++;
            minp = p[i];
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4412
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
	   
	public static void main(String[] args) throws IOException {
		 // TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String S= br.readLine();
			String T= br.readLine();
			String Alpha= "abcdefghijklmnopqrstuvwxyz";
			int[] Arrs = new int[26];
			int[] Arrt = new int[26];
			for(int i=0;i<Alpha.length();i++){
				char ch=Alpha.charAt(i);
				int count=0;
				for(int a=0;a<S.length();a++){
					char ch1=S.charAt(a);
					if(ch==ch1){
						count++;
					}
				}
				Arrs[i]=count;
			}
			for(int i=0;i<Alpha.length();i++){
				char ch=Alpha.charAt(i);
				int count=0;
				for(int a=0;a<T.length();a++){
					char ch1=T.charAt(a);
					if(ch==ch1){
						count++;
					}
				}
				Arrt[i]=count;
			}
			String s="";
			for(int x=0;x<Arrs.length;x++){
				char ch=Alpha.charAt(x);
				for(int y=0;y<Arrs[x];y++){
					s+=String.valueOf(ch);
				}
			}
			String t="";
			for(int x=Arrt.length-1;x>-1;x--){
				char ch=Alpha.charAt(x);
				for(int y=0;y<Arrt[x];y++){
					t+=String.valueOf(ch);
				}
			}
			if(s.length()>t.length()){
				int check=0;
				for(int z=0;z<t.length();z++){
					char ch1 = s.charAt(z);
					char ch2 = t.charAt(z);
					int index1=Alpha.indexOf(ch1);
					int index2=Alpha.indexOf(ch2);
					if(index1<index2){
						check=1;
						break;
					}
				}
				if(check==0){
					System.out.println("No");
				}
				else{
					System.out.println("Yes");
				}
			}
			else if(s.length()<t.length()){
				int check=0;
				for(int z=0;z<s.length();z++){
					char ch1 = s.charAt(z);
					char ch2 = t.charAt(z);
					int index1=Alpha.indexOf(ch1);
					int index2=Alpha.indexOf(ch2);
					if(index1<index2){
						check=1;
						break;
					}
				}
				int e=0;
				for(int z=0;z<s.length();z++){
					char ch1 = s.charAt(z);
					char ch2 = t.charAt(z);
					if(ch1!=ch2){
						e=1;
					}
				}
				if(e==0){
					System.out.println("Yes");
				}
				else if(e==1){
					if(check==0){
						System.out.println("No");
					}
					else{
						System.out.println("Yes");
					}
				}
				
			}
			else if(s.length()==t.length()){
				int check=0;
				for(int z=0;z<t.length();z++){
					char ch1 = s.charAt(z);
					char ch2 = t.charAt(z);
					int index1=Alpha.indexOf(ch1);
					int index2=Alpha.indexOf(ch2);
					if(index1<index2){
						check=1;
						break;
					}
				}
				if(check==0){
					System.out.println("No");
				}
				else{
					System.out.println("Yes");
				}
			}
			//System.out.println(s +" "+t);
			
	}
}

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


int main()
{
    int n; string s;
    cin >> n >> s;
    vector<bool> v(n);
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < 2; ++j) {
            v[0] = i;
            v[1] = j;
            for(int k = 2; k < n; ++k) v[k] = v[k-1] ^ v[k-2] ^ (s[k-1] == 'x');
            if((v[0] == (v[n-1] ^ v[n-2] ^ (s[n-1] == 'x'))) && (v[1] == (v[0] ^ v[n-1] ^ (s[0] == 'x')))) {
                for(bool b : v) cout << (b?'W':'S');
                cout << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3740
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N = int(input())
    a = list(map(float,input().split()))
    ha = -(-N//2)
    
    dp = np.zeros(N+1,dtype=float)
    dp[0] = 1
    for num in a:
        front = np.zeros(N+1,dtype=float)
        front[1:] = dp[:-1]*num
        dp *= (1-num)
        dp += front
    
    print(np.sum(dp[ha:]))
    
if __name__ == "__main__":
    main()


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,c; scanf("%d%d",&n,&c); n++;
    int sum=0;
    rep(i,0,c){
        int p; scanf("%d",&p); sum+=p;
    }
    printf("%d\n",(sum/n)+(bool)(sum%n));
    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
string a[100];
int dp[100][100],h,w;
const int inf=0x3f3f3f3f;
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++) cin>>a[i];
	dp[0][0]=(a[0][0]=='#');
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(i+j!=0)
			{
				dp[i][j]=inf;
				if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+(a[i][j]=='#'&&a[i-1][j]=='.'));
				if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]+(a[i][j]=='#'&&a[i][j-1]=='.'));
			}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))
#define PI 3.14159265358979

int main()
{
	int n,m;
	int i;
	while(scanf("%d %d",&n,&m),n)
	{
		int* list = mem(int,n);
		for(i = 0;i < n;i++)
		{
			scanf("%d",&list[i]);
		}
		int pt = 0;
		int count;
		int flg = 0;
		for(i = 0;i < m;i++)
		{
			int dice;
			scanf("%d",&dice);
			if(flg == 0)
			{
				pt += dice;
				if(pt >= n-1)
				{
					count = i+1;
					flg = 1;
					continue;
				}
				pt += list[pt];
				if(pt >= n-1)
				{
					count = i+1;
					flg = 1;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

const double PI = 2*acos(0.0);

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    h = (60*h+m)*0.5;
    m *= 6;
    double d = h-m;
    if(d<0) d+=360;
    d = min(d, 360-d);
    d = d/180*PI;
    cout << fixed << setprecision(12) << sqrt(a*a+b*b-2*a*b*cos(d)) << endl;
    return 0;
}

Measured memory_bytes: 4232
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;

	cin >> s;

	int i;

	bool difficult_flag = false;

	for (i = 0; i < s.size(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'L')
			{
				difficult_flag = true;
			}
		}

		if (i % 2 == 1)
		{
			if (s[i] == 'R')
			{
				difficult_flag = true;
			}
		}
	}

	if (difficult_flag == true)
	{
		printf("No");
	}
	else
	{
		printf("Yes");
	}
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CColoringColorfully solver = new CColoringColorfully();
        solver.solve(1, in, out);
        out.close();
    }

    static class CColoringColorfully {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int nbChanges = solve(s);
            out.println(nbChanges);
        }

        private int solve(String s) {
            return Math.min(solve(s, '0'), solve(s, '1'));
        }

        private int solve(String s, char cur) {
            int nbIfStart0 = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) != cur) {
                    nbIfStart0++;
                }
                cur = cur == '0' ? '1' : '0';
            }
            return nbIfStart0;
        }

    }
}



Measured memory_bytes: 26264
#include<stdio.h>
int main(void)
{
	int h, w, i, j, p = 1, q = 1;
	while (1) {
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			break;
		}
		for (i = 1; i <= h; i++) {
			if (i % 2 == 0) {
				for (j = 1; j <= w; j++) {
					if (j % 2 == 0) {
						printf("#");
					}
					else {
						printf(".");
					}
				}
			}
			else {
				for (j = 1; j <= w; j++) {
					if (j % 2 == 0) {
						printf(".");
					}
					else {
						printf("#");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return(0);
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int x;
    int ans;
    rep(i, 5) {
        cin >> x;
        if (x == 0) ans = i + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N;
int ans[101][101];
int main(){
	cin>>N;
	if(N==2){
	   cout<<-1<<endl;
	   return 0;
	}
	if(N%2==1){
	   REP(i,N-1){
	       REP(j,N){
	           ans[i][j]=(1+i+j)%N+1;
	           //cout<<(1+i+j)%N+1;
	           /*if(j==N-1){
	              cout<<endl;
	           }else{
	              cout<<" ";
	           }*/
	       }
	   }
	}else{
	  int now=0;
	  REP(i,N-3){
	      if(N/2-1==i)now++;
	      REP(j,N){
	          ans[i][j]=(1+now+j)%N+1;
	          /*cout<<(1+now+j)%N+1;
	          if(j==N-1){
	              cout<<endl;
	           }else{
	              cout<<" ";
	           }*/
	      }
	      now++;
          }
          REP(i,N){
             if(i<N/2){
                ans[N-3][i]=(i+N-1)%N+1;
                //cout<<(i+N-1)%N+1;
             }else{
                ans[N-3][i]=i-N/2+1;
                //cout<<i-N/2+1;
             }
             /*
             if(i==N-1){
	              cout<<endl;
	           }else{
	              cout<<" ";
	     }*/
          }
          
          REP(i,N){
             if(i>=N/2){
                ans[N-2][i]=(i+N-1)%N+1;
                //cout<<(i+N-1)%N+1;
             }else{
                ans[N-2][i]=i+N/2+1;
                //cout<<i+N/2+1;
             }
             /*
             if(i==N-1){
	              cout<<endl;
	           }else{
	              cout<<" ";
	     }*/
          }
	}
	REP(i,N){
	    REP(j,N-1){
	        cout<<ans[j][i];
	        if(j==N-2){
	              cout<<endl;
	           }else{
	              cout<<" ";
	        }
	    }
	}
        cout<<endl;
	return(0);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100000];
int main()
{
	int maxn=0;
	int sum=0;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>maxn)
		maxn=a[i];
		sum+=a[i];
	}
	cout<<sum-maxn/2;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
//---------------

const int N=200005;
ll a[N];

int main() {
	int n;
	while(~scanf("%d",&n)) {
		ll sum=0;
		rep(i,0,n) {
			scanf("%lld",a+i);
			sum=sum+a[i];
		}
		ll ans=(1ll<<62),now=0;
		rep(i,0,n-1) {
			now=now+a[i];
			ans=min(ans,abs(now-(sum-now)));
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


long long n;
long long d;
long long x, y;
long long ds, dn;

int main()
{
	scanf("%lld%lld", &n, &d);
	int count = 0;
	ds = d * d;
	for (int i = 0 ; i < n ; i++) {
		scanf("%lld%lld", &x, &y);
		dn = x * x + y * y;
		if (dn <= ds)
			count++;
	}
	
	printf("%d\n", count);
	
	return 0;
}



Measured memory_bytes: 1732
n,a,b = map(int,input().split())
ans = 0
s = n//(a+b)
t = n%(a+b)

if s >= 1 and t >= a:
  ans = a*(s+1)
elif s >= 1 and t < a:
  ans = a*s+t
elif s == 0 and t >= a:
  ans = a
elif s == 0 and t < a:
  ans = t

print(ans)




Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		long N=nextLong();
		String ans="";
		while(true){
			if(N%26==0){
				ans=String.valueOf((char)('a'+25))+ans;N--;
			}
			else
				ans=String.valueOf((char)('a'+N%26-1))+ans;
			if(N<=26)
				break;
			N/=26;
		}
		out.println(ans);
		out.flush();
	}
	static boolean isOK(int index,int key,ArrayList<Integer>a){
		if (a.get(index) >= key) return true;
	    else return false;
	}
	static int binary_search(int key,ArrayList<Integer> a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;

	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}


Measured memory_bytes: 37036
#include<bits/stdc++.h>
#define inti long long
using namespace std;
inti memo[1001][9000];
inti cost[1001];
inti tre[1001];
inti total;
inti n,m;
inti mini(inti a,inti b)
{
  return a<b?a:b;
}
inti min(int key,int treasure)
{
  if(key==m)
  {
  if(treasure==total)
    return 0;
    return INT_MAX;
  }
  if(memo[key][treasure]!=-1)return memo[key][treasure];
    inti a=min(key+1,treasure|tre[key])+cost[key];
  inti b=min(key+1,treasure);
  memo[key][treasure]=mini(a,b);
  return mini(a,b);
}
int main()
{
  cin>>n>>m;
  memset(memo,-1,sizeof(memo));
  for(int i=0;i<n;i++)
    total|=(1<<i);
  for(int i=0;i<m;i++)
  {
    inti costi,t;
    cin>>costi>>t;
    cost[i]=costi;
    for(int j=0;j<t;j++)
    {
      inti b;
      cin>>b;
      tre[i]|=(1<<(b-1));
    }
    
  }
  inti x=min(0,0);
  if(x>100000000 || x<=0 )
    cout<<-1<<"\n";
    else
      cout<<x<<"\n";
}
  

Measured memory_bytes: 70784
/*
https://abc053.contest.atcoder.jp/tasks/abc053_b
*/

// おかしいミスの原因は変数を初期化せず、使ってたから。
// 大きさを比較するときは必ず初期化を行う。

#include <stdio.h>
#include <string.h>

int main() {
  char s[200001] = {};
  int c_a,c_z;
  int flag = 0;

  scanf("%s", s);
  int len;
  len = strlen(s);

  for(int i = 0; i < len; i++){
      if(s[i] == 'A' && flag == 0){
       c_a = i;
       flag = 1;
     }
      if(s[i] == 'Z') c_z = i;

  }


  int ans;

  ans = c_z - c_a;
  ans += 1;
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        sc.close();

        long a = 0L;
        long b = 0L;

        for (long i=(long)Math.sqrt(N); i>0; i--) {
            if (N % i==0) {
                a = i;
                b = N / i;
                break;
            }
        }

        System.out.println(a+b-2);
    }
}

Measured memory_bytes: 23252
unittest
{
	assert( [ "25" ].parse.expand.solve == 17 );
	assert( [ "1" ].parse.expand.solve == 1 );
	assert( [ "100" ].parse.expand.solve == 108 );
	assert( [ "2020" ].parse.expand.solve == 40812 );
	assert( [ "200000" ].parse.expand.solve == 400000008 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	auto ps = new long[ 10 ][ 10 ];
	foreach( i; 1L .. n + 1 )
	{
		auto t = i % 10;
		if( t == 0 ) continue;
		auto h = i;
		while( 10 <= h ) h /= 10;
		ps[ h ][ t ]++;
	}
	
	auto ans = 0L;
	foreach( i; 1L .. n + 1 )
	{
		auto t = i % 10;
		if( t == 0 ) continue;
		auto h = i;
		while( 10 <= h ) h /= 10;
		ans += ps[ t ][ h ];
	}
	return ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n;
    cin >> n;
    vector<Int> p(n);
    for (Int i = 0; i < n; i++) cin >> p[i];
    Int cnt = 0;
    for (Int i = 1; i < n - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1])) {
            cnt++;
        }
    }
    dump(cnt);
    return 0;
}

Measured memory_bytes: 256
a=gets.to_i
b=gets.to_i
c=gets.to_i
x=gets.to_i
sumCount=0
(0..a).each do |aCount|
  totalValue=0
  (0..b).each do |bCount|
    (0..c).each do |cCount|
      totalValue=500*aCount+100*bCount+50*cCount
      sumCount+=1 if (totalValue==x)
      break if (totalValue>=x)
	end   
  end
end
puts sumCount

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

int main() {
    long long N;
    scanf("%lld", &N);
    long long ans;
    if (N == 0) ans = 0;
    else if (N <= 6) ans = 1;
    else if ((N-1) % 11 >= 6) ans = 2 * ((N-1) / 11) + 2;
    else ans = 2 * ((N-1) / 11) + 1;
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

int main(void)
{
    int N;
    std::cin >> N;

    std::vector<int> T(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> T[i];
    }

    int M;
    std::cin >> M;

    std::vector<std::pair<int, int>> PX(M);
    for (int i = 0; i < M; i++)
    {
        std::cin >> PX[i].first >> PX[i].second;
    }

    int a = std::accumulate(T.begin(), T.end(), 0);
    for (int i = 0; i < M; i++)
    {
        std::cout << (a + (PX[i].second - T[PX[i].first - 1]))<< std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
N = I()
s,t = S(),S()
ans = 2*N
minus = 0
for i in range(1,N+1):
    if s[-i:]==t[:i]:
        minus = max(minus,i)
print(ans-minus)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n , m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i ,n) cin >> a[i];
    int sumVote = 0;
    rep(i ,n) sumVote+=a[i];
    int counter = 0;
    rep(i ,n) if(a[i] >= (double)sumVote / ( 4 * m)) ++counter;
    cout << ( counter >= m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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>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(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  
  vector<ll> X,Y; // X=水,Y=砂糖 
  REP(i,3010){
    REP(j,3010){
      if(100*(A*i+B*j)<=F) X.PB(100*(A*i+B*j));
      if(C*i+D*j<=F) Y.PB(C*i+D*j);
    }
  }
  
  SORT(X);
  SORT(Y);
  REVERSE(X);
  REVERSE(Y);
  
  ll mxw=30000,mxs=-1;
  REP(i,(ll)X.size()){
    REP(j,(ll)Y.size()){
      if(X[i]+Y[j]<=F && Y[j]<=X[i]*E/100 && mxs*(X[i]+Y[j])<(mxw+mxs)*Y[j]){
        mxw=X[i];
        mxs=Y[j];
      }
    }
  }
  
  cout<<mxw+mxs<<" "<<mxs<<endl;
  return 0;
}

Measured memory_bytes: 5100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <ll> num(N+1, 1);
	ll ans = 1;
	for (int n = 2; n <= N; ++n){
		for (int ii = n; ii <= N; ii += n){
			num[ii]++;
		}
		ans += n*num[n];
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 81320
#include<stdio.h>
int main(void)
{
	int n,i;
	long long int a,sum=0,min=0,max=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a);
		sum += a;
		if (i == 0)
		{
			min = max = a;
		}
		if (min > a)
		{
			min = a;
		}
		if (max < a)
		{
			max = a;
		}
	}
	printf("%lld %lld %lld\n", min, max, sum);

	return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

int n, m, sum;
vi edges[maxn];
bool vis[maxn];

void dfs(int u)
{
    vis[u] = 1;
    sum++;

    for(auto v : edges[u]){
        if(!vis[v]) dfs(v);
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        int u, v;

        cin >> u >> v;

        edges[u].pb(v);
        edges[v].pb(u);
    }

    int ans = 0;

    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            sum = 0;
            dfs(i);
            ans = max(ans, sum);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 21020
#include <bits/stdc++.h>
    #define int long long
    const int MOD=1e9+7;
    using pii=std::pair<int,int>;
    using namespace std;
     
    int n, m, x[100005], y[100005];
    int32_t main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cin >> n >> m;
        for(int i = 0; i < n; i++)
            cin >> x[i];
        for(int i = 0; i < m; i++)
            cin >> y[i];
        sort(x, x + n);
        sort(y, y + m);
        int rowsum = 0, colsum = 0;
        for(int i = 0; i < n; i++)
        {
            rowsum += (i - (n - 1 - i)) * x[i];
            rowsum %= MOD;
        }
        for(int i = 0; i < m; i++)
        {
            colsum += (i - (m - 1 - i)) * y[i];
            colsum %= MOD;
        }
        rowsum = (rowsum + MOD) % MOD;
        colsum = (colsum + MOD) % MOD;
        cout << (rowsum * colsum) % MOD << "\n";
        return 0;
    }

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e-9
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,numbers[201]={};
	long result=INF;

	cin>>N;
	int x;
	REP(i,N){
		cin>>x;
		numbers[x+100]++;
	}

	FOR(best,-100,101){
		long result2=0;
		FOR(i,-100,101){
			result2+=(pow(i-best,2)*numbers[i+100]);
		}
		chmin(result,result2);
	}

	cout<<result<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  string in;
  cin >> n >> in;
  string a = in.substr(0,n);
  string b = in.substr(n,n);
  reverse(b.begin(),b.end());
  //cout << a << " " << b << endl;
  
  map<pair<string,string>,ll> mp;
  for(int i = 0; i < (1<<n); i++){//2のa乗回繰り返す(0 ~ 2^a- 1)
    string red;
    string blue;
    for(int j = 0;j < n;j++){
      if(i & (1<<j))red += a[j];
      else blue += a[j];
    }
    mp[make_pair(red,blue)]++;
  }
  
  ll res = 0;
  for(int i = 0;i < (1<<n);i++){
    string red;
    string blue;
    for(int j = 0;j < n;j++){
      if(i & (1<<j))red += b[j];
      else blue += b[j];
    }
    res += mp[make_pair(blue,red)];
    //cout << blue << " " << red << " " << mp[make_pair(blue,red)] << endl;
  }
  cout << res << endl;
}

Measured memory_bytes: 60896
#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
  int k,n;
  cin >> k >> n;
  vector<int> a(n + 1);
  vector<int> b(n);

  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  a.at(n) = k + a.at(0);
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    b.at(i) = abs(a.at(i + 1) - a.at(i));
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  ans = k - b.at(0);
  cout << ans << endl;
  
}

Measured memory_bytes: 1920
#include <cstdio>
#include <cstring>

using namespace std;

const int S = 1e5+5;

int a[S],head[S];

int father(int p){
	if(head[p]==p)return p;
	return head[p] = father(head[p]);
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		head[i] = i;
		
	}int t1,t2;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&t1,&t2);
		if(father(t1)!=father(t2))
			head[head[t1]]=head[t2];
	}int ans=0;
	for(int i=1;i<=n;i++){
		if(father(i)==father(a[i]))
			ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 896
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a, b, c = map(int,input().split())
    k = int(input())
    cunt = 0
    while a >= b:
        b *= 2
        cunt += 1
    while b >= c:
        c *= 2
        cunt += 1
    if cunt > k:
        print("No")
    else:
        print("Yes")
    


if __name__=='__main__':
    main()

Measured memory_bytes: 61816
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace A
{
    partial class Program
    {
        long n; long l;
        public IEnumerable<string> Solve()
        {
            n = Num;
            l = Num;

            var mn = l;
            var mx = l + n - 1;

            if (mn <= 0 && 0 <= mx)
            { }
            else if (mx < 0)
                mx--;
            else
                mn++;

            long res = (mn + mx) * (mx - mn + 1) / 2;

            yield return res.ToString();
        }
    }

    class StartingPoint
    {
        static void Main(string[] args)
        {
            if (args?.Any() == true)
            {
                var assembly = Assembly.GetExecutingAssembly();
                var resourceName = "AtCoder.Resources.In.txt";
                var stream = assembly.GetManifestResourceStream(resourceName);
                var streamReader = new StreamReader(stream, Encoding.UTF8);
                var str = streamReader.ReadToEnd();
                var textReader = new StringReader(str);
                Console.SetIn(textReader);
            }

            try
            {
                foreach (var s in new Program().Solve())
                {
                    Console.WriteLine(s);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                if (args?.Any() != true)
                    throw e;
            }

            if (args?.Any() == true)
                Console.ReadLine();
        }
    }

    partial class Program
    {
        long[] Nums(long count) => Enumerable.Range(0, (int)count).Select(_ => Num).ToArray();
        long Num => long.Parse(Str);
        double NumD => (double)Num;

        StringBuilder sb = new StringBuilder();

        string Str => GetStr();
        string GetStr()
        {
            sb.Clear();

            int r = 0;
            bool? b = null;
            do
            {
                r = Console.Read();
                b = IsBreak(r);
            } while (b == true);

            if (b == null)
                throw new Exception("input error: unexpected end of stream");

            do
            {
                sb.Append((char)r);
                r = Console.Read();
                b = IsBreak(r);
            } while (b == false);

            return sb.ToString();
        }

        bool? IsBreak(int c)
        {
            switch (c)
            {
                case -1:
                    return null;
                case (int)' ':
                case (int)'\n':
                case (int)'\r':
                    return true;
                default:
                    return false;
            }
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Sun Dec 22 21:00:17 JST 2019
 **/

signed main() {
    Int n = in();
    if (n % 2) {
        cout << 0 << endl;
        return 0;
    }
    n /= 2;
    Int ans = 0;
    while (n) {
        ans += n / 5;
        n /= 5;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int MAX_V = 200;
const ll INF = 2000000000;
vector<vector<ll>> dist(MAX_V, vector<ll>(MAX_V, INF));

int main()
{
    int V, E;
    cin >> V >> E;
    for (int i = 0; i < E; i++)
    {
        int from, to;
        ll d;
        cin >> from >> to >> d;
        dist[from][to] = d;
    }

    for (int i = 0; i < V; i++)
    {
        dist[i][i] = 0;
    }

    for (int k = 0; k < V; k++)
    {
        for (int i = 0; i < V; i++)
        {
            if (dist[i][k] == INF)
                continue;
            for (int j = 0; j < V; j++)
            {
                if (dist[k][j] == INF)
                    continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    for (int i = 0; i < V; i++)
    {
        if (dist[i][i] < 0)
        {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for (int i = 0; i < V; i++)
    {
        for (int j = 0; j < V; j++)
        {
            if (dist[i][j] == INF)
            {
                cout << "INF";
            }
            else
            {
                cout << dist[i][j];
            }
            if (j != V - 1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[n], b[m];
    ll acum[n + 1], bcum[m + 1];
    acum[0] = 0;
    bcum[0] = 0;
    for (ll i = 0; i < n; i++){
        cin >> a[i];
        acum[i + 1] = acum[i] + a[i];
    }
    for (ll i = 0; i < m; i++){
        cin >> b[i];
        bcum[i + 1] = bcum[i] + b[i];
    }
    ll res = 0;
    for (ll i = 0; i < n+1; i++) {
        ll ng = m + 1;
        ll ok = 0;
        if (k - acum[i] < 0) break;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if(acum[i]+bcum[mid]<=k){
                ok = mid;
            }
            else
                ng = mid;
        }
        chmax(res, i + ok);
    }
    cout << res << endl;
}

Measured memory_bytes: 9884
program sample
    implicit none
    character(1)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) s
   
        if(s.eq. 'T')then
            write(*,*)'A'
        elseif(s.eq. 'A')then
            write(*,*)'T'
        elseif(s.eq. 'C')then
            write(*,*)'G'
        elseif(s.eq. 'G')then
            write(*,*)'C'
        end if
    
    
    stop
end program sample
  



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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> c.at(i).at(j);
    }
  }
  int n = 0;
  int a21, a32, b21, b32;
  a21 = c.at(1).at(0) - c.at(0).at(0);
  a32 = c.at(2).at(0) - c.at(1).at(0);
  b21 = c.at(0).at(1) - c.at(0).at(0);
  b32 = c.at(0).at(2) - c.at(0).at(1);
  if(a21 != c.at(1).at(1) - c.at(0).at(1) || a21 != c.at(1).at(2) - c.at(0).at(2)) {
    n++;
  }
  if(a32 != c.at(2).at(1) - c.at(1).at(1) || a32 != c.at(2).at(2) - c.at(1).at(2)) {
    n++;
  }
  if(b21 != c.at(1).at(1) - c.at(1).at(0) || b21 != c.at(2).at(1) - c.at(2).at(0)) {
    n++;
  }
  if(b32 != c.at(1).at(2) - c.at(1).at(1) || b32 != c.at(2).at(2) - c.at(2).at(1)) {
    n++;
  }
  if(n == 0) {
    cout << "Yes" << endl;
  }
  if(n != 0) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const int N = 2e6+5;



void solve(){
	int n,x;
	cin>>n>>x;
	ll a[n];
	int g=0;
	rep(i,n){
		cin>>a[i];
		g=__gcd(g*1LL,abs(a[i]-x));
	}	
	cout<<g;

}
//999999999
int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

using graph = vector<vector<ll>>;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int count = 0;
    while(b <= a){
        b *= 2;
        count++;
    }
    while(c <= b){
        c *= 2;
        count++;
    }
    if(count <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {cout << 0 << endl; return 0;}
    int cnt = 0;
    while (1) {
        int tmp = a / 2 + b / 2;
        int tmp2 = a / 2 + c / 2;
        int tmp3 = b / 2 + c / 2;
        a = tmp3; b = tmp2; c = tmp;
        //cout << a << " " << b << " " << c << endl;
        cnt++;
        if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) break;
        if (cnt > inf / 100) {cout << -1 << endl; return 0;}
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
# frozen_string_literal: true

_ = gets
p = gets.split.map(&:to_i)
cnt = 0
flg = nil

p.each.with_index(1) do |p, idx|
  if flg
    flg = nil
    next
  end

  if p == idx
    cnt += 1
    flg = true
  end
end

puts cnt

Measured memory_bytes: 8068
#include <iostream>

#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{	
	int N;
	cin >> N;
	vector<int> T(N);
	for (int i = 0; i < N; i++)
	{
		cin >> T[i];
	}
	int M;
	
	cin >> M;
	int P, X,count = 0;
	vector<int> ans(M);
	for (int i = 0; i < M; i++)
	{
		cin >> P >> X;
		for (int j = 0; j < N; j++)
		{
			if (j == P - 1)
			{
				count += X;
			}
			else
			{
				count += T[j];
			}
		}

		ans[i] = count;
		count = 0;
		
	}
	
	for (int i = 0; i < M; i++)
	{
		cout << ans[i] << endl;
	}

	
	

	return 0;
}
	


Measured memory_bytes: 256
#!/usr/bin/env python3
n, a, b = map(int, input().split())
s = input()

cl = 0
clmax = a + b
wlrank = 0

for i in s:
    if i == "a":
        if cl < clmax:
            print("Yes")
            cl += 1
        else:
            print("No")

    elif i == "b":
        if cl < clmax:
            if wlrank < b:
                print("Yes")
                cl += 1
                wlrank += 1
            else:
                print("No")
        else:
            print("No") 
    else:
        print("No")


Measured memory_bytes: 9244
n = int(input())
a = list(map(int, input().split()))

flag = 0
 
ans = 1
for i in range(n - 1):
  if flag == 1:
    if a[i] > a[i + 1]:
      ans += 1
      flag = 0
  elif flag == -1:
    if a[i] < a[i + 1]:
      ans += 1
      flag = 0
  else:
    if a[i] > a[i + 1]:
      flag = -1
    elif a[i] < a[i + 1]:
      flag = 1
print(ans)

Measured memory_bytes: 14252
n, k = map(int, input().split())
ans = 0

for i in range(k, n + 2):
    minValue = i * (i - 1) / 2
    maxValue = n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2

    ans = (ans + (maxValue - minValue + 1)) % (10 ** 9 + 7)

print(int(ans))

Measured memory_bytes: 9192
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)


int main()
{int N, k, ans=0;
 cin >> N;
 int C[N];
 rep(i, N){
   cin >> C[i];}
 sort(C, C+N);
 rep(k, N){
   int cnt=1;
   while(C[k]==C[k+1]){
     cnt++;
     k++;}
   if(cnt%2)
     ans++;}
 cout << ans << endl;
     

      
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[21];
	int i;
	scanf("%s", str);
	for (i =  strlen(str) - 1; i >= 0; i--)
	{
		printf("%c", str[i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 524
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a +b)

Measured memory_bytes: 3060