akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n,r,i,j,p,c;
        int[] yama,temp;
        yama = new int[50];
        temp = new int[50];

        while(true){
            n=scan.nextInt();
            r=scan.nextInt();
            if(n==0 && r==0){
                break;
            }

            for(i=0;i<n;i++){
                yama[i]=n-i;    //上から数える
            }

            for(i=0;i<r;i++){
                p=scan.nextInt();
                c=scan.nextInt();

                for(j=0;j<c;j++){
                    temp[j]=yama[j+p-1];
                }
                for(j=c;j<p-1+c;j++){
                    temp[j]=yama[j-c];
                }
                for(j=0;j<p-1+c;j++){
                    yama[j]=temp[j];
                }
            }
            
            System.out.println(yama[0]);
        }

    }
}


Measured memory_bytes: 38432
#include<stdio.h>
 
void spin_w(int x[]){
  int sai1[6],i;
 
  for(i=0;i<6;i++){
    sai1[i]=x[i];
  }
 
  sai1[0]=x[2];
  sai1[2]=x[5];
  sai1[3]=x[0];
  sai1[5]=x[3];
 
  for(i=0;i<6;i++){
    x[i]=sai1[i];
  }
 
}
 
void spin_side(int x[]){
int sai1[6],i;
 
for(i=0;i<6;i++){
  sai1[i]=x[i];
 }
 
sai1[1]=x[2];
sai1[2]=x[4];
sai1[3]=x[1];
sai1[4]=x[3];
 
for(i=0;i<6;i++){
  x[i]=sai1[i];
 }
}
 
 
void spin_s(int x[]){
    int sai1[6],i;
     
  for(i=0;i<6;i++){
    sai1[i]=x[i];
  }
  sai1[0]=x[4];
  sai1[1]=x[0];
  sai1[4]=x[5];
    sai1[5]=x[1];
     
  for(i=0;i<6;i++){
    x[i]=sai1[i];
  }
}
 
int conf(int x[],int y[]){
     
    int i,count=0,count2=0,a=0,sai1[6],sai2[6];
     
    for(i=0;i<6;i++){
        sai1[i]=x[i];
        sai2[i]=y[i];
    }
     
    for(i=0;i<6;i++){
    if(sai1[i]==sai2[i]){
      count++;
    }
    }
     
  if(count!=6){
        for(i=0;i<=3;i++){
            spin_w(sai1);
            count2++;
        if(sai1[0]==sai2[0])break;
        }
        if(count2==4){
            for(i=0;i<=3;i++){
            spin_s(sai1);
        if(sai1[0]==sai2[0])break;
            }
        }
             
    for(i=0;i<=3;i++){
      spin_side(sai1);
      if(sai1[1]==sai2[1] && sai1[2]==sai2[2] && sai1[3]==sai2[3] && sai1[4]==sai2[4])break;
        }
  }
 
  count=0;
 
 
  for(i=0;i<6;i++){
    if(sai1[i]==sai2[i]){
      count++;
        }
    }
    if(count==6){
        return 1;
    }else{
        return 0;
    }
}
 
