akhauriyash/Code-Regression huggingface dataset:
#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  , M ;
    cin >> N >> M ;
    vector<ll> A(N) ;
    vector<ll> B(3000000) ;
    map<int,int> mp ;
    rep(i,N){
        cin >> A[i] ;
        mp[A[i]]++ ;
    } 
    priority_queue<pair<ll,ll>> P ;
    for(auto p : mp){
        ll num = p.first ;
        ll cou = p.second ;
        P.push(make_pair(num,cou)) ;
    }
    rep(i,M){
        int c , x ;
        cin >> c >> x ;
        P.push(make_pair(x,c)) ;
    }
    //sort(P.begin(),P.end()) ;
    int j = 0 ;
    while( j < N ){
        ll sum = P.top().first ;
        ll count = P.top().second ;
        P.pop() ;
        rep(k,count){
            B[j] = sum ;
            j++ ;
        }
    }
    ll ans = 0 ;
    rep(i,N) ans += B[i] ;
    cout << ans << endl;
}

Measured memory_bytes: 35312
while True:
    try:
        a,b=map(int,input().split())
        if a==0 and b==0:
            break
        else:
            if a<b:
                a,b=b,a
            else:
                pass
            i=0
            while True:
                c=a%b
                a=b
                b=c
                i+=1
                if b==0:
                    break
            print(a,i)
    except EOFError:
        pass


Measured memory_bytes: 5604
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
const int MAXN=1<<17;
const int INF=2147483647;
int seg[MAXN*2+1];

struct Seg{
	int n;//ノードの個数
	
	void init(int x){
		n=1;
		while(n<x)n*=2;//最下段の個数
		rep(i,n*2)seg[i]=INF;
	}
	void update(int i,int x){
		int now=i+n-1;
		seg[now]=x;
	
		while(now>0){
			now=(now-1)/2;
			seg[now]=min(seg[now*2+1],seg[now*2+2]);
		}
	}
	
	int find(int a,int b,int k,int l,int r){//(a,b,0,0,n)
		//cout<<"A"<<a<<" "<<b<<" "<<k<<" "<<l<<" "<<r<<endl;
		if(r<=a||b<=l)return INF;
		else if(a<=l&&r<=b)return seg[k];
		else{
			int v1,v2;
			v1=find(a,b,k*2+1,l,(l+r)/2);
			v2=find(a,b,k*2+2,(l+r)/2,r);
			return min(v1,v2);
		}
	}
	
	void debug(){
		for(int i=0;i<n*2-1;i++){
			cout<<seg[i]<<" ";
			bool ok=0;
			int t=0;
			for(int j=0;j<=17;j++){
				if(t==i)ok=1;
				t=t*2+2;
			}
			if(ok)cout<<endl;
		}	
	}
	
};
int main(){
Seg tree;
int m,q,c,x,y;
cin>>m>>q;
tree.init(m);

rep(i,q){
	cin>>c>>x>>y;
	if(c==0){
		tree.update(x,y);
	}
	else{
		int z=tree.find(x,y+1,0,0,tree.n);
		cout<<z<<endl;
	}
	
}

	return 0;
}


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

int main(void){
    int n,sum = 0;
    cin >> n;
    string s[n];
    int a[n];
    map<string,int> mp;
    for(int i = 0;i < n;i++){
        cin >> s[i];
        a[i] = 0;
    }
    sort(s,s+n);
    int ans = 1;
    for(int i = 1;i < n;i++){
        if(s[i-1] != s[i]){
            a[i-1] = ans;
            sum = max(ans,sum);
            ans = 1;
        } else ans++;
    }
    a[n-1] = ans;
    sum = max(sum,ans);
    for(int i = 0;i < n;i++){
        if(a[i] == sum)cout << s[i] << endl;
    }
}

