akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class CLower {
public:
    void solve(istream& cin, ostream& cout) {
        int n;
        cin >> n;
        ll run = 0, m = 0; int prev;
        for(int i=0; i<n ;i++) {
            int tp; cin >> tp;
            if(i == 0) {
                run = 0;
            } else {
                if(tp > prev) {
                    m = max(run, m);
                    run = 0;
                } else {
                    run++;
                }
            }
            prev = tp;
        }
        m = max(run, m);
        cout << m << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    CLower solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;



int main()
{
	int N, M;
	priority_queue<int> As;

	cin >> N >> M;

	int n;
	for(int ni = 0; ni <N; ni++){
		cin >> n;
		As.push(n);
	}

	int temp;
	while (M > 0) {
		temp = As.top();
		As.pop();
		As.push(temp / 2);
		M--;
	}


	long long ans = 0;
	while (!As.empty()) {
		ans += As.top();
		As.pop();
	}


	printf("%lld",ans);

	return 0;
}



Measured memory_bytes: 892
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
    String check = "No";
		for(int i = 1; i <= 9; i++){
      for(int j = 1; j <= 9; j++){
        if(i*j == N)
          check = "Yes";
      }
    }
    System.out.println(check);
	}
}

Measured memory_bytes: 23892
#include<algorithm>
#include<cstdio>
#define mxn 1010
using namespace std;
const int inf=1e9;
int T,n,m,sl,fh,a[mxn],x[mxn],y[mxn],f[mxn],g[mxn][5010];
int t,h[mxn];
char str[2][15]={"IMPOSSIBLE","POSSIBLE"};
struct Tre
{
	int to,nxt;
}e[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void add(int u,int v) {e[++t]=(Tre){v,h[u]};h[u]=t;}
void dfs(int u)
{
	for(int i=h[u];i;i=e[i].nxt) dfs(e[i].to);
	int v;fill(g[1]+1,g[1]+a[u]+1,inf);m=0;
	for(int i=h[u];i;i=e[i].nxt) x[++m]=f[v=e[i].to],y[m]=a[v];
	for(int i=1;i<=m;++i)
	{
		fill(g[i+1],g[i+1]+a[u]+1,inf);
		for(int j=0;j<=a[u];++j)
		{
			if(j+x[i]<=a[u]) g[i+1][j+x[i]]=min(g[i+1][j+x[i]],g[i][j]+y[i]);
			if(j+y[i]<=a[u]) g[i+1][j+y[i]]=min(g[i+1][j+y[i]],g[i][j]+x[i]);
		}
	}
	for(int i=0;i<=a[u];++i) f[u]=min(f[u],g[m+1][i]);
}
int main()
{
	n=rd();fill(h+1,h+n+1,0);t=0;
	fill(f+1,f+n+1,inf);
	for(int i=2;i<=n;++i) add(rd(),i);
	for(int i=1;i<=n;++i) a[i]=rd();
	dfs(1);puts(str[f[1]<inf]);
	return 0;
}

Measured memory_bytes: 17280
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int d;
    cin >> d;

    string ans = "Christmas";

    REP(i, 25 - d)
    {
        ans += " Eve";
    }

    cout << ans << endl;    
}

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

using namespace std;

int main(){
    long long int N,ans=0,tmpf,tmpb;
    cin >> N;
    vector<long long int> A(N);
    vector<pair<long long int,long long int>> P;

    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    sort(A.begin(),A.end());

    tmpf = A[0];
    tmpb = A.back();

    for(int i=1;i<N-1;i++){
        if(0<=A[i]){
            P.push_back({tmpf,A[i]});
            tmpf -= A[i];
        }else{
            P.push_back({tmpb,A[i]});
            tmpb -= A[i];
        }
    }

    P.push_back({tmpb,tmpf});

    cout << tmpb - tmpf << endl;

    for(int i=0;i<N-1;i++){
        cout << P[i].first << " " << P[i].second << endl;
    }
}

