akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

#define MAX_N 100006
int n,m;
int k;
int a[100006];
int b[100006];
int c[100006];
int fnum[100006];
int d[100006];
int par[MAX_N];
int rrank[MAX_N];
int nfnum[100006];
void init(int n)
{
	rep(i,n)
	{
		par[i]=i;
		rrank[i]=0;
	}
}
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(rrank[x]<rrank[y])par[x]=y;
	else
	{
		par[y]=x;
		if(rrank[x]==rrank[y])rrank[x]++;
	}
}
bool same(int x,int y)
{
	return find(x)==find(y);
}
vector<int> blo[100006];
int bnum[100006];
int Mnum[100006];
int main()
{
	cin>>n>>m>>k;
	rep(i,m)
	{
		cin>>a[i]>>b[i];a[i]--;b[i]--;
		nfnum[a[i]]++;nfnum[b[i]]++;
	}
	rep(i,k){
		
		cin>>c[i]>>d[i];
		c[i]--;d[i]--;
	}
	init(n);
	rep(i,m)
	{
		unite(a[i],b[i]);
	}
	rep(i,n)find(i);
	rep(i,k)
	{
		if(same(c[i],d[i]))
		{
			bnum[c[i]]++;bnum[d[i]]++;
		}
	}
	rep(i,n)
	{
		Mnum[par[i]]++;
	}
	rep(i,n)
	{
		fnum[i]=Mnum[par[i]];
	}
	rep(i,n)
	{
		cout<<fnum[i]-bnum[i]-nfnum[i]-1;
		if(i==n-1)cout<<endl;
		else cout<<' ';
	}
	return  0;
}

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

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

    string s;
    int _max = 0;
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if ((s[i] != 'A') && (s[i] != 'T') && (s[i] != 'C') && (s[i] != 'G')) continue;
        int tmp = 0;
        for (int j = i; j < s.size(); j++) {
            if ((s[j] != 'A') && (s[j] != 'T') && (s[j] != 'C') && (s[j] != 'G')) break;
            tmp++;
        }
        _max = max(_max, tmp);
    }
    cout << _max << endl;
    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

double n,m,d;

int main(){
  cin >> n >> m >> d;
  cout << setprecision(17);
  if(d == 0) cout << n*(m-1)/n/n << endl;
  else cout << (n-d)*2*(m-1)/n/n << endl;
}


Measured memory_bytes: 256
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a,b,c;
	
	cin>>a>>b>>c;
	
	c/=a;
	c*=a;
	
	if (b<=c) cout<<"OK";
	else cout<<"NG";
	
}


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

int main() {
	int N, H, W;
	int sum = 0;
	cin >> N >> H >> W;
	for (int i = 0; i < N; i++) {
		int h, w;
		cin >> h >> w;
		if (h >= H && w >= W)
			sum++;
	}
	cout << sum << endl;
}


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

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

    long long sum = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 && i % 5 == 0)
            continue;
        else if (i % 3 == 0)
            continue;
        else if (i % 5 == 0)
            continue;
        else
            sum += i;
    }
    cout << sum;
    
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
int n,m;
char ch[30][30];
int a[4]={0,0,1,-1};
int b[4]={1,-1,0,0};
int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>ch[i][j];
    int  ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            queue<pair<int,int> > q;
            q.push({i,j});
            int vis[30][30];
            memset(vis,0,sizeof(vis));
            int dist[30][30];
            memset(dist,0,sizeof(dist));
            vis[i][j]=1;
            int curr=0;
            if(ch[i][j]=='#')
                continue;
            while(!q.empty())
            {
                pair<int,int> p=q.front();
                q.pop();
                for(int k=0;k<4;k++)
                {
                    int x=p.first+a[k];
                    int y=p.second+b[k];
                    if(x<1||x>n||y<1||y>m||ch[x][y]=='#')
                        continue;
                    if(vis[x][y]==0)
                    {
                        dist[x][y]=dist[p.first][p.second]+1;
                        q.push({x,y});
                        vis[x][y]=1;
                        curr=max(curr,dist[x][y]);
                    }
                }
            }
            ans=max(ans,curr);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
/*
    Washief Hossain Mugdho
    19 September 2020
    Educational DP Matching
*/

#ifndef DEBUG
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define fastio ios_base::sync_with_stdio(0)
#define untie cin.tie(0)
#define ms(a, b) memset(a, b, sizeof a)
#define mod 1000000007
using namespace std;
bool a[22][22];
int memo[22][1 << 22];
int n;

int dp(int now, int mask)
{
    if (now >= n)
        return 1;
    int res = 0;

    if (memo[now][mask] != -1)
        return memo[now][mask];

    for (int i = 0; i < n; i++)
        if (a[now][i] && !(mask & (1 << i)))
            res = (res + dp(now + 1, mask | (1 << i))) % mod;

    return memo[now][mask] = res;
}

int main()
{
#ifdef LOCAL_OUTPUT
    freopen(LOCAL_OUTPUT, "w", stdout);
#endif
#ifdef LOCAL_INPUT
    freopen(LOCAL_INPUT, "r", stdin);
#endif
    cin >> n;
    ms(memo, -1);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];

    cout << dp(0, 0) << endl;
}


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

#define ll long long
const int inf = 1e9+7;
const ll INF = 1e18+7;

