akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 1000 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
int spf[N];
void sieve(int n ) 
{ 
    spf[1] = 1; 
    for (int i=2; i<n; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<n; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<n; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<n; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    sieve(N);
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    int g = a[0];
    for (int i = 0; i < n; ++i)
    {
        g = gcd(a[i],g);
    }
    bool ok = true;
    unordered_map<int,int> m;
    for (int i = 0; i < n; ++i)
    {
        unordered_map<int,int> temp;
        while(a[i]!=1)
        {
            temp[spf[a[i]]]++;
            a[i]/=spf[a[i]];
        }

        for(auto x : temp)
        {
            if(m.find(x.ff)!=m.end())
                ok = false;
            m[x.ff]+=x.ss;
        }
    }

    if(ok)
        cout<<"pairwise coprime";
    else if(g==1)
        cout<<"setwise coprime";
    else
        cout<<"not coprime";

    printclock;
    return 0;
}


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

int main(){
	
	int a;
	char c;
	string s;
	
	cin>>a;
	//cin>>c;
	cin>>s;
	int l=0;
	//cout<<a<<" "<<s<<endl;
	for(int i=0;s[i];i++){
		if(s[i]==s[i+1])
		while(s[i]==s[i+1]){
			i+=1;
			l+=1;
		}
		
	}
	cout<<a-l<<endl;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

if sum(a) < sum(b):
    print(-1)
    exit()

q = []
p = []
d = 0

for i in range(n):
    if a[i] - b[i] < 0:
        q.append(a[i]-b[i])
    elif a[i] - b[i] > 0:
        p.append(a[i]-b[i])
    else:
        d += 1

s = sum(q)
p = sorted(p)
while s < 0:
    if p == []:
        print(-1)
        exit()
    else:
        t = p.pop()
        s += t

print(n - d - len(p))



Measured memory_bytes: 18356
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static final int MOD = (int)Math.pow(10,9)+7;

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int N = scan.nextInt();
    long A[] = new long[N];
    for(int i = 0; i < N; i++) {
      A[i] = scan.nextInt();
    }
    long S[] = new long[N];
    long sum = 0;
    for(int i = N-1 ; i > 0; i--) {
      sum += A[i];
      sum %= MOD;
      S[i-1] = sum;
    }

    long ans = 0;

    for(int i = 0; i < N-1; i++) {
      ans += A[i]*S[i]%MOD;
      ans %= MOD;
    }

    os.println(ans);
  }
}


Measured memory_bytes: 51180
#include "iostream"
#include "string"

using namespace std;

int main() {
	int n, d[100];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> d[i];
	int num = n;
	bool flag = false;
	for (int i = 0; i < n; i++) {
		for (int s = i; s < n; s++) {
			if (d[i] == d[s] && i != s) flag = true;
		}
		if (flag) num--;
		flag = false;
	}
	cout << num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, k; read(n), read(k);
  int ans = 0;
  for (RI i = k; i <= n + 1; ++i) {
    int L = i * (i - 1) / 2;
    int R = i * (n + n - i + 1) / 2;
    ans = (ans + (R - L + 1)) % int(1e9 + 7);
  }
  printf("%lld\n", ans);

    
  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 3732
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}
using namespace MyLib;

string u[256];
string t;

int main() {
	int n, m;
	int open = 1;
	int flag = 0;
	cin >> n;
	REP(i, n)
		cin >> u[i];
	cin >> m;
	REP(i, m) {
		cin >> t;
		REP(j, n)
			if (t == u[j])
				if (open)
					cout << "Opened by " << t << endl, open = 0, flag = 1;
				else
					cout << "Closed by " << t << endl, open = 1, flag = 1;
		if (flag)
			flag = 0;
		else
			cout << "Unknown " << t << endl;

	}


	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}
int main()
{
  int k;cin>>k;
  int ans=0;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        ans+=gcd(a,gcd(b,c));
 	  }
  	}
  }
  cout<<ans;
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/09  Problem: ABC 121 D / Link: http://abc121.contest.atcoder.jp/tasks/abc121_d  ----- */

long long xorxor(long long  val) {
	long long ret = ((val + 1) / 2) % 2;
	for (int i = 0; i <= 59; i++) if ((val >> i) % 2) ret |= (1 ^ (val % 2)) << i;
	return ret;
}

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


	LL A, B; cin >> A >> B;
	LL ans = xorxor(B);
	if (A) {
		ans ^= xorxor(A - 1);
	}



	cout << (ans) << "\n";

	return 0;
}


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

