akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef int ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll priority ( char alpha )
{
    if(alpha == '+' || alpha =='-')
    {
        return(1);
    }
 
    if(alpha == '*' || alpha =='/')
    {
        return(2);
    }
 
    if(alpha == '^')
    {
        return(3);
    }
 
    return 0;
}
int main()
{
    fast;
   ll t=1;
   //std::cin >> t;
   while(t--)
   {
       string s;
       ll n;
       std::cin >> n;
       ll a[n],b[n],x=0,y=0;
       fr(i,0,n)
       {
           std::cin >> a[i]>>b[i];
           if(a[i]==b[i])
           x++;
           else
           x=0;
           if(x>=3)
           y=1;
       }
       if(y)
       cout<<"Yes\n";
       else
       cout<<"No\n";
   }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


ll dp[5000][5000], v[5000], n, flag[5000][5000];
ll calc(ll l, ll r){
    if(flag[l][r]) return dp[l][r];
    flag[l][r] = 1;
    if(l==r) return dp[l][r]=v[l];
    return dp[l][r] = max(v[l]-calc(l+1, r), v[r]-calc(l, r-1));
}
int main(){
    cin >> n;
    rep(i, n)   cin >> v[i+1];

    cout << calc(1, n) << endl;
}


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

int main(){
    ll r,d,x;
    cin >> r >> d >> x;
    int i;
    ll tmp;
    tmp=x;
    for(i=0;i<10;i++){
        tmp=r*tmp-d;
        cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int S,W;
  cin>>S>>W;
  if(S<=W) cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
 
  if(s.at(0)!=s.at(1)&&s.at(1)!=s.at(2)&&s.at(0)!=s.at(2))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int i,n,d[6]={2,4,8,16,32,64};
	cin>>n;
	for(i=0;i<6;i++){
		if(d[i]>n){
			cout<<d[i-1]<<endl;
			return 0;
		}
	}
  cout<<d[i-1]<<endl;
	return 0;
}

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


int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m);

    int sum = 0;
    rep(i, m) {
        cin >> a.at(i);
        sum += a.at(i);
    } 

    cout << max(n - sum, -1) << endl;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string s,t;
  cin >> s;
  cin >> t;
  if(t.find(s)==0 && t.length()==s.length()+1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
 using namespace std;
 int main()
 {
     long long int x,y;
     cin>>x>>y;
     long long int lc=(x*y)/__gcd(x,y);
     long long int answer=-1;
     for(int i=x;i<lc;i++)
     {
         if(i%y!=0)
         {
             answer=i;
             break;
         }
     }
     cout<<answer<<endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main(){
  int n;cin>>n;vector<int> p;
  for(int i = 1;i * i <= n;i++){
    if(i * i == n){
      cout << to_string(i).length() << endl;
      return 0;
    }
    if(!(n%i)){
      p.push_back(i);p.push_back(n/i);
    }
  }
  sort(p.begin(), p.end());
  int rt = ceil(sqrt(n)),
      low = *lower_bound(p.begin(), p.end(), rt);
  cout << to_string(low).length() << endl;
}

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

#pragma GCC diagnostic warning "-Wconversion"

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

using ll = long long;

int out[100][100];

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

        int h, w, n;
        cin >> h >> w >> n;

        int x = 0, y = 0;
        int dy = 1;
        forb(i, n)
        {
                int a;
                cin >> a;
                fora(j, a)
                {
                        out[x][y] = i;
                        y += dy;
                        if (y == -1 || y == w)
                        {
                                ++x;
                                dy *= -1;
                                y += dy;
                        }
                }
        }

        fora(i, h)
        {
                fora(j, w)
                {
                        cout << out[i][j] << ' ';
                }
                cout << '\n';
        }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  if(a >= b){
    cout << "delicious" << endl;
  }

  else{
    if(x >= b-a){
      cout << "safe" << endl;
    }
    else{
      cout << "dangerous" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n, m;
vector<vector<lli>> v;
vector<bool> seen;

void dfs(lli x){
  if(seen[x]) return;
  seen[x] = true;
  for(auto to : v[x]){
    dfs(to);
  }
  return;
}

lli getcomp(){
  lli ret = 0;
  rep(i, n){
    if(!seen[i]){
      dfs(i);
      ret++;
    }
  }
  return ret;
}

int main(void){
  cin >> n >> m;
  v.resize(n);
  seen.resize(n);
  rep(i, m){
    lli a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  cout << getcomp()-1 << endl;
  return 0;
}


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

int main()
{
  int N;scanf("%d",&N);
  int T[N];int sum=0;
  for(int i=0;i<N;i++){scanf("%d ",&T[i]);sum+=T[i];}
  int M;scanf("%d",&M);
  int P[M],X[M];
  for(int i=0;i<M;i++){scanf("%d %d",&P[i],&X[i]);int s=sum-T[P[i]-1]+X[i];printf("%d\n",s);}
}

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

int main(){
    int N,K; cin >> N >> K;
    int R,S,P; cin >> R >> S >> P;
    string T; cin >> T;
    int dp[N][3]={};
    int point[3]={R,S,P};
    int c[N];
    for(int i=0;i<N;i++){
        if(T[i]=='r') c[i]=2;
        if(T[i]=='p') c[i]=1;
        if(T[i]=='s') c[i]=0;
    }
    for(int i=0;i<K;i++){
        dp[i][c[i]]=point[c[i]];
        for(int j=i;j<N-K;j+=K){
            for(int k=0;k<3;k++){
                if(c[j+K]==k){
                    dp[j+K][k]=max(dp[j][(k+1)%3],dp[j][(k+2)%3])+point[k];
                }else{
                    dp[j+K][k]=max(dp[j][(k+1)%3],dp[j][(k+2)%3]);
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<=K;i++){
        ans+=max(dp[N-i][0],max(dp[N-i][1],dp[N-i][2]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const ll inf = 1e17, N = 2000007;
ll ar[N];
int main()
{
    ll n, m;
    cin>>n>>m;
    if(n > m)
    {
        cout<<min((m - (n % m)), n % m)<<"\n";
    }
    else cout<<min((m - n), n)<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(){
    while(true) {
        int a = 0, b = 0;
        int n = 0;
        std::cin >> a >> b;
        if(a == 0 && b == 0){
            break;
        }
        std::cin >> n;
        //2dim array : road
        std::vector<std::vector<int>> road;
        road = std::vector<std::vector<int>>(a, std::vector<int>(b, 0));
        //left end road = 1
        for (int i = 1; i < b; ++i) {
            road[0][i] = 1;
        }
        //bottom end road = 1
        for (int i = 1; i < a; ++i) {
            road[i][0] = 1;
        }

        //Construct point is -1
        for (int i = 0; i < n; ++i) {
            int x, y;
            std::cin >> x >> y;
            road[x-1][y-1] = -1;
            //if left end, later is 0
            if(x == 1){
                for(int i = y-1; i< b; ++i){
                    road[0][i] = 0;
                }
            }
            //if bottom end, later is 0 
            if(y == 1){
                for(int i = x-1; i < a; ++i){
                    road[i][0] = 0;
                }
            }
        }
        //constructing point is 0, and road[i-1][j] + road[i][j-1]
        for (int i = 1; i < a; ++i) {
            for (int j = 1; j < b; ++j) {
                if (road[i][j] == -1) {
                    road[i][j] = 0;
                } else {
                    road[i][j] = road[i-1][j] + road[i][j-1];
                }
            }
        }
        std::cout << road[a-1][b-1] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2968
#include<bits/stdc++.h>
#define IL inline
#define _ 1000005
#define ll long long
using namespace std ;

IL ll gi(){
	ll data = 0 , m = 1; char ch = 0;
	while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
	if(ch == '-'){m = 0 ; ch = getchar() ; }
	while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
	return (m) ? data : -data ; 
}

ll fa[_],sz[_],m,n,d[_],f[_],g[_] ; 
struct Item{ll id , dis ; } t[_] ; 

struct _Edge{int to,next ; }Edge[_<<1] ; int head[_],CNT ;  
IL void AddEdge(int u , int v) {
    Edge[++CNT] = (_Edge){v , head[u]} ; head[u] = CNT ; 
    return ;  
}

IL bool cmp1(Item A , Item B){
	return (A.dis ^ B.dis) ? A.dis < B.dis : A.id < B.id ;  
}
IL bool cmp2(Item A , Item B){
	return (A.id ^ B.id) ? A.id < B.id : A.dis < B.dis ;  
}

void dfs1(int u , int From) {
    sz[u] = 1ll ;
    for(int e = head[u] ; e ; e = Edge[e].next) {
        int v = Edge[e].to ; if(v == From) continue ; 
        dfs1(v , u) ;
        f[u] += f[v] + sz[v] ; 
        sz[u] += sz[v] ;  
    }
    return ; 
}
void dfs2(int u , int From) {
    for(int e = head[u] ; e ; e = Edge[e].next) {
        int v = Edge[e].to ; if(v == From) continue ; 
        g[v] = f[u] + g[u] - (f[v] + sz[v]) + (n - sz[v]) ; 
        dfs2(v , u) ; 
    }
    return ; 
}

int main() {
	n = gi() ;
	for(int i = 1; i <= n; i ++) t[i].id = i , t[i].dis = gi() ;
	sort(t + 1 , t + n + 1 , cmp1) ;
	for(int i = 1; i <= n; i ++) d[i] = t[i].dis ; 
	d[n + 1] = 1e18 ;  
	for(int i = n; i > 1; i --) {
		int u = t[i].id ; 
		sz[u] ++ ; 
		ll ds = t[i].dis + 2ll * sz[u] - n ;
		ll ps = lower_bound(d + 1 , d + n + 2 , ds) - d ;
		if(ps >= i || t[ps].dis != ds) return puts("-1") , 0 ;
		fa[u] = t[ps].id ;
		sz[t[ps].id] += sz[u] ; 
	}
	sort(t + 1 , t + n + 1 , cmp2) ; 
	for(int i = 1; i <= n; i ++) if(fa[i]) AddEdge(fa[i],i) , AddEdge(i,fa[i]) ; 
	dfs1(1 , 0) ; 
	dfs2(1 , 0) ; 
	//for(int i = 1; i <= n; i ++)
	//    printf("f[%d] = %lld  ;  g[%d] = %lld\n",i,f[i],i,g[i]) ;
	for(int i = 1; i <= n; i ++) if(f[i]+g[i] != t[i].dis) return puts("-1") , 0 ;
	for(int i = 1; i <= n; i ++) if(fa[i]) cout << fa[i] << " " << i << endl ;
	return 0 ; 
}

Measured memory_bytes: 28928
#include <complex>
#include <cstdio>
#include <iostream>
using namespace std;
#define X real()
#define Y imag()
#define EPS (1e-10)
typedef complex<double> P;
typedef pair<P, P> L;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

P projection(P a, P b){
  return dot(a, b)/abs(b)/abs(b)*b;
}


P intersection(L a, L b){
  //??´???a??¨??´???b?????????
  return a.first + cross(b.second-b.first,a.first-b.first)/(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first))*(a.second-a.first);
}


int main(){
  int q;
  cin >> q;
  P points[4];
  for(int i = 0; i < q; ++i){
    for(int j = 0; j < 4; ++j){
      double x, y;
      cin >> x >> y;
      points[j] = P(x, y);
    }
    L l1 = L(points[0],points[1]), l2 = L(points[2], points[3]);
    printf("%.10lf %.10lf\n", intersection(l1, l2).X, intersection(l1, l2).Y);
  }
  return 0;
}

Measured memory_bytes: 3208
#include<iostream>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
#define pi acos(-1)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ve vector<ll>
#define se set<ll>
#define pll vector<pair<ll,ll>>
const string space=" ";
const ll maxx=200;
ll n,m,k,sum,faltu,t,p,i,j;
bool fg,a[maxx];
int main()
{
string s;
cin>>s;
if(s=="ABC")
cout<<"ARC"<<endl;
else
cout<<"ABC"<<endl;
    return 0;
}
    

Measured memory_bytes: 3624
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll dp[N][3];

ll a[N], b[N], c[N];

void solve(){
    ll n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 1; i <= n; ++i){
        dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N, M;
  cin >> N >> M;
  int64_t S = 1, I = 1;
  for (int i = 1; i <= N; i++) {
    I *= i;
    I %= 1000000007;
  }
  for (int i = 1; i <= M; i++) {
    S *= i;
    S %= 1000000007;
  }
  if (abs(N - M) > 1) {
    cout << 0 << endl;
  }
  else if ((N - M) == 0) {
    int64_t ans = I * S;
    ans %= 1000000007;
    ans *= 2;
    ans %= 1000000007;
    cout << ans << endl;
  }
  else {
    int64_t ans = I * S;
    ans %= 1000000007;
    cout << ans << endl;
  }
}
  

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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  string ans;
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int> A(Q),P(N,K-Q);
  rep(i,Q) cin >> A[i];
  map<int, int> cnt;
  for (int x : A) {
    if (cnt.count(x-1)) {
      // 既に含まれているならインクリメント
      cnt.at(x-1)++;
    } else {
      // 含まれていないなら、1を追加
      cnt[x-1] = 1;
    }
  }
  
  for(int i=0;i<cnt.size();i++) {
    P[i] += cnt[i];
  }
  rep(i,N){
    if(P[i]>0) ans="Yes";
    else ans = "No";
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 8804
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	set<int> s;
	int q; cin >> q;
	VI qu(q), x(q);
	rep(i, q)cin >> qu[i] >> x[i];

	rep(i, q) {
		if (qu[i] == 0) {
			s.insert(x[i]);
			cout << sz(s) << endl;
		}
		else if (qu[i] == 1) {
			puts(s.find(x[i]) != s.end() ? "1" : "0");
		}
		else {
			s.erase(x[i]);
		}
	}
}


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




int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int scoreAlice = 0, scoreBob = 0;
	bool flag = true;
	for (int i = n - 1; i >= 0; i--) {
		if (flag == true) {
			scoreAlice += a[i];
			flag = false;
		}
		else {
			scoreBob += a[i];
			flag = true;
		}
	}
	cout << scoreAlice - scoreBob << endl;
	return 0;
}


Measured memory_bytes: 256
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();
		String t = sc.next();
		
		int same=0;
		int i;
		if(s.equals(t)){
			System.out.println(N);
		} else{
			for(i=0;i<N-1;i++){
				if(s.substring(N-1-i).equals(t.substring(0,i+1))) same=i+1;
			}
			
			System.out.println(2*N-same);
		}

	}

}


Measured memory_bytes: 9684
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/10 20:00:37
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

void run() {
    string s, t; cin >> s >> t;
    int n = s.length(), m = t.length();
    if (m == n + 1 && t.substr(0, n) == s) {
        cout << "Yes" << '\n';
    } else cout << "No" << '\n';
}

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

Measured memory_bytes: 3656
#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 h,w;
  cin >> h >> w;
  
  string s[h];
  rep(i,h) cin >> s[i];
  
  rep(i,h){
    cout << s[i] << endl << s[i] << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

/*
 * Constraints:
 * n = 1e5
 * X = 1e9
 * x[i] = 1e9
 */

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

	int n, x;
	cin >> n >> x;

	vi vec(n);
	rep(i, 0, n)
		cin >> vec[i];

	vec.push_back(x);

	sort(all(vec));

	int gcd = 0;
	rep(i, 0, n)
		gcd = __gcd(gcd, vec[i+1]-vec[i]);
	cout << gcd << endl;

	return 0;
}


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

int main(){
  char C;
  cin >> C;
  vector<char> alphabet={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  for(int i=0;i<25;i++){
    if(C==alphabet.at(i)){
      cout << alphabet.at(i+1) << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

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

    multiset<long long> left, right;
    long long a_sum = 0, b_sum = 0;

    for (int i = 0; i < q; i++) {
        int r;
        cin >> r;

        if (r == 1) {
            long long a, b;
            cin >> a >> b;

            if (i == 0 || (*left.rbegin() <= a && a <= *right.begin())) {
                left.insert(a);
                right.insert(a);
            } else if (a < *left.rbegin()) {
                a_sum += *left.rbegin() - a;
                left.insert(a);
                left.insert(a);
                right.insert(*left.rbegin());
                left.erase((++left.rbegin()).base());
            } else {
                a_sum += a - *right.begin();
                right.insert(a);
                right.insert(a);
                left.insert(*right.begin());
                right.erase(right.begin());
            }

            b_sum += b;
        } else {
            cout << *left.rbegin() << " " << a_sum + b_sum << endl;
        }
    }
}


Measured memory_bytes: 18944
#include <iostream>
inline void DPri(int n){
  std::cout<<n<<std::endl;
}
int recsion(int n,int a,int c){
  if(n==1)return c;
  int d=n;
  while(!(d%a)){
    if(!(d%a))d/=a,c++;
  }
  recsion(n-1,a,c);
}

int main(){
  int n;
  while(std::cin>>n){
    if(!n)break;
    int c=recsion(n,10,0),a=recsion(n,2,0)-c,b=recsion(n,5,0)-c,res=0;
    a>b?res+=(b+c):res+=(a+c);
    std::cout<<res<<std::endl;
  }
  return 0;
}

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

int main()
{
	bool b=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C') b=1;
		if(b&&s[i]=='F')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=60;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,ans=inf,fa1[N],fa2[N],vis[N],cnt=0,du[N];
vector<int> E1[N],E2[N],E[N];
void dfs1(int u,int fa) {
    fa1[u]=fa;
    for(int v:E1[u]) if(v!=fa) dfs1(v,u);
}
void dfs2(int u,int fa) {
    fa2[u]=fa;
    if(!fa) vis[u]=1,++cnt;
    else {
        vis[u]=vis[fa]&&(fa1[u]==fa2[u]);
        if(vis[u]) ++cnt;
    }
    for(int v:E2[u]) if(v!=fa) dfs2(v,u);
}
void solve(int u) {
    cnt=0,clr(du),clr(vis);
    for(int i=1;i<=n;i++) E[i].clear();
    dfs1(u,0),dfs2(u,0);
    for(int i=1;i<=n;i++)
        if(i!=u) {
            if(!vis[i]&&!vis[fa1[i]]) E[i].pb(fa1[i]),++du[fa1[i]];
            if(!vis[i]&&!vis[fa2[i]]) E[fa2[i]].pb(i),++du[i];
        }
    queue<int> q;
    for(int i=1;i<=n;i++) if(!du[i]) q.push(i);
    while(!q.empty()) {
        int u=q.front();q.pop();
        for(int v:E[u]) if(!--du[v]) q.push(v);
    }
    for(int i=1;i<=n;i++) if(du[i]) return;
    chkmin(ans,n-cnt);
}
void work() {
    n=gi(),ans=inf;
    for(int i=1;i<=n;i++) E1[i].clear(),E2[i].clear();
    for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E1[u].pb(v),E1[v].pb(u);
    for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E2[u].pb(v),E2[v].pb(u);
    int fl=1;
    for(int i=1;i<=n;i++) {
        sort(all(E1[i])),sort(all(E2[i]));
        if(E1[i]!=E2[i]) fl=0;
    }
    if(fl) { puts("0");return; }
    for(int i=1;i<=n;i++)
        if(sz(E1[i])==1) {
            int j=E1[i][0];
            for(int &x:E1[j]) if(x==i) { swap(x,E1[j].back());break; }
            for(int k=1;k<=n;k++)
                if(k!=i) {
                    E1[i].pop_back(),E1[j].pop_back(),E1[k].pb(i),E1[i].pb(k);
                    solve(i);
                    E1[k].pop_back(),E1[i].pop_back(),E1[i].pb(j),E1[j].pb(i);
                }
        }
    if(ans==inf) puts("-1");
    else printf("%d\n",ans+1);
}
int main() {
    int T=gi();
    while(T--) work();
    return 0;
}


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

const ll mod = 1000000007;
ll fact[210200];
ll invfact[210200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    if(k == 0){
        return 1;
    }
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

int main() {
    ll a_, b_, c_, n, a, b, c;
    cin >> n >> a_ >> b_ >> c_;

    a_ = mul(a_, mod_inv(100));
    b_ = mul(b_, mod_inv(100));
    a = mul(a_, mod_inv(a_ + b_));
    b = mul(b_, mod_inv(a_ + b_));
    c = mul(c_, mod_inv(100));

    make_fact(200010);
    make_invfact(200010);

    ll res = 0;
    for (int m = n; m < 2 * n; ++m) {
        ll now = comb(m - 1, n - 1);
        now = mul(now, m);

        ll tmp = add(mul(pow(a, n), pow(b, m - n)), mul(pow(b, n), pow(a, m - n)));
        now = mul(now, tmp);

        res = add(res, now);
    }

    res = mul(res, mod_inv(1 - c));
    cout << res << endl;

    return 0;
}

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

void mg(pair<int,char> a[],int l,int m,int r){
  int n1=m-l,n2=r-m;
  pair<int,char> L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++)L[i]=a[l+i];
  for(int i=0;i<n2;i++)R[i]=a[m+i];
  L[n1].first=1000000001,R[n2].first=1000000001;
  int i=0,j=0;
  for(int k=l;k<r;k++)L[i].first<=R[j].first?a[k]=L[i++]:a[k]=R[j++];
}

void mgs(pair<int,char> a[],int l,int r){
  if(l+1<r){
    int m=(l+r)/2;
    mgs(a,l,m);
    mgs(a,m,r);
    mg(a,l,m,r);
  }
}


int part(pair<int,char> a[],int p,int r){
  int x=a[r].first,i=p-1;
  for(int j=p;j<r;j++){
    if(a[j].first<=x){
      i++;
      swap(a[i],a[j]);
    }
  }
  swap(a[i+1],a[r]);
  return i+1;
}

void quick(pair<int,char> a[],int p,int r){
  if(p<r){
    int q=part(a,p,r);
    quick(a,p,q-1);
    quick(a,q,r);
  }
}

int main(){
  int n;
  pair<int,char> a[100001],b[100001];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i].second>>a[i].first;
    b[i]=a[i];
  }

  quick(a,0,n-1);
  mgs(b,0,n);
  
  int cnt=0;
  for(int i=0;i<n;i++)if(a[i].second!=b[i].second)cnt++;
  cout<<(cnt?"Not stable":"Stable")<<endl;
  for(int i=0;i<n;i++)cout<<a[i].second<<" "<<a[i].first<<endl;
  return 0;
}

Measured memory_bytes: 5292
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    int n;
    String s;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	int mx = 0;
	int x = 0;
	for(int i = 0; i < s.length(); i++) {
	    if(s.charAt(i) == 'I') x++;
	    else x--;

	    mx = Math.max(mx, x);
	}
	
	out(mx);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	s = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

template<class T>
inline void read(T& x) {
  T s = 0, base = 1;
  char c;
  while (!isdigit(c=getchar())) if (c == '-') base = -base;
  while (isdigit(c)) {
    s = s * 10 + (c^48);
    c = getchar();
  }
  x = base * s;
}

string S, T;

int main() {
  cin >> S >> T;

  REP(i,S.length()) {
    if (S[0] == T[i]) {
      bool bCheck = true;
      REP(j,S.length()) {
        if (S[j] != T[(i + j) % S.length()]) {
          bCheck = false;
          break;
        }
      }
      if (bCheck) {
        printf("Yes\n");
        return 0;
      }
    }
  }
  
  printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define tr1(x)                cout<<#x<<": "<<x<<endl
#define tr2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define tr4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define tr3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db1(x) cerr << #x << ": " << x <<'\n'
#define db2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define db3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int, int> &a,const pair<int, int> &b)
{
    if(a.ss == b.ss){
        return (a.ff < b.ff);
    }
    return (a.ss<b.ss);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b, int c){
    return(max( max(a,b), c ));
}
int min(int a, int b, int c){
    return (min ( min(a,b) , c));
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;

    return res;
}
int findlcm(int arr[], int n) 
{ 
    // Initialize result 
    int ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (__gcd(arr[i], ans))); 
  
    return ans; 
}
bool prime[100001];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}

//Define mx for maximum range and MOD for large numbers
#define mx 500005
#define mod 1000000007 

// Declare all the variables and global functions here -

int32_t main(){
    IOS;
    int n;
    cin >> n;
    vii v;
    rep(i, 0, n){
        int c,d;
        cin >>  c >> d;
        v.pb(mp(c, d));
    }

    sort(all(v), compare);
    int t = 0;
    rep(i, 0, n){
        t += v[i].ff;
        if(t > v[i].ss){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;



}   

Measured memory_bytes: 6512
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<lint> data;
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

public:
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> bridge(M);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		bridge[i] = { a,b };
	}

	lint incon = 1LL * N * (N - 1) / 2;
	vector<lint> ans(M);
	UnionFind uf(N);
	for (int i = M - 1; i >= 0; i--) {
		ans[i] = incon;
		if (!uf.is_same(bridge[i].first, bridge[i].second)) {
			incon -= 1LL * uf.size(bridge[i].first)*uf.size(bridge[i].second);
			uf.unify(bridge[i].first, bridge[i].second);
		}
	}

	for (const auto &e : ans) cout << e << "\n";

	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline int read()
{
	int x = 0, op = 1; char ch = 0;
	while(not isdigit(ch = getchar())) if(ch == '-') op = -op;
	do x = x * 10 + (ch - '0'); while(isdigit(ch = getchar()));
	return op * x;
}
inline bool check(int a, int x, int y, int z)
{
	int u = 0, v = 0, w = 0;
	#define pows(a, b) \
		u = (a), v = (b), w = 1;\
		while(v) { if(v & 1) w = w * u % x; u = u * u % x, v >>= 1; }
	pows(a, z);
	if(w > 1) { 
		for(int i = 0; i < y; i++)
		{
			if(w == x - 1) return true;
			w = w * w % x;
		}
		return false;
	}
	else return true;
}
bool isprime(int x)
{
	if(x == 2 || x == 3 || x == 7 || x == 61) return true;
	if(!(x % 2 && x % 7 && x % 61 && x % 3) || x == 1) return false;
	int y = 0, z = x - 1; while(!(z & 1)) y++, z >>= 1;
	bool ok = true;	
	ok &= check(2, x, y, z);
	ok &= check(3, x, y, z);
	ok &= check(7, x, y, z);
	ok &= check(61, x, y, z);
	return ok;
}
int n = 0, m = 0, pos[150], whi[300];
bool used[300]; int ans = 0;
int pygo[300]; bool insta[300];
bool dfs(int x, int p)
{
	for(int i = 1; i <= m; i++)
		if(not insta[i] && (abs(whi[x] - whi[i]) > 2 && isprime(abs(whi[x] - whi[i]))) && p != i)
		{
			insta[i] = true;
			if(!pygo[i] || dfs(pygo[i], p))
			{
				pygo[x] = i, pygo[i] = x;
				used[x] = used[i] = true;
				return true;
			}
		}
	return false;
}
signed main()
{
	n = read();
	for(int i = 1; i <= n; i++) pos[i] = read();
	sort(pos + 1, pos + n + 1);
	for(int i = 1; i <= n; i++)
	{
		if(i == 1 || pos[i] != pos[i - 1] + 1) whi[++m] = pos[i];
		if(i == n || pos[i] != pos[i + 1] - 1) whi[++m] = pos[i] + 1;
	}
	for(int i = 1; i <= m; i++)
		if(not used[i]) memset(insta, 0, sizeof insta), dfs(i, i);
	for(int i = 1; i <= m; i++)
		if(used[i]) ans++;
	/*for(int i = 1; i <= m; i++)
		if(used[i] && pygo[i] > i) cerr << whi[pygo[i]] - whi[i] << " ";
	cerr << endl;*/
	ans >>= 1LL;
	int tot[2] = {0, 0};
	for(int i = 1; i <= m; i++)
		if(not used[i]) tot[whi[i] & 1]++;
	ans += (((tot[0] / 2) + (tot[1] / 2)) * 2) + (tot[0] - tot[0] / 2 * 2) * 3LL;
	cout << ans << endl;
	return 0;
}

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

int main() {

    vector<ll> anss;
    
    for (ll n, m; cin >> n >> m, n; ) {

        vector<ll> d(n), p(n);
        REP(i, n) {
            cin >> d[i] >> p[i];
        }

        vector<ll> rp(n);
        iota(rp.begin(), rp.end(), 0LL);
        sort(rp.begin(), rp.end(), [&](ll i, ll j) {
            return p[i] > p[j];
        });
    
        ll ans = 0;
        REP(x, n) {
            ll i = rp[x];
            ll q = min(d[i], m);
            m -= q;
            ans += p[i] * (d[i] - q);
        }

        anss.push_back(ans);
        
    }

    for (ll ans : anss) cout << ans << endl;

}


Measured memory_bytes: 3220
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		String x = S.substring(0,S.length());
		String y = T.substring(0,S.length());
		if(x.equals(y)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
  }
}

Measured memory_bytes: 35572
fun main(args:Array<String>) {
  val n = readLine()
  var ins = readLine()!!.split(" ").map(String::toLong)

  var c = 0
  while(true) {
    if( ! ins.all { it%2L == 0L } ) break
    c += 1
    ins  = ins.map { it/2L }
  }
  println(c)
}

Measured memory_bytes: 37880
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if(K % 2 == 0) {
    cout << A - B << endl;
  }
  else {
    cout << B - A << endl;
  }
}

Measured memory_bytes: 3596
import java.util.*;
public class Main {
     
    class C {
        int ind;
        int value;
        public C(int ind, int value) {
            super();
            this.ind = ind;
            this.value = value;
        }
         
    }
 
    private void doit() {
        Scanner sc = new Scanner(System.in);
         
        while(true){
            String str = sc.nextLine();
            if(str.equals("0")){
                break;
            }
            String [] array = str.split(" ");
            int len = array.length;
            if(len > 22){
            	System.out.println(0);
            	continue;
            }
            int [] data = new int[len];
             
            for(int i =0 ;i  < len; i++){
                data[i] = Integer.parseInt(array[i]);
            }
             
            LinkedList<C> open = new LinkedList<C>();
            open.add(new C(0,0));
            int ans = 0;
            while(! open.isEmpty()){
                C now = open.removeFirst();
                int value = now.value;
                int index = now.ind;
                if(index + 1 == len){
                    if(data[index] == 1){
                        if(value + 11 <= 21){
                            ans = Math.max(ans, value + 11);
                            continue;
                        }
                        else if(value + 1 <= 21){
                        	ans = Math.max(ans, value + 1);
                            continue;
                        }
                        else{
                        	continue;
                        }
                    }
                    else if(data[index] >= 10){
                        value = value + 10;
                    }
                    else{
                        value = value + data[index];
                    }
                    if( value  > 21) value = 0;
                    ans = Math.max(ans, value);
                    continue;
                }
                if(data[index] == 1){
                    index++;
                    open.add(new C(index, value + 1));
                    open.add(new C(index, value + 11));
                }
                else if(data[index] >= 10){
                    index++;
                    open.add(new C(index, value + 10));
                }
                else{
                    index++;
                    open.add(new C(index,value + data[index - 1]));
                }
            }
            System.out.println(ans);
             
        }
    }
    public static void main(String[] args) {
        Main obj = new Main();
        obj.doit();
 
    }
 
}

Measured memory_bytes: 12000
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const W = 0;
const B = 1;

class S {
    public int stone;
    public int count;

    this(int stone, int count) {
        this.stone = stone;
        this.count = count;
    }
}

S[] group(string s) {
    S[] ss;
    int p = 0;
    int stone = -1;
    int count = 0;
    while (p < s.length) {
        int c = s[p] == '.' ? W : B;
        if (stone == c) {
            count++;
        }
        else {
            if (count > 0)
                ss ~= new S(stone, count);

            stone = c;
            count = 1;
        }

        p++;
    }

    if (count > 0)
        ss ~= new S(stone, count);
/*
    foreach (a; ss) {
        writeln(a.stone == W ? "W" : "B", " ", a.count);
    }
*/
    return ss;
}

int calc(string s) {
    S[] ss = group(s);
    int[] ww = new int[ss.length]; // [0, i] を全て W にするコスト
    int[] bb = new int[ss.length]; // [i, $] を全て B にするコスト
    int cost = 0;
    for (int i = 0; i < ss.length; i++) {
        // [0, i] を全て W にするコスト
        if (ss[i].stone == B)
            cost += ss[i].count;
        ww[i] = cost;
    }

    cost = 0;
    for (int i = cast(int)ss.length-1; i >= 0; i--) {
        if (ss[i].stone == W)
            cost += ss[i].count;
        bb[i] = cost;
    }

    int ans = min(ww[$-1], bb[0]);
    for (int i = 0; i < ss.length; i++) {
        // [0, i] を白、[i+1, $-1] を黒にするコスト
        int c = ww[i] + (i + 1 < ss.length ? bb[i + 1] : 0);
        ans = min(ans, c);
    }
    return ans;
}

void main() {
    readint;
    string s = read!string;
    int ans = calc(s);
    writeln(ans);
}


Measured memory_bytes: 12156
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	vector< vector<int> > C(N, vector<int>(N));
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			cin >> C[i][j];
	ll sum = 0;
	for (int i = 0; i < N; i++)
		for (int j = i + 1; j < N; j++)
			sum += min(C[i][j], C[j][i]);
	cout << sum << endl;
}

Measured memory_bytes: 1248