using namespace std;

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

  int h1,m1,h2,m2,k;
  cin >>h1>>m1>>h2>>m2>>k;
  int n1 = h1*60+m1;
  int n2 = h2*60+m2;
  cout<< n2-n1-k<<"\n";
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#define LL long long
#define db double
#define inf 0x3f3f3f3f
#define N 200005
#define rt 2*n+1
using namespace std;

int n,dua[N],dub[N],faa[N],fab[N];
int head[N<<1],cur[N<<1],to[N*6],ne[N*6],used[N*6],dir[N*6],num;

void adde(int u,int v) {
    to[++num]=v,ne[num]=head[u],head[u]=num;
    to[++num]=u,ne[num]=head[v],head[v]=num;
}
void dfs(int p) {
    for(int i;cur[p]!=-1;cur[p]=ne[cur[p]]) {
        i=cur[p];
        if(!used[i]) {
            used[i]=used[i^1]=1;
            dfs(to[i]);
            dir[i]=-1,dir[i^1]=1;
        }
        if(cur[p]==-1) break;
    }
}
int main() 
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        scanf("%d",&faa[i]);
        if(faa[i]!=-1) dua[faa[i]]++;
    }
    for(int i=1;i<=n;++i) {
        scanf("%d",&fab[i]);
        if(fab[i]!=-1) dub[fab[i]]++;
    }
    for(int i=1;i<=n;++i) 
        if((dua[i]&1)^(dub[i]&1)) {puts("IMPOSSIBLE"); return 0;}
    puts("POSSIBLE");
    num=-1; memset(head,-1,sizeof(head));
    for(int i=1;i<=n;++i) {
        if(!(dua[i]&1)) adde(i,i+n);
        if(faa[i]!=-1) adde(faa[i],i);
        else adde(i,rt);
        if(fab[i]!=-1) adde(fab[i]+n,i+n);
        else adde(i+n,rt);
    }
    for(int i=1;i<=rt;++i) cur[i]=head[i];
    dfs(1);
    for(int i=1;i<=n;++i) {
        if(dua[i]&1) printf("0");
        else { 
            for(int j=head[i];j!=-1;j=ne[j])
                if(to[j]==i+n) {printf("%d",dir[j]);break;}
        } 
        if(i!=n) printf(" ");
    }
    return 0;
}

Measured memory_bytes: 34432
// OURL: https://atcoder.jp/contests/abc135/tasks/abc135_a
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a+b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


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

int main() {
    map<ll, ll> mp;
    ll end, next, cnt = 0, cnt2 = 0;
    ll len;
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    mp[1]++;
    next = a[0];
    mp[next]++;
    for (;;) {
        //put(next);
        next = a[next - 1];
        mp[next]++;
        if ((mp[next] > 2)) {
            break;
        }
    }

    for(auto x:mp){
        if(x.second >= 2) cnt++;
        if(x.second < 2) cnt2++;
    }

    //for(auto y:mp){ cout << y.first << " " << y.second << endl;}

    if(k - cnt2 >= 0) len = (k - cnt2) % cnt;
    else{ len = k-1; next = a[0]; };

    //put(cnt);

    //next = pre;
    for(int i = 0; i < len; i++){
        next = a[next - 1];
        //put(next);
    }
    put(next);
}

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

