akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
using namespace std;

struct Card{
    char mark;
    int num;
};

void merge(struct Card *card, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;

    struct Card L[n1 + 1];
    for(int i = 0; i < n1; i++){
        L[i].mark = card[left + i].mark;
        L[i].num = card[left + i].num;
    }
    struct Card R[n2 + 1];
    for(int i = 0; i < n2; i++){
        R[i].mark = card[mid + i].mark;
        R[i].num = card[mid + i].num;
    }

    L[n1].num = 1000000001;
    R[n2].num = 1000000001;

    int i = 0;
    int j = 0;
    int k = 0;
    for(k = left; k < right; k++){
        if(L[i].num <= R[j].num){
            card[k].mark = L[i].mark;
            card[k].num = L[i].num;
            i++;
        }else{
            card[k].mark = R[j].mark;
            card[k].num = R[j].num;
            j++;
        }
    }
}

void mergeSort(struct Card *card, int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(card, left, mid);
        mergeSort(card, mid, right);
        merge(card, left, mid, right);
    }
}

int partition(struct Card *card, int p, int r){
    int x = card[r].num;
    int i = p - 1;
    for(int j = p; j < r; j++){
        if(card[j].num <= x){
            i++;
            swap(card[i], card[j]);
        }
    }
    swap(card[i + 1], card[r]);
    return i + 1;
}

void quickSort(struct Card *card , int p, int r){
    if(p < r){
        int q = partition(card, p, r);
        quickSort(card, p, q - 1);
        quickSort(card, q + 1, r);
    }
}

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

    struct Card card[100000];
    for(int i = 0; i < n; i++){
        char S[10];
        scanf("%s %d", S, &card[i].num);
        card[i].mark = S[0];
    }

    struct Card card_copy[100000];
    for(int i = 0; i < n; i++){
        card_copy[i].mark = card[i].mark;
        card_copy[i].num = card[i].num;
    }

    quickSort(card, 0, n - 1);
    mergeSort(card_copy, 0, n);

    bool is_stable = true;
    for(int i = 0; i < n; i++){
        if(card[i].num != card_copy[i].num || card[i].mark != card_copy[i].mark){
            is_stable = false;
            break;
        }
    }

    if(is_stable){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }

    for(int i = 0; i < n; i++){
        printf("%c %d\n", card[i].mark, card[i].num);
    }
}




Measured memory_bytes: 5528
#include<iostream>
using namespace std;
int a[1000][1000];
int n,m,x,y,p,q;
main()
{
	while(cin>>n>>m>>p>>q,n)
	{
		x=y=0;
		for(int i=0;i<1000;i++)for(int j=0;j<1000;j++)a[i][j]=0;
		for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[i][j]=1;
		for(;p--;)
		{
			int d,c;cin>>d>>c;
			if(d==2)
			{
				for(int i=0;i<1000;i++)
				{
					for(int j=0;j<c;j++)a[i][y+2*c-j-1]+=a[i][y+j];
				}
				y+=c;
			}
			else
			{
				for(int j=0;j<1000;j++)
				{
					for(int i=0;i<c;i++)a[x+2*c-i-1][j]+=a[x+i][j];
				}
				x+=c;
			}
		}
		for(;q--;)
		{
			int A,b;cin>>A>>b;
			cout<<a[x+A][y+b]<<endl;
		}
	}
}


Measured memory_bytes: 6916
#include<bits/stdc++.h>
#define MAX_N 200005
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(V) (V).begin(),(V).end()
#define reset(V) (V).clear();(V).resize(0);
#define sq(x) ((x)*(x))
#define abs(x) ((x)>0?(x):(-(x)))
#define fi first
#define se second
#define inf 0x3fffffff
#define full_inf 0x7fffffff
#define half_inf 0x3fffffff
//#define inf 0x3fffffff
#define MOD 1000000007LL
#define cpx_mod(x) (((LD)(((LL)x.real())%MOD)),((LD)(((LL)x.imag())%MOD)))
#define prev(x) (((x)+n-1)%n)
#define next(x) (((x)+1)%n)
#define mod(x) (((x)%h + h)%h)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pil;
typedef pair<LL,string> pls;
typedef complex<LD> Complex;
LL n,m;
int main(){
	scanf("%lld %lld",&n,&m);
	if(n == 1 || m == 1)	return !printf("1\n");
	printf("%lld\n",(n/2 + n%2) * (m/2 + m%2) + (n/2) * (m/2));
	return 0;
}	

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

