akhauriyash/Code-Regression huggingface dataset:
from copy import copy
n=int(input())
alpha="abcdefghij"
c=[0 for i in range(n)]
m=[0 for i in range(n)]
ans=[]
ans.append(copy(c))
while True:
  c[-1]+=1
  i=n-1
  while i!=0 and c[i]-2==m[i-1]:
    c[i]=0
    i-=1
    c[i]+=1
  if i==0:
    break
  for i in range(1,n):
    m[i]=max(m[i-1],c[i])
  ans.append(copy(c))
for i in ans:
  print("".join(map(lambda x:alpha[x],i)))

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

Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main()
{

   long long int n,d;
    cin>>n>>d;
   long long int a,b;
   int k=0;

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

    cin>>a>>b;

    if(a*a+b*b<=d*d)
        k++;


   }

    cout<<k<<endl;



    return 0;
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1

print(cnt)


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


int main()
{
	int n;
	while(true)
	{
		cin >> n;
		if (n == 0)
			break;
		double s = 0, avg, a = 0;
		int A[n];
		for (int i = 0; i < n; i++)
		{
			cin >> A[i];
			s += A[i]*1.0;
		}
		avg = s/n;
		for (int i = 0; i < n; i++)
			a += pow(avg - A[i]*1.0, 2);
		a = a/n;
		a = sqrt(a);
		printf("%.6f\n", a);
	}
	return 0;
}



Measured memory_bytes: 3176
// --------------------------------------------
// ****************  gzhffIThh  ***************
// --------------------------------------------
// #pragma GCC optimize(2)
// #pragma GCC optimize(3)

#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 100010;

int head[N], nxt[N << 1], v[N << 1], cnt, siz[N];

void add(int x, int y) {
	nxt[++cnt] = head[x]; head[x] = cnt; v[cnt] = y;
}

bool fl = 0;

void dfs(int now, int fa) {
	int su = 0;
	siz[now] = 1;
	for (int i = head[now]; i; i = nxt[i]) {
		if (v[i] == fa) continue;
		dfs(v[i], now);
		su += siz[v[i]];
		siz[now] ^= siz[v[i]];
	}
	if (su >= 2) {
		fl = 1;
	}
}

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

        int n;
        cin >> n;

        if (n & 1) {
                cout << "First\n";
                return 0;
        }

        for (int i = 1; i < n; i++) {
        	int x, y;
        	cin >> x >> y;
        	add(x, y);
        	add(y, x);
        }

        dfs(1, 0);

        if (fl) {
        	cout << "First\n";
        } else {
        	cout << "Second\n";
        }

        return 0; 
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 1e6 + 5;
const int inf = 1e16 + 2;


void solve(int Case) {
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0 ; i < n ; i ++) cin >> arr[i];
    sort(arr , arr + n);
    reverse(arr , arr + n);
    int ans = arr[0] , cnt = 2 , idx = 1;
    for(int i = 2 ; i < n ; i ++) {
        ans += arr[idx];
        cnt ++;
        if(cnt % 2 == 0) idx ++;
    }
    cout << ans << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case ++);
    }
    return 0;
}
 