int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; ++i) {
        string order, message;
        cin >> order >> message;
        reverse(order.begin(), order.end());

        for(int j=0; j<order.size(); ++j) {
            if(order[j] == 'J') {
                message = message.substr(message.size()-1, 1) + message.substr(0, message.size()-1);
            } else if(order[j] == 'C') {
                message = message.substr(1, message.size()-1) + message.substr(0, 1);
            } else if(order[j] == 'E') {
                string left = message.substr(0, message.size()/2);
                string right = message.substr((message.size()+1)/2, message.size()/2);
                if(message.size()%2 == 0) {
                    message = right + left;
                } else {
                    string mid = message.substr(message.size()/2, 1);
                    message = right + mid + left;
                }
            } else if(order[j] == 'A') {
                reverse(message.begin(), message.end());
            } else if(order[j] == 'P') {
                for(int k=0; k<message.size(); ++k) {
                    char c = message[k];
                    if('0' <= c && c <= '9') {
                        message[k] = '0' + (c-'0'+9)%10;
                    }
                }
            } else if(order[j] == 'M') {
                for(int k=0; k<message.size(); ++k) {
                    char c = message[k];
                    if('0' <= c && c <= '9') {
                        message[k] = '0' + (c-'0'+1)%10;
                    }
                }
            }
        }
        cout << message << endl;
    }
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B;cin>>A>>B;
  
  int C;
  if(B<10){
    C=A*10+B;
  }
  else if(10<=B&&B<100){
    C=A*100+B;
  }
  else{
    C=A*1000+B;
  }
  
  for(int i=1;i<340;i++){
    if(i*i==C){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  
  cout<<"No"<<endl;
}

Measured memory_bytes: 3476
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

typedef long long ll;

int main()
{
    int r;
    cin >> r;
    if(r<1200){
        cout << "ABC";
    }else if(r<2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }

    return 0;
}

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

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

bool dfs(int x, int y, vector<string> &threads) {
	if(threads[y][x] == '+') return true;
	if(islower(threads[y][x])) return false;

	const bool res = dfs(x, y - 1, threads);
	if(res) threads[y][x] = '|';
	return res;
}

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

	for(int n; cin >> n && n;) {
		vector<string> threads(n);
		for(auto &e : threads) cin >> e;

		for(auto &s : threads) {
			rep(i, s.size()) {
				if(s[i] != '.') break;
				s[i] = (islower(s[i + 1]) ? '+' : ' ');
			}
		}

		rep(y, n) {
			rep(x, threads[y].size()) {
				if(threads[y][x] == '+') {
					dfs(x, y - 1, threads);
				}
			}
		}

		for(const auto &s : threads) {
			cout << s << endl;
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1788
#include <stdio.h>

void abc90_a(){
    char a[3],b[3];
    for (int i = 0; i < 3; i++) {
        scanf("%s", a);
        printf("%c", a[i]);
    }
    printf("\n");
}


int main(int argc, char const *argv[]) {
	abc90_a();
    return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int c,a,b; cin>>c>>a>>b;
    cout<<a*c/2<<endl;
}


Measured memory_bytes: 3600
N,K=map(int,input().split())
A=[int(x)-1 for x in input().split()]

t,i,dist=0,0,{0:0}
while K>0:
    K,i,t=K-1,i+1,A[t]
    if t in dist:
        K%=i-dist[t]
    else:
        dist[t]=i

print(t+1)


Measured memory_bytes: 110552
#include <bits/stdc++.h>
using namespace std;
#define   ll long long int
#define maxn 1000000
vector<ll> dp(maxn,0);
ll mod=998244353;

int main(){

int n,k;
cin>>n>>k;
vector<pair<int,int> > p(k);
for(int i=0;i<k;i++){
    cin>>p[i].first>>p[i].second;
}

for(int j=0;j<k;j++){
        int l=p[j].first;
        int r=p[j].second;
        dp[1+l]+=1;
        dp[1+l]=dp[1+l]%mod;
        dp[1+r+1]-=1;
        dp[1+r+1]=dp[1+r+1]%mod;
    }
ll cum=dp[1];
for(int i=2;i<=n;i++){
    cum+=dp[i];
    cum=cum%mod;
    for(int j=0;j<k;j++){
        int l=p[j].first;
        int r=p[j].second;
        dp[i+l]+=cum;
        dp[i+l]=dp[i+l]%mod;
        dp[i+r+1]-=cum;
        dp[i+r+1]=(mod+dp[i+r+1])%mod;
    }
    //cout<<cum<<endl;
}
cout<<cum<<endl;



}


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

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

using namespace std;







int main(void)
{
	int N, M, a, b, ans = 0;
	queue<vector<int> > que;

	cin >> N >> M;

	vector<int> tmp, path;
	vector<vector<int>> edge(N, tmp);


	rep(i, M) {
		cin >> a >> b;
		a--; b--;

			edge[a].push_back(b);
			edge[b].push_back(a);		
	}

	rep(i, edge.size()) {
		sort(edge[i].begin(), edge[i].end());
	}

	tmp.clear();
	tmp.push_back(0);
	que.push(tmp);

	while (!que.empty()) {
		tmp = que.front();
		que.pop();

		if (tmp.size() >= N) {
			ans++;
			continue;
		}

		int node = tmp[tmp.size() - 1];
		rep(i, edge[node].size()) {
			if (find(tmp.begin(), tmp.end(), edge[node][i]) == tmp.end()) {
				path = tmp;
				path.push_back(edge[node][i]);
				que.push(path);
			}
		}

	}

	cout << ans << endl;




	return 0;
}


Measured memory_bytes: 3884
#include <iostream>
#include <algorithm>
#include <string>

// sequence
// a0 b0 c0: s0 = a0 - b0
// a1 b1 c1: s1 = a1 - b1 = (b0 + c0) - (a0 + C0) = b0 - a0 = -s0
// a2 b2 c2: s2 = b1 - a1 = -s1 = s0 
// a3 b3 c3: s3 = a3 - b3 = b2 + c3 - (a2 + c2) = b2 - a2 = -s2 = -s0 
// an bn cn: sn = (-1)^n s0
//
using namespace std;

int main() {
	double threshold = 1e18;
	double A,B,C;
	string Kstr;
  cin >> A >> B >> C >> Kstr;
	//cout << Kstr.data() << "," << Kstr.size() << endl;
	//cout << Kstr.data()[Kstr.size()-1] << endl;
	char k = Kstr.data()[Kstr.size()-1];
	// cout << k << endl;
	int sign = ((k % 2) == 0 ? 1 : -1);
	// cout << "sign: " << sign << endl;
	
	int ret = sign * (A-B);	
	if (ret > threshold) {
	 cout << "Unfair" << endl;	
	} else {
		cout << ret << endl;
	}
  return 0;
}	



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#define print(x) printf("%d\n",x)

using namespace std;

int main(){
  int n;
  while(~scanf("%d", &n)){
    if(n % 2){
      print((int)(1 + 2 * (pow(3, (n - 1) / 2) - 1)));
    }else{
      print((int)(2 + 3 * (pow(3, (n - 2) / 2) - 1)));
    }
  }
  return 0;
}

Measured memory_bytes: 0
//written by newbiechd
#include <cstdio>
#include <cctype>
#include <vector>
#define R register
#define I inline
#define B 1000000
using namespace std;
const int N = 307, yyb = 1e9 + 7;
char buf[B], *p1, *p2;
I char gc() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, B, stdin), p1 == p2) ? EOF : *p1++; }
I int rd() {
    R int f = 0;
    R char c = gc();
    while (c < 48 || c > 57)
        c = gc();
    while (c > 47 && c < 58)
        f = f * 10 + (c ^ 48), c = gc();
    return f;
}
int f[N][N][N];
struct restrict {
    int l, x;
}e[N];
vector <restrict> v[N];
I int check(int i, int j, int k, int r) {
    for (R int t = 0, s = v[r].size(), l; t < s; ++t) {
        l = v[r][t].l;
        if ((i >= l) + (j >= l) + (k >= l) != v[r][t].x)
            return 1;
    }
    return 0;
}
int main() {
    R int n = rd(), m = rd(), i, j, k, r, ans = 0;
    for (i = 1; i <= m; ++i)
        j = rd(), k = rd(), v[k].push_back((restrict){j, rd()});
    f[0][0][0] = 1;
    for (i = 0; i <= n; ++i)
        for (j = 0; j <= n; ++j)
            for (k = 0; k <= n; ++k) {
                if (!f[i][j][k] || (i && j && i == j) || (j && k && j == k) || (k && i && k == i))
                    continue;
                r = max(i, max(j, k));
                if (check(i, j, k, r)) {
                    f[i][j][k] = 0;
                    continue;
                }
                f[r + 1][j][k] = (f[r + 1][j][k] + f[i][j][k]) % yyb;
                f[i][r + 1][k] = (f[i][r + 1][k] + f[i][j][k]) % yyb;
                f[i][j][r + 1] = (f[i][j][r + 1] + f[i][j][k]) % yyb;
                if (r == n)
                    ans = (ans + f[i][j][k]) % yyb;
            }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 112896
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=1;i<(p);i++)
#define ce(d) cout<<d<<endl;

