akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{

    int i_containNum = 0;
    double i_inputNumA, i_inputNumB, i_minNum, i_maxNum, i_divideNum, displayNum;
    char c_flag = 0;
    scanf("%lf%lf", &i_inputNumA, &i_inputNumB);

    int ia_primeList[100000] = {0};
    if (i_inputNumA > i_inputNumB)
    {
        i_minNum = i_inputNumB;
        i_maxNum = i_inputNumA;
    }
    else
    {
        i_minNum = i_inputNumA;
        i_maxNum = i_inputNumB;
    }
    for (int count = 1; count <= i_minNum; count++)
    {
        if ((int) i_inputNumA % count == 0 && (int) i_inputNumB % count == 0)
        {
            ia_primeList[i_containNum] = count;
            i_containNum++;
        }
    }

    for (int index = 0; ia_primeList[index] != 0; index++)
    {
        if ((int) i_inputNumA % ia_primeList[index] == 0 && (int) i_inputNumB % ia_primeList[index] == 0)
        {
            i_divideNum = ia_primeList[index];
        }
    }

    displayNum = i_minNum * (i_maxNum / i_divideNum);

    printf("%.0lf", displayNum);
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s;
	cin>>s;
	bool ok = false;
	if(s[2] == s[3] && s[4]==s[5])ok = true;
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;cin >> s >> t;
	int n=s.size();
	vector<int> a(26,-1);
	vector<int> b(26,-1);
	bool flg=true;
	rep(i,n){
		int c=s.at(i)-'a',d=t.at(i)-'a';
		if(c==d){
			if(a.at(c)==b.at(d) && a.at(c)==-1){
				a.at(c)=c;
				b.at(d)=d;
			}
			else if(a.at(c)!=b.at(d)){
				flg=false;
				break;
			}
		}
		else{
			if(a.at(c)==b.at(d) && a.at(c)==-1){
				a.at(c)=d;
				b.at(d)=c;
			}
			else if(a.at(c)!=d || b.at(d)!=c){
				flg=false;
				break;
			}
		}
	}
	if(flg) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 916
#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n,d[55],ans;
int main(){
	n=rd();
	rep(i,1,n) d[i]=rd();
	rep(i,1,n) rep(j,i+1,n) ans+=d[i]*d[j];
	rt(ans);
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL; 
typedef long double dd; 
#define endl "\n"
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
LL dp[2000001];
LL mod=1e9+7;
bool vis[100000],ok=1;
using namespace std;
bool isPrime(LL n) {
  LL j; 
  for( j=2;j<=sqrt(n);j++){
    if(n%j==0){
      break;  
    } 
  }
  if(j>sqrt(n)){
    return 1; 
  }
  else{
    return 0; }
}
LL modexpo(LL a, LL b) {
  LL ans=1;
  a=a%mod;
  while(b>0){
    if((b&1)==1){
      ans=((ans%mod)*(a%mod))%mod;
    }
    b=b>>1;
    a=((a%mod)*(a%mod))%mod;
  }
  return ans; 
}
LL invmod(LL n){
  return modexpo(n,mod-2);
}
LL comb(LL n,LL r){
  if(r==0){
    return 1;
  }
  LL fact[n+1];
  fact[0] = 1; 
    for (LL i = 1; i <= n; i++){
       fact[i] = (fact[i - 1] * i) %mod;}
    return (fact[n] * invmod(fact[r]) % mod * invmod(fact[n - r]) % mod) %mod; 
}
LL gcd(LL a, LL b) {
  if (a == 0){
       return b;
       }  
    return gcd(b % a, a);  
}
LL lcm(LL a, LL b) {
  return (a*b)/gcd(a,b);
}
void solve(LL k){
  LL n; 
  cin>>n; 
  LL c=0;
  for(LL i=1;i<n;i++){
    c+=(n/i)-1;
    if(n%i!=0){
      c++;
    }
  }
  cout<<c<<endl; 
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
 LL t=1;
//cin>>t;
 LL k=1;
while(k<=t){
  if(ok==0){
    break; 
  }
   solve(k);
  k++;
  }
   return 0;
   }

Measured memory_bytes: 3696
// https://atcoder.jp/contests/abc047/tasks/abc047_b

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int w, h, n, x, y, a, s,
      xs[2] = {0, 100}, ys[2] = {0, 100};

  cin >> w >> h >> n;

  xs[1] = w;
  ys[1] = h;

  for (size_t i = 0; i < n; i++)
  {
    cin >> x >> y >> a;
    if (a == 1 && xs[0] < x)
      xs[0] = x;
    else if (a == 2 && x < xs[1])
      xs[1] = x;
    else if (a == 3 && ys[0] < y)
      ys[0] = y;
    else if (a == 4 && y < ys[1])
      ys[1] = y;
  }

  s = max(0, xs[1] - xs[0]) * max(0, ys[1] - ys[0]);

  cout << s << '\n';

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		try {
		    Scanner sc = new Scanner(System.in);
		    double t,d,s;
		    d=sc.nextDouble();
		    t=sc.nextDouble();
		    s=sc.nextDouble();
		    if((d/s)<=t)
		     System.out.println("Yes");
		     else
		     System.out.println("No");
		} catch(Exception e) {
		}
	}
}


