akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li l[111];
int main() {
    li n;
    cin >> n;
    rin{
        cin >> l[i];
    }
    li res = 0;
    sort(l, l + n);
    rep(i, n) {
        repp(j, i + 1, n) {
            repp(k, j + 1, n) {
                if (l[i] != l[j] && l[j] != l[k] && l[i] + l[j] > l[k]) {
                    res++;
                }
            }
        }
    }
    cout << res << endl;


    return 0;
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

const int N=100010;
int n,m;
vector<int>g[N];
int in[N],len[N];

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<m;++i){
		int u,v;cin>>u>>v;--u;--v;
		g[u].push_back(v);
		++in[v];
	}
	queue<int>q;
	for(int i=0;i<n;++i)if(!in[i])q.push(i);
	int res=0;
	while(!q.empty()){
		int u=q.front();q.pop();
		for(auto v:g[u]){
			len[v]=max(len[v],len[u]+1);
			if(!--in[v])q.push(v);
		}
		res=max(res,len[u]);
	}
	cout<<res<<endl;
}


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

#define endl "\n"

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

void solve()
{
	int n;
	cin >> n;
	int ans = n % 1000;
	if (ans)
		ans = 1000 - ans;
	cout << ans;
}


int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}




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

int main() {
    int N;
    std::cin >> N;
    std::vector<int> v(N);
    for (auto& e : v) std::cin >> e;

    if (std::prev_permutation(v.begin(), v.end())) {
        for (int i = 0; i < v.size(); ++i) {
            std::cout << v[i] << " \n"[i == v.size() - 1];
        }
    }
    std::next_permutation(v.begin(), v.end());
    for (int i = 0; i < v.size(); ++i) {
        std::cout << v[i] << " \n"[i == v.size() - 1];
    }
    if (std::next_permutation(v.begin(), v.end())) {
        for (int i = 0; i < v.size(); ++i) {
            std::cout << v[i] << " \n"[i == v.size() - 1];
        }
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

int N;
int H[111111];

signed main(){
	cin>>N;
	rep(i,N)cin>>H[i];

	int st=0;
	int ans=0;
	rep(i,N){
		if(i&&H[i-1]<H[i])st=0;
		st++;
		chmax(ans,st);
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 4440
n, k = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(k):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    a[0] = b[0]
    for i in range(1, n):
        a[i] = b[i] + a[i - 1]
    if sum(a) == pow(n, 2):
        break
print(*a)

Measured memory_bytes: 162672
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    cout<<n*800-200*(n/15)<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){
	int n;cin >> n;
	vector<ll> a;
	vector<ll> b;
	REP(i,n){
		ll tmp;cin >> tmp;
		if(i % 2 ==0)a.PB(tmp);
		else b.PB(tmp);
	}
	
	a.PB(INF);
	b.PB(INF);
	
	sort(ALL(a));
	sort(ALL(b));
	
	vector<pair<ll,ll>> aa;
	vector<pair<ll,ll>> bb;
		
	ll ans = 0;
	ll now = -1;
	ll cou = 0;
	
	REP(i,a.size()){
		if(now == a[i])cou++;
		else {
			aa.PB(MP(cou,now));
			cou = 1;
			now = a[i];
		}
	}
	
	now = -1;
	cou = 0;
	
	REP(i,b.size()){
		if(now == b[i])cou++;
		else {
			bb.PB(MP(cou,now));
			cou = 1;
			now = b[i];
		}
	}
	
	/*
	REP(i,aa.size()){
		cout << aa[i].FI << " " << aa[i].SE << endl;
	}

	REP(i,bb.size()){
		cout << bb[i].FI << " " << bb[i].SE << endl;
	}
	*/
	
	sort(ALL(aa),greater<pair<ll,ll>>());
	sort(ALL(bb),greater<pair<ll,ll>>());
	
	if(aa[0].SE != bb[0].SE) {
		ans = aa[0].FI + bb[0].FI;
	}
	else {
		ans = max(ans, aa[1].FI + bb[0].FI);
		ans = max(ans, aa[0].FI + bb[1].FI);
	}	
	
	cout << n - ans << endl;
	
	return 0;
}


Measured memory_bytes: 3312
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k,count=0;
	cin>>a>>b>>c>>k;
	while(a>=b){
		count++;
		b=b*2;
	}
	while(b>=c){
		count++;
		c=c*2;
	}
	if(count<=k)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){

  long left, right;
  scanf("%ld %ld", &left, &right);

	long mod_set = (right-left+1)/2019;

	long min = 2019;;
	long mod;
	if (mod_set > 0) {
		min = 0;
	} else {
		for (long i = left; i < right; i++) {
			for (long j = i+1; j <= right; j++) {
				mod = i%2019;
				mod *= j;
				mod %= 2019;
				if (mod < min) {
					min = mod;
				}
			}
		}
	}

	printf("%ld\n", min);

  return 0;
}

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

#define ll long long

int main(){
    ll S,ans = 999,p;
    cin >> S;
    for(int i = 0; i < 8; i++){
        p = 1;
        for(int j = 0; j < i; j++)p *= 10;
        if(S/p*1000){
            if(ans > abs((S/p)%1000 - 753))ans = abs((S/p)%1000 - 753);
        }else break;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void){
    int N,M;
    cin>>N>>M;
    vector<int> K(M);
    vector<vector<int>> s(M,vector<int>(N));
    vector<int> p(M);
    for(int i=0;i<M;i++){
        cin>>K[i];
        for(int j=0;j<K[i];j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<M;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=0;i<(1<<N);i++){
        int flag=true;
        for(int a=0;a<M;a++){
            int sum=0;
            for(int b=0;b<K[a];b++){
                if(i&(1<<(s[a][b]-1))) sum++;
            }
            if(sum%2!=p[a]) flag=false;
        }
        if(flag) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int all[15],two[15];

int solve(string x,int pos,bool e3=false,bool e5=false,bool e7=false);

int main() {
   string x;
    cin>>x;
    for(int i=1;i<=10;++i) {
        two[i] = powl(2,i);
        two[i] -= 2;
        all[i] = powl(3,i);
        all[i] -= two[i]*3;
        all[i] -= 3;
    }
    int ans = solve(x,0);
    if(x.size()>3) {
        for(int i=3;i<x.size();++i)
        ans += all[i];
    }
    cout<<ans<<endl;
}

int solve(string x,int pos,bool e3,bool e5,bool e7) {
    if(pos==x.size()) {
        return (e3&&e5&&e7);
    }
    int left = x.size()-pos-1;
    int res = 0;
    
    if(x[pos] == '3') {
        res += solve(x,pos+1,1,e5,e7);
    }else if(x[pos] <= '5' && x[pos] > '3') {
        if(x[pos] == '5') res += solve(x,pos+1,e3,1,e7); // 取 5
        res += all[left];//取 3
        int cnt = e5 + e7;
        if(cnt == 2) {
            res += 3*two[left];
            if(left)
                res += 3;
            else
                res += 1;
        } else if(cnt == 1) {
            res += 2*two[left];
            if(left)
                res += 1;
            
        } else {
            res += two[left];
        }
    } else if(x[pos]>'5' && x[pos] <= '7') {
        if(x[pos] == '7') res += solve(x,pos+1,e3,e5,1);
        res += all[left];
        int cnt = e5 + e7;
        if(cnt == 2) {
            res += 3*two[left];
            if(left)
                res += 3;
            else
                res += 1;
        } else if(cnt == 1) {
            res += 2*two[left];
            if(left)
                res += 1;
            
        } else {
            res += two[left];
        }
        res += all[left];
        cnt = e3 + e7;
        if(cnt == 2) {
            res += 3*two[left];
            if(left)
                res += 3;
            else
                res += 1;
        } else if(cnt == 1) {
            res += 2*two[left];
            if(left)
                res += 1;
            
        } else {
            res += two[left];
        }
    }else if(x[pos] >'7') {
        res += all[left+1];
        int cnt = e5+e3+e7;
        if(cnt == 3) {
            res += two[left+1]*3;
            res += 3;
        } else if(cnt == '2'){
            res += two[left+1]*2;
            res += 1;
        }else if(cnt == '1'){
            res += two[left+1];
        }
    }
    return res;
}



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

const ll M = 1e9 + 7;

ll sum (ll a, ll b) {
    return (a + b) % M;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ///freopen("input.in", "r", stdin);
    ///freopen("output.out", "w", stdout);
    ll n, m;
    cin >> n >> m;
    char a[n][m];
    for (ll i = 0; i < n; ++i)
        for (ll j = 0; j < m; ++j)
            cin >> a[i][j];
    ll dp[n][m];
    dp[0][0] = 1;
    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j < m; ++j) {
            if (i || j) {
                if (a[i][j] == '.')
                    dp[i][j] = sum((i - 1 >= 0 ? dp[i - 1][j] : 0), (j - 1 >= 0 ? dp[i][j - 1] : 0));
                else
                    dp[i][j] = 0;
            }
        }
    }
    cout << dp[n - 1][m - 1];
    return 0;
}

/**


**/


Measured memory_bytes: 9088
str = gets.chomp

a = ['L', 'U', 'D']
b = ['R', 'U', 'D']
result = ''
str.each_char.with_index{|c, i|
	next if (i.odd? && a.include?(c)) || (i.even? && b.include?(c))
	result = 'No'
}
result = 'Yes' if result == ''
puts result

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#define inf 999999999

int n,m,c,s,g;
int memo[25][105][105]={0};
int money[25][105][105]={0};
int ansmoney[105][105]={0};
int p[25]={0};
int q[25][51]={0};
int r[25][51]={0};
//rの1[i-1]までの累積和
int t[25][51]={0};

int main(void){
  int i,j,k,l,x,y,z;
  while(1){
    scanf("%d %d %d %d %d",&n,&m,&c,&s,&g);
    if(n+m+c+s+g==0)break;
    for(i=1;i<=c;i++)for(j=1;j<=n;j++)for(k=1;k<=n;k++){
	  if(j==k)memo[i][j][k]=0;
	  else memo[i][j][k]=inf;
	}
    for(i=0;i<m;i++){
      scanf("%d %d %d %d",&j,&k,&l,&x);
      
      if(memo[x][j][k]>l){
	memo[x][j][k]=l;
	memo[x][k][j]=l;
      }
    }
    for(i=1;i<=c;i++)for(j=1;j<=n;j++)for(k=1;k<=n;k++)for(l=1;l<=n;l++)if(memo[i][k][l]>memo[i][k][j]+memo[i][j][l])memo[i][k][l]=memo[i][k][j]+memo[i][j][l];
    
    for(i=1;i<=c;i++)scanf("%d",&p[i]);
    for(i=1;i<=c;i++){
      for(j=1;j<p[i];j++)scanf("%d",&q[i][j]);
      for(j=1;j<=p[i];j++)scanf("%d",&r[i][j]);
      for(j=2;j<=p[i];j++)t[i][j]=r[i][j-1]*(q[i][j-1]-q[i][j-2])+t[i][j-1];
    }

    for(i=1;i<=n;i++)for(j=1;j<=n;j++)ansmoney[i][j]=inf;
    for(i=1;i<=c;i++)for(j=1;j<=n;j++)for(k=1;k<=n;k++){
	  if(j==k)money[i][j][k]=0;
	  else if(memo[i][j][k]==inf)money[i][j][k]=inf;
	  else {
	    for(l=1;l<p[i];l++)if(q[i][l]>=memo[i][j][k])break;
	    money[i][j][k]=t[i][l]+r[i][l]*(memo[i][j][k]-q[i][l-1]);
	  }
	  if(ansmoney[j][k]>money[i][j][k])ansmoney[j][k]=money[i][j][k];
	}
    /*for(i=1;i<=n;i++){
      for(j=1;j<=n;j++)printf("%d ",ansmoney[i][j]);
      printf("\n");
    }
    printf("\n");*/
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)for(k=1;k<=n;k++)if(ansmoney[j][k]>ansmoney[i][k]+ansmoney[j][i])ansmoney[j][k]=ansmoney[i][k]+ansmoney[j][i];
    if(ansmoney[s][g]!=inf)printf("%d\n",ansmoney[s][g]);
    else printf("-1\n");

    /* for(i=1;i<=n;i++){
      for(j=1;j<=n;j++)printf("%d ",memo[2][i][j]);
      printf("\n");
      }*/
    /*printf("------\n");*/
      /*for(i=1;i<=n;i++){
      for(j=1;j<=n;j++)printf("%d ",money[2][i][j]);
      printf("\n");
      }*/
    

    
    for(i=0;i<=c;i++)for(j=0;j<=p[i];j++){
	q[i][j]=0;
	r[i][j]=0;
	t[i][j]=0;
      }
    for(i=0;i<=c;i++)p[i]=0;
  }
  
  return 0;
}



Measured memory_bytes: 3520
#include"bits/stdc++.h"

using namespace std;

typedef long long LL;

int A, B, C, D;

char convert(bool l)
{
	if (l)
	{
		return '+';
	}
	else
	{
		return '-';
	}
}

int op(int i1, int i2, bool plus)
{
	if (plus)
	{
		return i1 + i2;
	}
	else
	{
		return i1 - i2;
	}
}

bool ops(bool b[])
{
	int Ans;
	Ans = op(A, B, b[0]);
	Ans = op(Ans, C, b[1]);
	return op(Ans, D, b[2]) == 7;
}

bool* Ans;

bool saiki(bool b[], int d)
{
	if (d == 3)
	{
		if (ops(b))
		{
			Ans = b;
			return true;
		}
		return false;
	}
	b[d] = true;
	if (saiki(b, d + 1))
	{
		return true;
	}
	else
	{
		b[d] = false;
		if (saiki(b, d + 1))
		{
			return true;
		}
	}
	return false;
}

int main() 
{
	int n;
	cin >> n;
	A = n / 1000;
	B = n % 1000 / 100;
	C = n % 100 / 10;
	D = n % 10;
	
	bool b[3];
	b[0] = true;
	b[1] = true;
	b[2] = true;

	saiki(b, 0);

	cout << A << convert(Ans[0]) << B << convert(Ans[1]) << C << convert(Ans[2]) << D << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input())-1 for _ in range(n)]

check = [0 for _ in range(n)]
check[0] = 1
i = a[0]
c = 1
while i != 1 and check[i]==0:
    check[i] = 1
    i = a[i]
    c += 1
    
if i==1:
    print(c)
else:
    print(-1)

Measured memory_bytes: 7852
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001
#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;


int main(void){
  int X;
  cin >> X;
  cout << ((X >= 30)? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
char s[100001];
bool b[26] = { false };

int main() {
	cin >> s;
	rep(i, 0, 100001) {
		if (s[i] == '\0')break;
		b[s[i] - 'a'] = true;
	}
	rep(i, 0, 26) {
		if (!b[i]) {
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;

	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"io"
	"os"
)

func proc(r io.Reader, w io.Writer) {
	//var n, d int
	//fmt.Fscanf(r, "%d", &n)
	//arr := make([]int, n)
	//for i := 0; i < n; i++ {
	//	fmt.Fscanf(r, "%d", &d)
	//	arr[i] = d
	//}
	var n, y int
	fmt.Fscanf(r, "%d", &n)
	fmt.Fscanf(r, "%d", &y)
	y /= 1000
	for a := n; a >= 0; a-- {
		if a*10 > y {
			continue
		}
		for b := n - a; b >= 0; b-- {
			if a*10+b*5 > y {
				continue
			}
			c := n - a - b
			if a*10+b*5+c == y {
				fmt.Fprintf(w, "%d %d %d", a, b, c)
				return
			}
		}
	}

	fmt.Fprintf(w, "-1 -1 -1")
}

func main() {
	proc(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a[114514];
int main(){
	int n,l;cin>>n>>l;
	for(int i=0;i<n;i++)cin>>a[i];
	
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>=l){
			puts("Possible");
			for(int j=0;j<i;j++)cout<<j+1<<endl;
			for(int j=n-1;j>i;j--)cout<<j<<endl;
			return 0;
			}
		}cout<<"Impossible"<<endl;
	}


Measured memory_bytes: 1152
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int d;
	char a[2000];
	scanf("%s",a);
	while(strcmp(a,"0")!=0)
	{
		int len=strlen(a);
		d=0;
		for(int i=0 ; i<len ; i++)
		{
			d+=a[i]-'0';
		}
		printf("%d\n",d);
		scanf("%s",a);
	}
	return 0;
}

Measured memory_bytes: 3224
import java.util.*; 
class Main {
   public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
       int A = sc.nextInt();
       int B = sc.nextInt();
       int c = 0;
     
      for(int i = 0;i<2;i++){
       if(A>=B){c += A;A = A -1;}
        else{c += B;B = B -1;}
      }
       
     
     
     System.out.print(c);


   }
}


Measured memory_bytes: 21460
// https://atcoder.jp/contests/abc174/tasks/abc174_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

template <typename T, typename F>
T binarySearch(T ok, T ng, F isOK, T bound = 1) {
    while (abs(ng - ok) > bound) {
        T m = (ng + ok) / 2;
        if (isOK(m))
            ok = m;
        else
            ng = m;
    }
    return ok;
}

signed 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]; }

    // 全ての丸太を長さtarget以下にする
    auto fn = [&](int target) {
        int cnt = 0;
        REP(i, N) {
            // 例えば長さ7を7以下にするなら切らなくていい。
            // 7未満にするなら1回切るように数える。
            cnt += CEIL(A[i], target) - 1;
            if (cnt > K) {
                break;
            }
        }
        // 戻り値はboolean
        return cnt <= K;
    };
    // 二分探索で求める。正解の範囲は(ng+1)以上ok以下
    int ng = 0, ok = 1e9;
    cout << binarySearch(ok, ng, fn) << endl;

    return 0;
}


Measured memory_bytes: 4760
#もし0のときは終了
#if文で偶数のとき、奇数の時で分ける
#結果が１になるまで繰り返し回数をカウント

while True:
    n = int(input())
    count = 0
    if n == 0:
        break
    while n != 1:
        if n%2 == 0:
            n = n/2
            count += 1
        else:
            n = n * 3 + 1
            count += 1
    print(count)



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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  int ans=0;
  ans=a[n-1]-a[0];
  int t=0;
  for(int i=1;i<n-1;i++){
    if(a[i]<0){
      t=i;
      ans-=a[i];
    }
    else ans+=a[i];
  }
  cout << ans << endl;
  t++;
  int now=a[0];
  for(int i=t;i<n-1;i++){
    cout << now << " " << a[i] << endl;
    now-=a[i];
  }
  cout << a[n-1] << " " << now << endl;
  now=a[n-1]-now;
  for(int i=1;i<t;i++){
    cout << now << " " << a[i] << endl;
    now-=a[i];
  }
}