int main(){
  int i,j,k,l,sai1[6],sai2[6],sai_c[105][6],n,a=0;
     
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<6;j++){
            scanf("%d",&sai_c[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<6;j++){
            sai1[j]=sai_c[i][j];
        }
        for(k=i+1;k<n;k++){
            for(l=0;l<6;l++){
                sai2[l]=sai_c[k][l];
            }
                if(conf(sai1,sai2)==1){
            a++;
            }
        }
    }
  if(a==0){
      printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2616
#include<iostream>
#include<cstdio>
using namespace std;
int f[4][4];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&f[1][1],&f[1][2],&f[2][2]);
    a=f[2][2]*3;
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[1][1]-f[2][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    f[3][2]=a-f[1][2]-f[2][2];
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
            printf("%d ",f[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static long Ceil(long a,long b)
    {
        if (a % b == 0)
            return a / b;
        else
            return a / b + 1;
    }

    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        long A = long.Parse(Console.ReadLine());
        long B = long.Parse(Console.ReadLine());
        long C = long.Parse(Console.ReadLine());
        long D = long.Parse(Console.ReadLine());
        long E = long.Parse(Console.ReadLine());

        long a = Ceil(N, A);
        long b = Ceil(N, B);
        long c = Ceil(N, C);
        long d = Ceil(N, D);
        long e = Ceil(N, E);

        long m = Math.Max(Math.Max(Math.Max(a, b), Math.Max(c, d)), e);

        Console.WriteLine(4 + m);
    }
}

Measured memory_bytes: 13140
s = input()
n = len(s)
x, y = map(int, input().split())
for i in range(n):
    if s[i]=='T':
        break
else:
    i += 1
dp = {i}
xs = []
ys = []
now = 0
xy = 'y'
for j in range(i+1, n+1):
    if j<n and s[j]=='F':
        now += 1
        continue
    if xy=='x':
        if now>0:
            xs.append(now)
        xy = 'y'
    else:
        if now>0:
            ys.append(now)
        xy = 'x'
    now = 0

for i in xs:
    newdp = set()
    for j in dp:
        newdp.add(j+i)
        newdp.add(j-i)
    dp = newdp
if x not in dp:
    print('No')
    exit(0)
dp = {0}
for i in ys:
    newdp = set()
    for j in dp:
        newdp.add(j+i)
        newdp.add(j-i)
    dp = newdp
if y in dp:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9380
#include <algorithm>
#include <stack>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int h, w; cin >> h >> w;
    string s[h]; for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i < h-1; i++)
        for (int j = 0; j < w-1; j++) {
            int c = 0;
            if (s[i][j] == '#') c++;
            if (s[i][j+1] == '#') c++;
            if (s[i+1][j] == '#') c++;
            if (s[i+1][j+1] == '#') c++;
            if (c % 2 == 1) s[i][j] = 'x';
        }
    int d[2001] = {};
    int ans = 0;
    for (int i = 0; i < h-1; i++) {
        stack<pair<int, int> > st;
        st.push(make_pair(-1, -1));
        for (int j = 0; j < w; j++) {
            if (j == w-1 || s[i][j] == 'x') d[j] = 0;
            else d[j]++;
            while (!st.empty() && st.top().first >= d[j]) {
                auto p = st.top(); st.pop();
                int x = p.first, y = p.second, y2 = st.top().second;
                ans = max(ans, (j - y2) * (x + 1));
                // cerr << i << ' ' << j << ' ' << x << ' ' << y << ' ' << y2 << endl;
            }
            st.push(make_pair(d[j], j));
        }
    }
    cout << max({ans, h, w}) << endl;
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdlib.h>
using namespace std;

bool judge(int x, string y){
    if ( x % 3 == 0 && x % 5 == 0 ) return y == "FizzBuzz";
    if ( x % 3 == 0 ) return y == "Fizz";
    if ( x % 5 == 0 ) return y == "Buzz";
    if ( !isdigit(y[0]) ) return false;
    return x == atoi(y.c_str());
}

main(){
    int m, n;
    string num;
    while(1){
	cin >> m >> n;
	if ( m == 0 && n == 0 ) break;
	vector<int> P;
	int cur = 0, w = -1;
	for ( int i = 1; i <= m; i++ ) P.push_back(i);
	for ( int i = 1; i <= n; i++ ){
	    cin >> num;
	    if ( w != -1 ) continue;
	    if ( judge(i, num) ) cur++;
	    else P.erase(P.begin() + cur);
	    cur = cur%P.size();
	    if ( P.size() == 1 ) w = P[0];
	}
	if ( w != -1 ) cout << w << endl;
	else {
	    for ( int i = 0; i < P.size(); i++ ){
		if ( i ) cout << " ";
		cout << P[i];
	    }
	    cout << endl;
	}
    }
}

Measured memory_bytes: 952
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string s;
    getline(cin, s);
    rep(i, s.size()-4){
        if(s.substr(i, 5) == "apple"){
            s.replace(i, 5, "peach");
        }else if(s.substr(i, 5) == "peach"){
            s.replace(i, 5, "apple");
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3192
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	ll n, k;
	cin >> n >> k;
	ll a[n + 1];
	for (ll i = 0; i < n; i++)
		cin >> a[i];
	int j = k, i = 0;
	while (j < n)
	{
		if (a[j] > a[i])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
		j++, i++;
	}
	return 0;
}

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

int main(){
    deque<string> s;
    string s0;
    int q;
    cin >> s0 >> q;
    s.push_back(s0);
    int is_reverse = 0;
    rep(i, q){
        int ti;
        cin >> ti;
        if (ti == 1) is_reverse++;
        else{
            int fi;
            string ci;
            cin >> fi >> ci;
            if ((fi==1 && is_reverse%2==0) || fi==2 && is_reverse%2==1){
                s.push_front(ci);
            } else {
                s.push_back(ci);
            }
        }
    }
    int n = s.size();
    if(is_reverse%2==0){
        rep(i,n){
            cout << s[i];
        }
    } else {
        rep(i,n){
            string si = s[n-1-i];
            int m = si.size();
            rep(j,m){
                cout << si[m-1-j];
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 12544
n, m = map(int, input().split())
p = [list(map(str, input().split())) for _ in range(m)]

wa = 0
ac = 0


from collections import defaultdict
dict = defaultdict(list)
for i in range(m):
    dict[p[i][0]].append(p[i][1])

for i in dict:
    if "AC" not in dict[i]:
        continue
    for j in range(len(dict[i])):
        result = dict[i][j]
        if result == "WA":
            wa += 1
        if result == "AC":
            ac += 1
            break

print(ac, wa)

Measured memory_bytes: 47404
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int N, K;

vector<int> ret;

int main() {
	cin >> K >> N;
	if (K % 2 == 0) {
		printf("%d", K / 2);
		FOR (i, N - 1)
			printf(" %d", K);
		printf("\n");
	}
	else {
		int take = N / 2;
		ret.clear();
		FOR (i, N)
			ret.pb((K + 1) / 2);
		int last = ret.sz - 1;
		FOR (i, take) {
			if (ret[last] == 0)
				last--;
			ret[last]--;
			if (ret[last] > 0) {
				ffor (j, last + 1, ret.sz)
					ret[j] = K;
				last = ret.sz - 1;
			}
		}
		FOR (i, ret.sz)
			if (ret[i] > 0)
				printf("%d ", ret[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<queue>
#include<algorithm>
#include<stack>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<len;j++)
			{				
					if(s[j]=='F') 
					{
						cout<<"Yes";
						return 0;				
					}		
			}
		}
		//if (s[i]=='C'&&s[j]=='F') cout<<"Yes"<<endl;
		//break;	
	}
	cout<<"No"<<endl;
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int N = 1e6 + 5;
const ll INF = 1e18;
char s[N];
ll dp[N][2];

void min_self(ll &a, ll b) {
	a = min(a, b);
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	scanf("%s", s+1);
	s[0] = '0';
	int n = strlen(s);

	for (int i = 0; i <= n; i++)
		for (int j = 0; j < 2; j++)
			dp[i][j] = INF;
	dp[0][0] = 0;

	for (int i = 0; i < n; i++) {
		int d = s[i] - '0';
		min_self(dp[i+1][0], dp[i][0] + d);
		min_self(dp[i+1][1], dp[i][0] + d + 1);
		min_self(dp[i+1][0], dp[i][1] + 10 - d);
		min_self(dp[i+1][1], dp[i][1] + 9 - d);
	}

	printf("%lld\n", dp[n][0]);
}


Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N)cin >> A[i];
	REVSORT(A);
	int dis = 0;
	rep(i, N){
		if(i % 2 == 0)dis += A[i];
		else dis -= A[i];
	}
	cout << dis << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <functional>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];

int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	int ret=0;
	for(int i=0;i<n;i++) if(str[i]=='g') ret++;
	ret-=(n+1)/2;
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        int n = sc.nextInt();
        long t = sc.nextLong();
        long a = sc.nextLong();
        long T = 0,A = 0;
        for (int i = 1;i < n;i++) {
            T = sc.nextLong();
            A= sc.nextLong();
            long m = Math.max((t-1)/T+1,(a-1)/A+1);
            t = T*m;
            a = A*m;
        }
        
        System.out.println(t+a);
    }
}

Measured memory_bytes: 26368
#setの利用
#ABC091B - Two Colors Card Game
#https://atcoder.jp/contests/abc091/tasks/abc091_b

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

lst = list(set(s))
ans = 0
for i in range(len(lst)):
    a = lst[i]
    b = s.count(a) - t.count(a)
    if b > ans:
        ans = b
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,ans,sum;  
int a[100005],cishu[100005];  
void f(){
    for(int i=1;i<=sum;i++){
    	if(cishu[i]>1){
    		ans+=cishu[i]-1; 
		}else{
			continue;
		}
	}
    if(ans%2==1){
    	ans+=1;
	}  
    cout<<n-ans<<endl;  
    return ;  
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cishu[a[i]]++;
        if(a[i]>=sum){
        	sum=a[i];
		}
    }
    f();
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int n, ans = 1, count = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int counter = 0, temp = i;
		while (temp % 2 == 0) {
			++counter;
			temp /= 2;
		}
		if (count < counter) {
			count = counter;
			ans = i;
		}
	}
	cout << ans << endl;
}

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

public class Main
{
    public static void main(String[] args)
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            int i;
            int n = Integer.parseInt(br.readLine());
            ArrayDeque<String> list = new ArrayDeque<String>();
            String[] num = new String[2];
            String command;
            char c;
            for(i=0; i<n; i++)
            {
                command = br.readLine();
                c = command.charAt(0);

                if(c == 'd')
                {
                    c = command.charAt(6);
                    if(c == 'F')
                    {
                        list.pollFirst();
                    }
                    else if(c == 'L')
                    {
                        list.pollLast();
                    }
                    else
                    {
                        num = command.split(" ",0);
                        list.remove(num[1]);
                    }
                }
                else
                {
                    num = command.split(" ",0);
                    list.offerFirst(num[1]);
                }
            }

            StringBuilder s = new StringBuilder();
            s.append(list.poll());
            while(list.size()>0)
            {
                s.append(" ").append(list.poll());
            }
            System.out.println(s);
        }
        catch(Exception e)
        {
        }
    }
}