Measured memory_bytes: 37196
#include<stdio.h>
int main ()
{
    int p,q,r;
    scanf("%d%d%d",&p,&q,&r);
    int a=p+q,b=p+r,c=q+r;
    int minn=a;
    if(minn>b)
        minn=b;
    if(minn>c)
        minn=c;
    printf("%d\n",minn);
}


Measured memory_bytes: 128
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int k; cin >> k;
	string s; cin >> s;
	if (s.size() <= k)cout << s << endl;
	else
	{
		cout << s.substr(0, k);
		cout << "..." << endl;
	}
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(ll i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const ll max_n = 1e5 + 9;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}

ll dp[101][2];

void add(ll &a , ll b){
    a = (a + b)%mod;
}
int main()
{
    string s;
    cin >> s;
    ll  d,  n;
    cin >> d;
    n = s.size();

    dp[0][0] = 1;
    for(ll i = 0 ; i < n ; i++){
        ll num = s[i] - '0';
        ll new_dp[101][2];
        memset(new_dp, 0 , sizeof(new_dp));
        for(ll j = 0 ; j < d ; j++){
            for(ll k = 0 ; k <= 9 ; k++){
                if(k < num){
                    add(new_dp[(j + k)%d][1] , (dp[j%d][0] + dp[j%d][1])%mod);
                }
                else if(k == num){
                    add(new_dp[(j + k)%d][0] ,dp[j%d][0]);
                    add(new_dp[(j + k)%d][1] , dp[j%d][1]);
                }
                else{
                    add(new_dp[(j + k)%d][1] , dp[j%d][1]);
                }
            }
        }     
        for(ll i = 0 ; i < 101 ; i++){
            for(ll j = 0 ; j < 2 ; j++)
                dp[i][j] = new_dp[i][j];
        }
        // debug(dp[0][0]);
        // debug(dp[0][1]);
    }

    cout << (dp[0][1] + dp[0][0] - 1 + mod)%mod<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int c[100009];

int main(){
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  for(int i=0;i<Q;i++)cin >> A[i];
  for(int i=0;i<Q;i++){c[A[i]]++;}
  for(int i=1;i<=N;i++){
    int q=K-Q+c[i];
    if(q>0){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
  }
}

Measured memory_bytes: 1408
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();

		int B = sc.nextInt();

		String S = sc.next();

		boolean ans = true;

		for(int i=0;i<A;i++) {

			if(S.charAt(i)=='-') ans = false;
		}

		if(S.charAt(A)!='-') ans = false;

		for(int i=A+1;i<S.length();i++) {

			if(S.charAt(i)=='-') ans = false;
		}

		if(ans) System.out.println("Yes");

		else System.out.println("No");
	}

}


Measured memory_bytes: 23124
#include <stdio.h>