using namespace std;

const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int a;
	int b;

	int count = 1;
	int res = 0;
	cin >> a >> b;

/*	fi(10000000) {
		if (1+a*i-i>=b) {
			ce(i);
			break;
		}
	}
*/

	while(count<b){
		count--;
		count += a;
		res++;
	}

	ce(res);

}

int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n,W;
  cin >> n >> W;
  int w[n],v[n];
  for(int i=0;i<n;i++) {
    cin >> w[i] >> v[i];
  }
  const long long INF = 1e16;
  vector<long long> dp(100001,INF);
  dp[0] = 0;
  for(int item_no = n-1;item_no >=0;item_no--) {
    for(int value=100000;value > 0;value--) {
      if (v[item_no] <= value) {
          dp[value] = min(dp[value],dp[value-v[item_no]] + w[item_no]);
      }
    }
  }
  int res = 0;
  for(int i=1;i<100001;i++) {
    if (dp[i] <= W) {
      res = max(res,i);
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <atcoder/math>

using ll = long long;

using namespace std;

int main() {
    int t;
    cin >> t;
    for (int i=0, n, m, a, b; i<t; i++) {
        cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n, m, a, b) << '\n';
    }
    return 0;
}

Measured memory_bytes: 3588
package main

import "fmt"

func main() {
	var str string
	fmt.Scan(&str)

	sz := len(str)
	for sz >= 0 {
		sz--
		if sz&1 == 1 {
			continue
		}

		flag := true
		for i := 0; i < (sz >> 1); i++ {
			if str[i] != str[i+(sz>>1)] {
				flag = false
				break
			}
		}
		if flag {
			break
		}
	}

	fmt.Println(sz)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,m;
inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(ch<='9'&&ch>='0')s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
    return s*w;
}
int a[101]={};
int main()
{
    n=read();
    int ans=0;
    for(int i=1;i<=n;++i)a[i]=read();
    for(int i=1;i<n;++i)
     for(int j=i+1;j<=n;++j)
      ans+=a[i]*a[j];
    printf("%d\n",ans);
    // printf("%d\n",max(0,n-2*m));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  int h,m,s;
  double time, tapeb;

  while(cin >> h >> m >> s){
    if(h == -1 && m == -1 && s == -1) break;
    double tape = 2 * 3600;
    time = h * 3600 + m * 60 + s;
    tape -= time;
    tapeb = tape*3;
    h = 0;
    m = 0;
    s = 0;

    while(tape >= 3600){
      h++;
      tape -= 3600;
    }
    while(tape >= 60){
      m++;
      tape -= 60;
    }
    s = tape;

    cout <<"0" <<h << ":";
    if(m < 10) cout <<"0";
    cout << m << ":";
    if(s < 10) cout << "0";
    cout << s << endl;

    h = 0;
    m = 0;
    s = 0;
    
    while(tapeb >= 3600){
      h++;
      tapeb -= 3600;
    }
    while(tapeb >= 60){
      m++;
      tapeb -= 60;
    }
    s = tapeb;


    cout <<"0" <<h << ":";
    if(m < 10) cout <<"0";
    cout << m << ":";
    if(s < 10) cout << "0";
    cout << s << endl;

  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public  class Main  {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int  A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		int sum = 0;
		for(int i = 1; i<=T; i++) {
			if(i%A==0) {
				sum += B;
			}
			
			
		}
		System.out.println(sum);
		
	}
	

}


Measured memory_bytes: 21844
#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
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

struct ModX{
	using ull=uint64_t;
	static const ull mod=(1ll<<61)-1;
	static const ull MASK30=(1ll<<30)-1;
	static const ull MASK31=(1ll<<31)-1;

	ull a;

	ModX& s(ull vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}
	ModX(ull a=0):a(a%mod){}
	
	ModX& operator+=(const ModX& x){return s(a+x.a);}
	ModX& operator-=(const ModX& x){return s(a+mod-x.a);}
	ModX& operator*=(const ModX& x){
		const ull au=a>>31;
		const ull ad=a&MASK31;
		const ull bu=x.a>>31;
		const ull bd=x.a&MASK31;
		const ull mid=ad*bu+au*bd;
		const ull midu=mid>>30;
		const ull midd=mid&MASK30;
		const ull z=au*bu*2+midu+(midd<<31)+ad*bd;
		return s((z&mod)+(z>>61));
	}

	ModX operator+(const ModX &x)const{return ModX(*this)+=x;}
	ModX operator-(const ModX &x)const{return ModX(*this)-=x;}
	ModX operator*(const ModX &x)const{return ModX(*this)*=x;}

	bool operator==(const ModX &x)const{return a==x.a;}
	bool operator!=(const ModX &x)const{return a!=x.a;}
	bool operator<(const ModX &x)const{return a<x.a;}

	ModX operator-()const{return ModX()-*this;}
};

istream& operator>>(istream& in,const ModX& a){
	return (in>>a.a);
}

ostream& operator<<(ostream& out,const ModX& a){
	return (out<<a.a);
}
using xint=ModX;
const xint b(119);

xint po[5555];

int N;
string S;

xint h[5555];
signed main(){
	po[0]=1;
	for(int i=1;i<5555;i++)po[i]=po[i-1]*b;

	cin>>N>>S;
	rep(i,N){
		h[i+1]=h[i]*b+S[i];
	}

	int lb=0,ub=N;
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		bool ok=false;
		set<xint>s;
		for(int i=0;i+mid<=N;i++){
			if(i>=mid){
				auto hs=h[i]-h[i-mid]*po[mid];
				s.insert(hs);
			}
			auto hs=h[i+mid]-h[i]*po[mid];
			if(s.find(hs)!=s.end())ok=true;
		}
		if(ok)lb=mid;
		else ub=mid;
	}
	cout<<lb<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

#define MAX 250
#define NIL -2000000001

int key[MAX];

int parent(int c);
int right(int c);
int left(int c);

int main(){
  int i, n, h;

  scanf("%d", &n);

  for(i = 0; i < MAX; i++){
    key[i] = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d", &h);
    key[i] = h;
  }

  for(i = 0; i < n; i++){
    printf("node %d: key = %d, ", i+1, key[i]);
    if(key[parent(i)] != NIL && i != 0){
      printf("parent key = %d, ",key[parent(i)]);
    }
    if(MAX > left(i) &&  key[left(i)] != NIL){
      printf("left key = %d, ",key[left(i)]);
    }
    if(MAX > right(i) && key[right(i)] != NIL){
      printf("right key = %d, ",key[right(i)]);
    }
    printf("\n");
  }  
   
  return 0;
}

int parent(int c){
  return (c-1)/2;
}

int right(int c){
  return 2*c+2;
}

int left(int c){
  return 2*c+1;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,A[300001],mod=1e9+7;
    cin>>n;
    rep(i,n) cin>>A[i];
    ll B[70]={0};
    rep(i,n){
        ll p=A[i];
        for(int j=0;p>0;j++){
            B[j]+=p%2;
            p=p/2;
        }
    }
    ll x=0;
    rep(i,61){
        x=(x+B[i]*(B[i]-1)%mod*(ll(pow(2,i))%mod)%mod)%mod;
    }
    ll ans=0;
    rep(i,n) ans=(ans+A[i])%mod;
    ans=(n-1)*ans%mod;
    ans=(ans-x+mod)%mod;
    cout<<ans;
}

Measured memory_bytes: 2560
while True:
    
    n = int(input())
    if n == 0:
        break
    
    data = list(map(int, input().split()))
    sum, mean = 0, 0
    for i in range(n):
        sum += data[i]
        if i == n - 1:
            mean = sum / n
    
    diff = 0
    for i in range(n):
        diff += (data[i] - mean) ** 2
    
    print((diff / n) ** 0.5)



Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int k,a,b;
	cin >> k >> a >> b;
	if(a + 2 >= b){
		cout << k + 1 << endl;
		return 0;
	}
	if(k <= a){
		cout << k + 1 << endl;
		return 0;
	}
	cout << a + (k - a + 1) / 2 * (b - a) + (k - a + 1) % 2 << endl;
}


Measured memory_bytes: 256
def f1(n):
    divs = []
    for i in range(1, int(n ** 0.5) + 1):  # range(n, int(n ** 0.5) - 1, -1)とすると非常に遅い！！
        if n % i == 0:
            divs.append(i)
            j = n // i
            if i != j:
                divs.append(j)
    return divs


X = int(input())
divs = f1(X)
INF = 10 ** 15

for p in divs:
    a = 0
    A = pow(a, 5)
    b = a - p
    B = pow(b, 5)
    while A - B < INF:
        if A - B == X:
            print(a, b)
            exit()
        a += 1
        A = pow(a, 5)
        b = a - p
        B = pow(b, 5)


Measured memory_bytes: 82892
//ALDS1_7C
#include <iostream>
using namespace std;

#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
Node T[MAX];
int n;

void preParse(int u){
 if(u==NIL) return;
 cout<<" "<<u;
 preParse(T[u].l);
 preParse(T[u].r);
}

void inParse(int u){
 if(u==NIL) return;
 inParse(T[u].l);
 cout<<" "<<u;
 inParse(T[u].r);
}

void postParse(int u){
 if(u==NIL) return;
 postParse(T[u].l);
 postParse(T[u].r);
 cout<<" "<<u;
}

int main(){
 int v,l,r,root=0;
 cin>>n;
 for(int i=0;i<n;i++) T[i].p=NIL;
 for(int i=0;i<n;i++){
  cin>>v>>l>>r;
  T[v].l=l;
  T[v].r=r;
  if(l!=NIL) T[l].p=v;
  if(r!=NIL) T[r].p=v;
 }
 for(int i=0;i<n;i++){
  if(T[i].p==NIL) root=i;
 }
 cout<<"Preorder"<<endl;
 preParse(root);
 cout<<endl;
 cout<<"Inorder"<<endl;
 inParse(root);
 cout<<endl;
 cout<<"Postorder"<<endl;
 postParse(root);
 cout<<endl;

 return 0;
}

 

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

using namespace std;

const int nax = 1e3+3;
int n, m;
vector<pair<int, int>> bound;
vector<vector<char>> mat(nax, vector<char>(nax));
vector<vector<int>> cc(nax, vector<int>(nax, -1));
    

int dir[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
//vector<pair<int, int>> dir25 = {{-2, -2}, {-2, -1}, {-2, 0}};

bool IsValid(int x, int y) {
    return x>=0 && x<n && y>= 0 && y<m && cc[x][y] == -1;
}

bool IsValid1(int x, int y) {
    return x>=0 && x<n && y>= 0 && y<m && mat[x][y] != '#';
}

void dfs(int x, int y, int color) {
    cc[x][y] = color;
    bool badded = false;
    for(int i = 0; i < 4; i++) {
        if(IsValid(x+dir[i][0], y+dir[i][1])) {
            if(mat[x+dir[i][0]][y+dir[i][1]] == '#') {
                if(!badded) {
                    bound.push_back({x, y});
                    badded = true;
                }
            }
            else {
                dfs(x+dir[i][0], y + dir[i][1], color);
            }
        }
    }
}

int main() {
    pair<int, int> s, e;
    cin >> n >> m;
    cin >> s.first >> s.second;
    cin >> e.first >> e.second;
    s.first--, s.second--, e.first--, e.second--;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> mat[i][j];
        }
    }
    int ccn = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(mat[i][j] == '.' && cc[i][j] == -1) {
                dfs(i, j, ccn++);
            }
        }
    }
    vector<unordered_set<int>> adj(ccn);
    for(auto coor : bound) {
        int x = coor.first, y = coor.second;
        for(int i = -2; i < 3; i++) {
            for(int j = -2; j < 3; j++) {
                if(i || j) {
                    int nx = x+i, ny = y+j;
                    if(IsValid1(nx, ny) && cc[x][y] != cc[nx][ny]) {
                        if(adj[cc[x][y]].find(cc[nx][ny]) == adj[cc[x][y]].end()) {
                            adj[cc[x][y]].insert(cc[nx][ny]);
                            adj[cc[nx][ny]].insert(cc[x][y]);
                        }
                    }
                }
            }
        }
    }
    int st = cc[s.first][s.second], dt = cc[e.first][e.second];
    //cout << st << ' ' << dt << endl; 
    vector<bool> visited(ccn, false);
    queue<pair<int, int>> q;
    q.push({st, 0}), visited[st] = true;
    bool found = false;
    while(!q.empty()) {
        int v = q.front().first;
        int dist = q.front().second;
        q.pop();
        if(v == dt) {
            cout << dist;
            found = true;
            break;
        }
        for(auto x : adj[v]) {
            if(!visited[x]) {
                visited[x] = true;
                q.push({x, dist+1});
            }
        }
    }
    if(!found) cout << -1;
    return 0;
}