int main(){
    int X; cin >> X;
    int dp[2][2*X+1];

    int sum = 0, i = 1;
    for(;;i++){
        sum += i;
        if(sum > X){
          	break;
        }
        else if(sum == X) break;
    }
    cout << i;
}

Measured memory_bytes: 256
n = int(input())
lst = [int(x) for x in input().split()]

num = sum(lst)//n
sum1 = 0
sum2 = 0

for i in lst:
  sum1 += (i-num)**2
  sum2 += (i-num-1)**2
  
if sum1 < sum2:
  print(sum1)
else:
  print(sum2)

Measured memory_bytes: 3060
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N = ri()
S = input()
cnt = {'E': [0, S.count('E')],
       'W': [0, S.count('W')]}

ret = N
for c in S:
  cnt[c][1] -= 1
  ret = min(ret, cnt['W'][0] + cnt['E'][1])
  cnt[c][0] += 1
print(ret)

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

long long f (long long x, long long y) {
   long long a=min(x,y);
   long long i,xx=x,yy=y,b;
   for (i=1; i<=sqrt(a); i++) {
      if (x%i==0 && y%i==0 && i!=1) {
         xx=x/i,yy=y/i;break;
      }
      if (a%i==0) {
         b=a/i;
         if (x%b==0 && y%b==0) {
            xx=x/b;
            yy=y/b;
            i=b;
            break;
         }
      }
   }
   if (x==xx) return 1;
   else return i*f(xx,yy);
}

int main() {
   int N;
   cin >> N;
   long long T[N];
   long long t;
   for (int i=0; i<N; i++) {
      cin >> T[i];
      if (i==0) t=T[i];
      else {
         t=t/f(t,T[i])*T[i];
      }
   }
   cout << t << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char s1[101],s2[101];
int main()
{
	gets(s1);
	gets(s2);
	int n=strlen(s1);
	int m=strlen(s2); 
	sort(s1,s1+n);
	sort(s2,s2+m);
	for(int i=0;i<fmax(n,m);i++)
	{
		if(s1[i]<s2[m-i-1])
		{
			printf("Yes\n");
			return 0;
		}
		if(s1[i]>s2[m-i-1])
		{
			break;
		}
	}
	printf("No\n");
	return 0;
} 

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  startupcpp();
  ll i,N,T,A;
  cin>>N>>T>>A;
  A*=1000;
  T*=1000;
  pvec v(N);
  rep(i,N){
    cin>>v[i].first;
    v[i].first=abs(A-T+v[i].first*6);
    v[i].second=i+1;
  }
  vsort(v);
  cout<<v[0].second<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i, j;
    if (a >= b) {
        i = b;
    } else {
        i = a;
    }
    if (c <= d) {
        j = c;
    } else {
        j = d;
    }
    cout << i+j << endl;
    return 0;
}

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

int main() {
  int n; cin >> n;
  int a[n][3];
  REP(i,n) REP(j,3) cin >> a[i][j];
  int dp[n+1][3];
  REP(i,n+1) REP(j,3) dp[i][j] = 0;

  REP(i,n) {
    REP(j,3) {
      REP(k,3) {
        if (j==k) continue;
        dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i][j]);
      }
    }
  }
  int ans = 0;
  REP(i,3) ans = max(ans, dp[n][i]);
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
 
void process(int n) {
    int i;
 
    for (i=1; i<=n; i++) {
        if (i % 3 == 0) {
        printf(" %d", i);
    } else if (i % 10 == 3) {
        printf(" %d", i);
    } else if (i / 10 % 10 == 3) {
        printf(" %d", i);
    } else if (i / 100 > 0) {
        if (i / 100 % 10 == 3) {
        printf(" %d", i);
        } else if (i / 100 / 10 == 3) {
            printf(" %d", i);
        }
    } else if (i / 1000 > 0) {
        if (i / 1000 % 10 == 3) {
        printf(" %d", i);
        } else if (i / 1000 % 100 ==3) {
            printf(" %d", i);
        }
    }
    }
    printf("\n");
}
 
void scanner() {
    int n;
    scanf("%d", &n);
    process(n);
}
 
int main(void) {
    scanner();
    return 0;
}


Measured memory_bytes: 2084
#include <stdio.h>