Measured memory_bytes: 15872
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let h: usize = scan(tokens);
    let w: usize = scan(tokens);
    if h == 1 || w == 1 {
        println!("1");
    } else {
        println!("{}", (h * w + 1) / 2);
    }
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello
{

    public static void Main()
    {
        string s = Console.ReadLine();
        string ans = "";
        for (int i = 0; i < s.Length; i++)
        {
            if (i % 2 == 0) {
                ans += s[i];
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 34772
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()

typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int32_t, int32_t> pii;
typedef vector<int32_t> vi;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;

  int32_t n, c1 = 0, c2 = 0, c3 = 0;
  cin >> n;
  rep(i, n) {
    int32_t v;
    cin >> v;
    switch (v) {
      case 1:
        c1++;
        break;
      case 2:
        c2++;
        break;
      case 3:
        c3++;
        break;
    }
  }

  double dp[c1 + c2 + c3 + 1][c2 + c3 + 1][c3 + 1];

  loop(ic3, 0, c3 + 1) {
    // cerr << "\n***********************\nic3 = " << ic3 << "\n\n";
    loop(ic2, 0, c2 + (c3 - ic3) + 1) {
      loop(ic1, 0, c1 + (c2 - ic2) + (c3 - ic3) + 1) {
        if (ic1 + ic2 + ic3 == 0) {
          dp[0][0][0] = 0;
        } else {
          dp[ic1][ic2][ic3] = static_cast<double>(n) / (ic1 + ic2 + ic3);
          if (ic1 > 0)
            dp[ic1][ic2][ic3] += static_cast<double>(ic1) / (ic1 + ic2 + ic3) *
                                 dp[ic1 - 1][ic2][ic3];
          if (ic2 > 0)
            dp[ic1][ic2][ic3] += static_cast<double>(ic2) / (ic1 + ic2 + ic3) *
                                 dp[ic1 + 1][ic2 - 1][ic3];
          if (ic3 > 0)
            dp[ic1][ic2][ic3] += static_cast<double>(ic3) / (ic1 + ic2 + ic3) *
                                 dp[ic1][ic2 + 1][ic3 - 1];
        }
        // cerr << dp[ic1][ic2][ic3] << ' ';
      }
      // cerr << '\n';
    }
  }

  cout << dp[c1][c2][c3];
}

Measured memory_bytes: 211840
#!/usr/bin/env python
"""AtCoder Beginner Contest 173: B - 
https://atcoder.jp/contests/abc173/tasks/abc173_b
"""


def main():
    N = int(input())
    d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
    for _ in range(N):
        S = input()
        d[S] += 1

    print('AC x {}'.format(d['AC']))
    print('WA x {}'.format(d['WA']))
    print('TLE x {}'.format(d['TLE']))
    print('RE x {}'.format(d['RE']))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
import sys
import math
N = int(input())
array = list(map(int,input().split()))
set_array = set(array)

if not ( 3 <= N <= 10**5 and N % 2 == 1 ): sys.exit()

print(len(list(set_array))) if len(list(set_array)) % 2 == 1 else print(len(list(set_array)) - 1)

Measured memory_bytes: 20700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int n;cin>>n;cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
H_max = 0

for i in range(N-1):
    if H_max < H[i]:
        H_max = H[i]
    if H[i+1] < H_max - 1:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define endl '\n'
using namespace std;
const int N=60;
ll a[N];
int32_t main(){
    sync;
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    ll ans=0;
    while(true){
        ll p1=0;
        for (int i=1;i<=n;i++){
            if (a[i]>=n){
                ll z=a[i]/n;
                a[i]=a[i]%n;
                for (int j=1;j<i;j++) a[j]+=z;
                for (int j=i+1;j<=n;j++) a[j]+=z;
                ans+=z;
            }
        }
        for (int i=1;i<=n;i++) if (a[i]>=n) p1=1;
        if (!p1) break;
    }
    cout << ans << endl;
}


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

long long find_gcd(long long a, long long b)
{
	if (a < b)	return find_gcd(b, a);
	long long tmp;
	while ((tmp = a % b))
	{
		a = b;
		b = tmp;
	}
	return b;
}

int main(int, char**)
{
	long long A, B;
	cin >> A >> B;
	vector<long long> cds;
	auto gcd = find_gcd(A, B);
	auto end = static_cast<long long>(sqrt(gcd));
	for (long long i = 1; i <= end; ++i)
	{
		if (gcd % i == 0)
		{
			cds.push_back(i);
			if (i * i != gcd)
			{
				cds.push_back(gcd / i);
			}
		}
	}
	sort(cds.begin(), cds.end());
	vector<bool> oks(cds.size(), true);
	end = cds.size();
	for (long long i = 0; i < end; ++i)
	{
		if (!oks[i])	continue;
		if (cds[i] == 1)	continue;
		for (long long j = i + 1; j < end; ++j)
		{
			if (cds[j] % cds[i] == 0)
			{
				oks[j] = false;
			}
		}
	}
	long long count = 0;
	for (const auto& b : oks)
	{
		if (b)	++count;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<55);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll A; cin>>A;
    string B; cin>>B;
    ll C=0;
    C+=B[0]-'0';
    C*=10;
    C+=B[2]-'0';
    C*=10;
    C+=B[3]-'0';
    ll ans=A*C/100;
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;

signed main(){
  int n,k;cin>>n>>k;
  vector<int> v(n),w(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n;i++)w[i]=-v[i];
  sort(v.begin(),v.end());
  sort(w.begin(),w.end());
  int l=-LINF,r=LINF;
  while(r-l>1){
    int mid=(r+l)>>1,tmp=0;
    for(int i=0;i<n;i++){
      if(v[i]>0){
        int ll=-1,rr=n;
        while(rr-ll>1){
          int m=(rr+ll)>>1;
          (v[i]*v[m]>mid?rr:ll)=m;
        }
        tmp+=rr;
        if(v[i]*v[i]<=mid)tmp--;
      }
      if(v[i]==0)if(mid>=0)tmp+=n-1;
      if(v[i]<0){
        int ll=-1,rr=n;
        while(rr-ll>1){
          int m=(rr+ll)>>1;
          (-v[i]*w[m]>mid?rr:ll)=m;
        }
        tmp+=rr;
        if(v[i]*v[i]<=mid)tmp--;
      }
    }
    if(tmp>=k*2)r=mid;
    else l=mid;
  }
  cout<<r<<endl;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    
    if(A==B && B==C) {
        cout << "No" << endl;
    } else if(A!=B && B!=C && A!=C) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }



    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const string MINUSINF = "-";

typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}
vector<pair<int, int>> vp;

ll D[31][31];
ll c[510][510];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

    ll N, C;
    cin >> N >> C;

    for (int i = 0; i < C; ++i)
    {
        for (int j = 0; j < C; ++j)
        {
            cin >> D[i][j];
        }
    }

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

    vector<ll> v1, v2, v0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if ((i + j) % 3 == 0)
            {
                v0.push_back(c[i][j]);
            }
            if ((i + j) % 3 == 1)
            {
                v1.push_back(c[i][j]);
            }
            if ((i + j) % 3 == 2)
            {
                v2.push_back(c[i][j]);
            }
        }
    }

    vector<pair<ll, ll>> p1, p2, p0;

    for (int i = 0; i < C; ++i)
    {
        ll sum = 0;
        for (int j = 0; j < (int)v0.size(); ++j)
        {
            sum += D[v0[j]][i];
        }
        //cout << sum << endl;
        p0.push_back(make_pair(sum, i));
    }

    for (int i = 0; i < C; ++i)
    {
        ll sum = 0;
        for (int j = 0; j < (int)v1.size(); ++j)
        {
            sum += D[v1[j]][i];
        }
        //cout << sum << endl;
        p1.push_back(make_pair(sum, i));
    }

    for (int i = 0; i < C; ++i)
    {
        ll sum = 0;
        for (int j = 0; j < (int)v2.size(); ++j)
        {
            sum += D[v2[j]][i];
        }
        //cout << sum << endl;
        p2.push_back(make_pair(sum, i));
    }

    sort(p0.begin(), p0.end());
    sort(p1.begin(), p1.end());
    sort(p2.begin(), p2.end());

    ll ans = 1000000000;

    for (int i = 0; i < p0.size(); ++i)
    {
        for (int j = 0; j < p1.size(); ++j)
        {
            for (int k = 0; k < p2.size(); ++k)
            {
                if (p0[i].second == p1[j].second || p0[i].second == p2[k].second || p1[j].second == p2[k].second)
                    continue;
                ans = min(ans, p0[i].first + p1[j].first + p2[k].first);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	string S;
	cin >> S;
	int ans = 0;
	char c = S[0];
	REP(i, S.length())
	{
		if (S[i] != c)
		{
			ans++;
			c = S[i];
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll i = 1; i <= k; ++i) {
        r *= n--;
        r /= i;
    }
    return r;
}

int main()
{
    ll n,ans = 0,cnt = 1;
    cin >> n;
    vector<ll> a(n);
    rep0(i, n)cin >> a[i];
    rep0(i, n){
        if(a[i] == cnt){
            ++cnt;
        }else{
            ++ans;
        }
    }
    if(cnt == 1)pf(-1)
    else pf(ans)
    return 0;
}


Measured memory_bytes: 1792
#coding:utf-8

N = input()
K = int(input())
dp = [[[0 for _ in range(K+2)] for _ in range(2)] for _ in range(len(N) + 1)]
# 桁数、０以外が出た回数、未満フラグ
dp[0][0][0] = 1

for i in range(len(N)):
    for smaller in range(2):
        for k in range(K+1):
            for x in range(10 if smaller == 1 else int(N[i]) + 1):
                dp[i + 1][smaller == 1 or x < int(N[i])][k + 1 if x != 0 else k] += dp[i][smaller][k]
print(dp[len(N)][0][K] + dp[len(N)][1][K])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    int N;
    cin >> N;
    vi P(N);
    vi Q(N);
    in(N,P);in(N,Q);
    rep(i,N) P[i]--,Q[i]--;
    
    vector<int> c(N);
    rep(i,N) c[i] = i;
    int p=1,q=1;
    int ans_p,ans_q;
    do
    {
        int aa = 0;
        rep(i,N){
            if(c[i] != P[i]){
                aa = 1;
                break;
            }
        }
        if(aa == 1) p++;
        else ans_p = p;
        aa = 0;
        rep(i,N){
            if(c[i] != Q[i]){
                aa = 1;
                break;
            }
        }
        if(aa == 1) q++;
        else ans_q = q;
        
        
    } while (next_permutation(all(c)));
    

    cout << abs(ans_q-ans_p) << endl;

    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int D = A + B + C;

  cout << ((A * 2 == D || B * 2 == D || C * 2 == D) ? "Yes" : "No") << endl;
}

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

int main (){
	int H,W;
	while(true){
		cin >> H >>W;
		if(H==0 &&W==0) break;
		for(int i = 0;i<H;++i){
			if( i%2 == 0){
				for(int j=0;j<W;++j){
					if(j%2 == 0){
						cout <<"#";
					}
					else{
						cout <<".";
					}
				}
			}
			else {
				for(int j=0;j<W;++j){
					if(j%2 == 1){
						cout <<"#";
					}
					else{
						cout <<".";
					}
				}
			};
			cout << "\n";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1120
function Main(input) {
  var tmp = input.trim().split("\n");
  var XYZK = tmp[0].split(/\s/).map(val => parseInt(val, 10));
  var X = XYZK[0];
  var Y = XYZK[1];
  var Z = XYZK[2];
  var K = XYZK[3];
  var AAry = tmp[1].split(/\s/).map(val => parseInt(val, 10));
  var BAry = tmp[2].split(/\s/).map(val => parseInt(val, 10));
  var CAry = tmp[3].split(/\s/).map(val => parseInt(val, 10));

  AAry.sort((a, b) => b - a);
  BAry.sort((a, b) => b - a);
  CAry.sort((a, b) => b - a);

  var sumAry = [];
  var priorityQueue = new Map();

  priorityQueue.set("0,0,0", AAry[0] + BAry[0] + CAry[0]);

  for (var i = 0; i < K; i++) {
    var keyOfHighestVal = findKeyOfHighestValue(priorityQueue);
    sumAry.push(priorityQueue.get(keyOfHighestVal));
    priorityQueue.delete(keyOfHighestVal);

    var ary = keyOfHighestVal.split(",").map(val => parseInt(val, 10));
    var keyAry1Str = [ary[0] + 1, ary[1], ary[2]].join(",");

    if (
      !priorityQueue.has(keyAry1Str) &&
      (AAry[ary[0] + 1] && BAry[ary[1]] && CAry[ary[2]])
    )
      priorityQueue.set(
        keyAry1Str,
        AAry[ary[0] + 1] + BAry[ary[1]] + CAry[ary[2]]
      );
    var keyAry2Str = [ary[0], ary[1] + 1, ary[2]].join(",");
    if (
      !priorityQueue.has(keyAry2Str) &&
      (AAry[ary[0]] && BAry[ary[1] + 1] && CAry[ary[2]])
    )
      priorityQueue.set(
        keyAry2Str,
        AAry[ary[0]] + BAry[ary[1] + 1] + CAry[ary[2]]
      );
    var keyAry3Str = [ary[0], ary[1], ary[2] + 1].join(",");

    if (
      !priorityQueue.has(keyAry3Str) &&
      (AAry[ary[0]] && BAry[ary[1]] && CAry[ary[2] + 1])
    )
      priorityQueue.set(
        keyAry3Str,
        AAry[ary[0]] + BAry[ary[1]] + CAry[ary[2] + 1]
      );
  }
  for (var k = 0; k < sumAry.length; k++) {
    console.log(sumAry[k]);
  }
}

var findKeyOfHighestValue = map => {
  var highestValue = 0;
  var highestValueKey = null;
  map.forEach((val, key) => {
    if (highestValue < val) {
      highestValue = val;
      highestValueKey = key;
    }
  });

  return highestValueKey;
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 13124
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  int x = 1;
  int count = 0;
  for(int i=0; i<n; i++) {
    count++;
    if(v[x-1]==2) break;
    x = v[x-1];
  }
  if(count==n) cout << -1 << endl;
  else cout << count << endl;
  return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, l;
string s[105];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> l;
	FOR(i, n) cin >> s[i];
	sort(s, s+n);
	FOR(i, n) cout << s[i];
	cout << endl;
	return 0;
}

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

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> m(N);
	int minimum;
	int sum = 0;
	for(int i = 0; i < N; i++){
		cin >> m.at(i);
		sum += m.at(i);
		if(i == 0){
			minimum = m.at(i);
		}
		else{
			minimum = min(minimum, m.at(i));
		}
	}
	cout << N + (X - sum) / minimum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
    double n;
    cin >> n;
    cout << ceil(n/2);
}


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

using namespace std;

int main()
{
  int N;
  int C[500],S[500],F[500];
  cin>> N;
  for(int i=0;i<N-1;i++)cin>> C[i]>> S[i]>> F[i];

  for(int i=0;i<N;i++)
  {
    cerr<< "::"<< i<< endl;
    int ret=0;
    for(int j=i;j<N-1;j++)
    {
      if(ret<=S[j])ret=S[j];
      else if(ret%F[j])ret+=F[j]-ret%F[j];
      ret+=C[j];
      cerr<< ":"<< ret<< endl;
    }
    cout<< ret<< endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;

int main(){
  	ll N, A, B;
  	cin >> N >> A >> B;

  	if((B-A)%2==0){
  		cout << (B-A)/2 <<endl;
  		return 0;
  	}
  	ll ans = min(N-A, B-1);
 
 	ll a = min(A-1, N-B);
 	a += (B-A-1)/2 + 1;

 	ans = min(ans, a);

 	cout << ans <<endl;

  	//cout << min(100000000000000000-2, 99999999999999999) <<endl;    
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n,m;
    std::cin >> n>>m;
    n++;
    string s;
    std::cin >> s;
    std::vector<int>a(n);
    rep(i,n){
        int ii=s[n-1-i]-'0';
        a[i]=ii;
    }
    int no=0;
    std::vector<int> ans;
    while(no!=n-1){
        for (int i =min(m,n-no-1) ; i >= 1; i--) {
            if(a[no+i]==0){
                no+=i;
                ans.pb(i);
                break;
            }
            if(i==1){
                std::cout << -1 << std::endl;
                exit(0);
            }
        }
        
    }
    rep(i,ans.size())std::cout << ans[ans.size()-i-1] << std::endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> K(M), P(M);
    vector<int> S(M);
    int s;
    for ( int i = 0; i < M; i++ ) {
        cin >> K[i];
        for ( int j = 0; j < K[i]; j++ ) {
            cin >> s;
            S[i] |= 1 << (s-1);
        }
    }
    for ( int i = 0; i < M; i++ ) {
        cin >> P[i];
    }

    int NN = 1 << N;
    ll ans = 0;
    for ( s = 0; s < NN; s++ ) {
        bool on = true;
        for ( int j = 0; j < M; j++ ) {
            int x = s & S[j];
            int c = 0;
            while ( x != 0 ) {
                if ( x & 1 == 1 ) c++;
                x >>= 1;
            }
            if ( c % 2 != P[j] ) {
                on = false;
                break;
            }
        }
        if ( on ) ans++;
    }
    
    cout << ans << '\n';
    return 0;
}

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

int main() {
	
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	
	sort(l.begin(), l.end());
	
	ll ans = 0;
	for(int i = 0; i < n - 2; i++){
		for(int j = i + 1; j < n - 1; j++){
			for(int k = j + 1; k < n; k++){
				if(l[i] + l[j] > l[k]) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define mm (1e16)

ll Mod=(1e9+7);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b; cin>>a>>b;
    for(int i=0;;i++){
        if((a-1)*i+1 >= b){
            cout<<i;
            return 0;
        }
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans=0;
    for(int i=1;i<n;i++){
        int count=0;
        for(char c='a';c<='z';c++){
            bool left=false,right=false;
            for(int j=0;j<i;j++){
                if(s[j]==c){
                    left=true;
                }
            }
            for(int j=i;j<n;j++){
                if(s[j]==c){
                    right=true;
                }
            }
            if(left&&right){
                count++;
            }
        }
        ans=max(ans,count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int i,val,len;
	ll k;
	string s;
	cin>>s;
	cin>>k;
	len=s.length();
	rep(i,s.length()){
		if(s[i]!='1'){
			val=s[i]-'0';
			len=i;
			break;
		}
	}
	if(k<=len){
		cout<<1<<endl;
	}
	else{
		cout<<val<<endl;
	}
} 
	

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


int main() {
    int n; std::cin >> n;
    std::vector<int> weight(n), value(n);
    for (int i = 0; i < n; i++) {
        std::cin >> value[i] >> weight[i];
    }
    const int D = 9;
    const int B = 100000;
    auto chmax = [](int &a, int b) { return a = std::max(a, b); };
    std::vector<std::vector<int>>
        dp(1 << D, std::vector<int>(B + 2, -1e9));
    dp[0][0] = 0, dp[0][weight[0]] = value[0];
    for (int i = 1; i < std::min(1 << D, n); i++) {
        int par = (i - 1) / 2;
        for (int j = 0; j <= B; j++) {
            chmax(dp[i][j], dp[par][j]);
            if (j + weight[i] <= B)
                chmax(dp[i][j + weight[i]], dp[par][j] + value[i]);
        }
    }
    for (int i = 0; i < std::min(1 << D, n); i++) {
        for (int j = 0; j < B; j++) {
            chmax(dp[i][j + 1], dp[i][j]);
        }
    }
    int q; std::cin >> q;
    std::vector<std::pair<int, int>> buf;
    while (q--) {
        int v, lim; std::cin >> v >> lim;
        v--;
        buf.clear();
        while (v >= 1 << D) {
            buf.emplace_back(weight[v], value[v]);
            v = (v - 1) / 2;
        }
        int m = buf.size();
        int ans = 0;
        for (int i = 0; i < (1 << m); i++) {
            int wg = 0, vl = 0;
            for (int j = 0; j < m; j++) {
                if (~(i >> j) & 1) continue;
                wg += buf[j].first;
                vl += buf[j].second;
            }
            int targ = lim - wg;
            if (targ < 0) continue;
            chmax(ans, vl + dp[v][targ]);
        }
        std::cout << ans << std::endl;
    }
    return 0;
}


Measured memory_bytes: 206540
// Author : Parth Prajapati
// Institute : Pandit Deendayal Petroleum University
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/

int main()
{
	FASTIO
	//code
    int a,b;
    cin>>a>>b;
    if(a<10 && b<10)
    	cout<<a*b;
    else
    	cout<<"-1";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N,x;
  cin >> N >> x;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  ll ans = 0;
  ll pre = A.at(0);
  if(A.at(0)>x){
    ans+=A.at(0)-x;
    pre=x;
  }
  FOR(i,1,N){
    if(pre+A.at(i)>x){
      ans+=pre+A.at(i)-x;
      pre=x-pre;
    }else{
      pre=A.at(i);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
int n,i,ans=0;
char s[60];
scanf("%d",&n);
scanf("%s",s);
for (i=0;i<=strlen(s)-3;i++){
if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++; 
}
printf("%d",ans);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	ll cost[n];
	cost[0]=0;
	cost[1]=abs(arr[1]-arr[0]);
	for(ll i=2;i<n;i++)
		cost[i]=min(cost[i-1]+abs(arr[i]-arr[i-1]),cost[i-2]+abs(arr[i-2]-arr[i]));
	cout<<cost[n-1]<<endl;


}


Measured memory_bytes: 1792
from collections import defaultdict
d = defaultdict(int)
N=int(input())
s=input()
d[s]+=1
x=s[-1]
for i in range(N-1):
  s=input()
  if s[0]==x and d[s]==0:
    x=s[-1]
    d[s]+=1
  else:
    print('No')
    exit(0)
print('Yes')

Measured memory_bytes: 9412
S = int(input())  
    
if S == 10**18:
    X2 = 10**9
    Y3 = 10**9
    Y2 = 0
    X3 = 0
elif S > 10**9:
    r = 10**9 - (S % 10**9)
    Y2 = r
    X3 = 1
    S += r
    X2 = S //10**9
    Y3 = 10**9
else:
    Y2 = 0
    X3 = 0
    X2 = S
    Y3 = 1

        
print(0, 0, X2, Y2, X3, Y3)

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

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;

    rep(i,n) {
        string subs = s.substr(i, n-i);
        string subt = t.substr(0, n-i);
        if (subs == subt) {
            cout << n + i << endl;
            return 0;
        }
    }

    cout << 2*n << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>

int main(){
    int i;
    int count[1000]={0};
    char ch;
    
    while(std::cin>>ch){
        count[ch]++;
    }

    char moji='a';
    for(i=97;i<=122;i++){
        std::cout<<moji<<" : "<<count[i]+count[i-32]<<std::endl;
        moji++;
    }

    return 0;
}



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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()

{

    ll a,b,c, k;
    cin >> a >> b >> c >> k;
    vector<ll> v;
    v.pb(a), v.pb(b), v.pb(c);
    sort(all(v));
    ll x = v[2];
    for(ll i = 0; i < k; i++) x*=2;
    cout << x+v[0]+v[1];
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<string>
using namespace std;

int main(){
    int n, k;
    cin >> k >> n;
    if (k < 10)
        cout << n + 100 * (10 - k) << endl;
    else cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    //cin.ignore();
    cin>>s1;
    if(s1.size()<=n)
    {
        cout<<s1<<endl;
    }
    else{

        s2=s1.substr(0,n);
        cout<<s2<<"..."<<endl;

    }


}


Measured memory_bytes: 3652
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int n;cin>>n;
    REP(i,n){
        int cnt=0;
        for(int x=0; x<100; x++) for(int y=x; y<100; y++) for(int z=y; z<100; z++){
            int reg=(x+1)*(x+1) + (y+1)*(y+1) + (z+1)*(z+1) + (x+1)*(y+1) + (y+1)*(z+1) + (z+1)*(x+1);
            if(reg > i+1) break;
            if(reg == i+1){
                if((x==y) && (y==z) && (z==x)) cnt++;
                else if((x!=y) && (y!=z) && (z!=x)) cnt += 6;
                else cnt += 3;
            }
        }
        cout << cnt << endl;
    }
}

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


int N, Ma, Mb;
int dp[50][410][410] = {};

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

    int A[50] = {}, B[50] = {}, C[50] = {};
    for (int i=1; i<=N; i++) cin >> A[i] >> B[i] >> C[i];

    const int INF = 100000000;
    rep(i, 50) rep(a, 410) rep(b, 410) dp[i][a][b] = INF;

    dp[0][0][0] = 0;
    for (int i=1; i<=N; i++) {
        for (int ma=0; ma<=400; ma++) {
            for (int mb=0; mb<=400; mb++) {
                dp[i][ma][mb] = dp[i-1][ma][mb];
                if ((ma>=A[i]) && (mb>=B[i])) {
                    dp[i][ma][mb] = min(dp[i][ma][mb], dp[i-1][ma-A[i]][mb-B[i]] + C[i]);
                }
            }
        }
    }

    int ans = INF, k=1;
    while ((Ma*k <=400) && (Mb*k <=400)) {
        ans = min(ans, dp[N][Ma*k][Mb*k]);
        k++;
    }

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

    return 0;
}

 

Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S , T;
  cin >> S >> T; 
  for(int i = 0; i < S.size(); i++){
    if(S.at(i)!= T.at(i)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long[] a = new long[n];
		long z = scanner.nextLong();
		long w = scanner.nextLong();

		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextLong();
		}
		if(n>=2) {
			System.out.println(Math.max(Math.abs(a[n - 1] - w), Math.abs(a[n - 2] - a[n - 1])));
		}else{
			System.out.println(Math.abs(a[0] - w));
		}
	}
}

Measured memory_bytes: 26964
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n, m; cin >> n >> m;
	vector<p> a(m);
	vector<int> broke;
	rep(i, m) {
		int p1, p2; cin >> p1 >> p2;
		p1--; p2--;
		a[i] = { p2,p1 };
	}
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i, m) {
		bool flag = false;
		rep(j, broke.size()) {
			if (broke[j] < a[i].first&&broke[j] >= a[i].second) flag = true;
		}
		if (!flag) {
			ans++;
			broke.push_back(a[i].first - 1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

int main() {
  int a,b;
  cin >> a;
  int sum=0;
  for(int i =1; i<=a; i++){
    for(int j=1; j<=a; j++){
      for(int z=1; z<=a; z++){
        b=gcd(i,j);
        sum+=gcd(b,z);
        }
      }
    }
  cout <<sum <<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    int d;
    REP(i, 100){
        if(N <= bit(i)){
            d = i;
            break;
        }
    }
    if(N == bit(d)){
        Out("No");
        return 0;
    }

    //N>=3
    pairs ans;
    ans.pb(Pii(1, 3));
    ans.pb(Pii(3, 2));
    ans.pb(Pii(2, 1 + N));
    ans.pb(Pii(1 + N, 3 + N));
    ans.pb(Pii(3 + N, 2 + N));

    for(int i = 4; i <= N; i += 2){
        if(i < N){
            ans.pb(Pii(i, 1));
            ans.pb(Pii(i + 1, 1));
            ans.pb(Pii(i + N, i + 1));
            ans.pb(Pii(i + N + 1, i));
        }else{
            int k = N ^ bit(d - 1) ^ 1;
            ans.pb(Pii(N, bit(d - 1)));
            ans.pb(Pii(N + N, k));
        }
    }

    Out("Yes");
    REP(i, 2 * N - 1) cout << ans[i].f << " " << ans[i].s << endl;

    return 0;
}


Measured memory_bytes: 5872
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {

	int a, b;
	cin >> a >> b;
	if (a <= b) {
		a++;
	}
	cout << a-1 << endl;
}


Measured memory_bytes: 256