Measured memory_bytes: 4336
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long long i,long long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	long long n,a,b;//a=blue
	long long x,y;//x=blue
	cin >> n >> a >> b;
	//syc(n,1,1000000000000000000);
	//syc(a+b,0,1000000000000000000);
	if(n<0 || a<0 || b<0)exit(1);
	long long  ans = 0;
	
	x=n/(a+b);
	y=n%(a+b);
	if(y>a){
		y=a;
	}
	
	ans = x*a+y;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int x;
	cin>>x;
	int i=1;
	while(true){
		if((i*x)%360==0){
			puts(i);
			return 0;
		}
		i++;
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int N, x;
    scanf("%d%d", &N, &x);
    if (N == 2) {
        if (x == 2) {
            printf("Yes\n");
            printf("1\n");
            printf("2\n");
            printf("3\n");
            return 0;
        } else {
            printf("No\n");
            return 0;
        }
    }

    if (x == 1 || x == 2 * N - 1) {
        printf("No\n");
        return 0;
    } else {
        printf("Yes\n");
        if (x == 2) {
            int counter = 1;
            int i = 5;
            while (counter <= N - 3) {
                printf("%d\n", i++);
                counter++;
            }
            printf("4\n");
            printf("1\n");
            printf("2\n");
            printf("3\n");
            counter += 4;
            while (counter <= 2 * N - 1) {
                printf("%d\n", i++);
                counter++;
            }
            return 0;

        } else if (x == 3) {
            int counter = 1;
            int i = 5;
            while (counter <= N - 3) {
                printf("%d\n", i++);
                counter++;
            }
            printf("1\n");
            printf("4\n");
            printf("3\n");
            printf("2\n");
            counter += 4;
            while (counter <= 2 * N - 1) {
                printf("%d\n", i++);
                counter++;
            }
            return 0;
        } else {
            int counter = 1;
            int i = 1;
            while (counter <= N - 3) {
                printf("%d\n", i);
                counter++;
                if (i + 1 == x - 2) {
                    i = x + 2;
                } else {
                    i++;
                }
            }
            printf("%d\n", x - 2);
            printf("%d\n", x + 1);
            printf("%d\n", x);
            printf("%d\n", x - 1);
            counter += 4;
            while (counter <= 2 * N - 1) {
                printf("%d\n", i);
                counter++;
                if (i + 1 == x - 2) {
                    i = x + 2;
                } else {
                    i++;
                }
            }
        }
    }
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
int main(void){
    ll N, ANS=300005, L[300005], R[300005]; char S[300005];
    scanf("%lld\n%s", &N, S);
    ll count=0;
    rep(i, 0, N){
        L[i] = count;
        if(S[i]=='W') count++;
    }
    count = 0;
    for(ll i=N-1; i>=0; i--){
        R[i] = count;
        if(S[i]=='E') count++;
    }
    rep(i, 0, N) ANS = min(ANS, L[i]+R[i]);
    printf("%lld\n", ANS);
    return 0;
}
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 5120
Max=123456*2+1

a=Array.new Max
a[0]=a[1]=false
a[2]=true
index=4
while index<a.length
	a[index] = false
	index+=2
end
1.upto(Max/2-1){|i|
	num=i*2+1
	if a[num] == nil
		a[num] = true
		index = num*2
		while index < Max
			a[index]=false
			index+=num
		end
	end
}

while true
	n=gets.to_i
	break if n == 0

	count = 0
	i = n+1
	while i <= 2*n
		count += 1 if a[i]
		i+=1
	end
	p count
end

Measured memory_bytes: 8032
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }


/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;cin>>a;
    ll int sum = 0;
    sum +=a ;
    sum += (ll)a*a ;
    sum += (ll)((ll)a*a)*a;
    cout<<sum;
    return 0;
}
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll cnt = 0;
    for (int i = 0; i < s.length(); ++i)
    {
        if(s[i] != t[i])cnt++;
    }
    cout<<cnt;
    return 0;
}


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

int main() {
  bool A;
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      A = 1;
      break;
    } else {
      A = 0;
    }
  }
  if (A) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

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

using namespace std;

const int N = 2e5 + 5;

struct point {
    int x, y, id;
} p[N];

bool cmp1(const point& a, const point& b) {
    if (a.x != b.x) {
        return a.x < b.x;
    }
    return a.y < b.y;
}

bool cmp2(const point& a, const point& b) {
    if (a.y != b.y) {
        return a.y < b.y;
    }
    return a.x < b.x;
}

int n;
long long weight;
bool marked[N];
vector<pair<long long, int> > adj[N];