vector<ll> D;
void D_Listed(ll n){
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			D.push_back(i);
			if(i*i!=n)D.push_back(n/i);
		}
	}
	sort(D.begin(),D.end());
}

int main(){
	ll n,m;
	cin>>n>>m;
	D_Listed(m);
	for(auto x:D){
		if(n<=x){
			cout<<m/x<<endl;
			return 0;
		}
	}
	return 0;
}
//h[i]=H-abs(Cx-x[i])+abs(Cy-y[i])
//H=h[i]+abs(Cx-x[i])+abs(Cy-y[i])

Measured memory_bytes: 256
N,M=map(int,input().split())
requires=[]
for i in range(M):
    requires.append(list(map(int,input().split())))
sorted_requires=sorted(requires,key=lambda x:x[1])

broken_bridges=[0]
for sorted_require in sorted_requires:
    if max(broken_bridges) >sorted_require[0]:
        continue
    else:
        broken_bridges.append(sorted_require[1])

ans=len(broken_bridges)-1
print(ans)


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

int main() {
    int n;
    while(cin >> n, n){
        string s;
        cin >> s;
        int cnt[15]{}, a=0;
        for(int i=0;i<100;i++){
            cnt[i%n]++;
            if(s[i]=='S'){
                a += cnt[i%n];
                cnt[i%n] = 0;
            }
            else if(s[i]=='L'){
                cnt[i%n] += a;
                a = 0;
            }
        }
        sort(cnt, cnt+n);
        for(int i=0;i<n;i++){
            cout << cnt[i] << " ";
        }
        cout << a << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vll;

ll N,arr[200002];

int main(){
	cin>>N;
	for(int i=0; i<N; i++)cin>>arr[i];
	sort(arr,arr+N);
	ll total=0;
	for(int i=0; i<N; i++){
		if(i!=0){
			total+=arr[N-1-i/2];
		}
	}
	cout<<total<<'\n';
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K,sum;
  cin >> N >> K;
  sum = 1;
  for (int i = 0; i < N; i++){
   if( sum+K < sum*2 )
     sum += K;
   else if(sum*2 <= sum + K)
     sum *= 2;
  }
  cout << sum << endl;
}
       



Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 1005,M = 2005;
ll n,m;
set<ll> nc;
ll cur;
ll glo=0;
vvi graph(N);
vi vis(N,0);
set< ll > cycle;

void dfs(ll u,ll s)
{
	nc.insert(u);
	vis[u]=1;
	cur++;
	rep(i,0,sz(adj[u]))
	{
		ll ch = adj[u][i];
		// whatis(ch);
		if(ch==s && (cur<glo || glo==0)) cycle = nc,glo=cur;
		if(vis[ch]==0) dfs(ch,s);
	}
	nc.erase(u);
	cur--;
	return ;
}

int solve()
{
	cin>>n>>m;
	rep(i,0,m)
	{
		ll x,y;cin>>x>>y;
		x--,y--;
		adj[x].pb(y);
	}

	rep(i,0,n)
	{
		cur=0;
		nc.clear();
		rep(j,0,n) vis[j]=0;
		dfs(i,i);
	}

	if(sz(cycle)==0) cout<<"-1\n";
	else
	{
		cout<<sz(cycle)<<"\n";
		all(it,cycle) cout<<*it+1<<"\n";
	}
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int len=s.size();
int a[300] = {0};
for(int i=0;i<len;i++)
{
a[s[i]]=1;
}
if(a['N']!=a['S'])
puts("No");
else if(a['W']!=a['E'])
puts("No");
else 
puts("Yes");
return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
  if(A==B&&B==C) cout << YES << endl;
  else cout << NO << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,q;
	scanf("%d",&n);   scanf("%d",&q);
	
	char qname[n][11];
	int qtime[n];
	int next[n];
	int start=0,end=n-1;
	int tcount=0;
	
	int i;
	scanf("%s",qname[0]);   scanf("%d",&qtime[0]);
	for(i=1;i<n;i++){
		scanf("%s",qname[i]);   scanf("%d",&qtime[i]);
		next[i-1]=i;
		
		//printf("%s\n",qname[i]);
	}
	next[n-1]=-1;
	
	while(start!=-1){
		if(qtime[start]>q){
			qtime[start]-=q;
			next[end]=start;
			end=start;
			start=next[start];
			next[end]=-1;
			tcount+=q;
		}else{
			tcount+=qtime[start];
			printf("%s %d\n",qname[start],tcount);
			start=next[start];
		}
	}		
	return 0;
}


Measured memory_bytes: 2628
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int a, b, c;
	int m,mi;
	int k;

	cin >> a >> b >> c;
	cin >> k;


	m = a;
	mi = b + c;

	if (m < b) {
		m = b;
		mi = a + c;
	}
	if (m < c) {
		m = c;
		mi = a + b;
	}

	rep(k) {
		m *= 2;
	}

	cout << m + mi;

	return 0;
}

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

#define M 1000005
#define L 14

char H[M][L];

int gtchar(char m){
    if(m=='A')return 1;
    else if(m=='C')return 2;
    else if(m== 'G')return 3;
    else if(m== 'T')return 4;
    else return 0;
}

int h1(int key){
    return key % M;
}

int h2(int key){
    return (key % (M-1)) + 1;
}

long long gtkey(char m[]){
    long long total = 0, p=1,i;
    for(i=0;i<strlen(m);i++){
        total += p * gtchar(m[i]);
        p *=5;
    }
    return total;
}


int insert(char m[]){
    long long key,i,h;
    key = gtkey(m);
    for(i=0;;i++){
        h=(h1(key) + i * h2(key))%M;
        if( strcmp(H[h],m) == 0)return 1;
        else if( strlen(H[h]) == 0) {
            strcpy(H[h],m);
            return 0;
        }
    }
    return 0;
}

int find(char m[]){
    long long key,i,h;
    int ct=0,j;
    key=gtkey(m);
    for(i=0;;i++){
        h=(h1(key) + i * h2(key)) %M;
        if(strcmp(H[h],m)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}

int main(void){
    int i,n,ct=0;
    char com[9],m[L],ans[M][4];
    for(i=0;i<M;i++)H[i][0] = '\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s%s",com,m);
        if(com[0]=='i'){
            insert(m);
        }
        else if(find(m)==1){
            strcpy(ans[ct],"yes");
            ct++;
            continue;
        }
        else {
            strcpy(ans[ct],"no");
            ct++;
            continue;
        }
    }
    for(i=0;i<ct;i++){
        printf("%s\n",ans[i]);
    }
    return 0;
}



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

using namespace std;

int main() {
  int n; cin >> n;
  vector <int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sw = 1;
  for(int k = 0; k < n - 1; k++) {
        if(a[k + 1] < a[k]) {
          sw = 0;
          break;
        }
      }
      if(sw) {
        puts("YES");
        return 0;
      }
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      swap(a[i], a[j]);
      sw = 1;
      for(int k = 0; k < n - 1; k++) {
        if(a[k + 1] < a[k]) {
          sw = 0;
          break;
        }
      }
      if(sw) {
        puts("YES");
        return 0;
      }
      swap(a[i], a[j]);
    }
  }
  puts("NO");
}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    cout << max(A - 2 * B,0LL);

    return 0;
}