Measured memory_bytes: 2304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
                out.println("Possible");
            } else {
                out.println("Impossible");
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  int e;
  while(cin >> e, e){
    int m = INF;
    for(int z = 0; z*z*z <= e; z++){
      for(int y = 0; y*y <= e - z*z*z; y++){
        int x = e - z*z*z - y*y;
        m = min(m, x + y + z);
      }
    }
    cout << m << endl;
  }
}

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

const int mmax = 1e5 + 10;

int dp[mmax][3];

int main()
{
    int t = 1;
    //cin>>t;
    while (t--)
    {
        int n, a, b, c;
        cin >> n;
        cin >> a >> b >> c;
        dp[1][0] = a;
        dp[1][1] = b;
        dp[1][2] = c;
        for (int i = 2; i <= n; i++)
        {
            cin >> a >> b >> c;
            dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
            dp[i][2] = c + max(dp[i - 1][1], dp[i - 1][0]);
        }
        cout << max({dp[n][0], dp[n][1], dp[n][2]});
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

vector<vector<ll>> C(51, vector<ll>(51, 0)); // C[n][k] -> nCk

void comb_table(int N){
    for(int i=0; i<=N; i++){
        for(int j=0; j<=i; j++){
            if(j==0 || j==i) C[i][j] = 1LL;
            else C[i][j] = (C[i-1][j-1]+C[i-1][j]);
        }
    }
}

int main(){
    int n,p; cin >> n >> p;
    int even = 0, odd = 0;
    for(int i=0; i<n; i++){
        int a; cin >> a;
        if(a%2 == 0) even++;
        else odd++;
    }

    comb_table(50);
    ll ans = 0;
    if(p == 0){
        for(int i=0; i<=even; i++) for(int j=0; j<=odd; j+=2) ans += C[even][i]*C[odd][j];
    }
    else{
        for(int i=0; i<=even; i++) for(int j=1; j<=odd; j+=2) ans += C[even][i]*C[odd][j];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def gcd(x, y):
    '''
    最大公約数の計算
    '''
    if y == 0:
        return x
    return gcd(y, x % y)

G = gcd(A, B)



def prime_factorize(n):
    res, a = [], 2
    while a*a <= n:
        if n % a == 0:
            ex = 0
            while n % a == 0:
                ex += 1
                n //= a
            res.append((a, ex))
        a += 1
    if n != 1:
        res.append((n, 1))
    return res

prime = prime_factorize(G)

print(len(prime)+1)


Measured memory_bytes: 38512
n = int(input())

a = [int(_) for _ in input().split()]


if sum(a) % (n*(n+1)//2) != 0:
    print("NO")
    exit()

m = sum(a)//(n*(n+1)//2)
# print(m)
d = [a[i]-a[i-1]-m for i in range(n)]

# print(d)
for D in d:
    if D % n == 0:
        m += D//n
    if D % n != 0 or D > 0:
        print("NO")
        exit()
if m == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 14244
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner066
{
    public class ABC066B_ss
    {
        public static void Main(string[] args)
        {
            
            // 文字列の入力
            string str = Console.ReadLine();

            for( int len = ((str.Length-1) / 2) * 2; len >= 0; len-= 2 )
            {
                string left = str.Substring(0, len / 2);
                string right = str.Substring(len / 2, len / 2);

                if( left.Equals(right) )
                {
                    // 結果出力
                    Console.WriteLine(len);
                    return;
                }
            }

        }

    }
}

Measured memory_bytes: 13140
N=int(input())
A=list(map(int,input().split()))

A_sort=sorted(A[:])
A_median_1=A_sort[N//2]
A_median_2=A_sort[N//2-1]

ans=0
for a in A:
    if a<A_median_1:
        ans=A_median_1
    else:
        ans=A_median_2
    print(ans)

Measured memory_bytes: 25620
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
    int n;
    cin>>n;
    bool ok=true;
    vector<string> v(n);
    set<string> s;
    for(auto &it:v){
		cin>>it;
		s.insert(it);
	}
	if((int)s.size()!=n)cout<<"No"<<endl;
	else{
	  for(int i=0;i+1<n;i++){
		   if(v[i].back()!=v[i+1].front()){
			     ok=false;
			     break;
			  } 
		 }
	cout<<(ok?"Yes":"No")<<endl;	
	}
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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

using namespace std;

int main(void)
{
	int h, w;
	while (cin >> h >> w){
		if (h == 0 && w == 0) break;
		string str1="", str2="";
		for (int i=0; i<(w+1)/2; i++){
			str1.append("#.");
			str2.append(".#");
		}
		str1 = str1.substr(0, w);
		str2 = str2.substr(0, w);
		for (int i = 0; i < h; i++){
			if (i % 2 == 0){
				cout << str1 << endl;
			}else{
				cout << str2 << endl;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i <= (int)(n); i++)
#define Graph vector<vector<int>>
#define MOD 1000000007 
#define PMAX 1000000 

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


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

  vector<string> A(N);
  rep(i,N) cin >> A[i];

  sort(A.begin(),A.end());
 
  string ans = "";
  rep(i,N){
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

H, W = map(int, input().split())
a = [input() for _ in range(H)]

rows =[r for r in range(H) if '#' in a[r]]
columns = [c for c in range (W) if '#' in [a[r][c] for r in range(H)]]

for r in rows:
    for c in columns:
        print(a[r][c], end="")
    print()

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

int main(void) {
    int64_t a,b,x, s1;
    double s; 
    cin >> a >> b >> x;
    
    // 角と一致するパターン
    // tan(b/a) 
    s = a * a * b / 2;
    s1=s;

    if((((a*a*b)%2) == 0) && (s1 == x)) {
        cout << setprecision(12) << (double)atan((double)b/(double)a) * 180.0 / M_PI << "\n";
    } else if(s < x) {
    // 下に残るパターン
    double l = (double)2*((double)b* a*a -x) / (double)(a * a);
        cout << setprecision(12) << (double)atan((double)l/(double)a) * 180.0 / M_PI << "\n";
    } else if(s > x) {
    // 底面にずれこむパターン
        double l = (double)(2*x)/(double)(a*b);
        cout << setprecision(12) << (double)atan((double)b/(double)l) * 180.0 / M_PI << "\n";
    } 




    return 0;
}


Measured memory_bytes: 384
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x%MOD*x%MOD)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; } 
//s2>s1;if(not) rtrn -1;

ll maxSubArraySum(ll a[], ll size) 
{ 
   ll max_so_far = a[0]; 
   ll curr_max = a[0]; 
  
   for (ll i = 1; i < size; i++) 
   { 
        curr_max = max(a[i], curr_max+a[i]); 
        max_so_far = max(max_so_far, curr_max); 
   } 
   return max_so_far; 
} 
   
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll tt=1;

//	   cin>>tt;
	      while(tt--)
{

/*
3 2 3*/
ll n,j,i;
ll a[3];
fo(i,3)
cin>>a[i];
sort(a,a+3);
cout<<a[0]+a[1];
ee;	
	
}
return 0;
}













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

static const int MAX_H = 50;
static const int MAX_W = 50;

int H, W;
char grid[MAX_H][MAX_W + 1];
bool reached[MAX_H][MAX_W];

#define OCTAS
#ifdef OCTAS
static const int dh[]{-1, -1, -1, 0, 0, +1, +1, +1};
static const int dw[]{-1, 0, +1, -1, +1, -1, 0, +1};
#else
static const int dh[]{-1, 0, 0, +1};
static const int dw[]{0, -1, +1, 0};
#endif

bool dfs(int h, int w) {
  reached[h][w] = true;

  for (int i{}; i < sizeof(dh) / sizeof(int); ++i) {
    int nh = h + dh[i];
    if (nh < 0 || nh >= H)
      continue;
    int nw = w + dw[i];
    if (nw < 0 || nw >= W)
      continue;
    if (grid[nh][nw] == '0' || reached[nh][nw])
      continue;
    if (dfs(nh, nw))
      return true;
  }

  return false;
}

int main() {
  while (true) {
    cin >> W >> H;
    if (W == 0 && H == 0) break;
    for (int h{}; h < H; ++h) {
      for (int w{}; w < W; ++w) {
        cin >> grid[h][w];
      }
    }
    fill_n(reached[0], MAX_H * MAX_W, false);
    int count{};
    for (int h{}; h < H; ++h) {
      for (int w{}; w < W; ++w) {
        if (grid[h][w] == '0' || reached[h][w])
          continue;
        dfs(h, w);
        ++count;
      }
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MaxN = 100003;
LL dp[MaxN];
int n,e,t,x[MaxN];
int main() {
	scanf("%d%d%d",&n,&e,&t);
	for (int i=1;i<=n;i++) scanf("%d",x+i);
	int ptr=1;
	LL mn=0x7fffffff;
	dp[0]=0;
	for (int i=1;i<=n;i++) {
		while (ptr<=n && 2*(x[i]-x[ptr])>t) {
			mn=min(mn,dp[ptr-1]-x[ptr]*2);
			ptr++;
		}
		dp[i]=min(dp[ptr-1]+t,mn+x[i]*2);
	}
	printf("%lld\n",e+dp[n]);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, d, c = 1;
  vector<int> v;
  cin >> n;
  REP(i, n) {
    cin >> d;
    v.push_back(d);
  }
  sort(v.rbegin(), v.rend());
  REP(i, n - 1) {
    if (v[i] > v[i + 1]) ++c;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	s := getNextString(scanner)
	t := getNextString(scanner)
	q := getNextInt(scanner)
	sn := len(s)
	tn := len(t)
	sa := make([]int, sn+1)
	sb := make([]int, sn+1)
	ta := make([]int, tn+1)
	tb := make([]int, tn+1)
	for i := 0; i < sn; i++ {
		sa[i+1] = sa[i]
		sb[i+1] = sb[i]
		if s[i] == 'A' {
			sa[i+1]++
			continue
		}
		sb[i+1]++
	}
	for i := 0; i < tn; i++ {
		ta[i+1] = ta[i]
		tb[i+1] = tb[i]
		if t[i] == 'A' {
			ta[i+1]++
			continue
		}
		tb[i+1]++
	}

	for i := 0; i < q; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner)
		c := getNextInt(scanner) - 1
		d := getNextInt(scanner)

		ms := (((sa[b]-sa[a])-(sb[b]-sb[a]))%3 + 3) % 3
		mt := (((ta[d]-ta[c])-(tb[d]-tb[c]))%3 + 3) % 3
		if ms == mt {
			fmt.Fprintln(writer, "YES")
			continue
		}
		fmt.Fprintln(writer, "NO")
	}
	writer.Flush()
}


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

int main(){
    int buf[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
        int k;
    cin >> k;
    cout << buf[k-1];
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;

vector<ll>a(100);

int main(){
    ll n,ans=0;
    string s;
    cin>>n>>s;
    rep(i,n-1){
        if (s[i+1]==s[i])ans++;
    }
    cout<<n-ans<<endl;
}

Measured memory_bytes: 512
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
lena = len(a)
p = [k-lena for i in range(n)]
for i in a:
  p[i-1] += 1
for i in p:
  if i > 0:
    print('Yes')
  else:
    print('No')

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

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

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

	while(true){
		int n; cin >> n;
		if(n == 0) break;

		int a[2][200];
		memset(a,0,sizeof(a));
		for (int i = 0;i < 2;i++){
			for (int j = 0;j < n;j++){
				cin >> a[i][j];
			}
		}

		int b[2][200];
		memset(b,0,sizeof(b));
		for (int i = 0;i < 2;i++){
			for (int j = 0;j < n;j++){
				if(a[i][j] == 1 && a[i][j+1] != 1){
					for (int k = j;;k--){
						if(a[i][k] != 1) break;
						b[i][k] = j;
					}
				}
				if(a[i][j] != 2 && a[i][j+1] == 2){
					for (int k = j+1;;k++){
						if(a[i][k] != 2) break;
						b[i][k] = j;
					}
				}
			}
		}

		int d[2][200];
		memset(d,-1,sizeof(d));
		d[0][b[0][0]] = 0; d[1][b[1][0]] = 0;
		queue<P> que;
		que.push(P(0,b[0][0])); que.push(P(1,b[1][0]));
		while(que.size()){
			P p = que.front(); que.pop();
			if(p.second >= n-1) break;
			int nex = 1;
			if(p.first == 1) nex = 0;
			for (int i = 0;i < 3;i++){
				P t = P(nex,p.second+i);
				if(b[t.first][t.second] != 0){
					t = P(t.first,b[t.first][t.second]);
				}
				if(d[t.first][t.second] == -1){
					que.push(t);
					d[t.first][t.second] = d[p.first][p.second] + 1;
				}
			}
		}

		int ans =  min(d[1][n-1],d[0][n-1]);
		if(ans == -1) ans =  max(d[0][n-1],d[1][n-1]);
		if(ans == -1) cout << "NA" << endl;
		else cout << ans << endl;

	}

	return 0;

}



Measured memory_bytes: 3156
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxN = 300 + 10;

char grid[maxN][maxN];
char G[maxN][maxN];
int N;

void input()
{
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        scanf("%s", grid[i]);
}

int solve()
{
    int ans = 0;
    for (int A = 0; A < N; A++)
    {
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                G[i][j] = grid[(i + A) % N][j];

        bool ok = true;
        for (int i = 1;ok && i < N; i++)
            for (int j = 0;ok && j < i; j++)
                if (G[i][j] != G[j][i])
                    ok = false;
        if (ok)
            ans += N - A;
    }
    for (int B = 1; B < N; B++)
    {
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                G[i][j] = grid[i][(j + B) % N];

        bool ok = true;
        for (int i = 1;ok && i < N; i++)
            for (int j = 0;ok && j < i; j++)
                if (G[i][j] != G[j][i])
                    ok = false;
        if (ok)
            ans += N - B;
    }
    return ans;
}

int main()
{
    input();
    printf("%d", solve());
    return 0;
}


Measured memory_bytes: 384
import sys


class UnionFind:
    def __init__(self, n):
        # total number of nodes.
        self.n = n
        # node id -> root node id
        self._root_table = list(range(n))
        # root node id -> group size
        self._size_table = [1] * n

    def find(self, x):
        """Returns x's root node id."""
        r = self._root_table[x]
        if r != x:
            # Update the cache on query.
            r = self._root_table[x] = self.find(r)
        return r

    def union(self, x, y):
        """Merges two groups."""
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # Ensure that x is the larger (or equal) group.
        if self._size_table[x] < self._size_table[y]:
            x, y = y, x

        self._size_table[x] += self._size_table[y]
        self._root_table[y] = x

    def size(self, x):
        return self._size_table[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self._root_table) if x == i]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())


input = sys.stdin.readline


def main():
    N = int(input())
    cities, xs, ys = [], [], []
    for i in range(N):
        x, y = map(int, input().split())
        cities.append((x, y))
        xs.append((x, i))
        ys.append((y, i))
    xs.sort()
    ys.sort()
    xd, yd = [], []
    for i in range(1, N):
        x1, c1 = xs[i - 1]
        x2, c2 = xs[i]
        if x2 - x1 <= abs(cities[c1][1] - cities[c2][1]):
            xd.append((x2 - x1, c1, c2))
        y1, c1 = ys[i - 1]
        y2, c2 = ys[i]
        if y2 - y1 < abs(cities[c1][0] - cities[c2][0]):
            xd.append((y2 - y1, c1, c2))
    xd.sort()

    uf = UnionFind(N)
    cost = 0
    merged_cnt = 0
    for d1, c1, c2 in xd:
        if not uf.same(c1, c2):
            uf.union(c1, c2)
            cost += d1
            merged_cnt += 1
            if merged_cnt == N - 1:
                break
    print(cost)


if __name__ == "__main__":
    main()


Measured memory_bytes: 126108
#include <iostream>
using namespace std;
#include <string>
int main()
{
	string s;
	cin >> s;
	int sum = 0;
	for (char& c : s) {
		sum += (c - '0');
	}
	if (stoi(s) % sum == 0){
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = []
for i in input().split():
    h.append(int(i)) 
dp = [float('inf') ] * n
dp[0] = 0
for i in range(n):
    if i - 1 >= 0:
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i - 2 >=0:
        dp[i] = min(dp[i],dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5;
int gcd(int a,int b){
	return (!b?a:gcd(b,a%b)); 
}
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll e=gcd(max(c,d),min(c,d));
	e=c/e*d;
	ll num1=b/c-(a-1)/c,num2=b/d-(a-1)/d,num3=b/e-(a-1)/e;
	cout<<(b-a+1-num1-num2+num3);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b ,ans=0, kuti=1;
    cin >> a >> b;
    while(1){
        if(kuti>=b) break;
        ans++;
        kuti+=a-1;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256