Measured memory_bytes: 5212
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a%c==0&&b%d==0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    long long m = 1ll<<25;
    // long long m = 1ll<<2;
    for(int i=0;i<a;++i){
        for(int k=0;k<b;++k){
            if(i%c==0&&k%d==0){
                cout<<m<<" ";
            }
            else if(i%c==c-1&&k%d==d-1){
                cout<<-m-1<<" ";
            }
            else{
                cout<<0<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
}

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

using namespace std;
#define ll long long
const long double EPS = 1e-8;
const long double PI = acos(-1);
const int N = 1e5 + 9;
ll arr[N], ans[N];
const ll inf = 1e14 + 7LL;

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

    for (int i = 0; i < n; i++) {
        ans[i] = inf;
        scanf("%lld", &arr[i]);
        ans[0] = 0;
        for (int j = i-1; j >= i - k && j > -1; j--) {
            ans[i] = min(ans[i], ans[j] + abs(arr[i] - arr[j]));
        }
    }
    printf("%lld\n",ans[n-1]);
}


Measured memory_bytes: 1792
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    Z=10**18
    flag=True
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        if flag:
          H=abs(x-cx)+abs(y-cy)+h
          flag=False
        else:
          if H!=abs(x-cx)+abs(y-cy)+h:
            H=10**18+1
            break
      else:
        Z=min(Z,abs(x-cx)+abs(y-cy))
    if H<=Z:
      print(cx,cy,H)
      exit()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

typedef struct process{
  char name[100];
  int time;
}PROCESS;

PROCESS q[100000];
int head,tail;

void enqueue(PROCESS);
PROCESS dequeue(void);
int min(int,int);

int main()
{
  int n,q_main,i,time=0,c;
  PROCESS p;

  head = 1;
  
  scanf("%d %d",&n,&q_main);
  if(n<1 || n>100000) exit(1);
  if(q_main<1 || q_main>1000) exit(2);

  tail = n+1;

  for(i=1;i<=n;i++)
    scanf("%s %d",q[i].name,&q[i].time);

  while(head != tail){
    p = dequeue();
    c = min(q_main,p.time);
    p.time -= c;
    time += c;
    if(p.time > 0)
      enqueue(p);
    else
      printf("%s %d\n",p.name,time);
  }
    
  return 0;
}
  
void enqueue(PROCESS p)
{
  q[tail]=p;
  tail=(tail+1)%100000;
}

PROCESS dequeue()
{
  PROCESS p=q[head];

  head=(head+1)%100000;
  return p;
}

int min(int x,int y)
{
  if(x<y)
    return x;
  else
    return y;

  /* return x>y ? y : x; */
}



Measured memory_bytes: 11948
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define W while
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffor(i,a,b) for(ll i=a;i<=b;i++)
#define rfor(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"
#define go_t ll testcases; cin>>testcases; while(testcases--)
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';
using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e6 + 6;
const ll maxN = 2e5 + 5;
const ll MAX_SIZE = 1e8 + 8;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) // default argument
{ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;}

ll power(ll x, ll y)
{ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	// WHILE(!(SUCCEED == TRY()));
	// BEFORE WRITING MAKE SURE YOU HAVE ANALYSED THE CONSTRAINTS
	// AND THINK THROUGH THE LOGIC ONCE MORE
	FIO
	string s; cin >> s;
	string t; cin >> t;
	ll ans = 0;
	FOR(i, s.length()) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3796
import sys
def input():
    return sys.stdin.readline()[:-1]
N,Q=map(int, input().split())
S=input()
L=[None]*(N)
t=0
for i in range(N-1):
    L[i]=t
    if S[i]=="A" and S[i+1]=="C":
        t+=1
L[-1]=t
for i in range(Q):
    l,r=map(lambda x:int(x)-1,input().split())
    print(L[r]-L[l])

Measured memory_bytes: 6476
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int max = 0;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] >= max) {
				ans++;
				max = a[i];
			}
		}
		System.out.println(ans);
	}
}

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

