akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<cstdlib>
#include<memory>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

template <typename Type=int> class SegmentTree{
    public:
        int strnum;
        int strbeg;
        int nodemax;
        std::unique_ptr<Type[]> node;
        std::unique_ptr<std::pair<int,int>[]> noderange;

        SegmentTree(int a){
            strnum=a;
            strbeg=1;
            while(strbeg<strnum)strbeg*=2;
            strbeg-=1;
            nodemax=strbeg*2+1;
            node.reset(new Type[nodemax]);
            noderange.reset(new std::pair<int,int>[nodemax]);
            noderange[0]=std::make_pair(0,nodemax-strbeg-1);
            for(int i=1;i<nodemax;i++){
                int parent=(i-1)/2;
                int pleft=noderange[parent].first;
                int pright=noderange[parent].second;
                if(parent*2+1==i){
                    noderange[i]=std::make_pair(pleft,(pright+pleft)/2);
                }
                else{
                    noderange[i]=std::make_pair((pleft+pright)/2+1,pright);
                }
            }
        }
        Type operation(Type left,Type right){
            return left+right;
        }
        Type operation(Type left,Type center,Type right){
            return min(min(left,center),right);
        }
        void init(Type in){
            REP(i,nodemax)node[i]=in;
        }
        void update(int i,Type x){
            i+=strbeg;
            node[i]+=x;
            while(i>0){
                i=(i-1)/2;
                node[i]=operation(node[2*i+1],node[2*i+2]);
            }
        }
        Type find(int l,int r,int n=0){
            std::pair<int,int> ran=noderange[n];
            int center=(ran.first+ran.second)/2;
            if(l==ran.first&&r==ran.second)return node[n];
            else if(center<l)return find(l,r,2*n+2);
            else if(center>=r)return find(l,r,2*n+1);
            else return operation(find(l,center,2*n+1),find(center+1,r,2*n+2));
        }
};

int main()
{
    int n,q;
    scanf("%d %d\n",&n,&q);
    SegmentTree<long long int> a(n);
    a.init(0);
    long long int b,x,y;
    REP(i,q){
        scanf("%lld %lld %lld\n",&b,&x,&y);
        if(b==0){
            a.update(x-1,y);
        }
        else{
            printf("%lld\n",a.find(x-1,y-1));
        }
    }
    return 0;
}


Measured memory_bytes: 7036
#include<iostream>
#include<map>

#define LL long long

using namespace std;

LL a[200005];
LL s[200005];
LL x[200005]; 



int main(){

    int n;
    cin >> n;


    for(int i = 1; i <= n; i++){
         cin >> a[i];
         s[i] = s[i-1] + a[i];
         x[i] = x[i-1] ^ a[i];
     }

    LL ans = 0;    
    int l = 1;


    for(int r = 1; r <= n; r++){

          while( (s[r]-s[l-1]) != (x[r]^x[l-1])){
              l++;
            }
          
          ans += r - l + 1;
       }

    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
const int maxn = 110000;

int n, m, a, b;
vector <int> adj[maxn], cut;

bool mark[maxn];
int dp[maxn], h[maxn];
void dfs(int v)
{
    mark[v]=1;
    dp[v] = -1;
    bool p = 0;
    int t = max(0, h[v]-1), d = 0;
    for(auto u : adj[v])
    {
        if(!mark[u])
        {
            h[u] = h[v]+1, dfs(u);
            dp[v] = (dp[v]==-1 ? dp[u] : min(dp[v], dp[u]));
            d ++;
            if(dp[u] >= h[v])
                p = 1;
        }
        else
        {
            t = min(t, h[u]);
        }
    }
    if((v > 0 && p) || (v == 0 && d > 1))
        cut.pb(v);
    dp[v] = min((dp[v]==-1 ? t : dp[v]), t);
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m && cin>>a>>b; i ++)
        adj[a].pb(b), adj[b].pb(a);

    dfs(0);

    //for(int i = 0; i < n; i++)  cout << i << " : " << dp[i] << " , " << h[i] << endl;

    sort(cut.begin(), cut.end());
    for(auto v : cut)
        cout << v << endl;
    return 0;
}



Measured memory_bytes: 7120
// https://atcoder.jp/contests/abc129/tasks/abc129_a
#include <bits/stdc++.h>
#define debugi(x) cerr << "x -> " << x << endl;
#define For(i, n) for (__typeof(i) i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