Measured memory_bytes: 222208
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	string s,t;
	cin >> s >> t;
	map<char,set<int>> m;
	for(int i=0;i<s.size();i++){
		m[s[i]].insert(i+1);
	}
	for(int i=0;i<t.size();i++){
		if(m.find(t[i]) == m.end()){
			cout << "-1\n";
			return 0;
		}
	}
	long long ans = 0;
	int curr = 0;
	for(int i=0;i<t.size();i++){
		auto it = m[t[i]].upper_bound(curr);
		if(it == m[t[i]].end()){
			ans += (long long)s.size();
			curr = 0;
			it = m[t[i]].upper_bound(curr);
		}
		curr = *it;
	}
	ans += curr;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5120
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToList();

        var doubleElem = a.GroupBy(x => x).First(x => x.Count() == 2).Key;
        int firstIndexOfDouble = a.IndexOf(doubleElem);
        int lastIndexOfDouble = a.LastIndexOf(doubleElem);

        ModInt all = 1;
        ModInt duplicate = 1;
        for (int i = 1; i <= n + 1; i++)
        {
            all = (all * (n + 2 - i) / i);
            Console.WriteLine(all - duplicate);

            duplicate = duplicate * (firstIndexOfDouble + (n - lastIndexOfDouble) - i + 1) / i;
            
        }
    }
}


struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    public ModInt(long data) { Data = data; Eval(); }

    private long Eval() => (Data %= MOD) < 0 ? Data += MOD : Data;
    public static implicit operator long(ModInt modInt) => modInt.Eval();
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, ModInt b) => new ModInt(a.Eval() + b.Eval());
    public static ModInt operator -(ModInt a, ModInt b) => new ModInt(a.Eval() - b.Eval());
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt(a.Eval() * b.Eval());
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b.Eval(), MOD - 2);

    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}

Measured memory_bytes: 36472
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N + 1);
    vector<long long> B(N + 1);
    A[0] = 0;
    B[0] = 0;
    rep(i, 1, N + 1) {
        cin >> A[i];
        B[i] = 0;
    }
    int count = 0;
    rep(i, 1, N + 1) {
        int k = N + 1 - i;
        int sum = 0;
        rep(r, 2, N + 1) {
            if(k * r > N) {
                break;
            }
            sum += B[k * r];
            // cout << "k:" << k << "sum:" << sum << endl;
        }
        // cout << "k:" << k << "sum:" << sum << "Ak:" << A[k] << endl;
        if((sum % 2) != A[k]) {
            B[k] = 1;
            count++;
        }
    }
    cout << count << endl;
    rep(i, 1, N + 1) {
        if(B[i] == 1) {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 3968
#include "bits/stdc++.h"
using namespace std;

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

    int k;
    string s;
    cin >> k >> s;

    if (s.size() <= k)
        cout << s << '\n';
    else {
        string ans = s.substr(0, k);
        ans += "...";
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main(){
	int n;
	int a[100000];
	int cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
	}
	for (int i = 0; i < n; i++){
		/*if (a[i] < i){
			break;
		}*/
		if (a[a[i]] == i){
			cnt += 1;
		}
	}
	cout << cnt/2 << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

double w,h,x,y;

int main(){
	cin >> w >> h >> x >> y;
	cout << w*h / 2.0 << " " << (((ll)x*2 == (ll)w && (ll)y*2 == (ll)h) ? 1 : 0) << endl;
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  char x;
  cin >> x;
  if(int(x) < 97)cout << "A" << endl;
  else cout << "a" << endl;

}


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

string TL(string s){
    string t = s;
    for(int i=0;i<s.size();i++){
        t[i] = tolower(s[i]);
    }
    return t;
}


int main(){
    string W,T;

    cin >> W;
    W = TL(W);

    int ct=0;

    while(1){
       
        cin >> T;
       
        if(T == "END_OF_TEXT")break;

        T = TL(T);

        if(T == W){
            ct++;  
        }


    }

    cout << ct << endl;

    return 0;

}


Measured memory_bytes: 3156
## parse input
N, M = map(int, input().split()) # throw N away
Hs = list(map(int, input().split())) # int[N]
Rs = [] # (int, int)[M]

for i in range(M):
  a, b = map(int, input().split())
  Rs.append((a-1, b-1))

## preperation
#height_conds = [False]*N*N # boolean[N, N] if Hs[fst] > Hs[snd]
#for i in range(N):
#  for j in range(i+1, N):
#    height_conds[i*N+j] = Hs[i] > Hs[j]
#    height_conds[j*N+i] = Hs[j] > Hs[i]

## main
goods = [True] * N

for r in Rs:
  a, b = r
  if goods[a]:
  	goods[a] = Hs[a]>Hs[b]#height_conds[a*N+b]
  if goods[b]:
  	goods[b] = Hs[b]>Hs[a]#height_conds[b*N+a]

counter = 0
for i in range(N):
  if goods[i]:
    counter += 1

print(counter)


Measured memory_bytes: 27340
import sys
ip = sys.stdin.readline

N = int(input().rstrip())
A = list(map(int, ip().rstrip().split()))
B = list(map(int, ip().rstrip().split()))

s = 0
for i in range(N):
    c1 = min(A[i], B[i])
    s += c1
    B[i] -= c1
    c2 = min(A[i+1], B[i])
    s += c2
    A[i+1] -= c2

print(s)

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

using namespace std;

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {

	var n int
	var m int
	var sum int
	var list []int
	var salist []int

	fmt.Scan(&m)
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var l int
		fmt.Scan(&l)
		list = append(list, l)
	}

	sort.Ints(list)

	for i := 0; i < n-1; i++ {
		salist = append(salist, list[i+1] - list[i])
	}

	sort.Ints(salist)
	for i := 0; i < n-m; i++ {
		sum += salist[i]
	}

	fmt.Println(sum)

}


Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll N, T;
  std::cin >> N >> T;
  std::vector< ll > vt(N, 0);
  std::vector< ll >::iterator it;

  for (ll i = 0; i < N; i++) {
    std::cin >> vt[i];
  }

  ll sum  = 0;
  ll l_time = 0;
  ll r_time = 0;
  for (it = vt.begin(); it != vt.end(); it++) {
    l_time = r_time > *it ? r_time : *it;
    r_time = *it + T;
    sum += r_time - l_time;
  }

  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 1792
def LI():
    return list(map(int, input().split()))


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]


N, M, K = LI()
par = [-1]*N
not_kouho = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)
    not_kouho[a-1].append(b-1)
    not_kouho[b-1].append(a-1)

