akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define tp make_tuple
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
using namespace std;

int main()
{

    ll n,i,j,k;

    cin>>n;

    ll a[n+5],b[n+5];

    for(i=0;i<n;i++){

        cin>>a[i];
    }

    b[0]=a[0];

    for(i=1;i<n;i++){

        b[i]=a[i] ^ b[i-1];
    }

    k=b[n-1];

    for(i=0;i<n;i++){

        cout<<(k^a[i])<<" ";
    }

    cout<<endl;



}


Measured memory_bytes: 6696
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	map<int, int> check;
	bool flag = true;
	while( n-- ){
		int a; cin >> a;
		if( check[a] > 0 ){
			flag = false;
		} else {
			++check[a];
		}
	}
	if( flag ) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using namespace std;

int main(){
    int N;
    while(cin >> N && N >= 0){
        bool v_wall[40][40] = {}; // tate
        bool h_wall[40][40] = {}; // yoko
        REP(i, N){
            string d;
            int x, y;
            cin >> d >> x >> y;
            if(d[0] == 'x'){
                for(int dx = 0; dx < 4; dx++){
                    h_wall[4 * y][4 * x + dx] = true;
                }
            }else{
                for(int dy = 0; dy < 4; dy++){
                    v_wall[4 * y + dy][4 * x] = true;
                }
            }
        }
        int x = 3;
        int y = 1;
        int dx = 1;
        int dy = 1;
        while(true){
            x += dx;
            y += dy;
            if(h_wall[y][x]) dy *= -1;
            if(v_wall[y][x]) dx *= -1;
            if(!h_wall[y][x] && !v_wall[y][x]){
                if(x == 0 || x == 8 * 4 || y == 0 || y == 8 * 4){
                    break;
                }
                if(x == 3 && y == 1){
                    break;
                }
            }
        }
        cout << x * 25 << " " << y * 25 << endl;
    }
    return 0;
}

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

