akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int A,B;
  cin>>A>>B;
  string s;
  cin>>s;
  bool ok=true;
  rep(i,A+B+1){
    if(i==A){if(s[i]!='-') ok=false;}
    else if(s[i]=='-') ok=false;
  }

  cout<< ( ok ? "Yes" : "No" )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp110 {
    class Program {
        static void Main(string[] args) {
            long X = long.Parse(Console.ReadLine());

            long test_K = (long)Math.Ceiling(Math.Sqrt(2 * X)) - 1;

            if ((test_K - 1) * test_K / 2 < X && test_K * (test_K + 1) / 2 >= X) {
                Console.WriteLine(test_K);
            } else {
                Console.WriteLine(test_K + 1);
            }

        }
    }
}


Measured memory_bytes: 11092
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int m=sc.nextInt();
		
		List<Integer>list=new ArrayList<Integer>();
		//Set<Integer>set=new HashSet<Integer>();
		
		int[] hight=new int[n];
		boolean[] jugbe=new boolean[n];
		
		for(int i=0;i<n;i++){
			int a=sc.nextInt();
			
			hight[i]=a;
		}
		
		//ここまでで高さの入力
		
		for(int i=0;i<m;i++){
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			
			if(hight[a]<=hight[b]){
				jugbe[a]=true;
			}
			if(hight[a]>=hight[b]){
				jugbe[b]=true;
			}
		}
			
			int count=0;
			
			for(int i=0;i<n;i++){
				if(!jugbe[i])count++;
			}
		
		
		System.out.println(count);
	}
}

Measured memory_bytes: 59908
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

long int x, y;