int main(){
  int h,m,s,t;
  while(scanf("%d %d %d",&h,&m,&s),h!=-1){
    t=2*60*60-(((h*60+m)*60)+s);
    printf("%02d:%02d:%02d\n",t/60/60,(t%3600)/60,(t%60));
    t*=3;
    printf("%02d:%02d:%02d\n",t/60/60,(t%3600)/60,(t%60));
  }
  return 0;
}

Measured memory_bytes: 612
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 200001;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static boolean [][] grid;
    static int [] bishopr = {-1,1,-1,1};
    static int [] bishopc = {1,1,-1,-1};
    static long H,W,cnt;
    public static void main(String args[]) throws IOException {
        String n = in.next()+in.next();
        int val = Integer.parseInt(n);
        boolean yes = false;
        for(int i=1;i<=2000;i++){
            if(i*i==val){
                    yes= true;
            }
        }
        out.println(yes?"Yes":"No");
        out.flush();
    }



        static boolean isEven(long a) {
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
    

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int d, t, s;	
	cin >>  d>> t>> s;	
	int kyori = s * t;
	if(kyori < d){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3624
def modpow(a, b, mod=10 ** 9 + 7):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a = a * a % mod
        b //= 2
    return ret


def modcomb(n, c, mod=10 ** 9 + 7):
    if c > n - c:
        c = n - c
    u, d = 1, 1
    for i in range(c):
        u = u * (n - i) % mod
        d = d * (i + 1) % mod
    return u * modpow(d, mod - 2) % mod


mod = 10 ** 9 + 7
n, a, b = map(int, input().split())
ans = (modpow(2, n) - 1) % mod
ans = (ans - modcomb(n, a)) % mod
ans = (ans - modcomb(n, b)) % mod
print(ans)


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    ll g = 0;
    vector<ll> a(n+1);
    REP(i, n+1) {
        cin >> a[n-i];
        g = __gcd(g, abs(a[n-i]));
    }

    auto test = [&](ll p) {
        if(a[0]%p) return false;
        vector<ll> sum(p);
        FOR(i, 1, n+1) sum[i%(p-1)] += a[i];
        bool flag = true;
        REP(i, p) if(sum[i]%p != 0) flag = false;
        return flag;
    };

    vector<ll> ans;

    // P <= N
    vector<bool> prime(n+2, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (prime[i]) {
            if(test(i)) ans.push_back(i);
            for (int j = 2 * i; j <= n; j += i) {
                prime[j] = false;
            }
        }
    }

    // for(ll i=2; i*i<=g; ++i) {
    //     if(g%i==0) ans.push_back(i);
    //     while(g%i==0) g/=i;
    // }
    // if(g>1) ans.push_back(g);

    // // P > N
    ll t = abs(a[n]);
    vector<ll> div;
    for(ll i=2; i*i<=t; ++i) {
        if(t%i==0) div.push_back(i);
        while(t%i==0) t/=i;
    }
    if(t>1) div.push_back(t);
    for(auto i: div) {
        if(i <= n) continue;
        bool flag = true;
        REP(j, n+1) if(a[j]%i != 0) flag = false;
        if(flag) ans.push_back(i);
    }

    for(auto i: ans) cout << i << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int ans = 0;
		for(int i = 0;i < N;i++){
			a[i] = sc.nextInt();
			if((i+1) % 2 == 1 && a[i] % 2 == 1){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27184
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
	int i;
	char line[81];
	while (fgets(line, 81, stdin) != NULL) {
		while (1) {
			if (strstr(line, "the ") != NULL ||
				strstr(line, "this ") != NULL ||
				strstr(line, "that ") != NULL) {
				break;
			}
			for (i = 0; line[i] != '\0'; i++) {
				if (islower(line[i])) {
					line[i] = ((line[i] - 'a') + 1) % 26 + 'a';
				}
			}
		}
		printf("%s", line);
	}
	return 0;
}

Measured memory_bytes: 528
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int R= keyboard.nextInt();
		int G= keyboard.nextInt();
		int B= keyboard.nextInt();
		int K= keyboard.nextInt();
		
		String ans = "No";
		
		for(int c = K ;c>0; c--) {
			double ao = B * Math.pow(2, c);
			double midori = G * Math.pow(2, K-c);
			if(R<midori && midori<ao) {
				ans = "Yes";
			}
		}
		
		
		System.out.println(ans);
		keyboard.close();	
		
	}
}


Measured memory_bytes: 35832
N = int(input())
        
G = [[] for i in range(N)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    G[a - 1].append([b - 1, c])
    G[b - 1].append([a - 1, c])
    
color = [-1] * N
color[0] = 0
Q = [0]

while len(Q) != 0:
    cur = Q.pop()
    for to, dist in G[cur]:
        if color[to] == -1:
            color[to] = (color[cur] + dist) % 2
            Q.append(to)
            
for i in range(N):
    print(color[i])

Measured memory_bytes: 81952
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
long long A[3000];
const long long MOD = 998244353;
long long dp[3000][3001];
int main(){
  int N;
  int S;
  cin >> N >> S;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  dp[0][0] = 2;
  if(A[0] <= S){
    dp[0][A[0]] = 1;
  }

  for(int i = 1; i < N; i++){
    for(int j = 0; j <= S; j++){
      dp[i][j] = (dp[i - 1][j] * 2) % MOD;
      if(j - A[i] >= 0){
        dp[i][j] = (dp[i][j] + dp[i - 1][j - A[i]]) % MOD;
      }
    }
  }

  /*
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= S; j++){
      cout << dp[i][j] << " ";
    }
    cout <<endl;
  }
  */

  cout << dp[N - 1][S] << endl;
  return 0;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll n;
    cin >> n;
    int len = 1;
    ll mul = 26 , sum = 0;

    while(n > sum + mul){
        len++;
        sum += mul;
        mul *= 26;
    }

    n -= sum;
    n--;
    //cout << len << endl;
    string ans(len,'a');
    vector<ll> v(len+1,1);
    rloop(i,len-1)v[i] = v[i+1] * 26;
    loop(i,len){
        int inc = n / v[i+1];
        ans[i] += inc;
        n -= v[i+1] * inc;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    read!(usize);
    let mut A = read![[i64]]
        .into_iter()
        .enumerate()
        .map(|(i, a)| (a, i))
        .collect::<Vec<_>>();

    let mut freq = BTreeMap::new();
    for &(a, i) in &A {
        freq.entry(a).or_insert(Vec::new()).push(i);
    }

    let mut kill = HashSet::new();

    let mut k = 0_i64;

    A.sort();
    A.reverse();
    for (a, i) in A {
        if kill.contains(&i) {
            continue;
        }

        for h in 0..40 {
            let t = 1_i64 << h;
            if t <= a {
                continue;
            }

            let u = t - a;
            if let Some(items) = freq.get_mut(&u) {
                let mut same = false;

                while let Some(j) = items.pop() {
                    if kill.contains(&j) {
                        continue;
                    }

                    if i == j {
                        same = true;
                        continue;
                    }

                    // pair
                    kill.insert(i);
                    kill.insert(j);
                    k += 1;
                    debug!((i, j, a, u, t));
                    break;
                }

                if same {
                    items.push(i);
                }
            }
        }
    }

    println!("{}", k);
}


Measured memory_bytes: 34600
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[3];
    for(int i = 0 ; i < 3; ++i){
        scanf("%d",a + i);
    }
    for(int i = 0 ; i < 3 ; ++i){
        for(int j = 0 ; j < 3; ++j){
            for(int k = 0 ; k < 3; ++k){
                if(a[i] + a[j] == a[k]){
                    puts("Yes");
                    return 0;
                }
            }
        }
    }
    puts("No");
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const ll inf = 8e18;

ll x;

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) {
	    res=res*x;
	}
	x=x*x;
	y=y/2;
    }
    return res;
}