Measured memory_bytes: 34300
#include <iostream>

using namespace std;

int main(){
	int h,w;

	while(cin>>h>>w){
		if(h==0&&w==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}

	return 0;
}

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

bool solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true) {
        c -= b;
        if(c <= 0) return true;
        a -= d;
        if(a <= 0) return false;
    }
}

int main() {
    cout << (solve() ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug printf("*");
//#define mo 1e9+7
//const int N=;
int n,tot;
double eps=1e-6;
struct pos{
	double x,y;
}ans[5005];
void solve(pos from,pos to,int step){
	if(step==0){
		ans[++tot]=to;
		return;
	}
	
	double xa=from.x,ya=from.y,xb=to.x,yb=to.y;
	double tmp=(xb-xa)/3,tmp2=(yb-ya)/3;
	pos s,u,t;
	double k=(yb-ya)/(xb-xa);
	s=(pos){xa+tmp,ya+tmp2};t=(pos){xb-tmp,yb-tmp2};
	
	if(fabs(k)<eps) u=(pos){(xa+xb)/2,ya+tmp*sqrt(3)/2};
	if(fabs(k-sqrt(3))<eps) u=(pos){xa,yb-tmp2};
	if(fabs(k+sqrt(3))<eps) u=(pos){xb,yb-2*tmp2};
	
	solve(from,s,step-1);
	solve(s,u,step-1);
	solve(u,t,step-1);
	solve(t,to,step-1);
}
int main(){
	int n;
	scanf("%d",&n);
	solve((pos){0,0},(pos){100,0},n);
	printf("0.00000000 0.00000000\n");
	for(int i=1;i<=tot;i++)
		printf("%.8lf %.8lf\n",ans[i].x,ans[i].y);
	return 0;
}


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

// DATA TYPES
typedef long long ll;
#define double long double
//

// CONTAINERS
#define vec vector
#define pb push_back
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)x.size()
#define mp make_pair
#define ii pair<int, int>
#define F first
#define S second
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U> &L, const std::pair<T,U> &R) {
  return {L.first + R.first, L.second + R.second};
}
//