for i in range(K):
    a, b = map(int, input().split())
    if same(a-1, b-1):
        not_kouho[a-1].append(b-1)
        not_kouho[b-1].append(a-1)

for i in range(N):
    print(size(i)-len(not_kouho[i])-1, end=" ")


Measured memory_bytes: 37136
# -*- coding: utf-8 -*-
# abc141/abc141_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K, Q = i2nn()
    player = [0] * N
    for _ in range(Q):
        a = i2n() - 1
        player[a] += 1
    for p in player:
        print('Yes' if p + K > Q else 'No')
    return

main()


Measured memory_bytes: 4680
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,*a=map(int,open(0).read().split())\n"
"d={}\n"
"for i in a:d[i]=d.get(i,0)+1\n"
"print(sum(d[i]-i*(d[i]>=i)for i in d))\n"
"\"";
  system(s);
  return 0;
}            

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

int main() 
{
    string str;
    cin >> str;
    string ans = "";
    for (int i = 0; i < str.length(); i++) {
        if (i == 0 || i % 2 == 0) {
            ans += str[i];
        }
    }
    cout << ans << endl;
}

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

using namespace std;


#define mod        1000000007
#define ft         first
#define sd         second
#define pb         push_back
#define all(x)     x.begin(),x.end()
#define ll         long long int
#define bl         bool
#define db         long double
#define vbi        vector<bool> 
#define vlli       vector<ll>
#define mp         make_pair
#define ms(x,v)    memset(x, v, sizeof x)
#define cnl        printf("\n");
#define fr(i,b)    for(ll i=0; i<=b; i++)
#define frr(i,b)   for(ll i=0;i<b;i++)
#define fb(i,b)    for(ll i=b-1; i>=0; i--)
#define PI         3.14159265
ll i,j,k;