ll get(ll b5) {
    if (b5==0) return 0;
    bool neg = (b5<0);
    if (b5<0) b5*=-1;

    ll i=1;
    for (; pw(i,5)<b5; i++) {
    }

    if (pw(i,5)>b5) return inf;

    if (neg) i*=-1;
    return i;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>x;
    for (ll a=1;;a++) {
	ll tmp = pw(a,5)-x;
	ll b = get(tmp);
	if (b==inf) continue;
	cout<<a<<" "<<b<<endl;
	return 0;
    }

    assert(0);
    return 0;
}


Measured memory_bytes: 3592
n,m = map(int,input().split())
WA = [0]*n
AC  = [0]*n
wa = 0
for i in range(m):
    x = input().split()
    x[0] = int(x[0])
    if x[1] == 'WA' and AC[x[0]-1] == 0:
        WA[x[0]-1] += 1
    elif x[1] == 'AC' and AC[x[0]-1] == 0:
        AC[x[0]-1] += 1
        wa += WA[x[0]-1]
print(sum(AC),wa)        


Measured memory_bytes: 4596
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
        String input = sc.next();
        if(input.equals("A")){
            System.out.println("T");
        }else if(input.equals("T")){
            System.out.println("A");
        }else if(input.equals("C")){
            System.out.println("G");
        }else if(input.equals("G")){
            System.out.println("C");
        }
	}

}