void solve()
{
    int i;
    vector<int> flight_times(3, INT_MAX);
    For(i, 3)
    {
        cin >> flight_times[i];
    }
    sort(all(flight_times));
    cout << flight_times[0] + flight_times[1] << endl;
}
int main()
{
    _;
    ull testcases = 1LL;
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    // cin >> testcases;
    while (testcases--)
        solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/dp/tasks/dp_d
 * Knapsack 1
 */
public class Main {
	public static void main(String...args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w = sc.nextInt();
			int[] u = new int[n];
			long[] v = new long[n];
			for (int i = 0; i < n; i++) {
				u[i] = sc.nextInt();
				v[i] = sc.nextLong();
			}

			long[][] dp = new long[n+1][w+1];
			for (int i = 0; i < n; i++) {
				for (int j = 1; j <= w; j++) {
					dp[i+1][j] = maxdp(dp[i+1][j], dp[i][j]);
					if (u[i] <= j) {
						dp[i+1][j-u[i]] = maxdp(dp[i+1][j-u[i]], dp[i][j] + v[i]);
					}
				}
			}

			long max = Long.MIN_VALUE;
			for (int i = 0; i < n+1; i++) {
				for (int j = 0; j < w+1; j++) {
					if (max < dp[i][j]) {
						max = dp[i][j];
					}
				}
			}
			System.out.println(max);
		}
	}

	public static long maxdp(long a, long b) {
		if (a > b) return a;
		else return b;
	}
}


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

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

  int count = 0;
  int count_a = 0;
  int count_b = 0;
  int count_ba = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    for (int i = 0; i < s.size()-1; i++) {
      if (s[i] == 'A' && s[i+1] == 'B') count++;
    }
    if (s[0] == 'B') count_b++;
    if (s[s.size() - 1] == 'A') count_a++;
    if (s[0] == 'B' && s[s.size() - 1] == 'A') count_ba++;
  }
  int count_ua = count_a - count_ba;
  int count_ub = count_b - count_ba;
  
  count += min(count_ua, count_ub);
  count += max(count_ba - 1, 0);
  
  count_ua -= min(count_ua, count_ub);
  count_ub -= min(count_ua, count_ub);
  
  if (count_ba > 0) {
    if (count_ua > 0 || count_ub > 0) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

int main() {
    int n, l;
    cin >> n >> l;
    int azi[220];
    for (int i = 0; i < n; i++) {
        azi[i] = l + i;
    }

    /*
    for (int i = 0; i < n; i++) {
        cout << azi[i] << " ";
    }
    cout << endl;
    */

    int sum1 = 0;
    for (int i = 0; i < n; i++) {
        sum1 += azi[i];
    }

    int sum2 = 0;
    int mn = 200200;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        sum2 = sum1 - azi[i];
        //cout << sum2 << " ";
        if (mn > abs(sum1 - sum2)) {
            mn = abs(sum1 - sum2);
            ans = sum2;
            //cout << ans << " ";
            //cout << 'a' << endl;
        }
    }
    //cout << endl;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a = 0, b = 0, sum = 0;
	scanf("%d %d", &a, &b);
	sum = a - b * 2;
	if (sum > 0) {
		printf("%d", sum);
	}
	else {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

string s,t;

int main(){
    cin>>s>>t;
    int ans=0;
    rep(i,0,3) if(s[i]==t[i]) ans++;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		  Scanner sc = new Scanner(System.in);
		  
	        int n = sc.nextInt();
	        String s = sc.next();
	        sc.close();
	        int[] a = new int[s.length()];
	        for(int i = 0 ; i < s.length() ; i++ ){
	            a[i] = (s.charAt(i) - 65 + n) % 26 + 65;
	            System.out.print((char)a[i]);
	        }
	        System.out.println();
	}

}


Measured memory_bytes: 32060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, m, res;
  vector<int> v;
  cin >> n;
  m = n;

  for (int i = 2; i * i < m; i++) {
    while (n % i == 0) {
      if (find(v.begin(), v.end(), i) == v.end()) {
        v.push_back(i);
      }
      n /= i;
    }
  }

  if (n > 1) {
    v.push_back(n);
  }

  res = m;
  for (int i = 0; i < v.size(); i++) {
    res *= 1.0 - 1.0 / v[i];
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3168
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 3; i <= n; i++) {
            if (i % 3 == 0 || String.valueOf(i).contains("3"))
                System.out.print(" " + i);
        }
        System.out.println();
    }
}


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

string solve(int n);

int main(){
    int age = 0;
    cin >> age;
    
    cout << solve(age) << endl;
    
    return 0;
}