int main(){
  int n,count = 0,i=1,j=1,k,l;
  cin >> n;
  while(i<=n){
    // cout<< "i=" << i;
    i++;
    count++;
    l=i;
    k = 0;
    while(l>0){
      l/=10;
      k++;
    }
    // cout << ":k=" << k << endl;
    if(k%2 == 0){
    // cout << "k=" << k;
      // i = pow(100,j);
      i*=10;
      j++;
      // cout << "  new:" << i << endl;
    }
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[100],b[100];
int main()
{
	cin>>(a+1);
	cin>>(b+1);
	int la=strlen(a+1);
	int lb=strlen(b+1);
	int k=max(strlen(a+1),strlen(b+1));
	for(int i=1;i<=k;++i)
	{
		if(la>=i)
		cout<<a[i];
		if(lb>=i)
		cout<<b[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//?????§??¬?´???°
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, s;
int dp[10][101][1001];//i????????°???????????£????????§?????°??????????????§??????
signed main() {
	for (int i = 0; i < 101; i++) {
		dp[1][i][i] = 1;
	}
	for (int i = 1; i < 9; i++) {
		for (int j = 0; j < 101; j++) {
			for (int z = 0; z < 1001; z++) {
				for (int t = j + 1; t < 101; t++) {
					if (t + z > 1000)
						break;
					dp[i + 1][t][z + t] += dp[i][j][z];
				}
			}
		}
	}
	while (cin >> n >> s&&n + s != 0) {
		int ans = 0;
		for (int i = 0; i < 101; i++)
			ans += dp[n][i][s];
		cout << ans << endl;
	}
}

Measured memory_bytes: 9752
#include<bits/stdc++.h>
#define int long long
#define re(i,n) for(i=0;i<n;i++)
#define bre(i,n) for(i=n;i>0;i--)
#define rep(i,l,r) for(i=l;i<r;i++)
#define brep(i,l,r) for(i=r;i>l;i--)
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
template<int H,int W>int wa(int x1,int y1,int x2,int y2,int(&p)[H][W]){
	return p[y2][x2]-p[y2][x1]-p[y1][x2]+p[y1][x1];
}
struct Unif{
	vector<int> e;
	vector<int> rank;
	Unif(int n):e(n,-1),rank(n,1){}
	void uni(int a,int b){
		if(e[a]!=-1)
			uni(e[a],b);
		else if(e[b]!=-1)
			uni(a,e[b]);
		else{
			if(a==b)
				return;
			int ra=rank[a],rb=rank[b];
			if(ra>=rb){
				e[b]=a;
				if(ra==rb)
					rank[a]++;
			}
			else
				e[a]=b;
		}
	}
	bool find(int a,int b){
		if(e[a]!=-1)
			return find(e[a],b);
		else if(e[b]!=-1)
			return find(a,e[b]);
		else
			return a==b;
	}
	int num(int a){
		if(e[a]!=-1)
			return num(e[a]);
		else
			return a;
	}
};
int A,B,C,D,N,M,K,S,T,H,W;
int p[314514];
signed main(){
	int i,j,k;
	cin>>N>>A>>B;
	if(A*B<N||N-(A+B)<-1){
		cout<<-1<<endl;
		return 0;
	}
	int amari=N-A;
	k=0;
	for(i=1;i<=A;i++){
		p[k]=i;
		k++;
		for(j=1;amari&&j<B;j++,k++,amari--)
			p[k]=i-j;
	}
	for(i=0;i<N;){
		int u=i;
		for(;u<N-1&&p[u]>p[u+1];u++);
		u++;
		for(j=i;j<u;j++)
			p[j]=u-(j-i);
		i=u;
	}
	re(i,N)
		cout<<p[i]<<endl;
}

Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
char tmp[10]={' ',' ','k','s','t','n','h','m','y','r'};
int main(){
  map<char,char>t;
  t['T']='a';
  t['L']='i';
  t['U']='u';
  t['R']='e';
  t['D']='o';
  string in;
  cin>>in;
  int j=0;
  rep(i,in.size()){
    int d=in[j]-'0';
    j++;
    char g=in[j];
    if(d==0){
      if(g=='T')cout<<"wa";
      else if(g=='U')cout<<"nn";
      else if(g=='D')cout<<"wo";
    }else if(d==1)cout<<t[g];
    else cout<<tmp[d]<<t[g];
    j++;
    if(j==in.size())break;
  }
  cout<<endl;
}

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

int     main() {
        int N;
        cin >>N;
        vector<int> A(N, 0);
        for (int i=0; i<N; i++)
                cin >>A.at(i);
        sort(A.begin(), A.end());
        int S=0;
        for (int i=1; i<N; i++)
                if (A.at(i)==A.at(i-1))
                        S++;
        int NN=N-S;
        if (1==S%2)
                NN--;
        cout <<NN <<endl;
        return 0;
};

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

int n;
string s;

struct RollingHash {
  vector<unsigned long long> hash[2], power[2];
  const unsigned int seed = 10007;
  const unsigned int mod[2]  = {999999937, 1000000007};

  RollingHash(const string &s) {
    int n = (int)s.size();
    for(int m = 0; m < 2; ++m) {
      hash[m].assign( n + 1, 0);
      power[m].assign(n + 1, 1);

      for(int i = 0; i < n; ++i) {
        hash[m][i+1]  = (hash[m][i] * seed + s[i]) % mod[m];
        power[m][i+1] = power[m][i] * seed % mod[m];
      }
    }
  }

  // [l, r)
  inline unsigned long long get_hash(int l, int r, int m = 0) {
    unsigned long long ret = (hash[m][r] - hash[m][l] * power[m][r-l] % mod[m] + mod[m]) % mod[m];
    return ret;
  }
};

inline bool C(int k, RollingHash &rh) {
  for(int i = 0; i < n/2+n/4; ++i) 
    for(int j = i+k; j < n-k+1; ++j) {
      if(s[i] != s[j]) continue;
      if(rh.get_hash(i, i+k) == rh.get_hash(j, j+k)) return true;
    }
  return false;
}

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

  RollingHash rh(s);

  int ok = 0, ng = n/2+1;
  while(ng - ok > 1) {
    int mid = (ok + ng)>>1;
    if(C(mid, rh)) ok = mid;
    else ng = mid;
  }
  cout << ok << '\n';
  return 0;
}

Measured memory_bytes: 384
n,t =map(int,input().split())
time = list(map(int,input().split()))
flag =False
ans = 0
for i in range(1,n):
  if time[i]-time[i-1] <=t:
    ans += time[i]-time[i-1] 
  else: 
    ans +=t
print(ans+t)

Measured memory_bytes: 25196
def wa(a):
    ans = 0
    while(1):
        if a==0 :
            break;
        ans += a%10
        a = a//10
    
    return ans


n = int(input())
# print(wa(n))

ans=1145141919810


for a in range(1,n):
    b=n-a
    tmp=wa(a)+wa(b)
    if tmp < ans:
        ans=tmp
    
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define li long long int
#define mx 100005
li n;
li a[mx],b[mx],c[mx];
li dp[mx][4];

li f(li curr,li prev)
{
    if(curr==n+1)
    {
        return 0;
    }

    if(dp[curr][prev]!=-1)
    {
        return dp[curr][prev];
    }
    li ans=0;
    for(int i=1;i<=3;i++)
    {
        if(i!=prev && i==1)
        {
            ans=max(ans, a[curr]+f(curr+1,i));
        }
         if(i!=prev && i==2)
        {
            ans=max(ans, b[curr]+f(curr+1,i));
        }
         if(i!=prev && i==3)
        {
            ans=max(ans, c[curr]+f(curr+1,i));
        }
    }

    return dp[curr][prev]=ans;
}

int main()
{
    cin>>n;
    int i;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    cout<<f(1,0);
    return 0;
}


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

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

using ll = long long;
using namespace std;

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

    vector<int> x(n);
    rep (n, i) {
      cin >> x[i];
    }

    auto minsum = 1000000;
    for (int p = 1; p <= 100; ++p) {
      auto sum = 0;
      for (auto xi : x) {
        sum += (xi - p)*(xi - p);
      }
      minsum = min(minsum, sum);
    }
    cout << minsum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void dfs(VI &v, vector<vector<PII>> &g, int idx, int par) {
    for (auto &e: g[idx]) {
        int dest = e.first;
        int cost = e.second;
        if (dest == par) continue;
        // cerr << idx << ", " << dest << endl;
        // if (v[dest] <= v[idx] + cost) continue;
        if (v[dest] != 1000000001) continue;
        v[dest] = v[idx] + cost;
        dfs(v, g, dest, idx);
    }
}

void solve() {
    int n,m;
    cin >> n >> m;
    int l,r,d;
    vector<vector<PII>> g(n+1, vector<PII>());
    VI v(n+1, 1000000001);

    REP(i,0,m) {
        cin >> l >> r >> d;
        g[l].pb(r, d);
        g[r].pb(l, -d);
    }
    // 埋める
    REP(i,1,n+1) {
        if (v[i] == 1000000001) {
            v[i] = 0;
            dfs(v, g, i, -1);
        }
    }
    // REP(i,0,n+1) cerr << v[i] << endl;
    // 確かめる
    REP(i,1,n+1) {
        for (auto &e: g[i]) {
            int dest = e.first;
            int cost = e.second;    
            if (v[i] + cost != v[dest]) {
                cout << "No" << endl;
                return;
            }      
        }
    }
    cout << "Yes" << endl;
}

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


Measured memory_bytes: 13824
#include <bits/stdc++.h> 
using namespace std;
typedef long long intl;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	vector <int> v(2*n);
	for(int i=0;i<2*n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	int sum=0;
	for(int i=0;i<n;i++){
		sum+=v[i*2];
	}
	cout<<sum<<endl;
	
}

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

using namespace std;
long double eps = 1.0E-14;
 main()
{
    long  double l;
    cin>>l;
    long double ans = (l/3)*(l/3)*(l/3);
    cout<<setprecision(10)<<fixed<<ans<<endl;







    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x 1000000007
using namespace std;
int main()
{
    long long sum=0,k,n;
    scanf("%lld%lld",&n,&k);
    for(long long i=k;i<=n+1;i++){
    	sum+=n*i-i*i+i+1;
	}
	printf("%lld",sum%x);
	return 0; 
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    for(ll i=0;i<k;i++)
    {
    	if(a>=b)
    	{
    		b=b*2;
    	}
    	else if(b>=c)
    	{
    		c=c*2;
    	}
    	else
    	{
    		c=c*2;
    	}
    }
   // cout<<a<<b<<c;
    if(a<b && b<c)
    {
    	cout<<"Yes";
    }
    else
    {
    	cout<<"No";
    }
}
 

Measured memory_bytes: 3652
n=1<<18;L[1<<18],p;F[1<<18],X[1<<18];i;
long D[1<<20],Z[1<<20],A[1<<18],x,z;
long f(a,b,k,l,r){
	D[k]+=z=Z[k];
	Z[2*k]+=z;
	Z[2*k+1]+=z;
	Z[k]=0;
	return a<=l&r<=b?D[k]+(Z[k]=x):l<b&a<r?D[k]=fmax(
		f(a,b,2*k,l,(l+r)/2),
		f(a,b,2*k+1,(l+r)/2,r)
	):D[k];
}
main(j){
	for(gets(L);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];
	for(;p?:(p=F[++i],f(i,i+1,1,0,n),n/i);p=X[p])x=A[p],x=f(L[p],i+1,1,0,n);
	printf("%ld",x);
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/

Measured memory_bytes: 19200
x, y = map(int,input().split())
count = 0

for i in range(x+1):
  for j in range(x+1):
    if (i*2 + j*4 )== y and (i + j) == x:
      count +=1

if count == 0:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 9152
#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;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

class UnionFind{
	private:
		vector<int> par, depth;
	public:
		vector<int> cnt; // その集合の頂点数
		UnionFind() {}
		UnionFind(int n){
			init(n);
		}
		void init(int n){
			par = vector<int>(n);
			depth = vector<int>(n, 0);
			cnt = vector<int>(n, 1);
			rep(i,n){
				par[i] = i;
			}
		}
		int find(int x){
			if(par[x] == x){
				return x;
			}else {
				return par[x] = find(par[x]);
			}
		}
		void unite(int x, int y){
			x = find(x);
			y = find(y);
			if(x == y) return;

			if(depth[x] < depth[y]){
				par[x] = y;
				cnt[y] += cnt[x];
			}else{
				par[y] = x;
				cnt[x] += cnt[y];
				if(depth[x] == depth[y]) depth[x]++;
			}
		}
		bool same(int x, int y){
			return find(x) == find(y);
		}
};

int main(){
	int n, m;
	cin >> n >> m;

	vector<int> a(n);
	cin >> a;
	for(auto &i: a) i--;

	UnionFind uni(n);
	rep(i,m){
		int x, y;
		cin >> x >> y;
		x--; y--;
		uni.unite(x,y);
	}

	map<int,vector<int>> mpp;
	rep(i,n){
		mpp[uni.find(i)].emplace_back(i);
	}

	int ans = 0;
	for(auto i : mpp){
		set<int> s;
		for(auto j : i.second){
			s.emplace(a[j]);
		}
		for(auto j : i.second){
			if(s.count(j)) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
main()
{
	long long int n, p =1;
	cin >> n;
	long long int a[n];
	long long int i;
	bool ima = false;
	for(i=0;i<n;i++)
	{
	cin >> a[i];
    if(a[i] == 0)
    ima = true;
	}
	if(ima == true)
	{
		cout << 0 << endl;
		return 0;
	}
	long long int mod = 1000000000000000001;
	for(i=0;i<n;i++)
	{
		long long int pp = p;
		p = (p%mod*a[i]%mod)%mod;
		if(p/a[i] != pp)
		{
			cout <<-1 << endl;
			return 0;
		}
	 	}
 	cout << p << endl;
	return 0;
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 1; i < int(n); i++)
ll mod=998244353;

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ar[n],ans[n];
    forn(i,n)cin>>ar[i];
    ans[0]=ar[1];
    forn(i,n){
        if(ar[i]<ans[i-1]){ans[i-1]=ar[i];ans[i]=ar[i];}
        else ans[i]=ar[i];
    }
    int ans1=ans[0];
    forn(i,n){ans1+=ans[i];}
    cout<<ans1;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner scanner = new Scanner(System.in);

		int n = Integer.parseInt(scanner.nextLine());

		String[] tempList = scanner.nextLine().split(" ");
		int[] list = new int[n - 1];
		int[] resultList = new int[n];
		for(int i= 0; i < n - 1; i++) {
			list[i] = Integer.parseInt(tempList[i]);
		}

		for(int i : list) {
			int temp = i;
			resultList[i - 1] ++;
		}

		for(int i = 0; i < n; i++) {
			int result = 0;
			for(int j = resultList[i]; j > 0; j--) {
				result ++;
			}
			System.out.println(result);
		}

	}

}


Measured memory_bytes: 82180
#include<bits/stdc++.h>
#define int long long
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(int i=0;i<n;i++)
#define double long double
#define mod 998244353
#define F first
#define S second
#define pb push_back

using namespace std;

signed main()
{
	fast;
	int test=1;
	// cin>>test;
	for(int index=0;index<test;index++)
	{
        int s,w;
        cin>>s>>w;
        if(w>=s)
        {
            cout<<"unsafe"<<endl;
        }
        else
        {
            cout<<"safe"<<endl;
        }
        
        
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

const ll inf = LONG_LONG_MAX / 2 - 1;
const ll d[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
ll h, w;
vector<string> s;

ll f(ll sy, ll sx, ll gy, ll gx) {
    vector<vector<ll>> dist(h, vector<ll>(w, inf));
    dist[sy][sx] = 0;
    queue<pair<ll, ll>> q;
    q.push(make_pair(sy, sx));
    while(!q.empty()) {
        auto p = q.front(); q.pop();
        rep(i, 4) {
            ll ny = p.first + d[i][0];
            ll nx = p.second + d[i][1];
            ll nd = dist[p.first][p.second] + 1;
            if ((nx < 0) || (nx >= w) || (ny < 0) || (ny >= h)) continue;
            if ((nd >= dist[ny][nx]) || (s[ny][nx] == '#')) continue;
            dist[ny][nx] = nd;
            q.push(make_pair(ny, nx));
        }
    }
    return dist[gy][gx];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> h >> w;
    s.resize(h);
    rep(i, h) cin >> s[i];
    ll ans = 0;
    rep(sy, h) {
        rep(sx, w) {
            rep(gy, h) {
                rep(gx, w) {
                    if ((s[sy][sx] == '#') || (s[gy][gx] == '#')) continue;
                    ans = max(ans, f(sy, sx, gy, gx));
                    // printf("(%lld, %lld)->(%lld, %lld)=%lld\n", sy, sx, gy, gx, f(sy, sx, gy, gx));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;
ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  for(int i = 0; i < s.size(); ++i){
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		100050

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

vector<pair<ll, ll> > prime_factorize(ll n) {
	vector<pair<ll,ll> > res;
	for (ll p = 2; p * p <= n; ++p) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

int dp[105];
//
int main(){
	int N;
	cin>>N;

	REPS(i,2,N+1){
		auto t = prime_factorize(i);
		for(auto itr : t){
			dp[itr.first] += itr.second;
		}
	}
	int ans = 0;
	int twice=0,forth=0,to4=0,ni4=0,nasi=0;
	for(int d : dp){
		if(d>=2)twice++;
		if(d>=4)forth++;
		if(d>=14)to4++;
		if(d>=24)ni4++;
		if(d>=74)nasi++;
	}
	ans = (twice-2) * forth * (forth-1) /2;
	ans += to4 * (forth-1);
	ans += ni4 * (twice-1);
	ans += nasi;
	
	cout << ans << endl;

	return 0;
}




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

typedef long long LL;

const int N=300000;

int n,m,uni[N+9],ans;

int Query_uni(int k){return k==uni[k]?k:uni[k]=Query_uni(uni[k]);}

void into(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=n;++i) uni[i]=i;
  ans=n-1;
  for (int i=1;i<=m;++i){
	int x,y;
	scanf("%d%d",&x,&y);
	x=Query_uni(x);y=Query_uni(y);
	if (x==y) continue;
	--ans;
	uni[x]=y;
  }
}

void work(){
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int mod(int a,int b){
  int res=a%b;
  if(res<0) res+=b;
  return res;
}

int main() {
  string s;
  cin>>s;
  map<int,int> memo;
  vector<int> res;
  int b=1;
  for(int i=0;i<=200005;i++){
    if(i==0){
      res.push_back(1);
      continue;
    }
    b*=10;
    b=mod(b,2019);
    res.push_back(b);
  }
  memo[0]++;
  int a=0;
  for(int i=0;i<s.length();i++){
    a+=res[i]*(s[s.size()-1-i]-'0');
    a=mod(a,2019);
    memo[a]++;
  }
  ll ans=0;
  for(auto itr=memo.begin();itr!=memo.end();itr++){
    ans+=itr->second*(itr->second-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4476
def factorial(x):
    res = 1
    for i in range(1, x):
        res *= i + 1
        res %= 10 ** 9 + 7
    return res

n, m = map(int, input().split())
if abs(n - m) > 1:
    print(0)
elif n == m:
    print((factorial(n) * factorial(m) * 2) % (10 ** 9 + 7))
else:
    print(factorial(n) * factorial(m) % (10 ** 9 + 7))

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

int main(){
  int m, n, i, j, max=0, num=0;
  int a[1000]={ },b[1000],c[1000];

  cin >> n >> m;

  for (i=0; i<n; i++){
    cin >> c[i];
  }

  for (i=0; i<m; i++){
    cin >> b[i];
    for (j=0; j<n; j++){
      if (c[j]<=b[i]){
	a[j]++;
	break;
      }
    }
  }

  for (i=0; i<n; i++){
    if (max<a[i]){
      num=i; max=a[i];
    }
  }

  cout << num+1 << endl;

  return 0;

}

Measured memory_bytes: 3100
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        int cnt = 0;
        if (S.length() == 0) {
            cnt = 1;
        }
        else {
            char old = S.charAt(0);

            for (int i=1; i<S.length(); i++) {
                char now = S.charAt(i);
                if (old == now) {
                    cnt++;
                    if (now == '1') {
                        old = '0';
                    }
                    else {
                        old = '1';
                    }
                }
                else {
                    old = S.charAt(i);
                }

            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26676
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        int d = inp.nextInt();
        System.out.println(Math.min(a, b) + Math.min(c, d));
        inp.close();
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, k;
    cin >> n >> k;
    vector<int> negative, positive;
    positive.push_back(0);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(a == 0)  --k;
        else if(a < 0)  negative.push_back(-a);
        else    positive.push_back(a);
    }
    negative.push_back(0);
    reverse(negative.begin(), negative.end());
    int szn = negative.size(), szp = positive.size();
    ll ans = 1e+13;
    for(int i = 0; i <= min(k, szn - 1); ++i){
        if(k-i >= szp)  continue;
        ll sum = negative[i] + positive[k-i] * 2;
        chmin(ans, sum);
        sum = positive[k-i] + negative[i] * 2;
        chmin(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include<iostream>
using namespace std;
char a[16], b[16] = {'C', 'O', 'D', 'E', 'F', 'E', 'S', 'T', 'I', 'V', 'A', 'L', '2', '0', '1', '6'};
int ans;
int main()
{
    cin >> a;
    for(int i = 0; i < 16; i ++){
        if(a[i] != b[i]) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// reverse(a.begin(),a.end());
		cin>>s;
		n=s.length();
		// ll a[n];
		map<char,bool> p;
		rep(i,n)
		{
			p[s[i]]=1;
		}
		
		if(p.size()==2)
			cout<<"Yes";
		else 
			cout<<"No";
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

ll DP[20000];//DP[i] = sum(v)となる最小のw

signed main(){
  int N,W;
  cin >> N >> W;
  ll v,w;
  FOR(i,1,20000)DP[i] = LINF;
  FOR(i,0,N){
    cin >> v >> w;
    REP(i,0,10001){
      if(DP[i] != LINF || i == 0){
        DP[i+v] = min(DP[i]+w,DP[i+v]);
      }
    }
  }
  ll ans = 0;
  FOR(i,0,20000)if(DP[i] <= W)ans = max(ans,i);
  cout << ans << endl;
}


Measured memory_bytes: 3252
def calc(a, n):
    for x in range(n):
        if a[x] == 0:
            return 0

    result = 1
    max = 10 ** 18
    for x in range(n):
        result *= a[x]
        if result > max:
            return -1

    return result

n = int(input())
a = list(map(int, input().split()))

print(calc(a, n))


Measured memory_bytes: 21784
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    vector<int> input(3);
    cin >> input[0] >> input[1] >> input[2];
    sort(input.begin(), input.end());
    cout << input[0] << " " << input[1] << " " << input[2] << endl;
    return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>

int main(void){
int w,n,a,b,data[35],temp,i;
for(i=1;i<=30;i++){data[i]=i;}
scanf("%d",&w);
scanf("%d",&n);
for(i=0;i<n;i++){
	scanf("%d,%d",&a,&b);
	temp=data[a];data[a]=data[b];data[b]=temp;
}
for(i=1;i<=w;i++){
printf("%d\n",data[i]);
}
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    unordered_map<int, int> mp;
    int num;
    for(int i = 0; i < k; i ++)
    {
    	cin >> num;
    	for(int j = 0; j < num; j ++)
    	{
    		int data;
    		cin >> data;
    		mp[data] ++;
    	}

    }

    cout << n - mp.size();
}

Measured memory_bytes: 3604
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a;
    sfl(a);
    ll sum = a+a*a+a*a*a;
    pfl(sum);
    return 0;   
}


Measured memory_bytes: 3824
import math

a, b = map(int, input().split())
a_price = (math.ceil(a * 100 / 8), math.ceil((a + 1) * 100 / 8))
b_price = (b * 10, (b + 1) * 10)
ans = max(a_price[0], b_price[0])
if ans >= min(a_price[1], b_price[1]):
    ans = -1
print(ans)


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

int main(){
    int i, n;
    cin>>n;
    int str[n];
    for(i=0; i<n; i++){
        cin>>str[i];
    }
    int max = 0, kosu = 0;
    for(i=0; i<n; i++){
        if(max<=str[i]){
            kosu++;
            max = str[i];
        }
    }
    cout<<kosu<<endl;

    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
c = [int(input()) for _i in range(n)]
c.append(-1)
dic = [-1 for _i in range(10**5 *2 +1)]
dp = [0 for _i in range(n+1)]
dp[n] = 1
mod = 10**9 +7
for i in range(n):
    if c[i-1] != c[i]:
        if dic[c[i]] > 0:
            dp[i] = (dp[i-1] + dic[c[i]])%mod
        else:
            dp[i] = dp[i-1]
        dic[c[i]] = dp[i]
    else:
        dp[i] = dp[i-1]
    
print(dp[n-1]%mod)

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


int minimumCost(int index, int arr[], int size, vector<int>&memo ){
    if(index == size){
        return 0;
    }
    if(memo[index] != -1)
        return memo[index];
    int left = abs(arr[index] - arr[index+1]) + minimumCost(index + 1, arr, size,memo);
    int right = INT_MAX;
    if(index + 2 <= size)
        right = abs(arr[index] - arr[index+2]) + minimumCost(index + 2, arr, size,memo);
    return memo[index] = min(left, right);
}

int main(){
    int N;
    cin>>N;
    int arr[N];
    vector<int> memo(N,-1);
    for(int i = 0; i < N; ++i){
        cin>>arr[i];
    }
    // for (int i = 0; i < N; ++i)
        int val = minimumCost(0, arr, N-1,memo);
    cout << val << endl;
}

Measured memory_bytes: 11848
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a,b)<<" "<<max(0LL,a+b-n)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,s=0,x,a,j,d;
	scanf("%d\n%d %d",&n,&d,&x);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		for(j=1;j<=d;j+=a)
			s++;
	}
	printf("%d",s+x);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long int
#define N 100000
#define M 1000000007
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Sawlani
  *
  */

vector <pair <ll,ll> > v[N+1];
ll ans=0;
bool vis[N+1]={false};
ll dis=0;
ll color[N+1]={0};
 void dfs(ll i)
{
  f(j,0,v[i].size()-1)
  {
    ll p=v[i][j].first;
     if(!vis[p])
     {
         
         dis=dis+v[i][j].second;
        // cout <<  dis << endl;
         if(dis%2==0)
             color[p]=1;
        vis[p]=true;
        dfs(p);
        dis-=v[i][j].second;
      }
  }
     
     
     
}
ll a[N+1]={0};
  int main()
  {
      ll n;
      cin >> n;
     f(i,1,n-1)
    {
       ll x,y,w;
       cin >> x >> y >> w;
         v[x].pb({y,w});
         v[y].pb({x,w});
    }
     vis[1]=true;
     dfs(1);
     color[1]=1;
     f(i,1,n)
         cout << color[i] <<  endl;
}







Measured memory_bytes: 10240
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = 1
count = 0
j=2
x=int(input())
for i in range(2,x):
    while i**j<=x:
        ans=max(ans,i**j)
        j+=1
    j=2
print(ans)

Measured memory_bytes: 38256
n = int(input())
s = input()

count = 0

s_set = set([])
for i in range(n):
    t_set = set([])
    if (s[i] in s_set):
        continue
    t = s[i+1:]
    s_set.add(s[i])
    for j in range(n-(i+1)):
        if(t[j] in t_set):
            continue
        u = t[j+1:]
        count += len(set(u))
        t_set.add(t[j])
    
    
print(count)

Measured memory_bytes: 68476
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1;
ll T,a,b;
ll A[55],B[55],C[55],D[55],Q,l,r;
ll ans;
//bool D[100005];
ll S[100005]={};
string str;
map<string,int> m;

int main(){
	cin>>N;
	ll i;
	for(i=100000;i>0;--i){
		if(N%i==0&&N/i>=i)break;
	}
	int j;
	ll k=1000000000;
	for(j=10;j>0;--j){
		if((N/i)/k>0)break;
		k/=10;
	}
		cout<<j<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void trance(int A[],int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0){
            printf(" ");
        }
        printf("%d",A[i]);
    }
    printf("\n");   
}
void insertionSort(int A[],int N){
    int j,i,v;
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trance(A,N);
    }
}
int main(void)
{
    int N,i,j;
    int A[100];

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    trance(A,N);
    insertionSort(A,N);

    return 0;
}


Measured memory_bytes: 2144
// 2019.cpp : This file contains the 'main' function. Program execution begins and ends there.
//JANUARY: {1521, 1644} -> {1614, 1644} -> {1643, 1644} ->

#include <bits/stdc++.h>
using namespace std;


#define int long long
#define all(a) a.begin(), a.end()
#define need_for_speed ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const int INF = 1e18;
int dp[26][26];
string s[26];


signed main()
{
	need_for_speed;
	int n; cin >> n; 
	vector<vector<int> > A(n, vector<int>(3));
	vector<vector<int> >dp(n, vector<int>(3));
	for (int i = 0; i < n; i++)
		cin >> A[i][0] >> A[i][1] >> A[i][2];

	dp[0][0] = A[0][0];
	dp[0][1] = A[0][1];
	dp[0][2] = A[0][2];

	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + A[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + A[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + A[i][2];
	}

	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}




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

int main ()
{
	char number[1000];
	while (1)
	{
		cin >> number;
		if (number[0]==48)
			break;
		int sum=0;
		int i=0;
		while (number[i])
		{
			sum += number[i] - 48;
			i++;
			}	
		cout << sum << endl;
	}
	return 0;
}

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

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    ll step = 0;
    ll biscuits = 1;
    ll money = 0;
    if (b - a > 1) {
        if (a > k + 1) {
            biscuits = k + 1;
        }
        else {
            step += a - 1;
            // a, bの順で繰り返す
            ll possible = (k - step) / 2;
            biscuits = a + possible * (b - a);
            step += 2 * possible;
            biscuits += (k - step);
        }
    }
    else {
        biscuits = k + 1;
    }
    cout << biscuits << endl;
}


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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    int T;
    cin >> T;
    REP(i, T) {
        int N, M, A, B;
        cin >> N >> M >> A >> B;
        print(floor_sum(N, M, A, B));
    }

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
// #define mp make_pair
// #define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define show(x) cout << #x << " = " << x << endl;

ll modpow(ll x, ll y){
  ll tmp;
  if(y == 0)return 0;
  else if(y == 1)return x;
  else if(y % 2 == 0){
    tmp = pow(modpow(x,y/2),2);
    return tmp % MOD;
  }else{
    tmp = pow(modpow(x,y/2),2) * x;
    return tmp % MOD;
  }
}

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



int main(){
  ll x,y;
  cin >> x >> y;
  int ct = 0;
  while(x <= y && x > 0){
    x *= 2;
    ct++;
  }

  cout << ct << endl;


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main() {
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	printf("%d %d\n", min(A, B), max(0, A+B-N));
	return 0;
}


Measured memory_bytes: 128
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#define _for(i,n) for(ll i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

using namespace std;

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  for(ll a = 1; a<sqrt(n);a++) {
    if(n%a==0&&n/a-1>a) sum+=n/a-1;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,aux,i1=0,i2=0,cnt=0;
  cin>>n;
  vector<int> n1(n),n2(n),auxi(n);
  for(int i=0;i<n;i++){
    cin>>n1[i];
  }
  for(int i=0;i<n;i++){
    cin>>n2[i];
  }
  for(int i=0;i<n;i++){
    auxi[i]=i+1;
  }
  if(n1==n2){ cout<<0<<endl; return 0;}
  do{
    if(auxi==n1){
      i1=cnt;}
    if(auxi==n2){
      i2=cnt;}
    cnt++;
    } while(next_permutation(auxi.begin(),auxi.end()));
  
  cout<<abs(i1-i2)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;

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

    int a[5];
    for(int i = 0; i < 5; i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << i  + 1;
            return 0;
        }
    }

}



Measured memory_bytes: 3608