long long prim(int x) {
    priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > pq;
    int y;
    long long minCost = 0;
    pair<long long, int> p;
    pq.push({0, x});
    while(!pq.empty()) {
        p = pq.top();
        pq.pop();
        x = p.second;
        if(marked[x]) {
        	continue;
		}
        minCost += p.first;
        marked[x] = true;
        for(int i = 0; i < adj[x].size(); i++) {
            y = adj[x][i].second;
            if (!marked[y]) {
            	pq.push(adj[x][i]);
            }
        }
    }
    return minCost;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i].x >> p[i].y;
		p[i].id = i + 1;
	}
	sort(p, p + n, cmp1);
	for (int i = 1; i < n; i++) {
		adj[p[i].id].push_back({abs(p[i].x - p[i - 1].x), p[i - 1].id});
		adj[p[i - 1].id].push_back({abs(p[i].x - p[i - 1].x), p[i].id});
	}
	sort(p, p + n, cmp2);
	for (int i = 1; i < n; i++) {
		adj[p[i].id].push_back({abs(p[i].y - p[i - 1].y), p[i - 1].id});
		adj[p[i - 1].id].push_back({abs(p[i].y - p[i - 1].y), p[i].id});
	}
	cout << prim(1) << '\n';
	return 0;
}


Measured memory_bytes: 17524
H,W,K = list(map(int, input().split()))
C = [list(input()) for _ in range(H)]

import copy

# 全パターン試す
ans = 0
for f in range(2**(H+W)):
    
    # フィルタ処理
    B = copy.deepcopy(C)
    for bit in range(H+W):
        if f & (1<<bit):
            if bit < W:
                # 列フィルタ
                for i in range(H):
                    B[i][bit] = '.'
            else:
                # 行フィルタ
                bit -= W
                for i in range(W):
                    B[bit][i] = "."
    
    
    # 残った白マスを数える
    rem = 0
    for line in B:
        rem += ''.join(line).count('#')
    
    if rem == K:
        ans += 1

print(ans)

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

int main()
{
 
  int n,k;
  
  scanf("%d%d",&n,&k);
  
  int i,j,l;
  
  int d[101]={};
  int a[101][101]={};
  
  for(i=0;i<k;i++)
  {
    scanf("%d",&d[i]);
    for(j=0;j<d[i];j++)
    {
      scanf("%d",&a[i][j]);
    }
  }
  
  int array[101]={};
  
  for(i=0;i<n;i++)
  {
    array[i]=i+1;
  }
  
  for(i=0;i<n;i++)
  {
    for(j=0;j<k;j++)
    {
      for(l=0;l<d[j];l++)
      {
        if(array[i]==a[j][l])
        {
          array[i]=0;
        }
      }
    }
  }
  
  int ans=0;
  for(i=0;i<n;i++)
  {
    if(array[i]!=0)
    {
      ans++;
    }
  }
  
  printf("%d\n",ans);
  return 0;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    ll ans = 0;
    cin >> N;
    const auto &res = prime_factorize(N);
    for (auto p : res) {
        for(int i = 1; i*(i+1)/2 <= p.second; i++){
          ans++;
        }
    }
  cout << ans;
}

Measured memory_bytes: 3632
<?php
while($line=fgets(STDIN)){
    $line = rtrim($line);
    $data = explode(" ", $line);
    if ($data[0] < $data[1]) {
        echo "a < b" . PHP_EOL;
    } elseif ($data[0] == $data[1]) {
        echo "a == b" . PHP_EOL;
    } else {
        echo "a > b" . PHP_EOL;
    }
}