int main(){
ll a,b; cin>>a>>b;
if((a+b)%2==0) {
  ll c=(a+b)/2;
  cout<<c<<endl;
}
else{
  cout<<"IMPOSSIBLE"<<endl;
}









return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[200010];
int B[200010];
int find(int a){
    if(f[a] == a) return a;
    return f[a] = find(f[a]);
}
void jr(int a,int b){
    int t1 = find(a), t2 = find(b);
    if(t1 != t2) f[t1] = t2;
}
int n, m, x, y;
int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1 ; i <= 200000 ; i++) f[i] = i;
	for(int i = 1 ; i <= m ; i++){
		scanf("%d%d", &x, &y);
		jr(x, y);
	}
	int Ans = 0;
	for(int i = 1 ; i <= n ; i++){
		B[find(i)]++;
		Ans = max(Ans, B[find(i)]);
	}
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 10848
#include <stdio.h>
int main(void)
{
    int m,f,r,i,j;
  
 for(i=1;i>0;i++)
 {
     
        scanf("%d %d %d",&m,&f,&r);
  
        if(m==-1&&f==-1&&r==-1)
        {
            i = i*-1;
        }
      
        else
        {
     
        if(m==-1||f==-1)
        {
            printf("F\n");
        }
        else
        {
  
            if(m+f>=80)
            {
                printf("A\n");
            }   
      
            if(m+f>=65&&m+f<80)
            {
                printf("B\n");
            }
             
            if(m+f>=50&&m+f<65)
            {
             
                printf("C\n");
             
            }
             
            if(m+f>=30&&m+f<50)
            {
                if(r>=50)
                {
                    printf("C\n");
                }
                else
                {
                    printf("D\n");
                }   
            } 
  
                if(m+f<30)
                {
                    printf("F\n");
                }
  
             
        }
      }
 }  
    return 0;
  
  
  
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

#define MOD 1000000007

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n,m;
    cin>>n>>m;
    vector<int> dp(n+1);
    for(int i=0; i<m; i++){
        int tmp;
        cin>>tmp;
        dp[tmp]=-1;
    }

    dp[0]=1;
    for(int i=1; i<=n; i++){
        if(dp[i]==-1) continue;
        if(i>0 && dp[i-1]!=-1) dp[i]=dp[i-1];
        if(i>1 && dp[i-2]!=-1) dp[i]=(dp[i]+dp[i-2])%MOD;
    }
    cout<<dp[n];

    return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main(){
    int a, b;
    char op;
    int ans;
    std::cin >> a >> op >> b;

    switch(op){
        case '+':
            ans = a + b;
            break;
        case '-':
            ans = a - b;
            break;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll a, b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string l;
  cin >> n >> l;
  vector<int> s(n + 1, 0);
  vector<int> ans(n, 0);
  
  for (int i = 0; i < n; i++){
    if (l.at(i) == 'W'){
      s.at(i + 1) = s.at(i) + 1;
    }
    else{
      s.at(i + 1) = s.at(i);
    }
  }
  
  for (int i = 0; i < n; i++){
    ans.at(i) = s.at(i) + (n - (i + 1) - (s.at(n) - s.at(i + 1)));
  }
  
  sort(ans.begin(), ans.end());
  
  cout << ans.at(0) <<endl;
 
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    vector<string> month = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
    string L = S.substr(0, 2);
    string R = S.substr(2, 2);
    int l = 0;
    int r = 0;
    for(int i=0; i<12; i++) {
        if(L == month.at(i)) {
            l = 1;
        }
        if(R == month.at(i)) {
            r = 1;
        }
    }
    if(l) {
        if(r) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else if(r) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const double pi=acos(-1);



//基本的に勝つ手をだす．
//勝つ手がなければ，K回後に勝つ手以外を出す．

int main(){
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;



}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int d;
    ll g;
    cin >> d >> g;
    vector<ll>p(d),c(d);
    REP(i,d)cin >> p[i] >> c[i];
    ll answer = INT64_MAX;
    ll ope,tmpscore;
    for (int bit = 0; bit < (1<<d); ++bit) {
        ope=tmpscore=0;
        int max_pro=0;
        for (int i = 0; i < d; ++i) {
            if (bit & (1<<i)) {
                ope+=p[i];
                tmpscore+=p[i]*(i+1)*100+c[i];
            }else{
                max_pro = max(max_pro,i);
            }
        }
        int j = 0;
        while(tmpscore < g && j < p[max_pro]-1){
            tmpscore+=100*(max_pro+1);
            ope++;
            j++;
        }
        if(tmpscore >= g){
            answer = min(answer,ope);
        }
    }
    cout << answer << endl;
    return 0;
}

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

int main() {
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;

  int a = 0;
  string u(n, '.');
  for (int i = 0; i < n; i++) {
    switch (t[n - 1 - i]) {
      case 'r': {
        if (i < k || i - k >= 0 && u[i - k] != 'p') {
          a += p;
          u[i] = 'p';
        }
        break;
      }
      case 's': {
        if (i < k || i - k >= 0 && u[i - k] != 'r') {
          a += r;
          u[i] = 'r';
        }
        break;
      }
      case 'p': {
        if (i < k || i - k >= 0 && u[i - k] != 's') {
          a += s;
          u[i] = 's';
        }
        break;
      }
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 512
#class Array
#	def cumsum
#		r = 0
#		return self.map { |x| r+=x }
#	end
#end


x = $<.read.split.map(&:to_i)
N, A = x.shift(2)
x.map! { |y| A - y }.sort!

#idx = x.bsearch_index { |y| y >= 0 } || 0

#z = x[idx...N].reverse.cumsum.reverse || [0]
#z = [z[0]] * [idx,0].max + z  << 0

h = Hash.new(0)
h[0]=1

N.times do |i|
	hh = h.dup
	h.each do |k, v|
#		if x[i] + k + z[i] < 0
#			h.delete(x[i]+k)
#			next
#		p [x[i],k,hh[x[i]+k]]
		hh[x[i]+k] += v 
	end
	h = hh.dup
end
p h[0]-1


Measured memory_bytes: 4732
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int BIT_FLAG_0 = (1<<0);
const unsigned int BIT_FLAG_1 = (1<<1);
const unsigned int BIT_FLAG_2 = (1<<2);
const unsigned int BIT_FLAG_3 = (1<<3);
const unsigned int BIT_FLAG_4 = (1<<4);
const unsigned int BIT_FLAG_5 = (1<<5);
const unsigned int BIT_FLAG_6 = (1<<6);
const unsigned int BIT_FLAG_7 = (1<<7);


#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;



int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<b){if(a<c&&c<b)cout<<"Yes"; else cout<<"No";}
  else{if(c<a&&c>b)cout<<"Yes"; else cout<<"No";}
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args) throws Exception{

        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()){

            int x = sc.nextInt();
            int y = sc.nextInt();

            if(x == 0 && y == 0){
                break;
            }
            if(x < y){
                System.out.println(x + " " + y);
            }else {
                System.out.println(y + " " + x);
            }
        }

    }
}

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

#define ROOT 0
#define INTERNAL 1
#define LEAF 2

struct node {
  int id;
  int deg;
  int height;
  struct node *parent;
  int depth;
  int type;
  int child_id[2];
  struct node *child[2];
  struct node *sibling;
};

struct node *tree;

void set_depth(struct node *p);
int set_height(struct node *p);

int main(int argc, char *argv[])
{
  int i, j, n, num, ch;
  struct node *tmp;

  scanf("%d", &n);

  tree = (struct node *)malloc(sizeof(struct node) * n);

  for (i = 0; i < n; i++) tree[i].parent = NULL;

  for (i = 0; i < n; i++) {
    scanf("%d", &num);
    tree[num].id = num;

    tree[num].deg = 0;
    for (j = 0; j < 2; j++) {
      scanf("%d", &(tree[num].child_id[j]));
      if (tree[num].child_id[j] == -1) tree[num].child[j] = NULL;
      else {
	tree[num].deg++;
	ch = tree[num].child_id[j];
	tree[num].child[j] = &tree[ch];
	tree[ch].parent = &tree[num];
      }
    }

    if (tree[num].child[0] == NULL && tree[num].child[1] == NULL) {
      tree[num].type = LEAF;
    } else {
      tree[num].type = INTERNAL;
      if (tree[num].child[0] != NULL && tree[num].child[1] == NULL) {
	tree[num].child[0]->sibling = NULL;
      } else if (tree[num].child[0] == NULL && tree[num].child[1] != NULL) {
	tree[num].child[1]->sibling = NULL;
      } else {
	tree[num].child[0]->sibling = tree[num].child[1];
	tree[num].child[1]->sibling = tree[num].child[0];
      }
    }
  }

  for (i = 0; i < n; i++) {
    if (tree[i].parent == NULL) {
      tree[i].type = ROOT;
      break;
    }
  }
  set_depth(&tree[i]);
  set_height(&tree[i]);

  for (i = 0; i < n; i++) {
    printf("node %d: ", tree[i].id);
    
    if (tree[i].parent == NULL) printf("parent = -1, ");
    else printf("parent = %d, ", tree[i].parent->id);

    if (tree[i].sibling == NULL) printf("sibling = -1, ");
    else printf("sibling = %d, ", tree[i].sibling->id);
    
    printf("degree = %d, ", tree[i].deg);

    printf("depth = %d, ", tree[i].depth);

    printf("height = %d, ", tree[i].height);
    
    if (tree[i].type == ROOT) printf("root\n");
    else if (tree[i].type == INTERNAL) printf("internal node\n");
    else printf("leaf\n");
  }

  return 0;
}

void set_depth(struct node *p)
{
  int i;

  if (p->parent == NULL) p->depth = 0;
  else p->depth = p->parent->depth + 1;

  for (i = 0; i < 2; i++) {
    if (p->child[i] != NULL) set_depth(p->child[i]);
  }
}

int set_height(struct node *p)
{
  if (p->child[0] == NULL && p->child[1] == NULL) {
    p->height = 0;
  } else if (p->child[0] != NULL && p->child[1] == NULL) {
    p->height = set_height(p->child[0]) + 1;
  } else if (p->child[0] == NULL && p->child[1] != NULL) {
    p->height = set_height(p->child[1]) + 1;
  } else {
    p->height = (int)fmax(set_height(p->child[0]), set_height(p->child[1])) + 1;
  }

  return p->height;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

int main(){

    int N;
	int sum = 0;
 
	scanf("%d", &N);
	int tmp = N;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (N % sum == 0) {
		puts("Yes");
	} else {
		puts("No");
	}

    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

using Graph = vector<vector<int>>;

const int MOD = 1000000007;

//INT_MAX	2,147,483,647 = 2*1.0e9

vector<ll> colPat;
ll N, K;

void dfs(Graph& _g, int _v, int _p, ll _c){
  colPat[_v] = _c;

  int colOp;
  if(_p == -1) colOp = K-1;
  else colOp = K-2;

  for(auto nv : _g[_v]){
    if(nv == _p) continue;
    dfs(_g, nv, _v, colOp);
    colOp--;
  }
}


int main(){

  cin >> N >> K;
  Graph g(N);

  for(int i = 0; i < N-1; i++){
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  colPat.assign(N, 0);
  dfs(g, 0, -1, K);

  ll ans = 1;
  for(int i = 0; i < N; i++){
    ans *= colPat[i];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int P=924844033;
int n,d,len=1,f[N][2],g[N][2];
long long fac[N];
int main(){
	scanf("%d%d",&n,&d),fac[0]=fac[1]=f[0][0]=g[0][0]=1;
	for(int i=2;i<=n;i++)	fac[i]=fac[i-1]*i%P;
	for(int i=1;i<=d;i++){
		for(int j=1;j<=len;j++)
			g[j][0]=(g[j][0]+g[j][1])%P,g[j][1]=0;
		for(int j=i+d;j<=n;j+=d,++len){
			for(int k=1;k<=len;k++){
				f[k][0]=(g[k][0]+g[k][1])%P;
				f[k][1]=g[k-1][0];
			}
			for(int k=1;k<=len;k++){
				g[k][0]=f[k][0];
				g[k][1]=f[k][1];
			}
		}
	}
	for(int i=d+1;i<=d*2;i++){
		for(int j=1;j<=len;j++)
			g[j][0]=(g[j][0]+g[j][1])%P,g[j][1]=0;
		for(int j=i;j<=n;j+=d,++len){
			for(int k=1;k<=len;k++){
				f[k][0]=(g[k][0]+g[k][1])%P;
				f[k][1]=g[k-1][0];
			}
			for(int k=1;k<=len;k++){
				g[k][0]=f[k][0];
				g[k][1]=f[k][1];
			}
		}
	}
	long long ans=fac[n];
	for(int i=1;i<=n;i++)
		ans=(ans+(i&1?-1:1)*fac[n-i]*(f[i][0]+f[i][1])%P)%P;
	printf("%lld\n",(ans+P)%P);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int max(int a,int b)
{
    return a>b?a:b;
}
string lcs(string a,string b)
{
    string s="";
    int lcs[a.length()+1][b.length()+1];
    for(int i=0;i<=a.length();i++)
    {
        for(int j=0;j<=b.length();j++)
        {
            if(i==0||j==0)
            {
                lcs[i][j]=0;
            }
            else if(a[i-1]==b[j-1])
            {
                lcs[i][j]=lcs[i-1][j-1]+1;
            }
            else
                lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
        }
    }
    int i=a.length(),j=b.length();
    while(i!=0 && j!=0)
    {
        if(a[i-1]==b[j-1])
        {
            s=s+a[i-1];
            i--;
            j--;
        }
        else
        {
            if(lcs[i-1][j]>lcs[i][j-1])
            {
                i--;
            }
            else
                j--;
        }
    }
    string s1="";
    for(int k=s.length()-1;k>=0;k--)
    {
        s1=s1+s[k];
    }
    return s1;
}
int main()
{
    string s1,s2;
    cin>>s1;
    cin>>s2;
    cout<<lcs(s1,s2);
    return 0;
}


Measured memory_bytes: 35456