string solve(int n){
     if(n == 7 || n == 5 || n == 3){
        return "YES";
    }else{
        return "NO";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void){
	int len,cut_i;
	char str[1000];

	scanf("%[a-z .]",str);

	len = strlen(str);

	for(cut_i=0; cut_i<len; cut_i++){
		str[cut_i] = toupper(str[cut_i]);
	}
	
	puts(str);

	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;

  int ans = 0;
  int s, t, u, v;
  for(int i = a; i <= b; i++){
    s = i % 10;
    t = i / 10000 % 10;
    u = i / 10 % 10;
    v = i / 1000 % 10;
    if(s == t && u == v){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int P=1E9+7;
const int MAXN=2E5+10;

char str[MAXN];
int f[2][MAXN];

int main()
{
	scanf("%s",str+1);
	int n=strlen(str+1);
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		if(str[i]=='0')
		{
			f[0][i]=f[0][i-1];
			f[1][i]=3ll*f[1][i-1]%P;
		}
		else
		{
			f[0][i]=f[0][i-1]*2%P;
			f[1][i]=(f[0][i-1]+3ll*f[1][i-1])%P;
		}
	}
	printf("%lld\n",(1ll*f[0][n]+f[1][n])%P);
}


Measured memory_bytes: 1152
N = int(input())

a = list(map(int, input().split()))
b = [0] * N
flag = True

for k in range(N):
    i = N - k
    count = 0
    for m in range(i, N + 1, i):
        count += b[m - 1]

    if count % 2 == a[i - 1]:
        pass
    elif (count + 1) % 2 == a[i - 1]:
        b[i - 1] = 1
    else:
        print(-1)
        flag = False
        break

if flag:
    print(sum(b))
    for i in range(N):
        if b[i] == 1:
            print(i + 1, end=" ")
    print()

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

long long n;
string s;

long long moe(long long a,long long b)
{
    if (b==0) return 1;
    if (b%2==0) return moe(a*a,b/2);
    return a*moe(a*a,b/2);
}

void solve(long long k,int l)
{
    if (l==0) return;
    for (int i=1;i<=26;++i)
    {
        if (k>moe(26,l-1))
            k-=moe(26,l-1);
        else
        {
            char c='a'+i-1;
            s+=c;
            solve(k,l-1);
            return;
        }
    }
}

void process()
{
    int vt=1;
    while (moe(26,vt)<n)
    {
        n-=moe(26,vt);
        vt++;
    }
    solve(n,vt);
    cout<<s;
}

int main()
{
    scanf("%lld",&n);
    process();
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int n,p[100100];
int ans;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>p[i];
		
	for(int i=1;i<=n;i++)
	{
		if(i==n&&p[i]==i) ans++;
		else if(p[i]==i) i++,ans++; 
	}
	
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
const int Maxs=2e5+5;
int pw[Maxs];
int dp[Maxs];
int mod[Maxs];
int main(){
	string s;
	cin>>s;
	pw[0]=1;
	for(int i=1;i<Maxs;i++){
		pw[i]=pw[i-1]*10%2019;
	}
//	for(int i=0;i<=13;i++)cout<<pw[i]<<' ';cout<<endl;
	mod[0]++;
	int ans=0;
	for(int i=SZ(s)-1;i>=0;i--){
		dp[i]=(dp[i+1]+(s[i]-'0')*pw[SZ(s)-i-1])%2019;
		ans+=mod[dp[i]];
		mod[dp[i]]++;
	}
//	for(int i=0;i<SZ(s);i++)cout<<dp[i]<<' ';cout<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5332
# ABC079-B
def luca_memo(n):
    memo = [0] * (n+1)
    
    def luca(n):
        if n == 0:
            return 2
        if n ==1:
            return 1
        if memo[n] != 0:
            return memo[n]
        memo[n] = luca(n-2) + luca(n-1)
        return memo[n]
    return luca(n)
N = int(input())
print(luca_memo(N))

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

const int MOD = 1e9 + 7;

int n;
char S[2][66];

int main() {
	scanf("%d %s %s", &n, S[0] + 1, S[1] + 1);
    int ans = 1;
	for (int i = 1; i <= n; ++i) {
        if (S[0][i] != S[1][i]){
            if (i == 1) ans = 6LL * ans % MOD;
            else if (S[0][i - 1] == S[1][i - 1]) ans = 2LL * ans % MOD;
            else ans = 3LL * ans % MOD;
            ++i;
        } else {
            if (i == 1) ans = 3LL * ans % MOD;
            else if (S[0][i - 1] == S[1][i - 1]) ans = 2LL * ans % MOD;
        }
    }
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
  int ref = 0;
  int n; cin >> n;
  bool exist = false;
  while((ref*(ref+1)/2) < 100100){
    ++ref;
    if(n==(ref*(ref+1)/2)) {
      exist = true;
      break;
    }
  }

  if(!exist) cout << "No" << endl;
  else{
    cout << "Yes" << endl;
    cout << ref + 1 << endl;

    FOR(i,0,ref-1){
      cout << ref << " ";
      FOR(j,0,i){
        cout << i * (i+1) / 2 + j + 1 << " ";
      }
      int now = (i+1) * (i+2) / 2;
      FOR(j,i+1,ref-1){
        now += j;
        cout << now << " ";
      }
      cout << endl;
    }

    cout << ref << " ";
    FOR(i,1,ref){
      cout << i * (i+1) / 2 << " ";
    }
    cout << endl;
  }



}


Measured memory_bytes: 1408
#include <tuple>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
const int Maxn=2000;
int n;
int a[Maxn*3+5];
int dp[Maxn+5][Maxn+5];
int row_max[Maxn+5];
int zero,all_max;
vector<tuple<int,int,int> > vis;
void update(int i,int j,int k){
	vis.emplace_back(i,j,k);
	vis.emplace_back(j,i,k);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++){
		scanf("%d",&a[i]);
	}
	memset(row_max,-0x3f,sizeof row_max);
	memset(dp,-0x3f,sizeof dp);
	dp[a[1]][a[2]]=row_max[a[1]]=row_max[a[2]]=zero;
	for(int i=3;i<=3*n;i+=3){
		if(a[i]==a[i+1]&&a[i]==a[i+2]){
			zero--;
			continue;
		}
		for(int _=0;_<3;_++){
			swap(a[i],a[i+1]);
			swap(a[i+1],a[i+2]);
			update(a[i],a[i+1],max(all_max,dp[a[i+2]][a[i+2]]+1));
			for(int j=1;j<=n;j++){
				if(a[i+1]==a[i+2]){
					update(j,a[i],dp[j][a[i+1]]+1);
				}
				update(j,a[i],row_max[j]);
			}
		}
		for(tuple<int,int,int>j:vis){
			int e=get<0>(j),f=get<1>(j),g=get<2>(j);
			dp[e][f]=max(dp[e][f],g);
			row_max[e]=max(row_max[e],g);
			all_max=max(all_max,g);
		}
		vis.clear();
	}
	printf("%d\n",all_max-zero);
	return 0;
}


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

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    double r;
    scanf("%lf",&r);
    printf("%lf %lf\n",(double)(M_PI*r*r),(double)(M_PI*2*r));
    return 0;
}





Measured memory_bytes: 2112
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B;

  std::cin >> A >> B;

  if (B == 1) {
    std::cout << 0 << std::endl;
  }
  else {
    int c = 1, S = A;

    for ( ; S < B; S += A - 1, c ++)
      ;

    std::cout << c << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int A,X,Y,W,H,N,catX,catY,counter;
  
  cin >>A;
  
  for(int i=0 ; i < A ; i++){
 
    cin >>X>>Y>>W>>H;
    cin >>N;
    counter=0;

    for(int j=0 ; j < N ; j++){

      cin >>catX>>catY;
      
      if( (X <= catX && catX <= X+W) && (Y <= catY && catY <= Y+H) ){
	counter++;
      }

    }
    cout <<counter<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  if((100 * N)%108==0) cout << 100*N/108 << endl;
    else if(100*(N+1)%108==0) cout << ":(" << endl;
    else if(100*(N+1)/108==100*N/108) cout << ":(" << endl;
    else cout << 100*N/108+1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::vector<i64> sorted_A = A;
  std::sort(sorted_A.begin(), sorted_A.end(), std::greater<i64>());

  for (i64 i = 0; i < N; ++i) {
    std::cout << (A[i] == sorted_A[0] ? sorted_A[1] : sorted_A[0]) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,vmax=-(1<<30),vmin,tmp;
    scanf("%d %d",&n,&vmin);
    n--;
    for(;n>0;n--){
        scanf("%d",&tmp);
        vmax=max(vmax,tmp-vmin);
        vmin=min(vmin,tmp);
    }
    printf("%d\n",vmax);
    return 0;
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  double a, b;
  cin >> a >> b;

  rrep(i,1050) {
    if (int((double)i*0.08) == a && int((double)i*0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}

int n;
void dfs(string s, char mx) {
    if (s.length() == n) cout << s << endl;
    else {
        for (char c='a';c<=mx;c++) dfs(s + c, (c == mx) ? (char)(mx + 1) : mx);
    }
}

int main() {
    cin >> n;
    dfs("", 'a');
}

Measured memory_bytes: 1536
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int d = a / b;
	int r = a%b;
	double f;
	f = 1.0*a / b;
	cout << d << " " << r << " ";
	printf("%.5lf\n", f);

	return 0;
	}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

struct SegmentTree{
private:
    int n;
    vector<ll> node;
public:
    SegmentTree(int sz){
        n=1;
        while(n<sz)n*=2;
        node.resize(2*n-1);
        for(int i=0;i<2*n-1;i++){
            node[i]=-LINF;
        }
    }
    void update(int a,ll x){
        a+=n-1;
        node[a]=x;
        while(a>0){
            a=(a-1)/2;
            node[a]=max(node[2*a+1],node[2*a+2]);
        }
    }
    ll get(int a=0,int b=-1,int k=0,int l=0,int r=-1){
        if(b==-1)b=n;
        if(r==-1)r=n;
        if(b<=l||r<=a)return -LINF;
        if(a<=l&&r<=b){
            return node[k];
        }
        else{
            return max(get(a,b,2*k+1,l,(l+r)/2),get(a,b,2*k+2,(l+r)/2,r));
        }
    }
};

int main(){
    int n;
    cin>>n;
    pair<int,int> p[n];
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        p[i]={h,i};
    }
    sort(p,p+n);
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    SegmentTree seg(n);
    for(int i=0;i<n;i++){
        int h=p[i].first;
        int j=p[i].second;
        ll mx=seg.get(0,j+1);
        if(mx==-LINF){
            seg.update(j,a[j]);
        }
        else{
            seg.update(j,mx+a[j]);
        }
    }
    cout<<seg.get()<<endl;
}

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


#define INF 1000000000000


signed main()
 {
   int n,k;
   cin>>n>>k;
   int m=INF;
   vector<int> h(n);
   rep(i,n){
     cin>>h[i];
   }
   sort(h.begin(),h.end());
   rep(i,n-k+1){
     m=min(h[i+k-1]-h[i],m);
   }
   cout<<m;
 }


Measured memory_bytes: 1024
from numpy import*;B=searchsorted;a,b=loadtxt(open(0),'i4',skiprows=1);c=0;l=2**29
while l:h=l;l//=2;y=sort(hstack((b%h-h,b%h)));c+=sum(B(y,h-a%h)-B(y,l-a%h))%2*l
print(c)

Measured memory_bytes: 64164
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+15+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> s;
  s[0] = '2';
  s[1] = '0';
  s[2] = '1';
  s[3] = '8';
  print(s);
  return 0;
}

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

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  rep (i, n) {
    if (s.at(i) != s.at(n - 1 - i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  rep (i, n / 2) {
    if (s.at(i) != s.at((n - 1) / 2 - 1 - i)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 1000000

long long  gcd(long long x,long long y){
  long long mindata,maxdata;
  mindata=min(x,y);
  maxdata=max(x,y);
  while(maxdata%mindata!=0){
    long long temp;
    temp=maxdata%mindata;
    maxdata=mindata;
    mindata=temp;
  }
  return mindata;
}


int main(){
  long long temp;
  int n,x;
  cin>>n>>x;
  long long data[MAX];
  for(int i=0;i<n;i++){
    cin>>temp;
    temp-=x;
    if(temp<0) temp=(-1)*temp;
    data[i]=temp;
  }
  if(n==1){
    cout<<data[0]<<endl;
    return 0;
  }
  long long ans=gcd(data[0],data[1]);
  for(int i=2;i<n;i++){
    ans=gcd(ans,data[i]);
  }
  cout<<ans<<endl;
  
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll l,r;
ll ans = INF;

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


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

using namespace std;

typedef long long ll;

const int N = 405;
ll arr[N];
ll dp[N][N];
ll cost[N][N];

int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  for(int i = 0; i < n; i++)
  {
    cost[i][i] = arr[i];
    for(int j = i + 1; j < n; j++)
      cost[i][j] = cost[i][j - 1] + arr[j];
  }
  for(int i = n - 1; i >= 0; i--)
  {
    for(int j = i + 1; j < n; j++)
    {
      dp[i][j] = 1e18;
      for(int z = i; z <= j; z++)
      {
        dp[i][j] = min(dp[i][j], cost[i][z] + cost[z + 1][j] + dp[i][z] + dp[z + 1][j]);
      }
    }
  }
  cout << dp[0][n - 1];
  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, k; cin >> n >> k;
   vector<int> A(n);
   rep(i,n)cin >> A[i];
   int ans = 0;
   sort(A.begin(), A.end());
   rep(i,k){
      ans += A[i];
   }
   cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> p(n,0);
  double x;
  string u;
  double ans = 0;
  for(int i = 0; i < n; i++){
    cin >> x >> u;
    ans += (u == "JPY" ? x : x * 380000);
  }
  cout << ans << endl;
  return 0;

}


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

int N;
const int MAX_N = 1.0e5 + 100;
int a[MAX_N];

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

    int ans = 0;
    int j = 0;
    bool f = false;
    for (int i = 0; i < N; i++) {
        if (a[j] == 2) {
            ans++;
            f = true;
            break;
        }
        else {
            j = a[j] - 1;
            ans++;
        }
    }
    

    if (f) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0043

"""
import sys
from sys import stdin
input = stdin.readline


def dfs(hand, count):
    # ??¢??????n????????£??????????????¨????¢??????????
    if count < 1:
        return True

    for i, n in enumerate(hand[1:], start=1):
        if n == 0:
            continue
        if n >= 3:
            c_hand = hand[:]
            c_hand[i] -= 3
            res = dfs(c_hand[:], count-1)
            if res:
                return True
        if i > 7:
            return False
        if hand[i+1] >= 1 and hand[i+2] >= 1:
            c_hand = hand[:]
            c_hand[i] -= 1
            c_hand[i+1] -= 1
            c_hand[i+2] -= 1
            res = dfs(c_hand[:], count-1)
            if res:
                return True
        else:
            return False


def solve(data):
    """
    1) ??????1??????????????¨
    2) ??¢??????4??????????????¨
    3) ????????°??????5?????\??????????????¨
    :param data: ??????
    :return: ??????????????????
    """
    ans = []                    #  ???????????????????¨????

    # ?????¨?????????l???9??????????????????????????????????????????????????§??????????????????????????????????????§????????°????????????????????°????????????????????????
    for tsumo in range(1, 10):
        my_hand = data[:]
        my_hand.append(tsumo)       #  ????????????????????°??????1????¶????

        remaining = [0] * 10
        for n in my_hand:
            remaining[n] += 1

        if max(remaining) > 4:  #  ?????????3?¢????
            continue

        # ?????????1????¢????
        for i, atama in enumerate(remaining[1:], start=1):
            if atama >= 2:
                c_remaining = remaining[:]
                c_remaining[i] -= 2
                res = dfs(c_remaining[:], 4)
                if res:
                    ans.append(tsumo)
                    break
    return ans


def main(args):
    #hand = '3649596966777'
    #data = list(map(int, list(hand)))

    for line in sys.stdin:
        data = list(map(int, list(line.strip())))
        result = solve(data)

        if len(result) > 0:
            print(*result)
        else:
            print(0)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7780
n = int(input())
ls = list(map(int,input().split()))
mon = 1000
beet = 0
p = []
m = []
if ls[1]-ls[0] > 0:
    beet += int(mon//ls[0])
    mon -= ls[0]*int(mon//ls[0])
    be = True
else:
    be = False
for i in range(n-1):
    if ls[i] < ls[i+1]:
        if be == False:
            beet += int(mon//ls[i])
            mon -= ls[i]*int(mon//ls[i])
            be = True
    if ls[i] > ls[i+1]:
        if be == True:
            mon += ls[i] * beet
            beet = 0
            be = False
if beet > 0:
    mon += beet*ls[-1]
print(mon)

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

int main() {
  int D,Z=0;
  cin>>D;
  vector<int> sage(26);
  for(int i=0;i<26;i++){
    cin>>sage.at(i);
  }
  vector<vector<int>> man(D,vector<int>(26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin>>man.at(i).at(j);
    }
  }
  
  vector<int> rkai(26,-1);
  for(int i=0;i<D;i++){
    int a;
    cin>>a;
    a--;
    Z+=man.at(i).at(a);
    rkai.at(a)=i;
    for(int j=0;j<26;j++){
      Z-=(i-rkai.at(j))*sage.at(j);
    }
    cout<<Z<<endl;
  }
}

Measured memory_bytes: 3676
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	long long int a, b, ans = 0;
	scanf("%lld %lld", &a, &b);
	for(int i = 2; i < 1000; i++)
	{
		ans = a * i;
		if(ans % b != 0)
		{
			printf("%lld\n", ans);
			return 0;
			}
		}
	printf("%d\n", -1);
	return 0;
	}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.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 MOD 1000000007

int n;
int a,b;

ll ruijo(int a,int n,int mod){ 
  if(n==0) return 1;
  if(n%2==0){
    ll tmp=ruijo(a,n/2,mod);
    tmp*=tmp;
    return tmp%mod;}
  else{
    ll tmp=a*ruijo(a,n-1,mod)%mod;
    return tmp;}
}


int main(){
  scanf("%d%d%d",&n,&a,&b);

  ll ans=ruijo(2,n,MOD)-1;

  ll tmp=1;
  for(int i=1;i<a+1;i++){
    tmp=tmp*(n-i+1)%MOD*ruijo(i,MOD-2,MOD)%MOD;}
  //printf("%lld\n",tmp);
  ans+=MOD-tmp;
  for(int i=a+1;i<b+1;i++){
    tmp=tmp*(n-i+1)%MOD*ruijo(i,MOD-2,MOD)%MOD;}
  //printf("%lld\n",tmp);
  ans+=MOD-tmp;
  ans%=MOD;

  printf("%lld\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i =0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}
	cat ans =0;
	for(int i =0; i < N; i++) if(A[A[i]] == i) ans++;
	cout << ans/2 << "\n";
	return 0;}

// look at my code
// my code is amazing


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

int main()
{
    int a;
    cin >> a;

    int tmp = -1;
    for(int i=0; i<4; i++){
        if(tmp == a % 10){
            cout << "Bad" << endl;
            return 0;
        }
        tmp = a % 10;
        a = a / 10;
    }

    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'







int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
//     int t;
//      cin >> t;

//      while(t--){
    
// }
int n;
cin >> n;
int arr[n];
fo(i,0,n)cin >> arr[i];

int q;
cin >> q;
int sum = 0;
fo(i,0,n)sum += arr[i];
map<int,int>m;
fo(i,0,n)m[arr[i]]++;
while(q--){
	int b,c;
	cin >> b >> c;
	int x = m[b];
	m[c] += x;
	m[b] = 0;
	int re = c*x - b*x;
	sum += re;
	cout << sum << endl;
}


return 0;
}




Measured memory_bytes: 10328
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int a, b;

  cin >> a >> b;

  if(a <= 8 && b <= 8){
    puts("Yay!");
  }else{
    puts(":(");
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.*;// 从这行开始复制，这是第一行
import java.util.*;


public class Main {

    /**
     * TODO 提交的时候一定要设置为 true
     */
    private boolean submitFlag = true;

    private void solve() {
        int ans = 0;


        System.out.println(ans);
    }


    private void run() throws IOException {
        setReader();

        //TODO 从这里开始读入题目输入
        String s = reader.readLine();
        System.out.println(s.substring(0, 3));

    }


//    main以及输入输出========================================================================

    public static void main(String[] args) throws IOException {
        Main solution = new Main();
        solution.run();
        solution.reader.close();
    }

    /**
     * TODO 存档时，改一下moduleName
     */
    String moduleName = "atcoder-race";

    /**
     * 注意不同题目这里路径要设一下
     *
     * @throws IOException
     */
    private void setReader() throws IOException {
        if (submitFlag) {
            reader = new BufferedReader(new InputStreamReader(System.in));
        } else {
            String projectPath = System.getProperty("user.dir");
            String modulePath = projectPath + "/" + moduleName + "/src/main/java/";
            String className = this.getClass().getPackage().getName().replace(".", "\\");
            reader = new BufferedReader(new FileReader(modulePath + className + "\\input.txt"));
        }
    }

    private BufferedReader reader;
    private StringTokenizer tokenizer;

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String next() throws IOException {
        return nextToken();
    }

    private String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


Measured memory_bytes: 32604
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
		ll n,x,i,count=0;
		cin>>n>>x;
		ll a[n];
		for(i=0;i<n;i++){
			cin>>a[i];
		}
		sort(a,a+n);
		for(i=0;i<n;i++){
			x=x-a[i];
			if(x>=0&&i!=n-1){
				count++;
			}
			else if(i==n-1){
				if(x==0){
					count++;
				}
			}
		}
		cout<<count;
	
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	int n, tmp;
	string ans="No";
	cin >> n;
	for (int i = 1; i < 10; i++) {
		if (n % i == 0) {
			tmp = n / i;
			if (tmp < 10) {
				ans = "Yes";
			}
		}
	}
	cout << ans;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;
const ll MOD = 1000000007;

int n;
int X, Y, Z;
int XYZ;
int maxi;
// typedef pair<int,deque<int> > K;
typedef pair<int, ll> K;

bool isPossible(const deque<int>& vs) {
  int as[] = {X, Y, Z};
  int i = 0;
  for(int v : vs) {
    if(i >= 3) {
      return false;
    }
    as[i] -= v;
    if(as[i] < 0) {
      return false;
    } else if(as[i] == 0) {
      ++i;
    }
  }
  return i <= 3;
}

ll mypow(ll x, ll n) {
  if(n == 0) {
    return 1;
  } else if(n % 2 == 0){
    return mypow(x*x%MOD, n/2);
  } else {
    return mypow(x*x%MOD, n/2)*x%MOD;
  }
}

ostream& operator<<(ostream& out, const deque<int>& vs) {
  out << "{";
  for(int v : vs) {
    out << v << ",";
  }
  return out << "}";
}

ll encode(const deque<int>& vs) { // 解説読んで、コンパクトなエンコード方法を知った
  ll res = 0;
  for(int v : vs) {
    res = ((res << 1) | 1) << (v-1);
  }
  return res;
}

map<K, ll> memo;
ll solve(int rest, const deque<int>& vs, int sum) {
  //  K key(rest, vs);
  K key(rest, encode(vs));
  if(memo.count(key)) {
    return memo[key];
  }
  ll res = 0;
  if(rest > 0) {
    for(int cur = 1; cur <= 10; ++cur) {
      deque<int> nextVs = vs;
      int nextSum = sum;
      nextVs = vs;
      nextSum = sum;
      nextVs.push_back(cur);
      nextSum += cur;
      while(!nextVs.empty() && (nextSum > XYZ || !isPossible(nextVs))) {
        nextSum -= nextVs.front();
        nextVs.pop_front();
      }
      if(nextSum == XYZ) {
        res = (res + mypow(10, rest-1)) % MOD;
      } else {
        res = (res + solve(rest-1, nextVs, nextSum)) % MOD;
      }
    }
  }
  // if(res > 0 && rest == 3) {
  //   cerr << "solve(" << rest << "," << vs << ") = " << res << endl;
  // }
  return memo[key] = res;
}

int main(void) {
  int n;
  scanf("%d%d%d%d", &n, &X, &Y, &Z);
  maxi = max(max(X, Y), Z);
  XYZ = X + Y + Z;
  deque<int> vs;
  ll res = solve(n, vs, 0);
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 36992
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
  string S;
  cin >> S;
  
  int N = S.length();
  vector<int> cube(N);
  
  int red = 0;
  int blue = 0;
  
  for(int i=0; i<N; i++)
  {
    if(S[i] == '0')
    {
      red++;
    }else 
    if(S[i] == '1')
    {
      blue++;
    }
    
  }
  
  int ans = min(red, blue);
  
  cout << ans * 2 << endl;
  
  return 0;
}

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

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

  string W;
  cin >> W;
  set<string> S;
  S.insert(W);

  char prev = W[W.size()-1];
  bool flag = true;
  for (int i = 1; i < N; i++) {
    cin >> W;
    if (W[0] != prev || S.count(W) == 1) {
      flag = false;
    }
    prev = W[W.size()-1];
    S.insert(W);
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll N;
	cin >> N;
	vll U(N - 1), V(N - 1), W(N - 1);
	for (int i = 0; i < N - 1; i++)
	{
		cin >> U[i] >> V[i] >> W[i];
		U[i]--;
		V[i]--;
	}

	vvpll branch(N); // bese -> partner, weight


	for (int i = 0; i < N - 1; i++)
	{
		pair<ll, ll> temp = { V[i] , W[i] };
		branch[U[i]].emplace_back(temp);

		pair<ll, ll> temp2 = { U[i] , W[i] };
		branch[V[i]].emplace_back(temp2);
	}


	// 0を根にしたときの根からの最短距離
	vll dist(N);
	for (int i = 0; i < N; i++)
	{
		dist[i] = LLINF;
	}
	dist[0] = 0;

	queue<ll> check;
	check.push(0);


	while (!check.empty())
	{

		ll base = check.front();
		check.pop();


		for (int i = 0; i < branch[base].size(); i++)
		{
			ll partner = branch[base][i].first;
			ll weight = branch[base][i].second;

			if (dist[partner] == LLINF)
			{
				dist[partner] = dist[base] + weight;

				check.push(partner);
			}
		}

	}

	for (int i = 0; i < N; i++)
	{
		if (dist[i] % 2 == 0)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << 1 << endl;
		}
	}

}





Measured memory_bytes: 11008