Measured memory_bytes: 15260
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){

int n;
while(1){

scanf("%d",&n);if(n==0)break;
int y,t,b;

double s=0,max=0,r;
int MM=0;
scanf("%d",&y);
for(int i=0;i<n;i++){
scanf("%d %lf %d",&b,&r,&t);

if(t==1){
s=1+y*r/100;
}
else{
double s1=1+r/100;s=s1;

for(int j=1;j<y;j++)
{
	s=s*s1;
}
}

if(s>max){max=s;MM=b;}
}
printf("%d\n",MM);

}
return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>

using namespace std;

char c[5];

int main(){
  char a,b=0;
  int ca=1, cb=0;
  scanf("%s", c);

  a=c[0];
  for (int i=1;i<4;i++) {
    if (c[i] == a)
      ca++;
    else if (c[i] == b || b==0) {
      b=c[i];
      cb++;
    }
  }

  if(ca == 2 && cb == 2)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#coding: utf-8
from math import ceil
R, G, B, N = map(int, input().split())
ans = 0
for r in list(range(ceil(N/R) + 1))[::-1]:
	for g in range(ceil(N/G) + 1):
		if (N - r*R - g*G) % B == 0 and N >= r*R + g*G:
			ans += 1
print(ans)

Measured memory_bytes: 41196
#include<cstdio>
#include<vector>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
const int MAXN=200005;
int n,k,l,fa[MAXN],zfa[MAXN];
map<pair<int,int>,int>M;
int find(int x)
{
	if(fa[x]==x)
		return x;
	return fa[x]=find(fa[x]);
}
int zfind(int x)
{
	if(zfa[x]==x)
		return x;
	return zfa[x]=zfind(zfa[x]);
}
struct node
{
	int u,v;
	node(){}
}A[MAXN];
int main()
{
	scanf("%d %d %d",&n,&k,&l);
	for(int i=0;i<=n;i++)
		fa[i]=zfa[i]=i;
	for(int i=1;i<=k;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		int a=find(u),b=find(v);
		if(a!=b)
		{
			fa[a]=b;
		}
	}
	for(int i=1;i<=l;i++)
	{
		scanf("%d %d",&A[i].u,&A[i].v);
		int a=zfind(A[i].u),b=zfind(A[i].v);
		if(a!=b)
		{
			zfa[a]=b;
		}
	}
	for(int i=1;i<=n;i++)
	{
		pair<int,int> c;
		c.first=find(i);
		c.second=zfind(i);
		M[c]++;
	}
	for(int i=1;i<=n;i++)
	{
		pair<int,int> c;
		c.first=find(i);
		c.second=zfind(i);
		printf("%d%c",M[c],i==n?'\n':' ');
	}
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,l,maxl=0,sum=0;
	cin>>n;
	while(cin>>l){
		maxl=max(maxl,l);
		sum+=l;
	}
	cout<<(maxl<sum-maxl?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
// Cake Party 2018/12/28

#include <iostream>
using namespace std;

int main() {
    int N, C, cakes = 0;

    cin >> N >> C;
    N++; //私を足す
    for (int i = 0; i < C; i++) {
        int tmp;
        cin >> tmp;
        cakes += tmp;
    }

    if (cakes % N) // ぴったりじゃない
        cout << cakes / N + 1 << '\n';
    else
        cout << cakes / N << '\n';
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> value(n);
  vector<int> cost(n);
  
  for(int i=0; i<n; i++){
    cin >> value.at(i);
  }
  for(int i=0; i<n; i++){
    cin >> cost.at(i);
  }

  vector<int> dif(n);
  for(int i=0; i<n; i++){
    dif.at(i) = value.at(i) - cost.at(i);
  }
  
  int max=0;
  
  for(int i=0; i<n; i++){
    if(dif.at(i) > 0){
      max += dif.at(i);
    }
  }
  
  cout << max << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){

	lli a,b;
	cin>>a>>b;

	if(a<=9 && b<=9){
		cout<<a*b<<endl;
	}
	else{
		cout<<-1<<endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll arr[1000000+2];
int main(){
    ll a, b, ans=1;
    cin>>a>>b;
    int s1=sqrt(a), s2=sqrt(b);
    for (int i=2; i<=s1; i++){
        if (a%i==0) arr[i]++;
        while (a%i==0) a/=i;
    }
    for (int i=2; i<=s2; i++){
        if (b%i==0) arr[i]++;
        while (b%i==0) b/=i;
    }
    if (a<=1e6) arr[a]++, a=1;
    if (b<=1e6) arr[b]++, b=1;
    for (int i=2; i<=1e6; i++){
        if (arr[i]==2) ans++;
    }
    if (a==b && a!=1 && b!=1) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 2304
#include <cstdio>

struct Card{ char suit, value; };

void bubble(struct Card A[], int N){
	for (int i = 0; i < N; i++){
		for (int j = N - 1; j > i; j--){
			if (A[j].value < A[j - 1].value){
				Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
	}
}

void selection(struct Card A[], int N){
	for (int i = 0; i < N; i++){
		int minj = i;
		for (int j = i; j < N; j++){
			if (A[j].value < A[minj].value) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(struct Card A[], int N){
	for (int i = 0; i < N; i++){
		if (i > 0) putchar(' ');
		printf("%c%d", A[i].suit, A[i].value);
	}
	putchar('\n');
}

//????????????????????¨?????????????????????????????????
int isStable(struct Card C1[], struct Card C2[], int N){
	for (int i = 0; i < N; i++){
		if (C1[i].suit != C2[i].suit) return 0; // stable
	}
	return 1; //not stable
}

int main(){
	Card C1[100], C2[100];
	int N;
	char ch;

	scanf("%d", &N);
	for (int i = 0; i < N; i++){
		scanf("%*c%c%d", &C1[i].suit, &C1[i].value);
	}

	for (int i = 0; i < N; i++)C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	puts("Stable");
	print(C2, N);
	if (isStable(C1, C2, N)){
		puts("Stable");
	}
	else{
		puts("Not stable");
	}

	return 0;
	
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	char c;
 	cin >> c;
 	c++;
 	cout << c << endl;   
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG  // 添字の配列で範囲外エラー表示させる
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long;
using P = pair<int, int>;

const int INF = 1001001001;

int n, m, x;
vector<int> learingLevel;
vector<vector<int>> a;
vector<int> c;
int minCost = INF;

void dfs(vector<int> options) {
    if (options.size() == n + 1) {
        learingLevel.assign(m, 0);
        rep(i, n) {
            rep(j, m) {
                if (options[i + 1] == 1) {
                    learingLevel[j] += a[i][j];
                }
            }
        }

        bool ok = true;
        rep(i, m) {
            if (x > learingLevel[i]) ok = false;
        }

        if (ok) {
            int cost = 0;
            rep(i, n) {
                if (options[i + 1] == 1) {
                    cost += c[i];
                }
            }
            minCost = min(minCost, cost);
        }
        return;
    }
    options.push_back(0);
    while (options.back() <= 1) {
        dfs(options);
        options.back()++;
    }
}

int main() {
    cin >> n >> m >> x;
    a.assign(n, vector<int>(m, 0));
    c.assign(n, 0);

    learingLevel.assign(m, 0);

    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }

    dfs(vector<int>(1, 0));  // スタート地点を適当に作る

    if (minCost == INF)
        cout << -1 << endl;
    else
        cout << minCost << endl;

    return 0;
}

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

typedef struct {
    int num;
    int col;
} STONE;

int main(void)
{
    int i, j;
    int n;
    int bw, temp;
    int count;
    int sum;
    STONE data[100000];
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        count = -1;
        bw = 2;
        for (i = 0; i < n; i++){
            scanf("%d", &temp);
            if (temp != bw){
                count++;
                data[count].col = temp;
                data[count].num = 1;
                bw = temp;
            }
            else {
                data[count].num++;
            }
        }
        
        sum = 0;
        for (i = 0; i <= count; i++){
            sum += data[i].num;
            if ((sum - data[i].num) % 2 == 1){
                j = i - 1;
                while (j >= 0 && data[j].col != data[i].col){
                    data[j].col ^= 1;
                    j--;
                }
            }
        }
        
        sum = 0;
        for (i = 0; i <= count; i++){
            if (data[i].col == 0){
                sum += data[i].num;
            }
        }
        
        printf("%d\n", sum);
    }
    
    return (0);
}

Measured memory_bytes: 812
import sys
import collections

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())

N = ni()


def choose(n, k):
    num, den = n, 1
    for i in range(1, k):
        num *= n - i
        den *= i + 1
    return num // den


def solve():
    fs = collections.Counter()
    for n in range(2, N + 1):
        k = 2
        while k * k <= n:
            while n % k == 0:
                n //= k
                fs[k] += 1
            k += 1
        if n > 1:
            fs[n] += 1
    p74, p24, p14, p4, p2 = 0, 0, 0, 0, 0
    for k, v in fs.items():
        if v >= 74:
            p74 += 1
        if v >= 24:
            p24 += 1
        if v >= 14:
            p14 += 1
        if v >= 4:
            p4 += 1
        if v >= 2:
            p2 += 1

    a4_4_2 = p4 * (p4 - 1) // 2 * (p2 - 2)
    a14_4 = p14 * (p4 - 1)
    a24_2 = p24 * (p2 - 1)
    a74 = p74
    return a4_4_2 + a14_4 + a24_2 + a74


print(solve())


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

int main(){
    ll n;
    cin>>n;
    string ans;
    while(n){
        n--;
        ans+='a'+n%26;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define re register
#define ll long long
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define dec(i,j,k) for(re int i=j;i>=k;i--)
#define edge(u) for(re int i=head[u];i;i=e[i].nxt)
#define pb push_back
#define mp make_pair
#define In inline
#define fi first
#define se second
#define db double
#define ui unsigned int
#define ull unsigned long long 
using namespace std;
const int N=2e5+5; 
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,k,a[N][2],t;
bool check(){
	inc(i,1,n) if(a[i][t]!=n) return false;
	return true;
}
int main(){ 
	n=read(),k=read();
	inc(i,1,n) a[i][0]=read();
	while(k--){
		if(check()) break;
		inc(i,0,n+1) a[i][t^1]=0;
		inc(i,1,n){
			int l=max(1,i-a[i][t]),r=min(i+a[i][t]+1,n+1);
			a[l][t^1]++,a[r][t^1]--;
		}
		t^=1;
		inc(i,1,n) a[i][t]+=a[i-1][t];
	}
	inc(i,1,n) printf("%d ",a[i][t]);
}

Measured memory_bytes: 5276
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

const char *name[11] = {
  "light fly",
  "fly",
  "bantam",
  "feather",
  "light",
  "light welter",
  "welter",
  "light middle",
  "middle",
  "light heavy",
  "heavy"
};

const double weight[11] = {
  48.0,
  51.0,
  54.0,
  57.0,
  60.0,
  64.0,
  69.0,
  75.0,
  81.0,
  91.0,
  1e10
};

int main(){
  double w;
  while(cin>>w){
    int i=0;
    while(w > weight[i]) i++;
    cout << name[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();  //キーに対応する値にはキーの要素数を入れる
		int mapSize = 0;

		for(int i = 0; i < q; i++) {
			int query = sc.nextInt();

			switch(query) {
			case 0:
				int x = sc.nextInt();
				if(map.get(x) == null) {
					map.put(x, 1);
				}
				else map.replace(x, map.get(x) + 1);
				mapSize++;
				System.out.println(mapSize);
				break;

			case 1:
				x = sc.nextInt();
				if(map.get(x) == null) 	System.out.println(0);
				else System.out.println(map.get(x));
				break;

			case 2:
				x = sc.nextInt();
				if(map.get(x) != null) {
					mapSize -= map.get(x);
					map.remove(x);
				}
				break;

			case 3:
				int l = sc.nextInt();
				int r = sc.nextInt();

				for(int n : map.subMap(l, true, r, true).keySet()) {
					for(int j = 0; j < map.get(n); j++) {
						System.out.println(n);
					}
				}
				break;
			}
		}
	}

}



Measured memory_bytes: 176968
#include<cstdio>
#include<string>
#include<iostream>

using namespace std;

int a,b;

void game(int x,int y,int p,string s){
	if(x==a && y==b)cout << s << endl;
	else if(a>=4 && b>=4){
		if(x<4 || y<4){
			if(x<4)game(x+1,y,0,s+'A');
			if(y<4)game(x,y+1,1,s+'B');
		}else{
			if(x!=a)game(x+1,y,0,s+'A');
			if(y!=b)game(x,y+1,1,s+'B');
		}
	}else{
		if(a==5){
			if(x+1==a && y<b)game(x,y+1,1,s+'B');
			else{
				if(x<a)game(x+1,y,0,s+'A');
				if(y<b)game(x,y+1,1,s+'B');
			}
		}else if(b==5){
			if(y+1==b && x<a)game(x+1,y,0,s+'A');
			else{
				if(x<a)game(x+1,y,0,s+'A');
				if(y<b)game(x,y+1,1,s+'B');
			}
		}else{
			if(x<a)game(x+1,y,0,s+'A');
			if(y<b)game(x,y+1,1,s+'B');
		}
	}
}

int main(void){
	scanf("%d%d",&a,&b);
	string s;
	game(0,0,-1,s);
	return 0;
}

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

int main()
{
  int h,m,s, Sec;

  cin >> Sec;   // 秒数

  s= Sec % 60;  // 秒
  Sec /= 60;    // 分単位に・・・
  m= Sec % 60;  // 分
  h = Sec / 60; // 時

  cout << h << ":"<< m << ":" << s << endl;

  return 0;
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code

int main()
{
	int l, r; cin >> l >> r;
 
	long long ans = 2019;
	for (int i = l; i < r; ++i) {
		for (int j = i + 1; j <= r; ++j) {
			long long tmp = 1LL * i * j;
			ans = min(ans, tmp % 2019);
			if (ans == 0) {
				cout << "0" <<endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll a,b;
 sc(a);sc(b);  
 ans=0;
 if(a==b){
  pr(ans);
  return 0;
 }
 else if(a<0&&b==0){
  pr(abs(a));
  return 0;
 }
 else if(a==0&&b>0){
  pr(b);
  return 0;
 }
 else if(a>0&&b==0){
  pr(a+1);
  return 0;
 }
 else if(a==0&&b<0){
  pr(abs(b)+1);
  return 0;
 }
 else if(a*b<0){
  ans+=abs(abs(a)-abs(b))+1;
  pr(ans);
  return 0;
 }
 else if(a<b){
  ans+=b-a;
  pr(ans);
  return 0;
 }
 else if(a>b){
  ans+=a-b+2;
  pr(ans);
  return 0;
 }
return 0;}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
const int MAXN = 3e2+5;
const int MOD = 1e9+7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}
 
int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int n,d; 
    cin >> n >> d;
    d = d*2 + 1;
    cout << (n/d + (n%d != 0)) << endl;
    return 0;
}


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

using ll = long long;
const int mxn = 200020;
const int MOD = 1e9 + 7;
ll facts[mxn];

void init_facts(int n) {
    facts[0] = 1;
    for(int i = 1; i < n + 1; i++) {
        facts[i] = i * facts[i-1] % MOD;
    }
}

int main() {
    int N, M;
    cin >> N >> M;

    init_facts(N+M+1);

    ll ans = (facts[N] * facts[M]) % MOD;

    if(abs(N - M) > 1) cout << 0 << endl;
    else if(abs(N - M) == 1) cout << ans << endl;
    else cout << ans * 2 % MOD << endl;

    return 0;
}

Measured memory_bytes: 1792
use std::io;
use std::cmp;


fn main() {
    let a = read::<usize>();
    println!("{}", cmp::max(a[0] * a[1], a[2] * a[3]));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <string>
#include <sstream>
#include <numeric>
#include <stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	vector< int > ans(N);
	for (int i = N - 1; i >= 0; i--) {
		int tmp = 0;
		for (int j = 2 * (i + 1); j <= N; j += i + 1) {
			tmp += ans[j - 1];
		}
		(tmp += A[i]) %= 2;
		ans[i] = tmp;
	}
	vector< int > ans2;
	rep(i, N) if (ans[i]) {
		ans2.push_back(i + 1);
	}
	cout << ans2.size() << endl;
	;
	rep(i, ans2.size()) cout << ans2[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] + n <= 'Z') {
            s[i] += n;
        } else {
            int res = s[i] + n - 'Z';
            s[i] = 'A' + res - 1;
        }
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;

int main(){
	
	int n;
	
	cin >> n;
	
	vector<int>num(n);
	
	long long int mod = 1000000007;
	
	long long int sum = 0;
	for (int i = 0;i <n;i++ ){
		cin >> num[i];
		sum += num[i];
		sum %= mod;
	}
	
	long long int ans = 0;
	for (int i = 0; i < n;i++){
		sum -= num[i];
		
		if (sum < 0) sum += mod;
		ans += num[i]*sum;
		ans %= mod;
	}
	
	cout << ans;
	
	
	return 0;
}
		


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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
deque<int> p ;
long long N ; 
void solve(long long N){
    if(N == 1){
        return ;
    }
    if(N%2ll == 0){
        solve(N/2LL) ;
        int k = p.size() ;
        p.push_back(k+1) ;
        // cout << "pushback " << (k+1) << endl ;
    }
    else{
        solve(N - 1) ;
        int k = p.size() ;
        p.push_front(k+1) ;
        // cout << "pushfront " << (k+1) << endl ;
    }
    // cout << "@ N = " << N << endl ;
}
vector<int> ans ;
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
    //    freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    cin >> N ;
    solve(N + 1 )  ;
    while(!p.empty()){
        int f = p.front() ;
        p.pop_front() ;
        ans.push_back(f) ;
    }
    int sz = 2*ans.size() ;
    cout << sz << endl ;
    for(auto x:ans) cout << x << " " ;
    for(int i = 1 ; i <= ans.size() ; i++) cout << i << " " ;

    return 0 ; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);


class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m),b(m);
    UnionFind tree(n);
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    ll ans = n*(n-1) / 2;
    vector<ll> anse;
    for(ll i=0;i<m;i++){
        anse.push_back(ans);
        ll pa = a[m-i-1],pb = b[m-i-1];
        if(tree.issame(pa,pb)) continue;

        ll sa = tree.size(pa),sb = tree.size(pb);
        ans -= sa * sb;
        tree.merge(pa,pb);
    }
    reverse(anse.begin(),anse.end());
    for(int i=0;i<m;i++){
        cout << anse[i] << endl;
    }
}

Measured memory_bytes: 5364
#include <iostream>

using namespace std;


int main(void)
{
	int n;
	int debt = 100000;

	cin >> n;

	while(n > 0){
		debt *= 1.05;
		debt += (debt % 1000) ? 1000 - (debt % 1000) : 0;
		n--;
	}

	cout << debt << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int s, w;
    cin >>  s >> w;
    string ans = "safe";
    if (w>=s) ans = "unsafe";
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first1 ,
		BidirectionalIterator last1 ,
		BidirectionalIterator first2 ,
		BidirectionalIterator last2 ){
	if (( first1 == last1 ) || ( first2 == last2 )) {
		return false ;
	}
	BidirectionalIterator m1 = last1 ;
	BidirectionalIterator m2 = last2 ; --m2;
	while (--m1 != first1 && !(* m1 < *m2 )){
	}
	bool result = (m1 == first1 ) && !(* first1 < *m2 );
	if (! result ) {
		while ( first2 != m2 && !(* m1 < * first2 )) {
			++ first2 ;
		}
		first1 = m1;
		std :: iter_swap (first1 , first2 );
		++ first1 ;
		++ first2 ;
	}
	if (( first1 != last1 ) && ( first2 != last2 )) {
		m1 = last1 ; m2 = first2 ;
		while (( m1 != first1 ) && (m2 != last2 )) {
			std :: iter_swap (--m1 , m2 );
			++ m2;
		}
		std :: reverse (first1 , m1 );
		std :: reverse (first1 , last1 );
		std :: reverse (m2 , last2 );
		std :: reverse (first2 , last2 );
	}
	return ! result ;
}

template < class BidirectionalIterator > bool next_combination ( BidirectionalIterator first , BidirectionalIterator middle , BidirectionalIterator last )
{
	return next_combination (first , middle , middle , last );
}

//要素vからr個取り出す組み合わせ
int func(vector<int> v, int r, int s){
	int res = 0;
	do{
		do{
			int sum = 0;
			rep(i,r){
				sum += v[i] * (i + 1);
			}
			if(sum == s) res++;
		}while(next_permutation(v.begin(), v.begin() + r));
	}while(next_combination(v.begin(), v.begin() + r, v.end()));
	return res;
}

int main(){
	int n, s;
	while(cin >> n >> s){

		vector<int> v(10);
		iota(all(v),0);

		cout << func(v,n,s) << endl;
	}
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  map<char, int> m = {
      make_pair('S', 0),
      make_pair('N', 0),
      make_pair('E', 0),
      make_pair('W', 0),
  };

  for (int i = 0; i < s.size(); i++) {
    m[s[i]]++;
  }

  string ans = "Yes";
  if (m['S'] > 0 || m['N'] > 0) {
    if (m['S'] == 0 || m['N'] == 0) {
      ans = "No";
    }
  }

  if (m['W'] > 0 || m['E'] > 0) {
    if (m['W'] == 0 || m['E'] == 0) {
      ans = "No";
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int n,q;
vector<int>child[200005];
long long value[200005]={0};
void bfs(){
    queue<int>q;
    q.push(1);
    int u,v;
    while(!q.empty()){
        u=q.front();
        q.pop();
        for(int i=0;i<child[u].size();i++){
            v=child[u][i];
            value[v]+=value[u];
            if(child[v].size())
            q.push(v);
        }
    }
}
int main()
{
    int v,val;
    int f,c;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n-1;i++){
        scanf("%d%d",&f,&c);
        child[f].push_back(c);
    }
    while(q--){
        scanf("%d%d",&v,&val);
        value[v]+=val;
    }
    bfs();
    for(int i=1;i<=n;i++){
        printf("%lld%c",value[i]," \n"[i==n]);
    }
    return 0;
}


Measured memory_bytes: 14848
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[n];
		for(int i = 0; i < n; i++) {
			char[] s = sc.next().toCharArray();
			g[i] = new ArrayList<>();
			for(int j = 0; j < n; j++) {
				if(s[j] == '1') {
					g[i].add(j);
				}
			}
		}
		//check if bipartite
		int[] color = new int[n];
		color[0] = 1;
		LinkedList<Integer> q = new LinkedList<Integer>();
		q.add(0);
		while(!q.isEmpty()) {
			int u = q.pollFirst();
			for(int v: g[u]) {
				if(color[v] == 0) {
					color[v] = -color[u];
					q.add(v);
				}
				else if(color[v] == color[u]) {
					System.out.println(-1);
					return;
				}
			}
		}
		int max = 0;
		for(int u = 0; u < n; u++) {
			max = Integer.max(max, calc(u, g, n));
		}
		System.out.println(max+1);
	}
	static int calc(int v0, ArrayList<Integer>[] g, int n) {
		int[] dist = new int[n];
		Arrays.fill(dist, -1);
		dist[v0] = 0;
		LinkedList<Integer> q = new LinkedList<Integer>();
		q.add(v0);
		while(!q.isEmpty()) {
			int u = q.pollFirst();
			for(int v: g[u]) {
				if(dist[v] == -1) {
					dist[v] = dist[u]+1;
					q.add(v);
				}
			}
		}
		int max = 0;
		for(int u = 0; u < n; u++) {
			max = Integer.max(max, dist[u]);
		}
		return max;
	}

}


Measured memory_bytes: 28148