// LOOP
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
//

// BIT
#define bitcount(n) __builtin_popcountll(n)
//

// DEBUG
#define format(x) << #x << ": " << (x)
#define com << ", "
#define ndl << "\n"
#define debug1(x) cerr format(x) ndl;
#define debug2(x, y) cerr format(x) com format(y) ndl;
#define debug3(x, y, z) cerr format(x) com format(y) com format(z) ndl;
void debug_out() { cerr << "\n"; }
template <typename H, typename... T> 
void debug_out(H h, T... t) { cerr << " " << (h); debug_out(t...); }
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
// 

// CONSTANTS
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
//

// NUMERICAL OPERATIONS
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

int norm(int a) {
  return ((a % MOD) + MOD) % MOD;
}

int mul(int a, int b) {
  return int(a * 1LL * b % MOD);
}

int binPow(int a, int k) {
  int ans = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) {
      ans = mul(ans, a);
    }
    a = mul(a, a);
  }
  return ans;
}

// If I need to find (x / a) % MOD, I need to use this function:
//    (x / a) % MOD = (x * inv(a)) % MOD
int inv(int a) {
  int b = binPow(a, MOD - 2);
  assert(mul(a, b) == 1);
  return b;
}
//

// Init variables here
const int N = 1e6 + 7;