int main()
{
  char s[200000];

  fgets(s, sizeof(s), stdin);

  for (int i = 0; s[i] != '\0'; i++) {
    if (i%2 == 0) {
      printf("%c", s[i]);
    }
  }
      printf("\n");

  return 0;
}


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

int main() {
    int n;
    ll a,b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for ( int i=0; i<n; i++ ) {
        cin >> v[i];
    }
    ll lb=0, ub=1e9;
    while ( ub-lb>1 ) {
        ll x=(lb+ub)/2;
        auto ok=[&] {
            ll cnt=0;
            for ( int i=0; i<n; i++ ) {
                cnt+=(max(0LL,v[i]-b*x)+a-b-1)/(a-b);
            }
            return cnt<=x;
        }();
        if ( ok ) {
            ub=x;
        } else {
            lb=x;
        }
    }   
    cout << ub << '\n';
    return 0;
}




 





Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int x = x2 - x1;
    int y = y2 - y1;
    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    string S;
    int c=0,flag=0;
    cin >> S;
    
    flag+=(S[0]!='A');
    
    for(int i=2;i<S.length()-1;i++){
        c+=(S[i]=='C');
    }
    flag+=(c!=1);
    c=0;
    for(int i=0;i<S.length();i++){
        c+=(S[i]>='A' && S[i]<='Z');
    }
    flag+=(c!=2);
    if(flag)
        cout << "WA" << endl;
    else
        cout << "AC" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