Measured memory_bytes: 21972
N = int(input())
p = [int(x) for x in input().split(' ')]
#N = 4
#p = [5,3,8,1000]
#p = [1000,1000,1001,1000]

def check(a,b):
  while True:
    r = b % a
    if r != 0:

      #print(a,b,r)
      b = a
      a = r
    else:
      res = a
      #print('zero')
      break

  #print(res)
  return res

mval = -1
for i in range(N-1):
  a,b=p[i],p[1]
  m = check(a,b)
  if mval == -1:
    mval = m
  else:
    if m < mval:
      mval = m
      
print(mval)

Measured memory_bytes: 14252
_ = input()
n = list(map(int, input().split()))
s = sum(map(int, input().split()))
p = list(map(int, input().split()))
a = []
for i, (c, d) in enumerate(zip(n[1:], n[:-1])):
  if (c-d) == 1:
    a.append(d-1)

print(s + sum([p[i] for i in a]))

Measured memory_bytes: 3064
n=int(input())
s=input()
ans=s.count("E")
if s[0]=="E": ans-=1
chk=ans
for a,i in enumerate(s[1:]):
    if i=="E": chk-=1
    if s[a]=="W": chk+=1
    ans=min(ans,chk)
print(ans)


Measured memory_bytes: 3700
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

LL mul(LL x, LL y) {
    return (x * y) % MOD;
}

const int MAXN = 100005;
LL fact[MAXN];

int n, m;