void init() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);

}

void solve() {
  int n;
  cin >> n;
  int b[n];
  FOR(i, 0, n - 1) cin >> b[i];
  ll res = b[0];
  FOR(i, 1, n - 1) {
    res += min(b[i - 1], b[i]); 
  }
  res += b[n - 2];
  cout << res << "\n";
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie();
  //auto beginProgram = chrono::steady_clock::now();
  //int t; scanf("%d", &t); while (t--) 
  {
    init();
    solve();
  }
  //auto endProgram = chrono::steady_clock::now();

  return 0;
}



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

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b push_back
#define m_p make_pair

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
vector<ll>v;

map<ll,ll>mp;


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

    bool f=true;
    for(ll i=1;i<=n;i++){
        ll x;
        cin>>x;
        mp[x]++;
        if(mp[x]>1){
            f=false;
        }
    }

    if(f) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;



    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n-1);
    for(int i = 0; i < n-1; i++){
        cin >> b[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(i == 0) a[i] = b[i];
        else if(i == n-1) a[i] = b[i-1];
        else a[i] = min(b[i], b[i-1]);
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  ll a,b,q;
  cin >> a >> b >> q;
  ll x[1000000];
  vector<ll> s,t;
  ll unko;
  FOR(i,a){
    cin >> unko;
    s.push_back(unko);
  }
  FOR(i,b){
    cin >> unko;
    t.push_back(unko);
  }
  FOR(i,q){
    cin >> x[i];
  }
  ll sl,sr,tl,tr;
  
  FOR(i,q){
    auto ss=lower_bound(s.begin(),s.end(),x[i]);
    auto tt=lower_bound(t.begin(),t.end(),x[i]);

    sr=1000000000000000;
    sl=1000000000000000;
    tr=1000000000000000;
    tl=1000000000000000;
    
    if(ss-1>=s.begin()){
      sl=*(ss-1);
    }
    if(ss<s.end()){
      sr=*ss;
    }
    if(tt-1>=t.begin()){
      tl=*(tt-1);
    }
    if(tt<t.end()){
      tr=*tt;
    }
    
    

  

    

    cout << min({ abs(sl-x[i])+abs(sl-tl),
                  abs(sl-x[i])+abs(sl-tr),
                  abs(sr-x[i])+abs(sr-tl),
                  abs(sr-x[i])+abs(sr-tr),
                  abs(tl-x[i])+abs(sl-tl),
                  abs(tl-x[i])+abs(sr-tl),
                  abs(tr-x[i])+abs(sl-tr),
                  abs(tr-x[i])+abs(sr-tr),
                }) << endl;

  }



}


Measured memory_bytes: 5364
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] = self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

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

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

    def roots(self):
        return [i for i in self._root]


n, m = map(int, input().split())
P = list(map(int, input().split()))
par = []
for _ in range(m):
    x, y = map(int, input().split())
    par.append((x - 1, y - 1))

uf = UnionFind(n)
for i in range(m):
    uf.unite(par[i][0], par[i][1])