Measured memory_bytes: 3152
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))

from itertools import combinations
import math

def main():
    n, d = Input()
    x = [mapt(int, input().split()) for _ in range(n)]
    # print(x)
    comb = list(combinations(x,2))
    # print(comb)
    ans = 0
    for a, b in comb:
        r = 0
        for y, z in zip(a, b):

            r += abs(y-z)**2
            # print(y, z)
        r = math.sqrt(r)
        if (r*2)%2==0:
            ans += 1
    print(ans)

main()

Measured memory_bytes: 9264
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	LL N, K;
	scanf("%lld%lld", &N, &K);
	N %= K;
	printf("%lld\n", min(N, K - N));
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = 0;
		
		char[] s2 = S.toCharArray();
		char[] t2 = T.toCharArray();
		
		for (int i = 0 ; i < s2.length; i++)
		{
			if (s2[i]!=t2[i])
			{A++;}
			
		}
		
		
		System.out.println(A);
   
        }
		
	}

Measured memory_bytes: 41852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007 
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
vector<bool> IsPrime;
ll flag=0;
ll N;
vector<ll>A;
vector<ll>P;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
map<ll,ll>m;
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        if(m[a]==1){
            flag=1;
        }
        m[a]=1;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
        
    }

    // 最後に残った数について
    
    if (N != 1){
        if(m[N]==1){
        flag=1;
        }
        m[N]=1;
        res.push_back({N, 1});
    } 
    return res;
}
int main() {
    
    cin >>N;
    A.resize(N);
    
    rep(i,N){
        cin>>A[i];
    }
    sort(all(A));
    //sieve(1000050);

    /*rep(i,1000050){
        if(IsPrime(i)){
            P.pb(i);
        }
    }*/

    ll agcd=A[0];
    rep(i,N){
        prime_factorize(A[i]);
        if(flag==1){
            break;
        }
        
    }
    rep2(i,N-1){
        agcd=gcd(agcd,A[i]);
  
    
    }
    if(flag==0){
        cout<<"pairwise coprime"<<endl;
    }else if(agcd==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 11192
#include <iostream>
    #include <algorithm>
    using namespace std;
    using ll = long long;
     
    int main() {
        ll X, K, D;
        cin >> X >> K >> D;
        X = abs(X);
     
        ll straight = min(K, X / D);
        K -= straight;
        X -= straight * D;
     
        if (K % 2 == 0) {
            cout << X << endl;
        } else {
            cout << D - X << endl;
        }
     
        return 0;
    }

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


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

    string ans;
    bool f = true;

    while (true) {
        ans += 'a' + (n % 26);
        n /= 26;
        if (n == 0)
            break;
        n--;
    }

    reverse(rng(ans));
    prt(ans);

    return 0;
}


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

int main(){
    int N;  cin >> N;
    vector<vector<int>> hap;
    hap = vector<vector<int>>(N+1, vector<int>(3, 0));
    for(int i=1; i<=N; i++) cin >> hap[i][0] >> hap[i][1] >> hap[i][2];
    
    vector<vector<int>> dp;
    dp = vector<vector<int>>(N+1, vector<int>(3, 0));
    for(int i=1; i<=N; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(j != k){
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + hap[i][j]);
                }
            }
        }
    }

    int ans = 0;
    for(int i=0; i<3; i++) ans = max(ans, dp[N][i]);
    cout << ans << endl;
}