int main() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; i++) fact[i] = mul(fact[i-1], i);

    GI(n);
    GI(m);

    if (abs(n - m) > 1) {
        cout << 0 << "\n";
    }
    else if (abs(n - m) == 1) {
        cout << mul(fact[n], fact[m]) << "\n";
    }
    else {
        cout << mul(2, mul(fact[n], fact[m])) << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
	cin>>h[i];
    
    int height[n];
    height[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
    int a=abs(h[i+1]-h[i])+height[i+1];
    if(i+2<n)
    {
    int b=abs(h[i+2]-h[i])+height[i+2];
    height[i]=min(a,b);
    }
    else
    height[i]=a;
    }
    cout<<height[0];
	return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    priority_queue<int> que;
    REP(i,n) {
        int a;cin >> a;
        que.emplace(a);
    }
    REP(i,m) {
        int a = que.top(); que.pop();
        a /= 2;
        que.emplace(a);
    }
    ll ans = 0;
    while (!que.empty()) {
        ans += que.top(); que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include <numeric>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a==b&&b==c)
cout<<1<<endl;
else if(a==b&&b!=c)
cout<<2<<endl;
else if(b==c&&c!=a)
cout<<2<<endl;
else if(c==a&&a!=b)
cout<<2<<endl;
else 
cout<<3<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int N, A, B; cin >> N >> A >> B;

if (abs(A - B) % 2) cout << "Borys" << "\n";
else cout << "Alice" << "\n";


return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve(string s) {
    int n = s.size();
    int i,j,k,l;
    int ans = 0;
    for(i=0; i<n; i=l) {
        for(j=i; s[j]=='J'; j++) ;
        for(k=j; s[k]=='O'; k++) ;
        for(l=k; s[l]=='I'; l++) ;
        int a=j-i, b=k-j, c=l-k;
        if(a >= b and b <= c) ans = max(ans, b);
    }
    cout << ans << "\n";
    return ;
}

int main() {
    string s; cin >> s;
    solve(s);
    return 0;
}

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

int main()
{
  int n;
  
  cin>>n;
  
  int cnt=0;
  
  for(int i=1; i<=n; i++)
  {
    int x, y;
    
    cin>>x>>y;
    
    if(x==y)
    {
      cnt++;
    }
    else
    {
      cnt=0;
    }
    
    if(cnt==3)
    {
      cout<<"Yes"<<endl;
      
      return 0;
    }
  }
  
  cout<<"No"<<endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
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();}

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

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#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())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
int main(){
    int n, k;
    cin >> n >> k;
    map<int, int> a;
    REP(i,k){
        int d;
        cin >> d;
        REP(i,d){
            int tmp;
            cin >> tmp;
            tmp++;
            a[tmp]++;
        }
    }
    int cnt=a.size();
    cout << n-cnt << endl;
}
    




Measured memory_bytes: 3628
#include<stdio.h>
int main(void) {
	int x, y, z,i = 0;
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	scanf("%d",&z);
	while (z != 0) {
		i++;
		printf("Case %d: %d\n", i, z);
		scanf("%d", &z);
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    cin >> n >> m >> k;
    vl a(n);
    vl b(m);

    IPT(a, n)
    IPT(b, m)

    vl sum_a(n);
    vl sum_b(m);

    sum_a.at(0) = a.at(0);
    sum_b.at(0) = b.at(0);

    REP(i, 1, n) {
        sum_a[i] = sum_a.at(i - 1) + a.at(i);
    }

    REP(i, 1, m) {
        sum_b[i] = sum_b.at(i - 1) + b.at(i);
    }

    auto itr = upper_bound(ALL(sum_b), k);
    ans = distance(sum_b.begin(), itr);
    
    NREP() {
        if (sum_a.at(i) > k) {
            break;
        }

        auto b_itr = upper_bound(ALL(sum_b), k - sum_a.at(i));

        ll a_count = i + 1;
        ll b_count = distance(sum_b.begin(), b_itr);

        if (b_count < 0) b_count = 0;
        ans = max(ans, a_count + b_count);
    }
    MSG(ans)
}


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



int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string str; vector <int> f(1 << 8, 0); cin >> str;
	for(auto ch: str) f[ch] ^= 1;
	int c = 0;
	for(int x: f) c += x;
	cout << (c ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::io::stdin;

fn read<T: FromStr>() -> T{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}

fn main() {
    let s1 = read::<String>();
    let s2 = read::<String>();

    let mut c1: Vec<char> = s1.chars().collect();
    let mut c2: Vec<char> = s2.chars().collect();
    
    c2.reverse();

    if c1 == c2 {
        println!("YES")
    } else {
        println!("NO")
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int d, score;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26)), pos(26);

int get_score(vector<int> t){
    vector<int> pos(26, 0);
    int ans = 0;
    rep(i, d){
        int l = i + 1 - pos[t[i]];
        ans -= (l * (l-1) / 2) * c[t[i]];
        ans += s[i][t[i]];
        pos[t[i]] = i+1;
    }
    rep(i, 26){
        int l = d + 1 - pos[i];
        ans -= (l * (l-1) / 2)* c[i];
    }
    return ans;
}

int main() {
    cin >> d;
    rep(i, 26)cin >> c[i];
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------// 
    int score = 0;
    vector<int> t(d, 0), pos(26, 0);
    rep(i, d){
        int ma = 0;
        rep(j, 26){
            int now = score;
            now += s[i][j];
            now -= (i + 1 - pos[j]) + (i - pos[j]) / 2 * c[j];
            ma = max(ma, now);
        }
        rep(j, 26){
            int now = score;
            now += s[i][j];
            now -= (i + 1 - pos[j]) + (i - pos[j]) / 2 * c[j];
            if(now == ma){
                pos[j] = i+1;
                t[i] = j;
            }
        }
    }
    score = get_score(t);
    /*while(clock() < 1950000){
        int D = rand() % d, q = rand() % 26;
        int old = t[D], olds = get_score(t);
        t[D] = q;
        if(get_score(t) < olds)t[D] = old;
    }*/
    rep(i, d)cout << t[i]+1 << endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int MAX=100000;
const int logMAX=17;//2^17>=100000(=MAX)

int V;
vector<int> G[MAX];
int root;
int parent[logMAX][MAX];
int depth[MAX];

void dfs(int v,int p,int d)
{
	parent[0][v]=p;
	depth[v]=d;
	for(int i=0;i<G[v].size();i++)
	{
		if(G[v][i]!=p)dfs(G[v][i],v,d+1);
	}
	return;
}

void init()
{
	dfs(root,-1,0);
	for(int k=0;k+1<logMAX;k++)
	{
		for(int v=0;v<V;v++)
		{
			if(parent[k][v]<0)parent[k+1][v]=-1;
			else parent[k+1][v]=parent[k][parent[k][v]];
		}
	}
	return;
}

int lca(int u,int v)
{
	if(depth[u]>depth[v])swap(u,v);
	for(int k=0;k<logMAX;k++)
	{
		if((depth[v]-depth[u])>>k&1)
		{
			v=parent[k][v];
		}
	}
	if(u==v)return u;
	for(int k=logMAX-1;k>=0;k--)
	{
		if(parent[k][u]!=parent[k][v])
		{
			u=parent[k][u];
			v=parent[k][v];
		}
	}
	return parent[0][u];
}

int main()
{
	cin>>V;
	root=0;
	int k,c;
	for(int i=0;i<V;i++)
	{
		cin>>k;
		for(int j=0;j<k;j++)
		{
			cin>>c;
			G[i].push_back(c);
			G[c].push_back(i);
		}
	}
	init();
	int q;
	cin>>q;
	int u,v;
	for(int i=0;i<q;i++)
	{
		cin>>u>>v;
		cout<<lca(u,v)<<endl;
	}
	return 0;
}

Measured memory_bytes: 21784
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
const int INF = 1e9;

using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  int u, v; cin >> u >> v;
  --u, --v;

  vvi edge(N, vi());
  int d[N], d2[N];
  rep(i, N)
    d[i] = d2[i] = INF;
  d[u] = d2[v] = 0;

  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  stack<int> st;
  st.push(u);
  while(!st.empty()) {
    int p = st.top(); st.pop();
    for (const auto& e : edge[p]) {
      if (d[e] != INF)
        continue;
      d[e] = d[p] + 1;
      st.push(e);
    }
  }

  st.push(v);
  while(!st.empty()) {
    int p = st.top(); st.pop();
    for (const auto& e : edge[p]) {
      if (d2[e] != INF)
        continue;
      d2[e] = d2[p] + 1;
      st.push(e);
    }
  }
  int ans = 0;
  rep(i, N) {
    if (d2[i] >= d[i])
      ans = max(d2[i]-1, ans);
  }
  cout << ans << "\n";

  return 0;
}


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

int main(){
	int min = 99999;
	int sum = 0;
	int sum1 = 0;
	int b[100];
	int a;
	cin >> a;
	for(int i = 0;i<a;i++){
		cin >> b[i];
		sum += b[i];
	}
	for(int i = 0;i<a;i++){
		sum1 += b[i];
		if(min >= abs(sum-sum1-sum1)){
			min = abs(sum-sum1-sum1);
		}
	}
	cout << min;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;

  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
      }
}

int main(){

  int i,j,u,v,k;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();
  return 0;

}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
using namespace std;

// T = string or vector<long long>
template<class T> struct KMP {
    T pat;
    vector<int> fail;

    // construct
    KMP(const T &p) { init(p); }
    void init(const T &p) {
        pat = p;
        int m = (int)pat.size();
        fail.assign(m+1, -1);
        for (int i = 0, j = -1; i < m; ++i) {
            while (j >= 0 && pat[i] != pat[j]) j = fail[j];
            fail[i+1] = ++j;
        }
    }

    // the period of S[0:i]
    int period(int i) { return i - fail[i]; }
    
    // the index i such that S[i:] has the exact prefix p
    vector<int> match(const T &S) {
        int n = (int)S.size(), m = (int)pat.size();
        vector<int> res;
        for (int i = 0, k = 0; i < n; ++i) {
            while (k >= 0 && S[i] != pat[k]) k = fail[k];
            ++k;
            if (k >= m) res.push_back(i - m + 1), k = fail[k];
        }
        return res;
    }
};


void solve(int N, const vector<long long> &a, const vector<long long> &b) {
    vector<long long> da(N*2), db(N);
    for (int i = 0; i < N*2; ++i) {
        int j = i % N;
        int k = (i + 1) % N;
        da[i] = a[j] ^ a[k];
        if (i < N) db[i] = b[j] ^ b[k];
    }
    KMP<vector<long long> > kmp(db);
    auto v = kmp.match(da);
    for (auto k : v) {
        if (k < N) cout << k << " " << (a[k] ^ b[0]) << endl;
    }
}

int main() {
    int N;
    cin >> N;
    vector<long long> a(N), b(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    for (int i = 0; i < N; ++i) cin >> b[i];
    solve(N, a, b);
}


Measured memory_bytes: 14580
import java.util.Scanner;
 
class Main {
  static int count = 0;
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    StringBuilder output = new StringBuilder();
    int n = in.nextInt();
    int[] A = new int[n];
    for (int i = 0; n != 0; i++) {
      A[i] = in.nextInt();
      n--;
    }
    mergeSort(A);
    for (int i = 0; i < A.length; i++) {
      output.append(A[i]);
      if (i != A.length - 1) output.append(" ");
    }
    System.out.println(output.toString());
    System.out.println(Main.count);
  }
   
  static void merge(int[] A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int[] L = new int[n1];
    int[] R = new int[n2];
    for (int i = 0; i < n1; i++) { L[i] = A[left + i]; }
    for (int j = 0; j < n2; j++) { R[j] = A[mid +  j]; }
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++) {
      Main.count++;
      if      (i >= n1)       A[k] = R[j++];
      else if (j >= n2)       A[k] = L[i++];
      else if (L[i] <= R[j])  A[k] = L[i++];
      else                    A[k] = R[j++];
    }
  }
   
  static void mergeSort(int[] A) {
    int left = 0;
    int right = A.length;
    mergeSort(A, left, right);
  }
   
  static void mergeSort(int[] A, int left, int right) {
    if (left + 1 < right) {
      int mid = (left + right)/2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
    }
  }
   
}

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

using namespace std;

int main(){

    long a,b,c,d,e;



    cin >> a >> b >> c >> d;

  long m,n,p,temp;

  m=c;
  n=d;

  while (m % n != 0)
  {
    temp = n;
    n = m % n;
    m = temp;
  }
  p=c*d/n;


  cout << (b-(a-1))-((b/c-(a-1)/c)+(b/d-(a-1)/d)-(b/p-(a-1)/p))<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int V = sc.nextInt();
      int B = sc.nextInt();
      int W = sc.nextInt();
      int T = sc.nextInt();
      
      // 判定
      String result = "YES";
      if(V <= W){
        result = "NO";
      }else{
        int distance;
        if(A < B){
          distance = B - A;
        }else{
          distance = A - B;
        }
        
        long chase = (long)(V - W) * T;
        if(chase < distance){
          result = "NO";
        }
      }
      
      // 出力
      System.out.println(result);
    }
    

}

Measured memory_bytes: 35820