LL ans[10];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w, n;
    cin >> h >> w >> n;
    vector<PII> s, black;
    FOR(i, 0, n)
    {
        int x, y;
        cin >> x >> y;
        for (int nx = max(1, x - 2); nx <= min(x, h - 2); nx++)
        {
            for (int ny = max(1, y - 2); ny <= min(y, w - 2); ny++)
            {
                s.EB(nx, ny);
            }
        }
        black.EB(x, y);
    }
    sort(ALL(s));
    sort(ALL(black));
    s.erase(unique(ALL(s)), s.end());
    for (auto p : s)
    {
        int cnt = 0;
        for (int x = p.F; x < p.F + 3; x++)
        {
            for (int y = p.S; y < p.S + 3; y++)
            {
                cnt += binary_search(ALL(black), MP(x, y));
            }
        }
        ans[cnt]++;
    }
    ans[0] += (LL)(h - 2) * (w - 2) - SZ(s);
    for (auto x : ans)
    {
        cout << x << "\n";
    }    
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b, x;
    cin >> a >> b >> x;

    cout << (x < a ? "NO" : x <= (a + b) ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<ll> arr;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        arr.push_back(x);
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                set<ll> st;
                st.insert(arr[i]);
                st.insert(arr[j]);
                st.insert(arr[k]);
                if(st.size()==3 && (arr[i]+arr[j])>arr[k] && (arr[i]+arr[k])>arr[j] && (arr[j]+arr[k])>arr[i])
                {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define REP(i, k, n) for (int(i) = k; (i) <(int)(n); (i)++)
#define vi vector<int>
#define pii pair<int,int>

using ll = long long;

using namespace std;


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

    string s;
    cin >> s;

    rep(i,s.size()){
        s[i] = (s[i]-'A'+n)%26 + 'A'; 
    }
    cout << s << endl;
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string a,b;
  cin >> a >> b;

  if(a == b)
  {
    cout << "EQUAL" << endl;
  }
  else
  {

    if(sz(a) > sz(b))
    {
      cout << "GREATER" << endl;
    }
    else if(sz(a) < sz(b))
    {
      cout << "LESS" << endl;
    }
    else  // sz(a) == sz(b)
    {
      rep(i,sz(a))
      {
        if(a[i] > b[i])
        {
          cout << "GREATER" << endl;
          break;
        }
        else if(a[i] < b[i])
        {
          cout << "LESS" << endl;
          break;
        }
        else
        {
          continue; 
        }
        
      }
    }
    
    
  }
  

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int k; string s;
  cin >> k >> s;
  int n = s.size();
  if(n <= k) cout << s << endl;
  else{
    for(int i = 0; i < k; i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
<?php
$a = trim(fgets(STDIN));
$N = explode(" ",trim(fgets(STDIN)));
sort($N);
$ans  = 0;
foreach($N as $value){
$ans += $value;
}
$ans -= $N[$a-1];
if ($ans> $N[$a-1]){
echo "Yes";
}else{
echo "No";
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main(){
  int H,W;
  cin>>H>>W;
  string s[100];
  rep(i,H) cin>>s[i];
  rep(i,W+2) cout<<"#";
  cout<<endl;
  rep(i,H){
    cout<<"#";
    cout<<s[i];
    cout<<"#"<<endl;
  }
  rep(i,W+2) cout<<"#";
  cout<<endl;
  return 0;
}


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

#define ran 200020
int n, m, cntA[ran], cntB[ran];
vector<int> e[ran];
char s[ran];
queue<int> q;
bool inq[ran];
int main() {
	scanf("%d%d%s", &n, &m, s + 1);
	while (m--) {
		int x, y;
		scanf("%d%d", &x, &y);
		e[x].push_back(y);
		e[y].push_back(x);
		if (s[x] == 'A') cntA[y] ++;else
			cntB[y]++;
		if (s[y] == 'A') cntA[x] ++;else
			cntB[x]++;
	}
	for(int i=1; i<=n; i++)
		if (cntA[i] == 0 || cntB[i] == 0) {
			q.push(i);
			inq[i] = true;
		}
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		for (auto y : e[x]) {
			if (s[x] == 'A') {
				if (--cntA[y] == 0) {
					if (!inq[y]) {
						q.push(y);
						inq[y] = true;
					}
				}
			}
			else {
				if (--cntB[y] == 0) {
					if (!inq[y]) {
						q.push(y);
						inq[y] = true;
					}
				}
			}
		}
	}
	for (int i = 1; i <= n; i++)if (!inq[i]) {
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[0] == s[s.length() - 1])
	{
		if (s.length() % 2)
		{
			cout << "Second" << endl;
		}
		else
		{
			cout << "First" << endl;
		}
	}
	else
	{
		if (s.length() % 2)
		{
			cout << "First" << endl;
		}
		else
		{
			cout << "Second" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3736
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
int n,a[100001];
class IO{char buffer[10000001];char *h;int len;inline char gchar(){return *h++;}inline bool validdigit(char c){return c>='0' && c<='9';}public:inline void init(){len=fread(buffer,1,10000000,stdin);h=buffer;}inline int nextint(){register int i=0;register char c;do c=gchar();while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i;}}io;
int gcd(int a,int b){if(a<b)swap(a,b);for(register int t=a%b;t;a=b,b=t,t=a%b);return b;}
bool dfs()
{
	register int cnt=0,last=0,tmp;
	for(register int i=1;i<=n;++i)(a[i]&1)?last=i:++cnt;
	if(cnt&1)return true;
	if(cnt+1<n || a[last]==1)return false;
	tmp=a[last]-1;
	for(register int i=1;i<=n;++i)
		if(i!=last)tmp=gcd(tmp,a[i]);
	for(register int i=1;i<=n;++i)a[i]/=tmp;
	return !dfs();
}

int main()
{
	io.init();n=io.nextint();
	for(register int i=1;i<=n;++i)
		a[i]=io.nextint();
	puts(dfs()?"First":"Second");
}

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

using namespace std;

int main(){
	int a ,t = 1;
	long long b[200001];
	cin>>a;
	for(int i = 0 ; i < a ; i++) cin>>b[i];
	for(int i = 0 ; i < a ; i++) if(b[i] == t) t++;
	if(t > 1) cout<<a-t+1<<endl;
	else cout<<"-1"<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
    int count = 0;
    int max = 0;
    char b[10];
    std::cin >> b;
    for(int i = 0;i < 10;i++){
        if(b[i] == 'A' || b[i] == 'C' || b[i] == 'G' || b[i] == 'T'){
            count++;
        }
        else{
            if(max < count){
                max = count;
                count = 0;
            }
        }

       if(i == 9){
            if(max < count){
                max = count;
                count = 0;
            }
        }

    }
    std::cout << max << std::endl;
}

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

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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

map<int, int> num;

int main(){
    int N, K, ans, A[220000];
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> A[i];
    int B[N+1];
    for(int i = 0; i < N; ++i) {
        B[i] = i + 1;
        num[A[i]] = B[i];
    }
    sort(A, A+N);
    for(int i = 0; i < N; ++i) cout << num[A[i]] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int a,b;
  cin>>a>>b;
  for(int i=1;i<=10000;i++){
    int x=i*8/100;
    int y=i*10/100;
    if(x==a and y==b) drop(i);
  }
  drop(-1);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;

const int dx[8] = {1, 0,-1, 0, 1,-1,-1, 1};
const int dy[8] = {0, 1, 0,-1, 1, 1,-1,-1};
int main()
{
	int h,w;
	cin >> h >> w;
	char board[h][w];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> board[i][j];
		}
	}


	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(board[i][j]=='.'){
				int cnt=0;
			for(int d=0; d<8; d++){
				int ni = i+dx[d];
				int nj = j+dy[d];
				if(ni<0 || h<=ni) continue;
				if(nj<0 || w<=nj) continue;
				if(board[ni][nj]=='#'){
					cnt++;
				}
			}
				cout << cnt;
			}else{
				cout << '#';
			}
		}
		cout << endl;
	}

	return 0;
}

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

// why am I so weak

int a[3];

int main() {
	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	int res = 0;

	while (true) {
		if (a[0] & 1 || a[1] & 1 || a[2] & 1) {
			printf("%d\n", res);
			return 0;
		}

		if (a[0] == a[1] && a[1] == a[2]) {
			puts("-1");
			return 0;
		}

		int b[3];

		b[0] = (a[0] + a[1]) / 2;
		b[1] = (a[0] + a[2]) / 2;
		b[2] = (a[1] + a[2]) / 2;

		res++;
		swap(a, b);
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
ll n,a,b,ans;
int main(){
	n=read(),a=read(),b=read();
	ans+=n/(a+b)*a;
	n%=a+b;
	ans+=min(n,a);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
t=0
for i in range(n):
	aa,bb=a[i],b[i]
	if t>0:
		ans+=min(t,aa)
		aa=aa-t
		if aa<0:
			aa=0
	ans+=min(aa,bb)
	t=bb-aa
if t>0:
	ans+=min(t,a[n])
print(ans)

Measured memory_bytes: 19116
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	
	set<int> numList;
	map<int,int> num;

	for(int i=0;i<N;++i){
		int A;
		cin >> A;
		numList.insert( A );
		if( num.find( A ) != num.end() ){
			num[A]++;
		}else{
			num[A] = 1;
		}
	}
	set<int>::iterator itr,end;
	itr = numList.begin();
	end = numList.end();
	int ans = 0;
	for(;itr!=end;++itr){
		int res = *itr;
		if( num[res] & 1 ){
			++ans;
		}
	}
	cout << ans << endl;
	/*
	int N;
	cin >> N;
	vector<int> hist(10,0);//[0,9]
	for(int i=0;i<N;++i){
		int A;
		cin >> A;
		while(A){
			hist[ A%10 ]++;
			A /= 10;
		}
	}

	int ans = 0;
	for(int i=0;i<=9;++i){
		if( hist[i]&1 ){
			++ans;
		}
	}
	cout << ans << endl;
	*/
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pib = pair<int,bool>;
using ll = long long;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#ifdef fread_unlocked
#define fread fread_unlocked
#define fwrite fwrite_unlocked
#endif
#define mp make_pair
#define lc ind<<1
#define rc ind<<1|1
const int MN = 1e3+5, MOD = 1e9+7, BASE = 31, MASK = (1 << 10) - 1;
int main () {
	int x,y;
	scanf ("%d %d",&x,&y);
	if (y&1) printf ("No\n");
	else {
		int sum = y/2;
		if (sum - x < 0|| 2 * x - sum < 0) printf ("No\n");
		else printf ("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 3768
// C - pushpush

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	vector<int> head, tail;

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

		if (i % 2 == 0) tail.push_back(a);
		else head.push_back(a);
	}

	if (n % 2 == 0) {
		reverse(head.begin(), head.end());
		bool first = true;
		for (int b : head) {
			if (first) first = false;
			else cout << " ";

			cout << b;
		}
		for (int b : tail) {
			cout << " ";
			cout << b;
		}
		cout << endl;
	} else {
		reverse(tail.begin(), tail.end());
		bool first = true;
		for (int b : tail) {
			if (first) first = false;
			else cout << " ";

			cout << b;
		}
		for (int b : head) {
			cout << " ";
			cout << b;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,m;cin>>n>>m;
    rep(i,m){
        ll a;cin>>a;
        n-=a;
    }
    if(n>=0)out(n);
    else out(-1);
}

Measured memory_bytes: 3624
/*
author : seryu
title : CODE FESTIVAL 2017 qual A B_"fLIP"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;

void solve()
{	
    int n, m, k;
    cin >> n >> m >> k;
    rep(i, n+1)rep(j, m+1)
    {
        int b = i*m+j*n-2*i*j;
        if(b == k)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
	return;
}

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



Measured memory_bytes: 3644
n = int(input())
s = input()
if n%2 != 0:
  print('No')
else:
  for i in range(0,n//2):
    if s[i]!=s[i+n//2]:
      print('No')
      break
    else:
      pass
    
    if i==n//2-1:
      print('Yes')

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){

  int n,m,l,i,j,k;
  long am[100][100],bm[100][100],cm[100][100]={};

  cin>>n>>m>>l;
  for(i=0; i<n; i++)for(j=0; j<m; j++)cin>>am[i][j];
  for(j=0; j<m; j++)for(k=0; k<l; k++)cin>>bm[j][k];
  for(i=0; i<n; i++)for(k=0; k<l; k++)for(j=0; j<m; j++)cm[i][k]+=am[i][j]*bm[j\
][k];

  for(i=0; i<n; i++){
    for(k=0; k<l; k++){
            if(k==l-1){
        cout<<cm[i][k]<<"\n";
        break;
      }

      cout<<cm[i][k]<<" ";
    }
  }

}

Measured memory_bytes: 1408
using System;
using System.Globalization;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        var N = ScanInt();
        var array = new (int index, string s, int p)[N];
        for (int i = 0; i < N; i++) {
            array[i].index = i;
            array[i].s = Scan();
            array[i].p = ScanInt();
        }
        Array.Sort(array, (a, b) => a.s != b.s ? string.CompareOrdinal(a.s, b.s) : -a.p.CompareTo(b.p));
        foreach (var (index, _, _) in array) {
            Console.WriteLine(index + 1);
        }
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var ch = GetChar(); '!' <= ch && ch <= '~'; ch = (char) ConsoleIn()) {
            sb.Append(ch);
        }
        return sb.ToString();
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) ConsoleIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 23972
def reconsruction(pre, ino):
    if 0 == len(pre):
        return []
    else:
        root = pre[0]

        partition = ino.index(root)
        l_ino = ino[0:partition]
        r_ino = ino[partition+1:]

        pre_partition = len(l_ino)+1
        l_pre = pre[1:pre_partition]
        r_pre = pre[pre_partition:]

        return reconsruction(l_pre, l_ino) + reconsruction(r_pre, r_ino) + [root]

n = int(input())

t = [None] * n
pre = list(map(int, input().split()))
ino = list(map(int, input().split()))

print(*reconsruction(pre, ino))

Measured memory_bytes: 7732
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    

    ll n;
    string s;
    cin >> n >> s;

    ll r[n] = {0} , g[n] = {0} , b[n] = {0};

    for(ll i=0 ; i<n ; i++) {
        if(s[i]=='R') {
            r[i]++;
        }
        else if(s[i] == 'G') {
            g[i]++;
        }
        else {
            b[i]++;
        }

        if(i!=0) {
            r[i]+=r[i-1];
            g[i]+=g[i-1];
            b[i]+=b[i-1];
        }
    }

    ll ans=0;

    for(ll i=0 ; i<n-2;i++) {
        for(ll j = i+1 ; j<n-1 ; j++) {
            if(s[i] == s[j]) {
                continue;
            }
            ll k = 2*j-i;
            if(s[i]=='R' && s[j]=='G') {
                ans+=b[n-1] - b[j];
                if(k < n) {
                    if(s[k] == 'B') {
                        ans--;
                    }
                }
            }
            else if(s[i]=='R' && s[j]=='B') {
                ans+=g[n-1] - g[j];
                if(k < n) {
                    if(s[k] == 'G') {
                        ans--;
                    }
                }
            }
            else if(s[i]=='G' && s[j]=='R') {
                ans+=b[n-1] - b[j];
                if(k < n) {
                    if(s[k] == 'B') {
                        ans--;
                    }
                }
            }
            else if(s[i]=='G' && s[j]=='B') {
                ans+=r[n-1] - r[j];
                if(k < n) {
                    if(s[k] == 'R') {
                        ans--;
                    }
                }
            }
            else if(s[i]=='B' && s[j]=='R') {
                ans+=g[n-1] - g[j];
                if(k < n) {
                    if(s[k] == 'G') {
                        ans--;
                    }
                }
            }
            else if(s[i]=='B' && s[j]=='G') {
                ans+=r[n-1] - r[j];
                if(k < n) {
                    if(s[k] == 'R') {
                        ans--;
                    }
                }
            }
        }
    }

    cout << ans;

    
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
ll fac[200100];
ll inv[200100];
ll facinv[200100];
void C_init(){
    fac[0] = 1;
    for(int i = 1;i < 200100;i++)fac[i] = (fac[i-1] * i)%mod;
    inv[1] = 1;
    for(int i = 2;i < 200100;i++)inv[i] = ((-(mod/i)*inv[mod%i])%mod+mod)%mod;
    facinv[0] = 1;
    for(int i = 1;i < 200100;i++)facinv[i] = (facinv[i-1] * inv[i])%mod;
    return;
}
ll nCr(ll n, ll r){
    return max((ll)0,((fac[n] * facinv[n-r])%mod * facinv[r])%mod);
}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  ll n, k;
  cin >> n >> k;
  C_init();
  for (ll i = 1; i <= k; i++) {
    if (i <= n-k+1) {
    ll ans = nCr(k-1, i-1);
    ans %= mod;
    ll x = nCr(n-k+1, i);
    x %= mod;
    ans *= x;
    ans %= mod;
    cout << ans << endl;
    }
    else {
      cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))
now = a[0]
num = 1
ans = 0
for i in a[1:]:
  if now == i:
    num += 1
  else:
    ans += num // 2
    num = 1
  now = i
ans += num // 2
print(ans)
    

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x, t;
		x = sc.nextInt();
		t = sc.nextInt();
		sc.close();
		
		int ans = x - t;
		if(ans < 0)ans = 0;
		System.out.println(ans);
	}

}


Measured memory_bytes: 20948
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int R; cin >> R;

    string contest;
    if (R < 1200) {
        contest = "ABC";
    } else if (R < 2800) {
        contest = "ARC";
    } else {
        contest = "AGC";
    }

    cout << contest << endl;
    return 0;
}

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

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

int getIdx(int y, int x, int h, int w)
{
    if(y < 0 || y >= h || x < 0 || x >= w)
    {
        return -1;
    }
    return y*w+x;
}

pair<int,int> getXY(int idx, int w)
{
    return make_pair(idx%w,idx/w);
}

int main()
{
    int h,w;
    cin >> h >> w;
    vector<char> mat(h*w);
    vector<bool> checker(h*w);
    queue<pair<int,int>> que;
    for(int i = 0; i < h*w; ++i)
    {
        cin >> mat[i];
        if(mat[i] == '#')
        {
            que.push(make_pair(i,0));
            checker[i] = true;
        }
    }

    int ans = 0;
    while(!que.empty())
    {
        pair<int,int> tp = que.front();
        int t = tp.first;
        int layer = tp.second;
        ans = max(ans, layer);
        que.pop();
        pair<int,int> p = getXY(t,w);
        for(int i = 0; i < 4; ++i)
        {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            int nidx = getIdx(ny,nx,h,w);
            if(nidx != -1 && !checker[nidx])
            {
                que.push(make_pair(nidx,layer+1));
                checker[nidx] = true;
            }
        }
    }

    cout << ans << endl;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 ll LC(ll X, ll Y) {
   if (X < Y) swap(X, Y);
   ll x = X, y = Y;
   while (x % y != 0) {
     x %= y;
     swap(x, y);
   }
   return X * Y / y;
 }

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

   cout << B - A + 1 - (B / C - (A - 1) / C + B / D - (A - 1) / D - B / LC(C, D) + (A - 1) / LC(C, D)) << endl;
 }


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val x = readLine()!!.split(" ").map { it.toInt() }
    val ar = Array<Int>(100){0}

    for(i in 0 until 100) {
        var a = 0
        for(j in x) {
            a += (j - (i+1)) * (j - (i+1))
        }
        ar[i] = a
    }

    println(ar.min())

}

Measured memory_bytes: 37992
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
string x;
int o;
char a,b;
int main()
{
	cin>>x;
	a=x[0],b=x[x.size()-1];
	for(int i=1;;i++)
	{
		if(b==x[i]&&i>x.size()-2)break;
		o++;
	}
	cout<<a<<o<<b<<endl;
}

Measured memory_bytes: 256