Measured memory_bytes: 11152
#include <iostream>
using namespace std;
int a[101];
int main()
{
	int n,x;
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>x;
		a[x]=1;
	}
	int s=0;
	for(int i=1; i<=100; i++){
		if(a[i]==1){
			s++;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a = 0 ;
	int b = 0 ;
	
	scanf("%d",&a);
	scanf("%d",&b);	
	
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
n = int(input())
k = int(input())
x = [int(i) for i in input().split()]

ans = 0

for i in range(n):
  if abs(x[i]) >= abs(k-x[i]):
    ans += abs(k-x[i])*2
    
  else:
    ans += abs(x[i])*2
    
print(ans)



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

int W, H, x, y;
int main() {
    cin >> W >> H >> x >> y;

    int pat = 0;
    double a, b;
    a = W / 2.0;
    b = H / 2.0;
    if (a == x && b == y) pat = 1;
    // cout << pat << endl;

    printf("%.10f %d\n", double(W) * double(H) / 2, pat);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	char c; cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' ||c== 'o' || c == 'e')
		cout << "vowel\n";
	else
		cout << "consonant\n";
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int m;
    
    while(true){
        cin >> m;
        if(m == 0) break;
        
        int o; //おつり
        o = 1000 - m;
        int count = 0;
        if(o >= 500){
            count = count + o / 500;
            o = o % 500;
            if(o >= 100){
                count = count + o / 100;
                o = o % 100;
            }
            if(o >= 50){
                count = count + o / 50;
                o = o % 50;
            }
            if(o >= 10){
                count = count + o / 10;
                o = o % 10;
            }
            if(o >= 5){
                count = count + o / 5;
                o = o % 5;
            }
            count = count + o;
            cout << count << endl;
        }
       
        
        else if(o >= 100 && o < 500){
            
            count = count + o / 100;
            o = o % 100;
            
            if(o >= 50){
                count = count + o / 50;
                o = o % 50;
            }
            if(o >= 10){
                count = count + o / 10;
                o = o % 10;
            }
            if(o >= 5){
                count = count + o / 5;
                o = o % 5;
            }
            count = count + o;
            cout << count << endl;
        }
        
        
        else if(o >= 50 && o < 100){
            
            count = count + o / 50;
            o = o % 50;
            
            if(o >= 10){
                count = count + o / 10;
                o = o % 10;
            }
            if(o >= 5){
                count = count + o / 5;
                o = o % 5;
            }
            count = count + o;
            cout << count << endl;
        }
        
        
        else if(o >= 10 && o < 50){
            
            count = count + o / 10;
            o = o % 10;
            if(o >= 5){
                count = count + o / 5;
                o = o % 5;
            }
            count = count + o;
            cout << count << endl;
        }
        
        else if(o >= 5 && o < 10){
            count = count + o / 5;
            o = o % 5;
            count = count + o;
            cout << count << endl;
        }
        
        else{
            count = count + o;
            cout << count << endl;
        }
    }
}



Measured memory_bytes: 2964
#include "bits/stdc++.h"
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cout << #x << " : " << (x) << " --------------" << endl;
using namespace std;

int main(void){
    int e;
    while (cin >> e, e) {
        int m = 1000000;
        for (int z = 100; z >= 0; --z) {
            int val = z * z * z;
            if (val > e) continue;
            int y = sqrt(e-val);
            m = min(m, (e - val - y * y) + y + z);
        }
        cout << m << endl;
    }
    return EXIT_SUCCESS;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

//???
class Point
{
    public:
    double x,y;

    Point(double x=0, double y=0): x(x), y(y) {}

    Point operator + (Point p)
    {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p)
    {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (double a)
    {
        return Point(a*x,a*y);
    }

};

//????????????
typedef Point Vector;

//??????
struct Segment
{
    Point p1,p2;
};

double dist(Point p0, Point p1)
{
    return sqrt((p0.x-p1.x)*(p0.x-p1.x) + (p0.y-p1.y)*(p0.y-p1.y));
}

//??????
double dot(Vector a, Vector b)
{
    return a.x*b.x+a.y*b.y;
}

//??????
double cross(Vector a, Vector b)
{
    return a.x*b.y-a.y*b.x;
}

double EPS=1e-9;

double norm(Vector a)
{
    return a.x*a.x+a.y*a.y;
}

int ccw(Point p0, Point p1, Point p2)
{
    Vector a=p1-p0, b=p2-p0;
    if(cross(a,b)>EPS) return 1;
    if(cross(a,b)<-EPS) return -1;
    if(dot(a,b)<-EPS) return 2;
    if(norm(a)<norm(b)) return -2;

    return 0;
}

//????????????
bool intersect(Point p1, Point p2, Point p3, Point p4)
{
    return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
bool intersect(Segment s1, Segment s2)
{
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

Point getCrossPoint(Segment s1, Segment s2)
{
    Vector base=s2.p2-s2.p1;
    double d1=fabs(cross(base, s1.p1-s2.p1));
    double d2=fabs(cross(base, s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}


//?§??????????????????¢,?????¶or??°???(0/1)
typedef pair<double,int> P;

int main()
{
    int t;
    cin >>t;
    rep(T,t)
    {
        Segment newline;
        cin >>newline.p1.x >>newline.p1.y >>newline.p2.x    >>newline.p2.y;

        int n;
        cin >>n;

        vector<Segment> line(n);
        vector<int> o(n),l(n);
        rep(i,n) cin >>line[i].p1.x >>line[i].p1.y >>line[i].p2.x >>line[i].p2.y >>o[i] >>l[i];

        //cross points
        vector<P> cps;

        //i???????????????????????????
        rep(i,n)
        {
            //??°????????¨????????????????????????
            if(intersect(newline,line[i]))
            {
                Point cp=getCrossPoint(newline,line[i]);
                cps.pb(P(dist(newline.p1,cp),(o[i]==l[i])));
            }
        }

        sort(all(cps));

        int ans=0;
        if(cps.size()>0)
        {
            rep(i,cps.size()-1)
            {
                if(cps[i].se!=cps[i+1].se) ++ans;
            }
        }

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

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

int N, K; cin >> N >> K;
VI x(N), y(N); 
rep(i, 0, N) {
    cin >> x[i] >> y[i];
}
VI X = x, Y = y;
sort(ALL(X));
sort(ALL(Y));

i64 ans = (X[N-1] - X[0]) * (Y[N-1] - Y[0]);

rep(xi, 0, N) rep(xj, xi + 1, N) rep(yi, 0, N) rep(yj, yi + 1, N){
    int num = 0;
    i64 lx = X[xi], rx = X[xj];
    i64 by = Y[yi], uy = Y[yj];

    rep(i, 0, N){
        if (lx <= x[i] && x[i] <= rx && by <= y[i] && y[i]<= uy)
            ++num;
    }
    if (num >= K) ans = min(ans, (rx - lx) * (uy - by));
}


cout << ans << "\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int sum = 0;
    for (int i = 0; i < N;) {
        int res = 0;
        for (int j = i; j < N; j++) {
            if (vec.at(i) == vec.at(j) && j != N - 1) {
                res++;
            }
            else if (vec.at(i) == vec.at(j) && j == N - 1) {
                res++;
                sum += res / 2;
            }
            else {
                sum += res / 2;
                break;
            }
        }
        i += res;
    }
    cout << sum << endl;
}

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

using namespace std;

int main (){

int total, k;

cin >> total;
cin >> k;

int arr [total];

for(int i = 0; i<total; i++){
    cin>> arr[i];
}

sort(arr,arr+total);

int sum = 0;
for(int i = 0; i<k; i++) {
    sum += arr[i];
}

cout << sum;
    
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; ll K; cin >> N >> K; ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  ll X = 0;
  rep(i, 41){
    int cnt=0;
    rep(j, N){
      if((1LL<<(40-i))&a[j]) cnt++;
    }
    if(cnt<(N+1)/2 && X+(1LL<<(40-i))<=K){
      X+=(1LL<<(40-i));
    }
  }
  //cout << X << endl;
  ll ans=0;
  rep(i, N){
    ans+=a[i]^X;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = nm[0];
        int m = nm[1];
        //累積取って、余りの個数
        Dictionary<long, long> dict = new Dictionary<long, long>();
        dict.Add(0, 1);
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long ruiseki = 0;
        for (int i = 0; i < n; i++)
        {
            ruiseki += a[i];
            if (!dict.ContainsKey(ruiseki % m))
            {
                dict.Add(ruiseki % m, 0);
            }
            dict[ruiseki % m]++;
        }
        long res = 0;
        foreach (var val in dict.Values)
        {
            res += (val - 1) * val;
        }
        Console.WriteLine(res / 2);
    }
}

Measured memory_bytes: 21856
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  int price[n];
  int i;
  int max;
  int ans = 0;
  for(i = 0;i < n;++i){
    cin >> price[i];
  }
  max = price[0];
  for(i = 0;i < n;++i){
    if(price[i] > max){
      max = price[i];
    }
    ans += price[i];
  }
  ans -= max/2;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
    long long count = 0;
    string s;
    cin >> s;
    long long len = s.size();
    for(int i = 0;i < len;i++){
        count += s.at(i) - '0';
    }
    if(count % 9 == 0)
        cout << "Yes";
    else
        cout << "No";
}





Measured memory_bytes: 3716
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
     while(cin>>x>>y)
     {
         if(x+y>=10) cout<<"error"<<en;
         else cout<<x+y<<en;
     }
}



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

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

	int ans = 0;

	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (500 * i + 100 * j + 50 * k == X)ans++;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3540
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
for i in range(d):
	s.append(l())
day = [0 for i in range(26)]
su = 0
for i in range(1,d+1):
	ppp = onem()
	su += s[i-1][ppp-1]
	day[ppp-1] = i
	for j in range(26):
		su -= c[j] * (i-day[j])
	print(su)


Measured memory_bytes: 68704
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
int mul(int x, int y) { return 1ll * x * y % mod; }
void sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
string s;
int n, cnt[26];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	fw (i, 0, n) cnt[s[i] - 'a']++;
	int ans = 1;
	fw (i, 0, 26) ans = mul(ans, cnt[i] + 1);
	sub(ans, 1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1100
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    ans = 0
    a_ = int(input())
    if a_ != 0:
        print(-1)
        return True
    for n in range(N-1):
        a = int(input())
        if a - a_ > 1:
            print(-1)
            return True
        if a - a_ == 1:
            ans += 1
            a_ = a
        else:
            ans += a
            a_ = a
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9204
#親要素を示す
par = {}
size_list = []

# 初期化 -- すべての要素が根である --
def init(n):
    for i in range(n):
        par[i] = i
        size_list.append(1)
    return 

# 根を求める
def root(x):
    if par[x] == x:
        return x
    else:
        #根の直下にxを置く
        par[x] = root(par[x])
        return par[x]

#　同じ集合に属するかどうかは根が同じかで判定
def same(x, y):
    return root(x) == root(y)

#　別々のUnion同士を融合する
def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    else:
        par[x] = y
        size_list[y] += size_list[x]
        size_list[x] = 0
        return


N, M = map(int, input().split())
init(N)
for mi in range(M):
    a, b = map(int, input().split())
    unite(a-1,b-1)
print(max(size_list))

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long K, std::string S) {}

int main() {
    long long K;
    scanf("%lld", &K);
    std::string S;
    std::cin >> S;
    if (S.size() <= K) {
        cout << S << endl;
    }

    else {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3692
import numpy as np

N, K = (int(i) for i in input().split())
x = np.sort(np.array([int(i) for i in input().split()]))

result = []
if(N==1):
    print(np.abs(x[0]))

else:
    for i in range(N - K + 1):
        left = x[i]
        right = x[i + K - 1]

        if (left * right < 0):
            if (np.abs(left) < np.abs(right)):
                diff = np.abs(left) * 2 + np.abs(right)
            else:
                diff = np.abs(left) + np.abs(right) * 2

        else:
            diff = np.max([np.abs(left), np.abs(right)])

        result.append(diff)

    print(np.min(result))


Measured memory_bytes: 23120
use proconio::input;
use proconio::marker::Chars;


fn main() {

    input!{
        mut S:Chars,
        mut K:usize,
    }

    let N = S.len();

    for i in 0..N{
        let s = S[i];
        let k = ('a' as usize +26 - s as usize) % 26;
        if K >= k{
            K -= k;
            S[i] = 'a';
        }
    }
    K %= 26;
    S[N-1] = ((S[N-1] as u8 - 'a' as u8 + K as u8)%26 + 'a' as u8) as char;
    
    let ans = Chars2String(&S);
    println!("{}",ans);
}

fn Chars2String(C:&Vec<char>) -> String{
    let mut ret = String::new();
    for &c in C {ret.push(c);}
    ret
}

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

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

using pii = pair<int, int>;

double kyori(pii x, pii y) {
  return sqrt(pow(x.first - y.first, 2) + pow(x.second - y.second, 2));
}

inline void Main() {
  // code
  int n,r=1;
  string s;
  cin>>n>>s;
  repi(i,1,n) {
    if(s.at(i-1) != s.at(i)) {
      r++;
    }
  }
  cout<<r<<endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{   
    int n,m;
    scanf("%d%d",&n,&m);
    int flag[100000]={1},number[100000]={0};
    for(int i=0;i<n;i++){
        number[i]++;
        //printf("num%d=%d\n",i,number[i]);
    }
    int x[m],y[m];
    for(int i=0;i<m;i++){
        scanf("%d%d",&x[i],&y[i]);
        number[(x[i]-1)]--;
        if(flag[(x[i]-1)]==1){
            flag[(y[i]-1)]=1;
        }
        if(number[(x[i]-1)]==0){
            flag[(x[i]-1)]=0;
        }
        number[(y[i]-1)]++;
        
    }
    int ans=0;
    for(int i=0;i<n;i++){
        //printf("number%d=%d flag%d=%d\n",i,number[i],i,flag[i]);
        if(flag[i]==1)ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1664
import java.util.*;
// cin=sc.nextInt();
// List<Integer> a = new ArrayList<Integer>(n);
 
public class Main {
    public static void main(String args[]){
		    Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int t = n/100;
            int s = n%100;
            int u = s/5;
            if(s%5!=0){
                u++;
            }
            int ans = (t>=u) ? 1 : 0;
            System.out.println(ans);

	}
}


Measured memory_bytes: 23764
N, L = map(int, input().split())

taste = [0] * N
for i in range(N):
    taste[i] = L+i

taste.sort()
ans = 0
if 0 in taste:
    ans = sum(taste)
elif taste[0] > 0:
    ans = sum(taste) - taste[0]
else:
    ans = sum(taste) - taste[-1]

print(ans)


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

int main (){
  int H1, M1, H2, M2, K;

  cin >> H1 >> M1 >> H2 >> M2 >> K ;

  int L = H2 * 60 + M2;
  int W = H1 * 60 + M1;

  int time = L - K;
  int ans = time - W;
  cout << ans;    
}


Measured memory_bytes: 3632
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = (ll)1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;
[[maybe_unused]] static constexpr double e = 2.71828182846;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a, b) for (ll i = a; i < b; ++i)
#define rrrep(i, a, b) for (ll i = a; i >= b; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second



int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    int cnt0 = 0, cnt1 = 0;
    for (char c : S) {
        if (c == '0') ++cnt0;
        else ++cnt1;
    }
    cout << S.size() - abs(cnt0 - cnt1) << endl;
}


Measured memory_bytes: 512
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
l = list(map(int, input().split()))
l.sort()
if len(l)%2==1:
    l = l[1:]
ans = 0
ans = sum(l[::2])
print(ans)

Measured memory_bytes: 62072
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
    long long  int n,a,b=0,i,j,k;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            for(k=1; k<=n; k++)
            {
            b=b+__gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<b<<endl;

}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
x = 'Y'
num = -1
while x == 'Y':
    l = []
    num += 1
    for i in a:
        if i%2 == 0:
            l.append(i//2)
        else:
            x = 'N'
            break
    a = l
print(num)

Measured memory_bytes: 9112
# Problem D - Megalomania

# input
N = int(input())

# initialization
cost_list = []
for i in range(N):
    A, B = map(int, input().split())
    cost_list.append([A, B])
cost_list.sort(key=lambda x: x[1])
time_cost = 0

# time count
is_ok = True
for c in cost_list:
    A = c[0]
    B = c[1]
    time_cost += A
    if time_cost>B:
        is_ok = False
        break

# output
if is_ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 85248