akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

// /*   nCr % mod

const int N = 200090;
ll fact[N];
ll finv[N];
ll inv[N];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < N;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}


int NN, a, b;
vector<int> g[1<<20];

ll C[1<<20]; // count of nodes in subtree i
ll P[1<<20]; // possible way to fill subtree i --> (MAIN ROOT:0)
ll A[1<<20]; // exact answer when MAIN ROOT: i

void dfs(int s, int p) {
  ll ans = 1;
  ll count = 0;
  for(auto x: g[s]) {
    if(x != p) {
      dfs(x, s);
      count += C[x];
      ans = ans*P[x]%mod*finv[C[x]]%mod;
    }
  }

  (ans *= fact[count]) %= mod;
  P[s] = ans;
  C[s] = count+1;
}


void dfs2(int s, int p) {
  if(p == -1) A[s] = P[s];
  else {
    A[s] = A[p]*fact[NN-1-C[s]]%mod*fact[C[s]]%mod*finv[NN-C[s]]%mod*finv[C[s]-1]%mod;
  }
  // debug(A[s]);

  // A[1]=1
  // P[s]=1
  // A[p]=1
  // C[s]=1
  // s=2,p=1
  // ((A[p]/P[s])/fact[N-1])*fact[N-1-C[s]]*fact[C[s]] * (P[s] / fact[N-C[s]])*fact[n-1]/fact[C[s]-1]

  for(auto x: g[s]) {
    if(x != p) {
      dfs2(x, s);
    }
  }

}