int main() {

  int N , K;

  cin >> N >> K;

  vector<long long int> A(N);

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

  for(int i = 0;i < N-K ; i++){
    if(A[i]<A[i+K]){
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 4772
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
using namespace std;  
const int MAXN = 1010;  
const int INF = 10000007;  
  
int arr[MAXN],num;  
  
int dfs(int n,int step){  
    if (num > step)  
        return 0;  
    if (arr[num] == n)  
        return 1;  
    if (arr[num] << (step-num) < n)  
        return false;  
    for (int i = 0; i <= num; i++){  
        num++;  
        arr[num] = arr[num-1] + arr[i];  
        if (arr[num] <= 10000 && dfs(n,step))  
            return true;  
        arr[num] = arr[num-1] - arr[i];  
        if (arr[num] > 0 && dfs(n,step))  
            return 1;  
        num--;  
    }  
    return 0;  
}  
  
int main(){  
    int n;  
    while (scanf("%d",&n) != EOF && n){  
        int i;  
        for (i = 0; ; i++){  
            arr[num = 0] = 1;  
            if (dfs(n,i))  
                break;  
        }  
        printf("%d\n",i);  
    }      
    return 0;  
}  


Measured memory_bytes: 3160
S = input()
N = len(S)
i = 0
while i < N:
    sig = 0
    S5 = S[i:i+5]
    if S5 == 'dream':
        sig = 1
        if S[i+5:i+7] == 'er' and S[i+7:i+8] != 'a':
            i += 2
        i += 5
    elif S5 == 'erase':
        sig = 1
        if S[i+5:i+6] == 'r':
            i += 1
        i += 5
    if sig == 0:
        sig = 2
        Answer = 'NO'
        break
if sig != 2:
    Answer = 'YES'
print(Answer)

Measured memory_bytes: 9108
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	String s = sc.next();
	sc.close();
	int bl =0; int wh =0;
	for(int i =0; i<n; i++) {
     if(s.charAt(i)=='.') {
    	 wh++;
     }
}
	int min = wh;
	for(int i =0; i<n; i++) {
	     if(s.charAt(i)=='#') {
	    	 bl++;
	     }
	     else {
	    	 wh--;
	     }
	     min = Math.min(min, wh+bl);
	}
	
  System.out.println(min);
    }

}


Measured memory_bytes: 27576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String[] tmpArray = br.readLine().split(" ");
		
		int input[] = new int[n];
		
		for(int i = 0; i < n; i++) {
			input[i] = Integer.parseInt(tmpArray[i]);
		}
		
		int target = 1;
		int length = 0;
		for(int i = 0; i < n; i++) {
			if(input[i] == target) {
				target++;
				length++;
			}
		}
		
		System.out.println(length > 0 ? n - length : -1);
	}
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  vector<ll> v(3*N);
  for(int i = 0; i < 3*N; i++){
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  ll ans = 0;
  int num = 0;
  int index = N;
  while(num < N){
    ans += v.at(index);
    num++;
    index += 2;
  }
  cout << ans << endl;
  // cerr << num << endl;
}


Measured memory_bytes: 2560
W, H, N = map(int, input().split())
x1 = y1 = a1 = 0
xmin = 0
xmax = W
ymin = 0
ymax = H
for _ in range(N):
  x2, y2, a2 = map(int, input().split())
  if (a2 == 1):
    xmin = max(x2, xmin)
  if (a2 == 2):
    xmax = min(x2, xmax)
  if (a2 == 3):
    ymin = max(y2, ymin)
  if (a2 == 4):
    ymax = min(y2, ymax)
  if (xmax<= xmin or ymax <= ymin):
    print(0)
    exit()
print((xmax - xmin) * (ymax - ymin))

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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

const int N = 2e5+10;
int f[N],invf[N];

const long long mod = 1e9+7;
long long  powmod(long long a,long long p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=mod;a%=mod;
	}
	return ans;
}

long long mdinv(long long a){return powmod(a,mod-2); }


inline int ways(int a1,int b1,int a2,int b2){
	return f[(a2-a1+b2-b1)]*invf[a2-a1]%mod*invf[b2-b1]%mod;
}

signed main(){
	IOS
	int h,w,a,b;cin>>h>>w>>a>>b;
	f[0]=invf[0]=1;
	for(int i=1;i<N;i++){
		f[i]=f[i-1]*i%mod;
		invf[i]=mdinv(f[i]);
	}

	int ans= ways(1,1,h,w);
	for(int i=1;i<=b;i++){
		ans-=ways(1,1,h-a,i)*ways(h-a+1,i,h,w)%mod;
		ans%=mod;
	}
	ans+=mod;ans%=mod;
	cout<<ans;
}

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

int main()
{
  int n;
  cin >> n;
  
  char s[n];
  rep(i,n) cin >> s[i];
  
  rep(i,n){
    if(s[i] == 'Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  
  cout << "Three" << endl;
}

Measured memory_bytes: 3592
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        pn(Math.min(ni()*ni(), ni()));
    }


    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;
    static long mod=(long)1e9+7l;

    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll N,K;
    cin>>N>>K;
    vi A(N);
    rep(i,0,N)cin>>A[i],A[i]--;
    int nxt=0;
    int a=0;
    vi visit;
    vi  cnt(N,-1);
    while(cnt[nxt]==-1){
        visit.push_back(nxt+1);
        cnt[nxt]=a++;
        nxt=A[nxt];
    }
    if(K<visit.size()){
        cout<<visit[K]<<endl;
        return 0;
    }
    else{
        int loopsize=visit.size()-cnt[nxt];
        int l=visit.size()-loopsize;
        K-=l;
        K%=loopsize;
        cout<<visit[K+l]<<endl;
    }
    return 0;
}




Measured memory_bytes: 5888
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