cnt = 0
for i in range(n):
  if uf.same(i, P[i]-1):
    cnt += 1
print(cnt)


Measured memory_bytes: 21412
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
    
using namespace std;

typedef long long ll;

ll l;
int n;
vector<ll> x, s;

int main() {
    cin >> l >> n;
    ll xin, sin = 0;
    x.push_back(0);
    s.push_back(0);
    for (int i = 0; i < n; i++) {
        cin >> xin;
        sin += xin;
        x.push_back(xin);
        s.push_back(sin);
    }
    
    sort(x.begin(), x.end());
    sort(s.begin(), s.end());
    ll ans1 = 0, ans2 = 0;
    for (int i = 1; i <= n; i++) {
        ll r = x.at(i);
        ll m1 = (n - i) / 2, m2 = (n - i - 1) / 2;
        if (n-i == 0) {
            ans1 = max(ans1, r);
            break;
        }
        if ((n - i) % 2 == 0) r += 2*(s.at(i+m1)-s.at(i-1)) - x.at(i) - x.at(i+m1) + 2*m1*l - 2*(s.at(n)-s.at(n-m1));
        else r += 2*(s.at(i+m2)-s.at(i-1)) - x.at(i) + (2*m2+1)*l - 2*(s.at(n)-s.at(n-m2-1)) + x.at(i+m2+1);
        ans1 = max(ans1, r);
    }
    for (int i = 1; i <= n; i++) {
        ll r = l - x.at(n - i + 1);
        ll m1 = (n - i) / 2, m2 = (n - i + 1) / 2;
        if (n-i == 0) {
            ans2 = max(ans2, r);
            break;
        }
        if ((n - i) % 2 == 0) r += 2 * s.at(m1) + 2*m1*l - 2 * (s.at(n-i+1) - s.at(m1)) + x.at(n-i+1) + x.at(m1+1);
        else r += (2*m2-1)*l - 2*(s.at(n-i+1) - s.at(m2)) + x.at(n-i+1) + 2 * s.at(m2) - x.at(m2);
        ans2 = max(ans2, r);
    }
    ll ans = max(ans1, ans2);
    
    cout << ans << endl;
}


Measured memory_bytes: 3564
#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,h;
  cin>>n>>h;
  vector<Int> a(n),b(n),c(n),d(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];

  const Int MAX = 300;
  vector<vector<Int> > G(MAX*2);
  vector<Int> od(MAX*2,0),id(MAX*2,0);
  for(Int i=0;i<n;i++){
    Int l=c[i]==0? a[i]:-c[i];
    Int r=d[i]==0?-b[i]: d[i];
    G[MAX+l].emplace_back(MAX+r);
    od[MAX+l]++;
    id[MAX+r]++;
  }
  
  auto NO=[](){cout<<"NO"<<endl;exit(0);};
  
  Int w=0;
  for(Int i=1;i<MAX;i++){    
    while(od[MAX+i]>id[MAX+i]){
      G[MAX+w].emplace_back(MAX+i);
      od[MAX+w]++;
      id[MAX+i]++;
    }
    while(od[MAX-i]<id[MAX-i]){
      G[MAX-i].emplace_back(MAX-w);
      od[MAX-i]++;
      id[MAX-w]++;
    }
    //cout<<i<<"+:"<<od[MAX+i]<<" "<<id[MAX+i]<<endl;
    //cout<<i<<"-:"<<od[MAX-i]<<" "<<id[MAX-i]<<endl;
    if(od[MAX+i]!=id[MAX+i]) NO();
    if(od[MAX-i]!=id[MAX-i]) NO();
  }

  vector<Int> used(MAX*2);
  queue<Int> q;

  used[MAX+w]=1;
  q.emplace(MAX+w);
  
  while(!q.empty()){
    Int v=q.front();q.pop();
    for(Int u:G[v]){
      if(used[u]) continue;
      used[u]=1;
      q.emplace(u);
    }
  }
  
  for(Int i=0;i<MAX*2;i++)
    if((id[i]||od[i])&&!used[i]) NO();
  
  cout<<"YES"<<endl;
  return 0;
}


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

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

int mod = 998244353;
int add(int a, int b) {
	a += b;
	while(a >= mod) a -= mod;
	return a;
}

int mul(int a, int b) {
	return (LL) a * b % mod;
}

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

	int n;
	string x;
	cin >> n >> x;

	int ans = 0, pref = 0;
	vector<PII> d;

	FOR(i, 1, n - 1) {
		pref = add(pref, pref + x[i - 1] - '0');

		if(n % i == 0 && (n / i) % 2 == 1) {
			bool last_is_good = true;
			int pos = 0;
			for(int j = i; j < n; j++) {
				char expected = '1' - (x[j - i] - '0');
				if(expected != x[j]) {
					last_is_good = expected == '0';
					break;
				}
			}

			int r = pref + last_is_good;
			for(PII &p : d) {
				if(i % p.ST	== 0)
					r = add(r, mod - p.ND);
			}

			ans = add(ans, mul(r, (n - i) * 2));
			d.emplace_back(i, r);
			debug(i * 2, r);
		}
	}

	pref = add(pref, pref + x[n - 1] - '0');
	ans = mod - ans;
	ans = add(ans, mul(pref + 1, n * 2));
	cout << ans << "\n";
}


Measured memory_bytes: 720