int main() {

//  freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> NN;
  rep(i, NN-1) {
    cin >> a >> b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  inverse_modulao();
  // rep(i, NN) {
    dfs(0, -1);
    // debug(P[i]);
  // }

  dfs2(0, -1);
  rep(i, NN) {
    cout << A[i] << endl;
  }



  return 0;
}


Measured memory_bytes: 44148
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin>>n>>m;
    vector<string> a(n),b(m);
    rep(i,0,n) cin>>a[i];
    rep(i,0,m) cin>>b[i];

Rep(i,0,n-m){
        Rep(j,0,n-m){
            bool f=true;
            rep(k,0,m){
                rep(l,0,m){
                    if(a[i+k][j+l]!=b[k][l]) f=false;
                }
            }
            if(f){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <bitset>
#include <climits>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define SZ(x) ((int)(x).size())
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 222222;
int a[maxn];
LL L;
int n;
int main(int argc, char const *argv[])
{
    RI(n);
    cin>>L;
    REP(i,n){
        RI(a[i]);
    }
    
    int i = 0;
    for(;i<n-1;++i)if((LL)a[i]+a[i+1] >= L)break;
    if(i==n-1){
        puts("Impossible");
        return 0;
    }
    i++;
    puts("Possible");
    vector<int>ans;
    for(int j=1;j<i;++j)ans.push_back(j);
    for(int j=n-1;j>i;--j)ans.PB(j);
        ans.PB(i);

    for(int j=0;j<SZ(ans);++j)OI(ans[j]);

    return 0;
}

Measured memory_bytes: 1656
n = int(input())
a = list(map(int, input().split()))
a.append(0)
ans = 1000
mx = -1
mn = -1
i = n-1
for j in range(n-1):
    if a[j]<a[j+1]:
        mn = a[j]
        i = j
        break
dec = False
if(i==n-1):
    dec = True
while i<n:
    if not dec and a[i]>a[i+1]:
        mx = a[i]
        dec = True
        ans += (mx-mn)*(ans//mn)
    if dec and a[i]<a[i+1]:
        mn = a[i]
        dec = False
    i+=1
        
print(ans)

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

void fnInput(string& rsColor)
{
  int nColorSiz;
  cin >> nColorSiz >> rsColor;
}

int fnColorCount(string sColor)
{
  int nColorCnt = 0;
  int nBgn = 0;

  while (nBgn < sColor.size())
  {
    nColorCnt++;
    int nFoward = nBgn;

    while ( nFoward < sColor.size()  &&
            sColor[nFoward] == sColor[nBgn] )
      nFoward++;

    nBgn = nFoward;
  }
  return nColorCnt;
}

int main()
{
  string sColor;

  fnInput(sColor);
  cout << fnColorCount(sColor) << endl;

  return 0;
}

Measured memory_bytes: 512
import math , sys

H,W = list(map( int, input().split() ))
maze = []
for i in range(H):
    maze.append(input())
if H==1:
    print(W-1)
    sys.exit()
if W ==1:
    print(H-1)
    sys.exit()

di = [(-1,0),(1,0),(0,1),(0,-1)]
"""
def sol(s,g):
    h = s[0] ; w = s[1]
    gh, gw = g
    d = [[math.inf for _ in range(W)] for _ in range(H)]
    cand = []
    dis = 0
    while True:
        for each in di:
            dh , dw = each
            if h + dh>=0 and h + dh<H and w + dw>=0 and w + dw<W and maze[h+dh][w+dw]=="." and d[h+dh][w+dw]>dis+1:
                cand.append((h+dh, w+dw))
                d[h+dh][w+dw] = dis +1
        if len(cand)==0:
            break
        h , w =cand.pop(0)
        dis = d[h][w]
    return d[g[0]][g[1]]
"""
ans = 0
for h in range(H):
    for w in range(W):
        if maze[h][w]=="#":
            continue
        d = [[math.inf for _ in range(W)] for _ in range(H)]
        cand = []
        dis = 0
        while True:
            for each in di:
                dh , dw = each
                if h + dh>=0 and h + dh<H and w + dw>=0 and w + dw<W and maze[h+dh][w+dw]=="." and d[h+dh][w+dw]>dis+1:
                    cand.append((h+dh, w+dw))
                    d[h+dh][w+dw] = dis +1
                    ans = max(ans, dis+1)
            #print(h,w,cand, d,dis,ans)
            if len(cand)==0:
                break
            h , w =cand.pop(0)
            dis = d[h][w]

print(ans)

Measured memory_bytes: 74372
n=int(input())
a_list=list(input().split())
a_list = [int(n) for n in a_list]
a_list.sort(reverse=True)
a = 0
b = 0
for i in range(n):
    if i % 2 == 0:
        a += int(a_list[i])
    elif i % 2 == 1:
        b += int(a_list[i])
print(a-b)

Measured memory_bytes: 3064
K,N=[int(i) for i in input().split()]
A=list(map(int,input().split()))
kyori=[abs(A[i+1]-A[i]) for i in range(N-1)]
kyori.append(K-A[N-1]+A[0])
a=max(kyori)
saitan=K-a
print(saitan)


Measured memory_bytes: 26444
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int m = sc.nextInt();
      int f = sc.nextInt();
      int r = sc.nextInt();
      if (m == -1 && f == -1 && r == -1) break;
      if (m == -1 || f == -1) {
        System.out.println("F");
      } else if (m + f >= 80) {
        System.out.println("A");
      } else if (m + f >= 65) {
        System.out.println("B");
      } else if (m + f >= 50) {
        System.out.println("C");
      } else if (m + f >= 30) {
        if (r >= 50) {
          System.out.println("C");
        } else {
          System.out.println("D");
        }
      } else {
        System.out.println("F");
      }
    }
  }
}



Measured memory_bytes: 26336
while True:
    try:
        li=list(input())
        JOI=0
        IOI=0
        for i in range(len(li)-2):
            if li[i]=='J' and li[i+1]=='O' and li[i+2]=='I':
                JOI+=1
            if li[i]=='I' and li[i+1]=='O' and li[i+2]=='I':
                IOI+=1
        print(JOI)
        print(IOI)
        
    except:
        break


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

ll dp[3333][3333];
ll sum[3333][3333];

void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

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

	ll n, m;cin >> n >> m;
	vector<ll> a(n);REP(i, n)cin >> a[i];
	vector<ll> b(m);REP(i, m)cin >> b[i];

	REP(i, n){
		REP(j, m){
			if(a[i] == b[j]){
				mod_add(dp[i][j], 1);
				if(i > 0 && j > 0){
					mod_add(dp[i][j], sum[i-1][j-1]);
				}
			}
			sum[i][j] = dp[i][j];
			if(i > 0)mod_add(sum[i][j], sum[i-1][j]);
			if(j > 0)mod_add(sum[i][j], sum[i][j-1]);
			if(i > 0 && j > 0)mod_add(sum[i][j], MOD - sum[i-1][j-1]);
		}
	}

	cout << sum[n-1][m-1] + 1 << endl;

	return 0;
}


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

int main(){
	int n;
	scanf("%d",&n);
	int p[n],q[n];
	for(int i=0;i<n;i++)scanf("%d",&p[i]);
	for(int i=0;i<n;i++)scanf("%d",&q[i]);
	int arr[n]; for(int i=0;i<n;i++)arr[i]=i+1;
	int a=-1,b=-1;
	int c=0;
	do{
		bool poss=1;
		for(int i=0;i<n;i++){
			if(arr[i]!=p[i])poss=0;
		}
		if(poss)a=c;
		poss=1;
		for(int i=0;i<n;i++){
			if(arr[i]!=q[i])poss=0;
		}
		if(poss)b=c;
		c++;
	}while(next_permutation(arr,arr+n));
	printf("%d",abs(a-b));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;
using ll = long long;

int main()
{
  int H,W;
  cin >> H >> W;
  int ch,cw,dh,dw;
  cin >> ch >> cw >> dh >> dw;
  vector<string> s(H);
  for(int i=0;i<H;i++) cin >> s[i];

  // 0～h,wの座標系で処理をするため
  ch--;
  cw--;
  dh--;
  dw--;

  deque<pair<int,int>> que;
  vector<vector<int>> dist(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      dist[i][j] = -1;
    }
  }

  //初期条件
  que.push_front(make_pair(ch,cw));
  dist[ch][cw] = 0;

  //bfs
  //distはそのマスにたどり着くために必要な最小のワープ回数
  while(!que.empty()){
    pair<int,int> v = que.front();
    que.pop_front();

    int h = v.first;
    int w = v.second;

    for(int i=-2;i<=2;i++){
      for(int j=-2;j<=2;j++){
        int nh = h + i;
        int nw = w + j;

        if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if(nh == h && nw == w) continue;
        if(s[nh][nw] == '#') continue;


        if(!((i==0&&j==-1)||(i==0&&j==1)||(i==-1&&j==0)||(i==1&&j==0))){
          if(dist[nh][nw] == -1){
            dist[nh][nw] = dist[h][w] + 1;
            que.push_back(make_pair(nh,nw));
          }else if(dist[nh][nw] > dist[h][w] && dist[h][w] != -1){
            dist[nh][nw] = dist[h][w] + 1;
            que.push_back(make_pair(nh,nw));
          }
        }else{
          if(dist[nh][nw] == -1){
            dist[nh][nw] = dist[h][w];
            que.push_front(make_pair(nh,nw));
          }else if(dist[nh][nw] > dist[h][w] && dist[h][w] != -1){
            dist[nh][nw] = dist[h][w];
            que.push_front(make_pair(nh,nw));
          }
        }
      }
    }
  }

  cout << dist[dh][dw] << endl;
}

Measured memory_bytes: 9968
n = int(input())
list_a = [int(input()) for _ in range(n)]

ans = -1
num = 1
cnt = 0
for _ in range(n):
    num = list_a[num-1]
    cnt += 1
    if num == 2:
        ans = cnt
        break
    if cnt == n+1:
        break

print(ans)

Measured memory_bytes: 7084
def bag(x):
  max_num = x // 100
  print(int(max_num * 5 >= x % 100))
 
if __name__ == "__main__":
  import sys
  in_str = ''
  for line in sys.stdin:
    in_str += line
  n = [int(_) for _ in in_str.split()][0]
  bag(n)

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a == 2 && b == 2)cout << "Yes" << endl;
    else if(a == 4 || a == 6 || a == 9 || a == 11){
        if(b == 4 || b == 6 || b == 9 || b == 11){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else if(a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12){
        if(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}

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


int main() {
  long a,b,c,d,n;
  cin >> a>>b>>c>>d>>n;
  if(n%2==0){
    long ans;
    ans=min(4L*a*n,2L*b*n);
    ans=min(ans,c*n);
    ans=min(ans,n/2*d);
    cout<<ans<<endl;
  }
  else{
    long ans;
    ans=min(4L*a*n,2L*b*n);
    ans=min(ans,c*n);
    ans=min(ans,n/2*d+ans/n);
    cout<<ans<<endl;
  }
  
}

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

using namespace std;
vector<int> B;
vector<int> C;

bool calc(int a[], int n, vector<int>& Vec)
{
	Vec.push_back(a[n - 1]);
	if(n == 10)
	{
		return(true);
	}
	if(B[B.size() - 1] > a[n] && C[C.size() - 1] > a[n])
	{
		return(false);
	}
	else if(B[B.size() - 1] < a[n] && C[C.size() - 1] < a[n])
	{
		return(calc(a, n + 1, B) || calc(a, n + 1, C));
	}
	else if(B[B.size() - 1] < a[n])
	{
		return(calc(a, n + 1, B));
	}
	else if(C[C.size() - 1] < a[n])
	{
		return(calc(a, n + 1, C));
	}
}

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		B.clear();
		C.clear();
		int a[10];
		for(int i = 0; i < 10; ++i)
		{
			cin >> a[i];
		}
		C.push_back(0);
		if(calc(a, 1, B))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while(true){
			String[] str = (br.readLine()).split(" ");
			int x = Integer.parseInt(str[0]); 
			int y = Integer.parseInt(str[1]); 
			if ( x==0 && y==0) {
				break;
			}else if(x < y){
				sb.append(x).append(" ").append(y).append("\n");
			}else{
				sb.append(y).append(" ").append(x).append("\n");
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 26388
#include <cstdio>
using ll = long long;
constexpr int MOD = 1e9 + 7;
inline int quick_pow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		n >>= 1;
	}
	return res;
}
int fact[1000005], inv[1000005], dp[1000005][2];
int main()
{
	// freopen("AGC032-F.in", "r", stdin);
	int n, ans = 0;
	scanf("%d", &n);
	fact[0] = 1;
	for (int i = 1; i <= n; i++)
		fact[i] = (ll)fact[i - 1] * i % MOD;
	inv[n] = quick_pow(fact[n], MOD - 2);
	for (int i = n; i; i--)
		inv[i - 1] = (ll)inv[i] * i % MOD;
	dp[0][0] = 1;
	for (int k = 0; k < n; k++)
	{
		dp[k + 1][0] = (dp[k][1] + dp[k][1]) % MOD;
		dp[k + 1][1] = (dp[k][0] + dp[k][1]) % MOD;
	}
	for (int k = 1; k <= n; k++)
	{
		int val = (ll)fact[n] * inv[k] % MOD * inv[n - k] % MOD;
		val = (ll)val * quick_pow((ll)3 * k * n % MOD, MOD - 2) % MOD;
		ans = (ans + (ll)val * dp[k][1]) % MOD;
	}
	ans = (ll)ans * quick_pow(quick_pow(3, n - 1), MOD - 2) % MOD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 15872
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
h,w = ma()
t="."*w
ls=[]
for i in range(h):
    s=input()
    if s!=t:
        ls.append(s)

l = len(ls)
t="."*l
ans = [[] for i in range(l)]
for i in range(w):
    f=False
    for j in range(l):
        if ls[j][i]=="#":
            f=True
    if f:
        for j in range(l):
            ans[j].append(ls[j][i])
for a in ans:
    print("".join(a))


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

ll n, m;
ll ans = 0;
vector<vector<bool>> v;

void dfs(ll now, set<ll> visited) {
	if (visited.find(now) != visited.end())return;
	visited.insert(now);
	if (visited.size() == n) {
		++ans;
		return;
	}
	for (int i = 0; i < n; ++i) {
		if (v[now][i])dfs(i, visited);
	}
}

int main() {
	cin >> n >> m;
	vector<bool> tmp(n, false);
	v.resize(n, tmp);
	for (ll i = 0; i < m; ++i) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		v[a][b] = true;
		v[b][a] = true;
	}
	dfs(0, {});
	cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main() {
  ll n, x;
  cin >> n >> x;
  ll v;
  cin >> v;
  ll d = abs(v - x);
  while (cin >> v)
    d = __gcd(d, abs(v - x));
  cout << d << endl;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;

// エラトステネスの篩
bool is_prime[55555+1];

void sieve(int n) {
    memset(is_prime, true, sizeof(is_prime));
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            for (int j = i + i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
}

void solve() {
    sieve(55555);
    vector<int> p;
    for (int i = 3; i <= 55555; i+=10) {
        if (is_prime[i])
            p.push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cout << p[i];
        if (i == n-1) cout << endl;
        else cout << " ";
    }
}

void input() {
    cin >> n;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 384
import sys
import itertools
from collections import defaultdict

sys.setrecursionlimit(10**8)

def find(x,table):	#xの根を返す	
	if table[x] == x:
		return x
	else:
		table[x] = find(table[x],table)	#親の更新(根を直接親にして参照距離を短く)
		return table[x]

def union(x,y,table,rank):	#xとyを繋げる
	x = find(x,table)	
	y = find(y,table)
	
	if x == y:
		return
	
	if rank[x] > rank[y]:
		table[y] = x
	else:
		table[x] = y
		if rank[x] == rank[y]:
			rank[y] += 1

def check(x,y,table):
	if find(x,table) == find(y,table):
		return True
	else:
		return False

N,K,L = map(int,input().split())

table_car = [i for i in range(N)]	#木の親 table[x] == x なら根	
rank_car  = [1 for i in range(N)]	#木の長さ
table_tr  = [i for i in range(N)] 
rank_tr   = [1 for i in range(N)]

for i in range(0,K):
	a,b = map(int, input().split())
	union(a-1,b-1,table_car,rank_car)
	
for i in range(0,L):
	a,b = map(int, input().split())
	union(a-1,b-1,table_tr,rank_tr)
	
ar = [(find(i,table_car),find(i,table_tr)) for i in range(N)]
dd = defaultdict(int)
for s in ar:
    dd[s] += 1
	
ans =[]
for i in range(N):
    ans.append(dd[ar[i]])
	
print(' '.join(map(str, ans)))


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

int  main(){
  vector<int> x;
  int q;
  cin>>q;
  lp(i,q){
    int n,z;
    cin>>n;
    if(n==0){
      cin>>z;
      x.push_back(z);
    }
    if(n==1){
      cin>>z;
      cout<<x[z]<<endl;
    }
    if(n==2){
      x.pop_back();
    }
  }
  return 0;
}



Measured memory_bytes: 3828
n=int(input())
inp=list(map(int,input().split()))
inp=[2*item for item in inp]
s=0
for i in range(1,len(inp)):
    if i%2==1:
        s-=inp[i]
    else:
        s+=inp[i]
ans=[(s+inp[0])//2]
for i in range(len(inp)-1):
    ans.append(inp[i]-ans[-1])
for item in ans:
    print (item,end=" ")

Measured memory_bytes: 20540
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;   
}


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

long long N;
long long A[300005];

int main(){
	cin >> N;
	for(long long i = 0; i < 3*N; i++){
		cin >> A[i];
	}
	sort(A, A + 3 * N);

	long long ans = 0;
	for(long long i = 0; i < N; i++){
		ans += A[N + 2 * i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <cctype>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "Yes";
const string NO = "No";

void solve(ll A, ll B, string S) {
  bool pred = all_of(begin(S), begin(S)+A, [](unsigned char c){return isdigit(c);}) && all_of(rbegin(S), rbegin(S)+B, [](unsigned char c){return isdigit(c);}) && S[A]=='-';

  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  string S;
  cin >> S;
  solve(A, B, S);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, A, B;
    cin >> N >> A >> B;
    cout << ((N * A) > B ? B : N * A) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 200001;
ll a[MAX];
ll xo[MAX][22];
ll sumxo[22] = {};
int main() {
    

    ll n;
    cin >> n;
    for (ll i=0;i<n;i++){
        cin >> a[i];
        ll tmp = a[i];
        for (int j=0;j<22;j++){
            xo[i][j] = tmp % 2;
            tmp /= 2;
        }
    }
    ll ans = 0;
    int flag = 0;
    ll tmp;
    ll j = 0;
    for (ll i=0;i<n;i++){
        flag = 0;
        if(i != 0) {
            for (ll k = 0; k < 22; k++) {
                sumxo[k] -= xo[i - 1][k];
            }
        }
        if(i>j){
            j = i;
        }
        while(true){
            for (ll k=0;k<22;k++) {
                sumxo[k] += xo[j][k];
                if(sumxo[k] > 1){
                    flag = 1;
                }
            }
            if(flag == 1 or j >= n){
//                cout << i << " " << j << endl;
                if(flag == 1) {
                    for (ll k = 0; k < 22; k++) {
                        sumxo[k] -= xo[j][k];
                    }
                }
                tmp = j-1;
                break;
            }else{
                j++;
            }
        }
//        cout << i << " " << j << endl;
//        cout << tmp - i + 1 << endl;
        ans += tmp - i + 1;
    }
    cout << ans << endl;
//    for (ll i=0;i<n;i++){
//        cout << a[i] << " ";
//        for (ll j=0;j<22;j++){
//            cout << xo[i][j] << " ";
//        }
//        cout << endl;
//    }


}




Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  bool S = false;
  for(int i = 0; i < N - 2; i++) {
    if(A.at(i) == B.at(i)) {
      if(A.at(i + 1) == B.at(i + 1)) {
        if(A.at(i + 2) == B.at(i + 2)) {
          S = true;
        }
      }
    }
  }
  if(S) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){

    y=x;

    if(z->key<x->key) x=x->left;
    else x=x->right;
  }

    z->parent=y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;

}


void inorder(Node u){
  if(u==NIL) return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;

  printf(" %d",u->key); 
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<bitset>
#include<iterator>
#include <stack>
#define ll long long
typedef long double ld;
#define all(v) ((v).begin()),((v).end())
#define vec2(n,m) vector<vector<ll>>vv(n + 10, vector<ll>(m + 10, 0));
#define p_q1   priority_queue<int,vector<int>,greater<int>>pq1;
#define format(n) fixed<<setprecision(n)
#define ll_min LLONG_MIN;
#define ll_max LLONG_MIN;
#define endl "\n"
#define F first 
#define S second
#define mkpr(x,y)  make_pair(x,y)
using namespace std;
void weza()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main()
{
    weza();
    int n, m,a,mx=0;
    cin >> n;
    vector<int>fre(200100);
    for (int i = 1; i < n; i++)
    {
        cin >>a;
        fre[a]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << fre[i] << endl;
  }

}

Measured memory_bytes: 3676
inputs = gets.split.map { |i| i.match(/\d+/) ? i.to_i : i.to_sym }
stack = []
inputs.each do |e|
  if e.is_a?(Integer)
    stack.push(e)
  else
    a, b = stack.pop(2)
    stack << a.method(e).call(b)
  end
end
puts stack

Measured memory_bytes: 8644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++ ) {
            a[i] = sc.nextInt();
        }
        long count = 0;
        for (int i = 0 ; i < n - 1 ; i++) {
            //右側の箱から優先して飴を取り出すように実装。
            int b = a[i] + a[i + 1];
            if (b > x) {
                if (a[i + 1] > b - x) {
                    a[i + 1] -= b - x;
                    count += b - x;
                } else {
                    count += b - x;
                    a[i + 1] = 0;
                }
            }
        }
        System.out.println(count);

    }

}

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

int main() {
    int N;
    cin >> N;
    set<int> S;
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      S.insert(a);
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 1000

int main(void){
  int i,num,j,k;
  int n[N];
  int ms[15][15];
  int curX,curY;

  for(i=0;;i++){
    scanf("%d",&n[i]);
    if(n[i]==0)
      break;
  }
  num=i;
  for(i=0;i<num;i++){
    for(j=0;j<n[i];j++){
      for(k=0;k<n[i];k++){
        ms[j][k]=0;
      }
    }
    curX=n[i]/2+1;
    curY=n[i]/2;
    ms[curX][curY]=1;
    for(j=2;j<=n[i]*n[i];j++){
      curX++;
      curY++;
      if(curX>=n[i])
        curX=0;
      if(curY>=n[i])
        curY=0;
      if(ms[curX][curY]!=0){
        curX++;
        curY--;
        if(curX>=n[i])
          curX=0;
        else if(curX==-1)
          curX=n[i]-1;
        if(curY>=n[i])
          curY=0;
        else if(curY==-1)
          curY=n[i]-1;
      }
      ms[curX][curY]=j;
    }
    for(j=0;j<n[i];j++){
      for(k=0;k<n[i];k++){
        printf("%4d",ms[j][k]);
      }
      printf("\n");
    }
  }
  return 0;
}

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

int main(){
  char A;
  cin >> A;
  bool a=false;
  for(char c='a';c<='z';c++){
    if(A==c){
      a=true;
      break;
    }
  }
  if(a){
    cout << "a" << endl;
  }
  else{
    cout << "A" << endl;
  }
}
  
  

Measured memory_bytes: 3616
Imports System.Console
Module Module1
    Dim ans As Integer
    Sub Main()
        Dim a, b, c As Integer
        Dim s() As String = ReadLine().Split()
        a = s(0)
        b = s(1)
        c = s(2)
        Dim k As Integer = ReadLine()
        Dim sousa As Integer
        Do Until b > a
            b *= 2
            sousa += 1
        Loop
        Do Until c > b
            c *= 2
            sousa += 1
        Loop
        If sousa > k Then
            WriteLine("No")
        Else
            WriteLine("Yes")
        End If
    End Sub
End Module


Measured memory_bytes: 28396
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &H[i]);
  }
  ll nmax = H[0];
  for (int i = 0; i < N; ++i)
  {
    if (nmax - 1 > H[i])
    {
      cout << NO << endl;
      return 0;
    }
    nmax = max(nmax, H[i]);
  }
  cout << YES << endl;

  return 0;
}


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

int main()
{
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    if (x >= r && x <= W- r && y >= r && y <= H- r) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
from collections import Counter
n=int(input())
V=list(map(int,input().split()))

E=Counter(V[::2]).most_common() + [(0, 0)]
O=Counter(V[1::2]).most_common() + [(0, 0)]
if E[0][0]!=O[0][0]:
  print(n-E[0][1]-O[0][1])
else:
  print(n-max(E[1][1]+O[0][1],E[0][1]+O[1][1]))

Measured memory_bytes: 20572
#include<bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;

ll N;

ll getd(ll n){
    string strn;
    strn = to_string(n);
    int sum =0;
    for(auto ch: strn){
        sum += ch-'0';
    }
    return sum;
}

int main(){
    scanf("%lld" ,&N);
    if(N%getd(N) == 0) printf("Yes");
    else printf("No");
    return 0;
}


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

struct data {
  long long from, to, dis;
};

long long x, n = 0;
vector<data> v;

void solve();

int main() {
  cin >> x;
  solve();
  cout << n << " " << v.size() << endl;
  for(int i = 0; i < v.size(); ++i)
    cout << v[i].from + 1 << " " << v[i].to + 1 << " "
         << v[i].dis << endl;
  return 0;
}

void solve() {
  long long now = 0;
  while(1LL << (n + 1) <= x) ++n;
  for(int i = 0; i < n; ++i) {
    v.push_back({i, i + 1, 1 << i});
    v.push_back({i, i + 1, 0});
  }
  x -= (1LL << n);
  ++n;
  now = 1LL << (n - 1);
  for(int i = n - 2; i >= 0; --i)
    if(1LL << i <= x) {
      v.push_back({i, n - 1, now});
      x -= 1LL << i;
      now += 1LL << i;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    int N;
    ll X;
    cin >> N >> X;
    ll S = pow(2, N+2) - 3;
    ll ans = 0;
    ll cnt = 0;
    while(1){
        cnt++;
        if(cnt > 100000)break;
        if(X == -1)break;
        if(S / 2 + 1 < X){
            ans += pow(2, N);
            S -= 3;
            S /= 2;
            X -= S + 2;
            N--;
        }else if(S / 2 + 1 > X){
            S -= 3;
            S /= 2;
            X--;
            N--;
        }else{
            ans += pow(2, N);
            break;
        }
    }
    
    cout << ans << endl;
    
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

struct Unifind{
	vector<int> par;

	Unifind(){}
	Unifind(int n) :
		par(n+1, -1)
	{}
	int root(int x){
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	int size(int x){
		return -par[root(x)];
	}
	bool same(int a, int b){
		return root(a) == root(b);
	}
	bool marge(int a, int b){
		a = root(a), b = root(b);
		if(a == b) return false;
		if(par[a] > par[b]) swap(a, b);
		par[a] += par[b];
		par[b] = a;
		return true;
	}
};

int main(){
	llong N, M;
	vector<P> edge;

	cin >> N >> M;
	Unifind uf(N);
	edge.resize(M);
	for(int i = 0; i < M; i++)
		scanf("%lld%lld", &edge[i].first, &edge[i].second);

	vector<llong> ans;
	ans.push_back((N*(N-1))/2);
	cerr << endl;
	for(int i = M-1; i > 0; i--){
		llong e1 = edge[i].first;
		llong e2 = edge[i].second;
		if(uf.root(e1) == uf.root(e2)){
			ans.push_back(ans[ans.size()-1]);
			continue;
		}

		ans.push_back(ans[ans.size()-1] - uf.size(e1)*uf.size(e2));
		uf.marge(e1,e2);
	}

	for(int i = ans.size()-1; i >= 0; i--)
		printf("%lld\n", ans[i]);

	return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};

int32_t main() 
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n;
    cin >> n;

    pair<int, int> p[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i].ff >> p[i].ss;
    }

    int mi = INT_MAX, ma = INT_MIN;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        mi = min(mi, p[i].ff + p[i].ss);
        ma = max(ma, p[i].ff + p[i].ss);
    }

    ans = max(ans, ma - mi);

    ma = INT_MIN, mi = INT_MAX;
    for (int i = 0; i < n; ++i)
    {
        mi = min(mi, p[i].ff - p[i].ss);
        ma = max(ma, p[i].ff - p[i].ss);
    }

    ans = max(ans, ma - mi);

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

Measured memory_bytes: 6692
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<ll> enum_divisors(ll N) {
  vector<ll> res;
  for (ll i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      if (N/i != i) res.push_back(N/i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main() {
  ll n,m;
  cin >> n >> m;
  const auto &res = enum_divisors(m);
  ll ans = 0;
  for (ll i : res) {
    if (n * i <= m) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
<?php
fscanf(STDIN, "%s", $n);

$a = ['' => $n[0]];
for ($i = 1; $i <= 3; $i++) {
	$b = [];
	foreach ($a as $k => $v) {
		$b[$k.'+'] = $v + $n[$i];
		$b[$k.'-'] = $v - $n[$i];
	}
	$a = $b;
}
foreach ($a as $k => $v) {
	if ($v == 7) {
		exit("$n[0]$k[0]$n[1]$k[1]$n[2]$k[2]$n[3]=7");
	}
}

Measured memory_bytes: 4728
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<(n);i++)
#include<algorithm>
using namespace std;
typedef long long ll;

int main(void){
    ll l, r;
    cin>>l>>r;
    int minimam=2018;
    r=min(r, l+2019*2);

    for(ll i=l;i<=r;i++){
        for(ll j=i+1;j<=r;j++){
            if(j<=r){
                int a=(i*j)%2019;
                minimam=min(a, minimam);
            }
        }
    }
    
    cout<<minimam<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	//	for()
	if(s2==(s1+s2[s2.size()-1]))
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
}


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

using namespace std;

int main(void){
  string str;
  int Q;
  cin >> str;
  cin >> Q;
  bool flag = true;
  string pre;
  string post;
  for(int i=0;i<Q;i++){
    int t;
    cin >> t;
    if(t == 1){
      flag = !flag;
    }else{
      int f;
      string c;
      cin >> f;
      cin >> c;
      if(f == 1){
	if(flag){
	  pre = c + pre;
	}else{
	  post = post + c;
	}
      }else{
	if(flag){
	  post = post + c;
	}else{
	  pre = c + pre;
	}
      }
    }
  }
  // 最後に反転+ post
  str = pre + str + post; 
  if(!flag){
    string tmp = str;
    for(int i=0;i<str.length();i++){
      str[i] = tmp[str.length() - 1 - i];
    }
  }
  cout << str << endl;
  return 0;
}


Measured memory_bytes: 1512
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
 
int main(){
	
	int H,N,sum=0;
    cin >> H >> N;
    int A[N];
    rep(i,N)cin >> A[i];
    rep(i,N)sum += A[i];
    if(sum>=H)cout << "Yes";
    else cout << "No";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int T[MAX_N];
int n,c,K;

int main()
{
	scanf("%d%d%d",&n,&c,&K);
	rep(i,n){
		scanf("%d",&T[i]);
	}
	sort(T,T+n);
	int fir = T[0];
	int ans = 1;
	int used = 1;
	for(int i=1;i<n;i++){
		if(fir+K < T[i] || used >= c){
			fir = T[i];
			used = 0;
			ans++;
		}
		used++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[1000];
int solve(int n)
{
    int sum=0;
    while(true)
    {
        for(int i=1;i<=n;i++)
        {
            if(a[i]%2==1) return sum;
            else a[i]=a[i]/2;
        }
        sum++;
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    cout<<solve(n)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new C().doIt();
    }
    class C{
    	double map[][];
    	double DP[][];
        void doIt(){
        	int n = sc.nextInt();
        	int m = sc.nextInt();
        	map = new double[n][401];
        	DP = new double[n][401];
        	for(int i = 0;i < n;i++){
        		int s = sc.nextInt();
        		double Hsum = 0;
        		double start = 1;
        		for(int j = 0;j < s;j++){
        			double S = sc.nextDouble();
        			double H = sc.nextDouble();
        			Hsum = Hsum + (H*S);
        			for(int k = (int)start;k <= Hsum;k++){
        				if(k > 400)break;
        				map[i][k] = map[i][k-1] + (1.0/S);
        			}
        			start = Hsum + 1;
        		}
        	}
        	for(int i = 1;i <= 400;i++){
        		DP[0][i] = map[0][i];
        		if(DP[0][i] == 0)DP[0][i] = DP[0][i-1];
        	}
        	for(int i = 1;i < n;i++){
        		for(int j = 1;j <= 400;j++){
        			for(int k = 0;k <= j;k++){
        				DP[i][j] = Math.max(DP[i][j],DP[i-1][j-k]+map[i][k]);
        			}
        		}
        	}
//        	for(int i = 0;i < n;i++){
//        		for(int j = 0;j <= 15;j++){
//        			System.out.printf("%.3f ",DP[i][j]);
//        		}
//        		System.out.println();
//        	}
//        	System.out.println();
//        	for(int i = 0;i < n;i++){
//        		for(int j = 0;j <= 15;j++){
//        			System.out.printf("%.3f ",map[i][j]);
//        		}
//        		System.out.println();
//        	}
        	System.out.println(DP[n-1][m]);
        }
    }
}

Measured memory_bytes: 47576
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n, a = 0, b = 0, c = 0,d = 0;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC")
        a++;
        else if(s=="WA")
        b++;
        else if(s=="TLE")
        c++;
        else
        d++;
    }
    cout<<"AC x "<<a<<endl<<"WA x "<<b<<endl<<"TLE x "<<c<<endl<<"RE x "<<d<<endl;
	return 0;
}

Measured memory_bytes: 3628
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

const int M=200005;
int n;
int dp_niche[M];
int dp[M];
vector<int>adj[M];
int fact[M],inv[M];
int s[M];
void dfs(int u,int par)
{
    s[u]=1;
    int x=1;
    for(auto v:adj[u])
    {
        if(v==par)continue;
        dfs(v,u);
        s[u]+=s[v];
        x=gun(x,inv[s[v]]);
        x=gun(x,dp_niche[v]);
    }
    x=gun(x,fact[s[u]-1]);
    dp_niche[u]=x;
}
void abr_dfs(int u,int par)
{
    if(u==1)
    {
        dp[u]=dp_niche[u];
    }
    else
    {
       int x=dp_niche[u];
       x=gun(x,inv[s[u]-1]);
       x=gun(x,fact[n-1]);
       int upor_sz=n-s[u];
       x=gun(x,inv[upor_sz]);
       int y=dp[par];
       y=gun(y,fact[s[u]]);
       y=gun(y,inv[n-1]);
       y=gun(y,fact[n-s[u]-1]);
       y=gun(y,bigmod(dp_niche[u],mod-2));
       x=gun(x,y);
       dp[u]=x;
    }
    for(auto v:adj[u])
    {
        if(v==par)continue;
        abr_dfs(v,u);
    }
}
void init()
{
   fact[0]=1;
   inv[0]=1;
   f(i,1,M-1)
   {
       fact[i]=(fact[i-1]*i)%mod;
   }
   inv[M-1]=bigmod(fact[M-1],mod-2);
   rf(i,M-2,1)
   {
       inv[i]=(inv[i+1]*(i+1))%mod;
   }
}
 main()

{
    fast
    init();
    cin>>n;
    f(i,1,n-1)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1,0);
    abr_dfs(1,0);
    f(i,1,n)
    {
        cout<<dp[i]<<"\n";
    }
    return 0;

}





































Measured memory_bytes: 23540