ll gcd(ll A, ll B){
    if (B==0)
        return A;
    return gcd(B,A%B);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    int arr[n];
    
    int *dp = new int [1000001];
    bool *sieve = new bool [1000001];
    
    for (int i=0;i<1e6+1;i++){
        dp[i] = 0;
        sieve[i] = false;
    }
    
    for (int i=0;i<n;i++){
        cin >> arr[i];
        dp[arr[i]]++;
    }
    
    bool ans = true;
    
    for (int i=2;i<1e6+1;i++){
        if (sieve[i])
            continue;
        int count = 0;
        for (int j=i;j<1e6+1;j=j+i){
            sieve[j] = true;
            count = count + dp[j];
        }
        if (count>1){
            ans = false;
            break;
        }
    }
    
    if (ans){
        cout << "pairwise coprime\n";
    } else {
        ans = false;
        ll GCD = arr[0];
        for(int i=1;i<n;i++){
            GCD = gcd(maxl(GCD,arr[i]),minl(GCD,arr[i]));
        }
        if (GCD == 1){
            ans = true;
        }
        if (ans){
            cout << "setwise coprime\n";
        } else {
            cout << "not coprime\n";
        }
    }
}


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

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> field(H, vector<char>(W));
    vector<vector<int>> dist(H, vector<int>(W, INF));
    queue<pair<int, int>> que;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> field[i][j];
            if (field[i][j] == '#') {
                que.push(pair<int, int>(i, j));
                dist[i][j] = 0;
            }
        }
    }

    while (!que.empty()) {
        pair<int, int> p = que.front(); que.pop();

        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (nx >= 0 && nx < H && ny >= 0 && ny < W && dist[nx][ny] == INF) {
                que.push(pair<int, int>(nx, ny));
                dist[nx][ny] = dist[p.first][p.second] + 1;
            }
        }
    }

    int res = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            res = max(res, dist[i][j]);
        }
    }
    cout << res << endl;
    return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n, k; scan(n, k);
      LI xs(n); scan(xs);
      Int res = 0;
      for(Int i = 0; i < n; ++i) {
         res += 2 * std::min(xs[i], std::abs(k-xs[i]));
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
//
//  main.cpp
//  0406
//
//  Created by kao ching shan on 2019/4/6.
//  Copyright © 2019年 kao ching shan. All rights reserved.
//

#include <iostream>
#include <algorithm>

using namespace std;
long long int arr[5];

int main(int argc, const char * argv[]) {
    
    long long int n,temp;
    cin >> n;
    for(int i=0;i<5;i++)
        cin >> arr[i];
    
    
    sort(arr,arr+5);
    
    if(arr[0]<n){
        
        if( (n%arr[0]) ==0){
            cout << (n/arr[0])+4;
        }else{
            cout << (n/arr[0])+5;
        }
    }
    else
        cout << '5';
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<int> dx={0,-1,0,1},dy={-1,0,1,0};
int main(){
while(1){
	int h,w;
	cin>>w>>h;
	if(w==0)return 0;
	V<V<bool>> used(h,V<bool>(w,false));
	V<string> s(h);
	for(int i=0;i<h;i++)cin>>s[i];
	queue<P> q;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='@'){
				q.push(P(i,j));
				used[i][j]=true;
			}
		}
	}
	while(!q.empty()){
		P now=q.front();
		q.pop();
		for(int i=0;i<4;i++){
			int nx=dx[i]+now.fi,ny=dy[i]+now.se;
			if(nx<0||nx>=h||ny<0||ny>=w)continue;
			if(s[nx][ny]=='#'||used[nx][ny])continue;
			used[nx][ny]=true;
			q.push(P(nx,ny));
		}
	}
	int ans=0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(used[i][j])ans++;
	cout<<ans<<endl;
}
}



Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
//const int MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin>>s>>t;
	int n = (int) s.length();
	int lenT = (int) t.length();
	int ans = lenT;
	for(int i = 0;i <= n - lenT;i++){
		int tmp = 0, k = 0, j = i;
		while(k < lenT){
			if(t[k] != s[j]) tmp++;
			k++;j++;
		}
		ans = min(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}
//ios_base::sync_with_stdio(false);
//cin.tie(0);
//tod-ngen


Measured memory_bytes: 3748
#include<stdio.h>
#include<stdlib.h>

int main(int argc, char const *argv[]) {
    int a, b, c, d;
    int ttl;
    ttl = 0;

    scanf("%d%d%d%d", &a, &b,&c,&d);

    ttl += a > b ? b : a;
    ttl += c > d ? d : c;

    printf("%d\n", ttl);

    return 0;
}


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

int main(int argc, char *argv[]) {
	std::string input;
	std::cin >> input;

	std::string result;
	for (int i = 0; i < input.size(); i++) {
		if (input[i] == '9') {
			result += '1';
		}
		if (input[i] == '1') {
			result += '9';
		}
	}

	std::cout << result << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define mod 1000000007
 #define f first
 #define se second
 #define pb push_back
 #define int long long int
using namespace std;
int ans=1;
int k;
int dis[100005];
vector<int>v[100005];

int npr(int n,int r)
{
    int x = n;
    int y = n-r+1;

    int mul = 1;
    for(int i = x;i>=y;i--)
    {
        mul = mul*(i);
        mul%=mod;
    }
    return mul;
}
void dfs(int s,int p,int h)
{
    dis[s] = h;
    if(s==1)
    {
       // cout<<npr(k-1,v[1].size())<<"\n";
        ans = ans*(npr(k-1,v[1].size()));
        ans = ans%mod;
    }
    else
    {
        ans = ans*(npr(k-2,v[s].size()-1));
        ans = ans%mod;
    }

    
    for(auto it:v[s])
    {
        if(it==p)continue;
        dfs(it,s,h+1);
    }
}
 signed main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);cout.tie(NULL);
     
    

        int n;
        cin>>n>>k;
        ans = k;
      

        for(int i=0;i<n-1;i++)
        {
            int a,b;
            cin>>a>>b;
            v[a].pb(b);
            v[b].pb(a);
        }

        dfs(1,0,1);

        cout<<ans<<"\n";

   


 }


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x,count=0;
    long int t;
    vector<int> num;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        num.push_back(x);
    }
    sort(num.begin(),num.end());
    while(num.size()>1){
        t=1;
        x=num[num.size()-1];
        //cout << x << endl;
        num.pop_back();
        while(t<=x){
            t*=2;
        }
        auto it=lower_bound(num.begin(),num.end(),t-x);
        if(it==num.end()) continue;
        if(*it==t-x){
            //cout << "found" << *it <<endl;
            num.erase(it);
            count++;
        }else{
            continue;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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

int main() {
  int a, b;
  cin >> a >> b;
  int digit = 1;

  int a_copy = a;
  int b_copy = b;
  for (int i = 1; i < b; i++)
  {
      /* code */
      digit *= 10;
    //   cout << digit << endl;
      a_copy += a * digit;
    //   cout << a << endl;
  }
  digit = 1;
  for (int j = 1; j < a; j++)
  {
      /* code */
      digit *= 10;
    //   cout << digit << endl;
      b_copy += b * digit;
    //   cout << b << endl;
  }
  
  string ans = (a_copy > b_copy) ? to_string(a_copy) : to_string(b_copy);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200100;
int n,a[maxn],b[maxn];
set<pair<int,int> > S;
inline int prev(int x){return x==1?n:x-1;}
inline int nxtv(int x){return x==n?1:x+1;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) scanf("%d",b+i);
	for(int i=1;i<=n;i++) S.insert(make_pair(b[i],i));
	long long ans=0;
	while(S.size())
	{
		pair<int,int> ttt=*--S.end();S.erase(--S.end());
		int id=ttt.second;if(a[id]==ttt.first) continue;
		int cnt=(b[id]-a[id])/(b[prev(id)]+b[nxtv(id)]);
		if(cnt==0) return puts("-1"),0;
		b[id]-=cnt*(b[prev(id)]+b[nxtv(id)]);
		S.insert(make_pair(b[id],id));ans+=cnt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14536
/* be name khoda */

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

typedef long long ll;

// ------------------------------------------------------------------

ll l, r;

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

    cin >> l >> r;
    if (l == r) return cout << "1\n", 0;
    ll i;
    for (i = 59; i >= 0; --i) {
        if (l >= (1LL << i)) l -= 1LL << i, r -= 1LL << i;
        else if (r >= (1LL << i)) break;
    }
    ll ans = (1LL << i) - l;
    ll r2 = r - (1LL << i);
    ll j;
    for (j = i; j >= 0 && r2 < (1LL << j); --j);
    r2 = 1LL << (j + 1);
    ans += (1LL << i) - max(0LL, l - r2);
    cout << ans << '\n';

}



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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int n;
int m[101][101];
int d[101];
int color[101];
int p[101];

int prim(){
	rep(i, n){
		d[i] = 1e5;
		color[i] = 0;
	}
	d[0] = 0;
	p[0] = -1;
	while(1){
		int mincost = 1e5;
		int u = -1;
		rep(i, n){
			if(d[i] < mincost && color[i] != -1){
				mincost = d[i];
				u = i;
			}
		}
		color[u] = -1;
		if(u == -1) break;
		rep(v, n){
			if(color[v] != -1 && m[u][v] != -1){
				if(m[u][v] < d[v]){
					d[v] = m[u][v];
					p[v] = u;
					color[v] = 1;
				}
			}
		}
	}
	int sum = 0;
	rep(i, n){
		sum += d[i];
	}
	return sum;
}

int main(){
	cin >> n;
	rep(i, n){
		rep(j, n){
			cin >> m[i][j];
		}
	}
	cout << prim() << endl;
}



Measured memory_bytes: 3104
#include <cstdio>
#include <map>

using namespace std;

int main() {
  int i;
  int N;
  int A[100010];
  map<int, int> numbers;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    if (numbers.find(A[i]) != numbers.end()) {
      numbers[A[i]] += 1;
    } else {
      numbers[A[i]] = 1;
    }
  }
  long long largest = 0;
  long long largest2 = 0;
  for (auto x : numbers) {
    if (x.second > 1) {
      if (x.second > 3) {
	if (x.first >= largest) {
	  largest = x.first;
	  largest2 = x.first;
	}
      }
      if (x.first > largest) {
	largest2 = largest;
	largest = x.first;
      } else if (x.first > largest2) {
	largest2 = x.first;
      }
    }
  }
  printf("%lld", largest * largest2);
  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int P=1e9+7,N=505;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

int n,d[N][N],del[N][N],X[N*N],Y[N*N],ans;
void upd(int x,int y){
	int dx[]={-1,0,0,1},dy[]={0,-1,1,0};
	lop(k,0,4){
		int nx=x+dx[k],ny=y+dy[k];
		if(nx<1||nx>n||ny<1||ny>n)continue;
		if(d[nx][ny]>d[x][y]+(!del[nx][ny])){
			d[nx][ny]=d[x][y]+(!del[nx][ny]);
			upd(nx,ny);
		}
	}
}
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n); 
	rep(i,1,n*n){
		int u; read(u); 
		X[i]=(u-1)/n+1,Y[i]=(u-1)%n+1;
	}
	rep(i,1,n)rep(j,1,n)d[i][j]=min(min(i,n-i+1),min(j,n-j+1)); 
	rep(i,1,n*n){
		d[X[i]][Y[i]]-=1;
		ans+=d[X[i]][Y[i]]; 
		del[X[i]][Y[i]]=1;
		upd(X[i],Y[i]); 
	}
	cout<<ans<<endl;
	return 0; 
}


Measured memory_bytes: 30120
#include<iostream>
#include<algorithm>
#include<math.h>
#define _USE_MATH_DEFINES

using namespace std;

int a, b, ans = 0;

int main(){
	cin >> a >> b;
	ans = max(a + b, a - b);
	ans = max(ans, a * b);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);



ll ami[101][10];

int main() {
    ll h,w,k;
    cin>>h>>w>>k;

    vector<vector<int>> cami;
    for(int i=0;i<(1<<(w-1));i++){
        vector<int> v(w+1);
        v[0]=0;
        v[w]=0;

        for(int j=0;j<w-1;j++){
         if(i>>j&1){
             v[j+1]=1;
         }else{
             v[j+1]=0;
         }
        }
        bool t=true;
        rep(j,w){if(v[j]+v[j+1]==2)t=false;}
        if(t){cami.push_back(v);}

    }

//    rep(i,cami.size()){
//       rep(j,cami[i].size())cout<<cami[i][j];
//       cout<<endl;
//    }



   ami[0][1]=1;


    for(int j=0;j<h;j++){//たて
    for(int n=0;n<cami.size();n++){
        vector<int> v1=cami[n];
        for(int i=1;i<=w;i++){//横

            if(v1[i-1]==0&&v1[i]==0){
                ami[j+1][i]+=(ami[j][i]%MOD);

            }else if(v1[i-1]==1&&v1[i]==0){
                ami[j+1][i]+=(ami[j][i-1]%MOD);

            }else if(v1[i-1]==0&&v1[i]==1){
                ami[j+1][i]+=(ami[j][i+1]%MOD);
            }
           }






       }
   }

//       rep(i,h+1){
//            rep(j,w+1){
//                cout<<ami[i][j]<<" ";
//            }
//            cout<<endl;
//        }



   cout<<ami[h][k]%MOD<<endl;



    return 0;
}


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

int main()
{
    char a[4],b[4],c[4];
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    printf("%c%c%c\n",a[0],b[1],c[2]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll K;
    Scll(K);

    int N = 50;
    vector<ll> a(N,49);

    ll plus = K / 50;

    Rep(i,N){
        a[i] += plus;
    }

    printf ("%d\n", N );
    ll dis = K % 50;
    Rep(i,N){
        if( i < dis ) a[i] += 51-dis;
        else a[i] -= dis;
        printf ("%llu%c", a[i] , i == 49 ? '\n' : ' ');
    }


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

const long double pi = 3.14159265358979323846264338327;

void solve() {
	cout << setprecision(10);
	int r;
	cin >> r;
	cout << (long double) 2.0 * (long double) r * pi << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int INF = 1e+9;


void dfs(int curr_pos, int curr_d, vector<int>& d, vector<vector<int>>& G)
{
    if(d[curr_pos] < curr_d) return;
    d[curr_pos] = curr_d;
    for(auto v: G[curr_pos]){
        dfs(v, curr_d+1, d, G);
    }
}


int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    --X, --Y;

    // Create the Graph
    vector<vector<int>> G(N);
    REP(i, N-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X].push_back(Y);
    G[Y].push_back(X);

    // Calculate the distance
    vector<vector<int>> d(N, vector<int>(N, INF));
    REP(i, N) dfs(i, 0, d[i], G);

    // Count the number
    vector<int> ans(N);
    REP(i, N){
        FOR(j, i+1, N) ++ans[d[i][j]];
    }
    FOR(i, 1, N) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
ll a[10];
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    int n;
    cin>>n;
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        ll x,y;
        cin>>x>>y;
          if(i==0)
          {
               a[1]=x+y;
               a[2]=-x+y;
               a[3]=-x-y;
               a[4]=x-y;
          }
          else
          {
              ans=max({ans,a[1]-x-y,a[2]+x-y,a[3]+x+y,a[4]+y-x});
               a[1]=max(a[1],x+y);
               a[2]=max(a[2],-x+y);
               a[3]=max(a[3],-x-y);
               a[4]=max(a[4],x-y);
          }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
signed main() {
	ll x, y;
	cin >> x >> y;
	ll a = abs(abs(x - 0) - abs(y - 0));
	if (x <= y && ((x >= 0 && y >= 0) || (x <= 0 && y <= 0)))cout << a << endl;
	else if (x > y && ((x > 0 && y > 0) || (x < 0 && y < 0)))cout << a + 2 << endl;
	else cout << a + 1 << endl;
	ggr
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <math.h>

using namespace std;

int main() {
int n, k;
int d[100];
int a[100][100];
int flg[100];
int sum;
cin >> n >> k;
for (int i = 0;i < n;i++){
    flg[i]=1;
}
for (int i = 0;i < k;i++){
    cin >> d[i];
    for (int j = 0; j < d[i]; j++){
        cin >> a[i][j];
        flg[a[i][j]-1]=0;
    }
}
for (int i = 0;i < n;i++){
    sum = sum + flg[i];
}
cout << sum;
}

Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val X = IntArray(N)
    var sum = 0
    
    for (i in X.indices) {
      X[i] = input.nextInt()
      sum += X[i]
    }
    
    val p1 = sum / N
    var stamina1 = 0
      
    for (i in X.indices) {
      val dist = X[i] - p1
      stamina1 += dist * dist
    }
    
    val p2 = p1 + 1
    var stamina2 = 0
      
    for (i in X.indices) {
      val dist = X[i] - p2
      stamina2 += dist * dist
    }
    
    val stamina = Math.min(stamina1, stamina2)
    
    println(stamina)
  } 
}

Measured memory_bytes: 36752
S=input()
l=['AKIHABARA','KIHABARA','AKIHBARA','AKIHABRA','AKIHABAR',
   'KIHBARA','AKIHBRA','AKIHABR','KIHABRA',
   'AKIHBAR','KIHABAR',
   'KIHBRA','AKIHBR','KIHABR','KIHBAR','KIHBR']

if S in l:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
// ABC042B - 文字列大好きいろはちゃんイージー

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

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

	vector<string> S(N);

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

	sort(S.begin(), S.end());

	string answer = "";
	for (int i = 0; i < N; i++) {
		answer += S.at(i);
	}

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

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

int p[2][4];
void solve(){

}
int main(){
  int ans=0;
  for(int i=0;i<2;i++){
    int sum=0;
    for(int j=0;j<4;j++){
      int p;
      cin >> p;
      sum+=p;     
    }
    ans = max(ans,sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
     int i,j,H,W;
     while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0) break;
        for(j=0; j<H; j++){
            for(i=0; i<W; i++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
     }    
    return 0;
}


Measured memory_bytes: 2124
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string S;
	
	cin>>S;
	
	for(int i = 0; i < S.size(); i++){
		cout<<"x";
	}
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())

def prime_factor(x) :
  ret = dict()
  if x % 2 == 0 :
    ret[2] = 0
    while x % 2 == 0 :
      x //= 2
      ret[2] += 1
          
  i = 3
  while i * i <= x :
    if x % i == 0 :
      ret[i] = 0
      
      while x % i == 0 :
        x //= i
        ret[i] += 1
    i += 2
      
  if x != 1 :
    ret[x] = 1
  
  return ret

ret = 0
for k, v in prime_factor(N).items() :
  i = 1
  while v >= i :
    v -= i
    i += 1
    ret += 1
print(ret)

Measured memory_bytes: 62888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    ll N; cin >> N;
    vector<string> S(N);
    map<string, ll> mp;
    rep(i, N) {
        cin >> S[i]; mp[S[i]]++;
    }
    ll M; cin >> M;
    vector<string> T(M);
    rep(i, M) {
        cin >> T[i];
        if (mp.count(T[i])) {
            if (mp[T[i]] < 0) {
                mp.erase(T[i]);
            } else {
                mp[T[i]]--;
            }
        }
    }

    ll ans = 0;
    rep(i, N) ans = max(ans, mp[S[i]]);
    cout << ans << endl;
}

Measured memory_bytes: 3640
def d_string_formation():
    from collections import deque
    S = input()
    Q = int(input())
    Query = [input().split() for _ in range(Q)]

    ans = deque(list(S))
    turn = False
    for q in Query:
        if q[0] == '1':
            turn = not turn
        else:
            _, f, c = q
            if f == '1':
                if turn:
                    ans.append(c)
                else:
                    ans.appendleft(c)
            else:
                if turn:
                    ans.appendleft(c)
                else:
                    ans.append(c)
    return ''.join(ans) if not turn else ''.join(reversed(ans))

print(d_string_formation())

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

int n , kind[11];
char c[10];
void dfs(int i){
    for(int j=0;j<=i&&kind[j]>0;j++){
        c[i]='a'+j;
        kind[j+1]++;
        if(i < n-1){
            dfs(i+1);
        } else {
            printf("%s\n",c);
        }
        kind[j+1]--;
    }
    return;
}
signed main(){
    cin>>n;
    kind[0]=1;
    dfs(0);
    return(0);
}

Measured memory_bytes: 1536
num = gets.to_i
line1 = gets.split.map(&:to_i)
line2 = line1.dup.sort
key = 0
i = 0
if line1 == line2
  puts "YES"
else
  while key == 0 do
    if line1[i] != i+1
      kari = line1[i]
      line1[i] = i+1
      a = num-(i+1)
		a.times do |j|
			if line1[j+i+1] == i+1
			line1[j+i+1] = kari
            end
		end
    key += 1
	end
   i += 1
   end
  end


if key == 0
  
elsif line1 == line2 
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#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 = 0; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	int n; cin >> n;
	int sum = 0;
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		sum += b-a+1;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256