int main() {
  cin >> x >> y;

  int cnt = 0;
  for ( long int i = x; i <= y; i *= 2) {
    cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int N;
int CALC(int K) {

	int num = 0;
	while (K > 0) { K /= 10; num++; }

	return num;
}
int main(void) {

	cin >> N;

	long long int ans=0;

	for (int k = 1; k <= N; k++) {
		if (CALC(k) % 2 == 1) { ans++; }
	}

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

Measured memory_bytes: 256
using System;
 
class Program {
	static void Main(string[] args) {
	    string input = Console.ReadLine();
	    string[] lines = input.Split(' ');
	    
	    int numberOfMonitors = int.Parse(lines[0]);
	    int numberOfFoods = int.Parse(lines[1]);
	    
	    int numberOfFavorites = 0;
	    int foodId = 0;
	    bool[,] isFavorite = new bool[numberOfMonitors, numberOfFoods];
	    
	    for (int i = 0; i < numberOfMonitors; i++) {
	        input = Console.ReadLine();
	        lines = input.Split(' ');
	        numberOfFavorites = int.Parse(lines[0]);
	        
	        for (int k = 1; k <= numberOfFavorites; k++) {
	            foodId = int.Parse(lines[k]);
	            isFavorite[i, foodId -1] = true;
	            // Console.WriteLine(foodId + " thisFoodIsliked" + " by " + i);
	        }
	    }
	    
	    bool thisFoodIsDisliked = false;
	    int outputNumber = 0;
	    
	    for (int k = 0; k < numberOfFoods; k++) {
	        for (int i = 0; i < numberOfMonitors; i++) {
	            if (!isFavorite[i, k]) {
	                thisFoodIsDisliked = true;
	                // Console.WriteLine(k + " thisFoodIsDisliked" + " by " + i);
	            }
	        }
	        
	        if (!thisFoodIsDisliked) {
	            // Console.WriteLine(k + " thisFoodIsLiked" + " by everyone");
	            outputNumber++;
	        }
	        thisFoodIsDisliked = false;
	    }
	    
	    string outputLine = outputNumber.ToString();
	    Console.WriteLine(outputLine);
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=1e9+7;
ll ksm(int a,int b)
{
    ll ans=1;
    for(;b;b>>=1,a*=a) if(b&1) ans*=a;
    return ans;
}
int main()
{
    //freopen("input.txt","r",stdin);
    int n,k;cin>>n>>k;
    cout<<1ll*k*ksm(k-1,n-1);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input = br.readLine();
		char[] cinput = input.toCharArray();
		char[] hint = br.readLine().toCharArray();
		
		//まずは力任せでやってみる
		for(int i = cinput.length - hint.length; i >= 0; i--){
			if(canReplace(cinput, hint, i)){
				replaceHint(cinput, hint, i);
				replaceToA(cinput);
				System.out.println(cinput);
				return;
			}
		}
		System.out.println("UNRESTORABLE");

	}
	
	static void replaceToA(char[] input){
		for(int i = 0; i < input.length ; i++){
			if(input[i] == '?'){
				input[i] = 'a';
			}
		}
	}
	
	static void replaceHint(char[] input, char[] hint, int start){
		for(int i = start ; i < start + hint.length ; i++){
			input[i] = hint[i - start];
		}
	}
	
	static boolean canReplace(char[] input, char[] hint, int start){
		for(int i = start ; i < start + hint.length ; i++){
			if(!(input[i] == '?' || input[i] == hint[i - start])){
				return false;
			}
		}
		
		return true;
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int a[100010],t[16],ans,S,f[1100010];
vector<int>g[16];
int main()
{
	memset(f,0x3f,sizeof(f));
	int n;scanf("%d",&n);
	for(int i=1,u,v,w;i<n;i++)scanf("%d%d%d",&u,&v,&w),a[u]^=w,a[v]^=w;
	for(int i=0;i<n;i++)t[a[i]]++;
	for(int i=1;i<16;i++)ans+=(t[i]>>1),S|=(t[i]&1)<<(i-1);
	for(int i=0;i<=S;i++)
	{
		int x=i,ss=0;
		while(x)
		{
			if(x&1)ss++; 
			x>>=1;
		}
		g[ss].push_back(i);
	} 
	f[S]=0;
	for(int p=15;p>=2;p--)
		for(int e=0,s;e<g[p].size();e++)
		{
			s=g[p][e];if(f[s]==f[S+1])continue;
			for(int i=1;i<16;i++)if(s&(1<<(i-1)))for(int j=1;j<16;j++)if(i!=j&&(s&(1<<(j-1))))
			{
				int a=i^j; 
				if(s&(1<<(a-1)))f[s-(1<<(i-1))-(1<<(j-1))-(1<<(a-1))]=min(f[s-(1<<(i-1))-(1<<(j-1))-(1<<(a-1))],f[s]+2);
				else f[s-(1<<(i-1))-(1<<(j-1))+(1<<(a-1))]=min(f[s-(1<<(i-1))-(1<<(j-1))+(1<<(a-1))],f[s]+1);
			}
		}
	printf("%d",f[0]+ans);
	return 0;
}

Measured memory_bytes: 8572
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

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[] b = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        int[] c = new int[N];
        int[] d = new int[N];
        for (int i = 0; i < N; ++i) {
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        System.out.println(solve(a, b, c, d));

        sc.close();
    }

    static int solve(int[] a, int[] b, int[] c, int[] d) {
        int N = a.length;

        @SuppressWarnings("unchecked")
        List<Integer>[] leftAdjLists = new List[N];
        for (int i = 0; i < leftAdjLists.length; ++i) {
            leftAdjLists[i] = new ArrayList<>();
        }

        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (a[i] < c[j] && b[i] < d[j]) {
                    leftAdjLists[i].add(j);
                }
            }
        }

        int matchCount = 0;
        int[] leftMatches = IntStream.range(0, N).map(i -> -1).toArray();
        int[] rightMatches = IntStream.range(0, N).map(i -> -1).toArray();
        for (int i = 0; i < leftMatches.length; ++i) {
            if (leftMatches[i] == -1 && search(leftAdjLists, leftMatches, rightMatches, new boolean[N], i)) {
                ++matchCount;
            }
        }

        return matchCount;
    }

    static boolean search(List<Integer>[] leftAdjLists, int[] leftMatches, int[] rightMatches, boolean[] rightVisited,
            int leftIndex) {
        for (int rightIndex : leftAdjLists[leftIndex]) {
            if (!rightVisited[rightIndex]) {
                rightVisited[rightIndex] = true;

                if (rightMatches[rightIndex] == -1
                        || search(leftAdjLists, leftMatches, rightMatches, rightVisited, rightMatches[rightIndex])) {
                    leftMatches[leftIndex] = rightIndex;
                    rightMatches[rightIndex] = leftIndex;

                    return true;
                }
            }
        }

        return false;
    }
}

Measured memory_bytes: 27988
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int a[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, cnt = 0, cur = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int L = 0, R = 0;
  while(L < n) {

    if(a[R] >= a[R+1] && R + 1 < n) {
      ++R;
      ++cnt;
      cur = max(cnt, cur);
    } else {
      ++L;
      if(L >= R) {
        cnt = 0;
        R = L;
      } else
        --cnt;
    }

  }
  cout << cur;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define P 1000000007
using namespace std;
int n,c[26];
char s[100007];
int main(){
    scanf("%d%s",&n,s);
    for(int i=0;i<n;++i)++c[s[i]-'a'];
    int ans=1;
    for(int i=0;i<26;++i)ans=1LL*ans*(c[i]+1)%P;
    printf("%d\n",(ans+P-1)%P);
}


Measured memory_bytes: 384
// AOJ 0606: Tower of JOIOI
// 2018.1.10 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

char s[1000005], *p;

int check(char *p, int m)
{
	int i, si, oi, soi, n;

	i = si = oi = soi = n = 0;
	while (*p) {
		if (*p == 'J') {
			if (soi > oi) { oi++; if (++n == m) return 1; }
		} else if (*p == 'O') {
			if (si > i && soi < m) soi++, i++;
		} else {						// *p == 'I'
			if (si < m) si++;
			else if (soi > oi) { oi++; if (++n == m) return 1; }
		}
		p--;
	}
	return 0;
}

int main()
{
	int n, i, oi, ans;
	int lo, hi, m;

	fgets(s+1, 10, stdin), n = atoi(s+1);
	fgets(s+1, 1000005, stdin);
	i = oi = ans = 0;
	p = s+n; while (*p) {
		if (*p == 'J') {
			if (oi) ans++, oi--;
		} else if (*p == 'O') {
			if (i) oi++, i--;
		} else i++;					// *p == 'I'
		p--;
	}
	if (oi > 0) {
		lo = ans, hi = ans + 1 + (i + oi)/2;
		while (lo + 1 < hi) {
			m = (lo + hi) >> 1;
			if (check(s+n, m)) lo = m; else hi = m;
		}
		ans = lo;
	}
	printf("%d\n", ans);
	return 0;
}


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

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

    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7')
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;
int P[200005];
int sz[200005];
int N;
int rez;
int main(){
    cin >> N;
    for(int i = 1;i <= N;i++){
        cin >> P[i];
        sz[P[i]] = 1 + sz[P[i]  - 1];
        rez = max(rez,sz[P[i]]);
    }
    cout << N - rez;
    return 0;
}


Measured memory_bytes: 1792
N, K = map(int, input().split())
A = list(map(int, input().split()))

timestep_pos_map = []  # (i -> n)
pos_timestep_map = {}  # (n -> i)

timestep_pos_map.append(1)  # start
pos_timestep_map[1] = 0     # start

for timestep in range(1, min(K + 1, N + 1 + 1)):
    prev_pos = timestep_pos_map[-1]
    cur_pos = A[prev_pos - 1]

    if timestep == K:
        print(cur_pos)
        exit()

    if cur_pos in pos_timestep_map:
        prev_timestep = pos_timestep_map[cur_pos]
        interval = timestep - prev_timestep
        offset = (K - prev_timestep) % interval
        print(timestep_pos_map[prev_timestep + offset])
        exit()

    timestep_pos_map.append(cur_pos)
    pos_timestep_map[cur_pos] = timestep


Measured memory_bytes: 119892
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  IN(a);
  IN(b);
  cout<<min(a*n, b);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll unsigned long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  deque<ll> q;
  vector<ll> vec;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    vec.pb(x);
  }
  sort(vec.begin(), vec.end());

  for(int i = 1; i < vec.size(); i++){
    q.pb(vec[i]);
  }

  ll res = 0;
  ll left = vec[0];
  ll right = vec[0];
  int flag = 1;
  while(!q.empty()){
    if(flag > 0){
      ll val = q.back(); q.pop_back();
      res += abs((int)(val - right));
      right = val;
      if(!q.empty()){
        ll val = q.back(); q.pop_back();
        res += abs(int(val - left));
        left = val;
      }
    }else{
      ll val = q.front(); q.pop_front();
      res += abs(int(right - val));
      right = val;
      if(!q.empty()){
        ll val = q.front(); q.pop_front();
        res += abs(int(left - val));
        left = val;
      }
    }

    flag *= -1;
  }

  for(int i = 0; i < vec.size() - 1; i++){
    q.pb(vec[i]);
  }

  ll res2 = 0;
  left = vec[n - 1];
  right = vec[n - 1];
  flag = -1;
  while(!q.empty()){
    if(flag > 0){
      ll val = q.back(); q.pop_back();
      res2 += abs(int(val - right));
      right = val;
      if(!q.empty()){
        ll val = q.back(); q.pop_back();
        res2 += abs(int(val - left));
        left = val;
      }
    }else{
      ll val = q.front(); q.pop_front();
      res2 += abs(int(right - val));
      right = val;
      if(!q.empty()){
        ll val = q.front(); q.pop_front();
        res2 += abs(int(left - val));
        left = val;
      }
    }

    flag *= -1;
  }
  cout << max(res, res2) << endl;

	return 0;
}


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


void solve(long long X, long long Y){
	cout << X + Y / 2 << endl;
	return;
}
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main(){

  vector<string> vs;
  map<string,int> dict;

  int idx=0;
  vs.push_back("Rock");dict["Rock"]=idx++;
  vs.push_back("Fire");dict["Fire"]=idx++;
  vs.push_back("Scissors");dict["Scissors"]=idx++;
  vs.push_back("Snake");dict["Snake"]=idx++;
  vs.push_back("Human");dict["Human"]=idx++;
  vs.push_back("Tree");dict["Tree"]=idx++;
  vs.push_back("Wolf");dict["Wolf"]=idx++;
  vs.push_back("Sponge");dict["Sponge"]=idx++;
  vs.push_back("Paper");dict["Paper"]=idx++;
  vs.push_back("Air");dict["Air"]=idx++;
  vs.push_back("Water");dict["Water"]=idx++;
  vs.push_back("Dragon");dict["Dragon"]=idx++;
  vs.push_back("Devil");dict["Devil"]=idx++;
  vs.push_back("Lightning");dict["Lightning"]=idx++;
  vs.push_back("Gun");dict["Gun"]=idx++;
  int n;
  while(cin>>n&&n!=0){
    string str;
    vector<string> hands;
    for(int i = 0; i < n; i++){
      cin>>str;
      hands.push_back(str);
    }
    bool w=false;
    for(int i = 0; i < n; i++){
      int win=0;
      int lose=0;
      int drow=0;
      int iidx=dict[hands[i]];
      for(int j = 0; j < n; j++){
	if(i==j)continue;
	// jÌèÌêðTµÄ«ÄA»ÌêÉ¶Ä
	int jidx=dict[hands[j]];
	if(iidx==jidx){
	  drow++;
	  continue;
	}
	int prv,nxt;
	// är³ÌidxÌÙ¤ª¬³¢ê
	if(iidx<jidx){
	  prv=jidx-iidx;
	  nxt=iidx+1+(vs.size()-1-jidx);
	}
	else{
	  prv=vs.size()-1-iidx+jidx+1;
	  nxt=iidx-jidx;
	}
	if(prv<nxt)
	  win++;
	else
	  lose++;
      }
      //cout<<"win:"<<win<<"lose:"<<lose<<"draw:"<<drow<<endl;
      if(lose>0)
	continue;
      else if(win>=1){
	// win
	w=true;
	cout<<hands[i]<<endl;
	break;
      }
    }
    if(!w){
      cout<<"Draw"<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 952
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    int n; string str;
    cin>>n>>str;
    if(n%2) cout<<"No"<<endl;
    else
    {
        string a,b;
        for(int i=0;i<n/2;i++) a+=str[i];
        for(int i=n/2;i<n;i++) b+=str[i];
        if(a==b) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n,a;
  scanf("%ld %ld", &n, &a);
  long x[n];
  long plus = 0, minus = 0, zero = 0;
  for (long i = 0; i < n; i++) {
    scanf("%ld", &x[i]);
    x[i] -= a;
    if (x[i] > 0) {
      plus++;
    } else if (x[i] < 0) {
      minus++;
    } else {
      zero++;
    }
  }
  qsort(x, n, sizeof(long), cmpnum);
  long plus_sum[2500+1],minus_sum[2500+1],tmp[2500+1];
  plus_sum[0] = 1;
  minus_sum[0] = 1;
  for (long i = 1; i <= 2500; i++) {
    plus_sum[i] = 0;
    minus_sum[i] = 0;
  }
  for (long i = 0; i < plus; i++) {
    for (long j = 0; j <= 2500; j++) {
      tmp[j] = 0;
    }
    for (long j = 0; x[i]+j <= 2500; j++) {
      tmp[x[i]+j] = plus_sum[j];
    }
    for (long j = 0; j <= 2500; j++) {
      plus_sum[j] += tmp[j];
    }
  }
  for (long i = plus+zero; i < n; i++) {
    for (long j = 0; j <= 2500; j++) {
      tmp[j] = 0;
    }
    for (long j = 0; -x[i]+j <= 2500; j++) {
      tmp[-x[i]+j] = minus_sum[j];
    }
    for (long j = 0; j <= 2500; j++) {
      minus_sum[j] += tmp[j];
    }
  }
  long ans = 0;
  for (long i = 0; i <= 2500; i++) {
    ans += plus_sum[i]*minus_sum[i];
  }
  ans *= pow(2,zero);
  ans--;
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
    void BubbleUp(int Index)
    {
        assert(FArray.size() > Index);
        if(Index == 1) return;
        int Parent = Index / 2;
        if(FArray[Index] <= FArray[Parent]){
            return;
        }
        std::swap(FArray[Index], FArray[Parent]);
        BubbleUp(Parent);
    }
    void BubbleDown(int Index)
    {
        assert(FArray.size() > Index);
        int Left  = Index * 2;
        if(Left  >= FArray.size()) return;
        int Right = Left + 1;
        const int& Target = Right >= FArray.size() ? Left : FArray[Left] > FArray[Right] ? Left : Right;
        if(FArray[Target] > FArray[Index]){
            std::swap(FArray[Index], FArray[Target]);
            BubbleDown(Target);
        }
    }
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        FArray.push_back(Value);
        BubbleUp(FArray.size()-1);
    }
    void pop()
    {
        assert(FArray.size() >= 1);
        FArray[1] = FArray.back();
        FArray.pop_back();
        if(FArray.size() == 1) return; // dummy???????????????
        BubbleDown(1);
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6188
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
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<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{
  int N;
  cin>>N;
  string s,t;
  cin>>s;
  cin>>t;
  int MAX = 0;
  for (int i = 0; i < N; i++)
  {
    string ss =s.substr(N-i-1,N);
    string st = t.substr(0,i+1);
    if(ss == st) chmax(MAX,i+1);
  }
  cout<<2*N - MAX<<endl;
  
  return;
}
  
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e5+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}


lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}

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

vvi graph(int n, int m){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	return v;
}

// ---- コーディングはここから！ ('-')7

void solve(){
	int n; cin>>n;
	lli k; cin>>k;
	vi v(n+1); fore(i,1,n+1)cin>>v[i];
	vi pos(n+1,-1);
	vi c;
	int x = 1;
	while(pos[x]==-1){
		pos[x]=sz(c);
		c.pb(x);
		x = v[x];
	}
	if(k<pos[x])cout<<c[k]<<ENDL;
	else {
		k-=pos[x];
		int z = sz(c)-pos[x];
		cout<<c[pos[x]+(k%z)]<<ENDL;
	}

}

int main(){_
//	int t; cin>>t; while(t--)
	solve();
}


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


const int MOD =1e9+7;
const int MAXH = 100005;
const int MAXW = 100005;

long long A[MAXH + MAXW];


long long mod_pow(long long x, long long p){
	long long res = 1;
	while(p){
		if(p&1) res = res * x % MOD;
		x = x * x % MOD;
		p >>= 1;
	}
	return res;
}

long long F2(long long x){
	return mod_pow(x, MOD-2);
}

long long F(long long h, long long w){
	return A[h+w-2] * F2(A[h-1])%MOD * F2(A[w-1])%MOD;
}


int main(){
	for(int i=A[0]=1;i<MAXH+MAXW;i++)
		A[i] = A[i-1]*i%MOD;
	
	long long H,W,A,B,ans=0;
	cin >> H >> W >> A >> B;
	
	for(int i=B+1;i<=W;i++)
	( ans += F(H-A,i) * F(A,W-i+1) % MOD) %= MOD;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

signed main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  ll s = 0, ma = 0, mb = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s -= a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    s += b[i];
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] < b[i]) {
      ma += (b[i] - a[i] + 1) / 2;
      if ((b[i] + a[i]) % 2) {
        ++mb;
      }
    } else {
      mb += a[i] - b[i];
    }
  }
  if (s >= max(ma, mb)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


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

int main(void)
{
	int a;
	char s[10];
	cin >> a >> s;
	
	if(a >= 3200)
	{
		cout << s << endl;
	}
	
	else
	{
		cout << "red" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 998244353;
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;
}


class ModCom {
    public:
        ModCom(int _n, long long _mod){
            assert(_n>=2);
            n = _n+1;
            mod = _mod;
            _fac.assign(n,0);
            _finv.assign(n,0);
            _inv.assign(n,0);
            init();
        }

        long long com(int _n, int k){
            if(_n < k){return 0;}
            if(_n < 0 || k < 0){return 0;}
            return _fac.at(_n) * (_finv.at(k) * _finv.at(_n - k) % mod) % mod;
        }

        long long fac(int _n) {
            return _fac.at(_n);
        }

        long long inv(int _n) {
            return _inv.at(_n);
        }

        long long finv(int _n) {
            return _finv.at(_n);
        }

    private:
        int n;
        long long mod;
        vector<long long> _fac;
        vector<long long> _finv;
        vector<long long> _inv;

        void init(void){
            _fac.at(0) = _fac.at(1) = 1;
            _finv.at(0) = _finv.at(1) = 1;
            _inv.at(1) = 1;
            for(int i = 2;i < n; i++){
                _fac.at(i) = _fac.at(i - 1) * i % mod;
                _inv.at(i) = mod - _inv.at(mod % i) * (mod / i) % mod;
                _finv.at(i) = _finv.at(i - 1) * _inv.at(i) % mod;
            }
            return;
        }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


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

    ll n,m,k;cin>>n>>m>>k;
    ModCom com(200000+1000,MOD);
    ll res = 0;
    rep(i,k+1) {
        ll tmp = com.com(n-1,i);
        tmp *= modpow(m-1, n-i-1, MOD);
        tmp %= MOD;
        tmp *= m;
        tmp %= MOD;
        res = (res + tmp) % MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 7952
S=list(input())

if S[0]!='A':
    print('WA')
    exit()

if S[2:len(S)-1].count('C')!=1:
    print('WA')
    exit()

S.remove('C')
S.remove('A')

for i in S:
    if i not in 'abcdefghizklmnopqrstuvwxyz':
        print('WA')
        exit()


print('AC')


Measured memory_bytes: 3060
class IrohasObsession:
	def getMinimumValue(self,n,k,d):
		nums=list(set(d)^set([0,1,2,3,4,5,6,7,8,9]))
		for i in range(100000):
			digits=[int(str(n)[i]) for i in range(len(str(n)))]
			flag=1
			for j in range(len(digits)):
				if not digits[j] in nums: flag=0
			if flag: print n; return
			n+=1
		print -1

if __name__ == "__main__":
	n,k=[int(i) for i in raw_input().split()]
	d=[int(i) for i in raw_input().split()]
	i=IrohasObsession()
	i.getMinimumValue(n,k,d)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	string s, t; cin >> s >> t;
	LL ans = (s[0]==t[2])&&(s[1]==t[1])&&(s[2]==t[0]);
	cout<<(ans?"YES":"NO")<<endl;

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    int x[10001],i=1;
    while (1){
    scanf("%d",&x[i]);
    if(x[i]==0)break;
    i++;
    }
    i=1;
    while (1){
    if(x[i]==0)break;
    printf("Case %d: %d\n",i,x[i]);
    i++;
    }
    return 0;
}

Measured memory_bytes: 640
def main():
    n = int(input())
    A = []
    B = []
    for _ in range(n):
        a, b = map(int, input().split())
        A += [a]
        B += [b]
    A.sort()
    B.sort()

    if n % 2 == 0:
        mid_pos = n // 2
        mid_A = A[mid_pos - 1] + A[mid_pos]
        mid_B = B[mid_pos - 1] + B[mid_pos]
        cnt = mid_B - mid_A + 1
    else:
        mid_pos = (n + 1) // 2 - 1
        mid_A = A[mid_pos]
        mid_B = B[mid_pos]
        cnt = mid_B - mid_A + 1
    print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 25312
#include <bits/stdc++.h>
using namespace std;
int main() {
   int n,x,y;
   cin>>n>>x>>y;
   int ans[n];
   memset(ans,0,sizeof(ans));
   for(int i=1;i<=n;i++)
   {
       for(int j=i+1;j<=n;j++)
       {
           int mn=min(abs(i-j),abs(i-x)+abs(j-y)+1);
           ans[mn]++;
       }
   }
   for(int i=1;i<n;i++)
   cout<<ans[i]<<" ";

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

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

    string s,t;
    cin>>s>>t;
    t+=s;
    cout<<t<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans,m;
string s[11];
signed main(){
	cin>>n>>m>>k;
	rep(i,n)cin>>s[i];
	rep(i,1<<n){
		rep(j,1<<m){
			int cnt=0;
			rep(ii,n){
				rep(jj,m){
					if(((1<<ii)&i)||((1<<jj)&j)){
						continue;
						
					}
					if(s[ii][jj]=='#')cnt++;
				}
			}
			//cout<<cnt<<endl;
			if(cnt==k)ans++;
			cnt=0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3648
import math

N = input()

a=[]

for i in range(1, int(math.sqrt(N)+1)):
    if(N%i==0):
        a.append(i)

b=[]

for i in a:
    x=int(math.log10(i) + 1)
    y=int(math.log10(N/i) + 1)
    b.append(max([x,y]))

print min(b)

Measured memory_bytes: 5764
import java.util.*;
public class Main {
	public static void main(String[] args){
		taskScheduling();
	}
	
	public static void taskScheduling() {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		a[0] =  sc.nextInt();
		a[1] =  sc.nextInt();
		a[2] =  sc.nextInt();
		Arrays.sort(a);
		int res = 0;
		for (int i=1; i<a.length; i++) {
			res += a[i]-a[i-1];
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 21844
ri = raw_input().split()
stack = []
for i in xrange(len(ri)):
  if ri[i] == "+":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)+int(b)))
  elif ri[i] == "-":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)-int(b)))
  elif ri[i] == "*":
    b = stack.pop()
    a = stack.pop()
    stack.append(str(int(a)*int(b)))
  else:
    stack.append(ri[i])
print stack.pop()

Measured memory_bytes: 6484
#![allow(unused_imports)]
use itertools::Itertools;
use num::integer::gcd;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        keys: [(i64, [Usize1]);m],
    }

    let ptn = 1 << n;

    let keys = keys
        .into_iter()
        .map(|(price, boxes)| {
            let boxes = boxes.into_iter().fold(0, |acc, x| acc | 1 << x);
            (price, boxes)
        })
        .collect::<Vec<(i64, usize)>>();

    let mut dp: Vec<Vec<i64>> = vec![vec![12 * 100_000 + 1; ptn + 1]; m + 1];
    dp[0][0] = 0;

    for i in 0..m {
        let (price, boxes) = &keys[i];
        for j in 0..ptn {
            dp[i + 1][j | boxes] = min(dp[i + 1][j | boxes], dp[i][j] + price);
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    let mut ans = std::i64::MAX;
    for i in 0..=m {
        ans = min(dp[i][ptn - 1], ans);
    }

    if ans >= 12 * 100_000 + 1 {
        ans = -1;
    }

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


Measured memory_bytes: 34192
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	N := getStdinInt64()
	A := getStdinIntArr64()
	Q := getStdinInt64()

	AMap := make(map[int64]int64, N+Q)
	var ASum int64 = 0
	for _, val := range A {
		AMap[val]++
		ASum += val
	}

	sumlist := make([]int64, 0)
	var i int64 = 0
	for ; i < Q; i++ {
		list := getStdinIntArr64()
		B := list[0]
		C := list[1]

		sum := ASum
		num := AMap[B]
		sum -= num * B
		sum += num * C
		ASum = sum
		AMap[B] = 0
		AMap[C] += num

		sumlist = append(sumlist, sum)
	}

	for _, val := range sumlist {
		fmt.Printf("%d\n", val)
	}
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()

#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d\n",n)
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif
//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
typedef long long int 	LL;
typedef long double 	LD;
typedef pair<int,int>   II;
typedef vector<int>     VI;
const int MOD = 1e9 + 7;
const int N = 100011;
int C[N], F[N], S[N];

int main() {
    int n;
    SI(n);
    for(int i = 0; i < n - 1; ++i) {
        SI(C[i]), SI(S[i]), SI(F[i]);
    }
    
    for(int i = 0; i < n - 1; ++i) {
        int time = S[i] + C[i];
        for(int j = i + 1; j < n - 1; ++j) {
            if(time < S[j])
                time = S[j];
            time += time % F[j] ? (F[j] - time % F[j]) : 0;
            time += C[j];
        }
        PI(time);
    }
    PI(0);

    return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

int n;
llint memo[101][5][5][5];

llint dfs(int idx, int a, int b, int c)
{
    if(idx == n) return 1;
    if(memo[idx][a][b][c] != -1) return memo[idx][a][b][c];

    llint rec = 0;
    
    rec += dfs(idx + 1, b, c, 1);
    if(!(b == 1 && c == 3)) rec += dfs(idx + 1, b, c, 2);
    if(!(b == 1 && c == 2) &&
       !(b == 2 && c == 1) &&
       !(a == 1 && c == 2) &&
       !(a == 1 && b == 2)) rec += dfs(idx + 1, b, c, 3);
    rec += dfs(idx + 1, b, c, 4);
    
    return memo[idx][a][b][c] = rec % MOD;
}

int main()
{
    ci >> n;

    memset(memo, -1, sizeof(memo));
    
    co << dfs(0, 0, 0, 0) << en;
  
    return 0;
}


Measured memory_bytes: 384
/*
   Author: Shivam Shukla
   Problem URL: 
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();
  
    string exp;
    getline(cin,exp,'\n');

    int pos = -1, op = -1;
    for(int i=0;i<exp.length();i++)
       if(exp[i] == '+' || exp[i] == '-'){
          op = exp[i] == '+' ? 1 : 0;
          pos = i;
          break;
       }

    ll n1 = stoi(exp.substr(0,pos-1)), n2 = stoi(exp.substr(pos+2));
    ll ans = op == 0 ? n1-n2 : n1+n2;
    cout<<ans<<endl;
  
    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>


#define CI cin >>
#define CO cout <<
#define E << endl;
#define F(i,max) (for(int i = 0;i < max;++i))

using namespace std;

int n = 0;
int num = 0;
int fish = 0;
int event = 0;
int max_[2] = {};
int maxx[2] = {};
vector<int>part;




int main(void) {
	CI n >> event;

	max_[1] = 0;
	
	part.resize(n, 0);

	for (int i = 0; i < event; ++i) {
		CI num;
		CI fish;
		part[num - 1] += fish;
		
		
		if (fish > 0) {
			if (part[num - 1] > max_[1]) {
				max_[0] = num;
				max_[1] = part[num - 1];
			}
			else {
				if (part[num - 1] == max_[1]) {
					if (num < max_[0]) {
						max_[0] = num;
					}
				}

			}
		}
		else {
			if (max_[0] == num) {
				for (int j = 0; j < n; ++j) {
					if (maxx[1] < part[j]) {
						maxx[1] = part[j];
						maxx[0] = j + 1;
					}
				
				}
				max_[0] = maxx[0];
				max_[1] = maxx[1];
				maxx[0] = 0;
				maxx[1] = 0;
			}
		}

		CO max_[0] << ' ' << max_[1] E
	}
	

	
	return 0;
}

Measured memory_bytes: 4964
n, k=map(int, input().split())
a=[0]+list(map(int, input().split()))

t=[1]

for i in range(2*n):
    nxt=a[t[-1]]
    t.append(nxt)

if k<n+1:
    print(t[k])
    exit()

loop_end=n
loop_start=n-1

while t[loop_start]!=t[loop_end]:
    loop_start-=1

cycle=loop_end-loop_start
k%=cycle

while k<n+1:
    k+=cycle

print(t[k])

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

typedef long long ll;

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

    int d,n;
    cin >> d >> n;
    int ans;
    if(d==0){
        if(n==100) ans = 101;
        else ans = n;
    }
    else if(d==1){
        if(n==100) ans = 10100;
        else ans = 100 * n;
    }
    else{
        if(n==100) ans = 1010000;
        else ans = 10000 * n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384