akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> a(n+1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	vector<int> ball(n+1, 0);
	vector<int> ans;
	for (int i = n; i >= 1; i--) {
		if (ball[i] % 2 == a[i]) {
			continue;
		}

		ans.emplace_back(i);
		for (int j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				ball[j]++;
				if (j * j != i) {
					ball[i/j]++;
				}
			}
		}
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		if (i != 0) {
			cout << " ";
		}
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


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

int main()
{
	ll q, p, n, l = 0, r = 0;
	char c;
	cin >> q;
	while (q--) {
		cin >> p >> c >> n;
		if (c == '(') {
			l += n;
		}
		else {
			r += n;
		}
		puts(l == r ? "Yes" : "No");
	}
	return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;

const ll MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cout << fixed << setprecision(12);
    ll x, y;
    cin >> x >> y;

    ll a = -1;
    ll b = -1;
    for(ll i = 0; 2*i <= x; i++){
        ll aa = i;
        ll bb = x-2*aa;
        if(aa+2*bb == y){
            a = aa;
            b = bb;
            break;
        }
    }
    if(a == -1 || b == -1) {
        cout << 0 << endl;
        return 0;
    }
    debug(a);
    debug(b);
    ll n = a+b;

    COMinit();

    cout << COM(n, a) << endl;
//    cout << COM(n, b) << endl;

    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans = n;
  for(int i = 0; i <= n; i++){
    int cost = 0;
    for(int j = i; j > 0; j /= 6)cost += j % 6;
    for(int j = n - i; j > 0; j /= 9)cost += j % 9;
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 1e6 + 7;

ll n, f[N];

int main() {
  scanf("%lld", &n);
  f[0] = 1;
  f[1] = n;
  f[2] = (ll)n * n % MOD;
  ll cry = f[0] + n - 1;
  for(int i = 3; i <= n; i++) {
    f[i] = (f[i] + f[i - 1]) % MOD;
    f[i] = (f[i] + cry) % MOD;
    f[i] = ((n - i + 1) * (n) % MOD + f[i]) % MOD;
    cry = ((cry + n - 1) + f[i - 2]) % MOD;
  }
  printf("%lld\n", f[n]);
  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n;
	int ite=0;
	int ans = 0;
	// a<b<c
	int a=0, b=0, c=0;
	int sideTmp;
	cin >> n;
	vector<int> side = {};
	rep(i, n) {
		cin >> sideTmp;
		side.push_back(sideTmp);
	}
	sort(side.begin(), side.end());
	if (n >= 3) {
		rep(i, n - 2) {
			for (int j = i + 1; j < n - 1; j++) {
				for (int k = j + 1; k < n; k++) {
					a = side[i];
					b = side[j];
					c = side[k];
					if (a != b) {
						if (b != c) {
							if (a + b > c) {
								ans++;
							}
						}
					}

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

Measured memory_bytes: 3588
#!/usr/bin/env python3

import sys
import math
import random

def calc_sat_change(d, q): # d日目をコンテストqにチェンジしたときの満足度の差
  dif_sat = s[d-1][q-1] - s[d-1][ans[d-1]-1]

  lastday = 0
  nextday = D+1
  for i in reversed(range(d-1)):
    if ans[i] == q:
      lastday = i+1
      break
  for i in range(d, D):
    if ans[i] == q:
      nextday = i+1
      break
  dif_sat += c[q-1]*(d+1-lastday)*(nextday-d+1)

  lastday = 0
  nextday = D+1
  for i in reversed(range(d-1)):
    if ans[i] == ans[d-1]:
      lastday = i+1
      break
  for i in range(d, D):
    if ans[i] == ans[d-1]:
      nextday = i+1
      break
  dif_sat -= c[ans[d-1]-1]*(d+1-lastday)*(nextday-d+1)

  return dif_sat


D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

lastdays = [0] * 26
ans = [0] * D

for i in range(D):
  maxtmpsat = -1000000
  for j in range(26):
    tmpsat = s[i][j] + c[j] * (i+1 - lastdays[j]) # その日に何も開催しなかった場合との満足度の差
    if tmpsat > maxtmpsat:
      maxtmpsat = tmpsat
      ans[i] = j+1
  lastdays[ans[i]-1] = i+1

for _ in range(10000):
  d = random.randint(1, 5)
  q = random.randint(1, 26)
  if calc_sat_change(d, q) > 0:
    ans[d-1] = q

for i in range(D):
  print(ans[i])




Measured memory_bytes: 9876
#include <vector>
#include <iostream>
#include <bitset>
typedef long long int ll;
using namespace std;

ll l, r;
bitset<60> L, R;
ll memo[60][2][2][2];
void init(ll l, ll r){
  L = bitset<60> (l);
  R = bitset<60> (r);
  //std::cout << L << '\n';
  //std::cout << R << '\n';
  for(int i=0;i<60;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++)for(int t=0;t<2;t++) memo[i][j][k][t] = -1;
}
ll f(ll pos, int flagX, int flagY, int flagZ){
  if(pos==-1) return 1;
  if(memo[pos][flagX][flagY][flagZ]!=-1) return memo[pos][flagX][flagY][flagZ];
  ll ret = 0;

  if(flagX||!L[pos]) ret += f(pos-1, flagX, (R[pos]?1:flagY), flagZ);
  if((flagX||!L[pos])&&(flagY||R[pos])&&flagZ) ret += f(pos-1, flagX, flagY, flagZ);
  if(flagY||R[pos]) ret += f(pos-1, (!L[pos]?1:flagX), flagY, 1);
  ret %= 1000000007;
  return memo[pos][flagX][flagY][flagZ] = ret;
}
int main(int argc, char const *argv[]) {
  std::cin >> l >> r;
  init(l, r);
  std::cout << (f(59, 0, 0, 0)) << '\n';
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

typedef long long int ll;
typedef long double ld;

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

// order_of_key (k) : Number of items strictly smaller than k, basically 0-based index of k
// find_by_order(k) : K-th element in a set (counting from zero)

const int M = 1e9 + 7;

ll fct[100003], C[100003], a[100003];

ll po (ll x, ll y) {
	if (y == 0) return 1;
	if (y == 1) return x % M;
	ll z = po(x, y / 2);
	z = (1LL * z * z) % M;
	if (y & 1) z = (1LL * x * z) % M;
	return z;
}

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	fct[0] = 1;
	for (int i=1; i<=100000; ++i)
		fct[i] = (1LL * i * fct[i - 1]) % M;
	int n, k; cin >> n >> k;
	for (int i=k-1; i<=n-1; ++i) {
		int t = (1LL * fct[k - 1] * fct[i - k + 1]) % M;
		C[i] = (1LL * fct[i] * po(t, M - 2)) % M;
	}
	for (int i=1; i<=n; ++i)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int ans = 0;
	for (int i=1; i<=n; ++i) {
		if (i >= k)
			ans = (ans + (1LL * a[i] * C[i - 1])%M)%M;
		if (n - i >= k - 1)
			ans = (ans - ((1LL * a[i] * C[n - i])%M) + M) % M;
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<int> v(n);
	int ans = 0;

	for(int i=0; i<n; i++)
		cin>>v[i];

	for(int i=0; i<n; i++)
	{
		if(v[i]%2==1 && (i+1)%2==1)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

  ll ans = 1;

  REP(i,N){
    ans *= i;
    ans %= 1000000007;
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
int arr[500][500];
bool isp[500][500];
ll q;
int n;
bool isvalid(int i,int j){
    if(i>=n || i<0 || j<0 || j>=n){
        return false;;
    }
    return true;
}
void update(int i,int j){
    if(!isp[i][j]){
    if(isvalid(i+1,j))
        if(arr[i+1][j]==arr[i][j]+1){
            arr[i+1][j]--;
            update(i+1,j);
        }
    if(isvalid(i-1,j))    
        if(arr[i-1][j]==arr[i][j]+1){
            arr[i-1][j]--;
            update(i-1,j);
        }
    if(isvalid(i,j+1)) 
        if(arr[i][j+1]==arr[i][j]+1){
            arr[i][j+1]--;
            update(i,j+1);
        }
     if(isvalid(i,j-1)) 
        if(arr[i][j-1]==arr[i][j]+1){
            arr[i][j-1]--;
            update(i,j-1);
        }
    }else{
        if(isvalid(i+1,j))
        if(arr[i+1][j]==arr[i][j]+2){
            arr[i+1][j]--;
            update(i+1,j);
        }
    if(isvalid(i-1,j))    
        if(arr[i-1][j]==arr[i][j]+2){
            arr[i-1][j]--;
            update(i-1,j);
        }
    if(isvalid(i,j+1)) 
        if(arr[i][j+1]==arr[i][j]+2){
            arr[i][j+1]--;
            update(i,j+1);
        }
     if(isvalid(i,j-1)) 
        if(arr[i][j-1]==arr[i][j]+2){
            arr[i][j-1]--;
            update(i,j-1);
        }
    }    
}
void solve(){
    cin>>n;
    ll m = n*n;
    for(int i=0;i<n;i++){
        for(int j=i;j<n-i;j++){
            arr[i][j]=i;
            arr[n-i-1][j]=i;
            arr[j][i]=i;
            arr[j][n-i-1]=i;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            isp[i][j]=1;
        }
    }
    ll ans = 0;
    ll a,b;
    for(int i=0;i<m;i++){
        cin>>q;
        q--;
        a = q/n;
        b = q%n;
        ans+=arr[a][b];
        isp[a][b]=0;
        update(a,b);
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    solve();
}





Measured memory_bytes: 35140
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<climits>
#include<cmath>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

typedef unsigned int uint;
typedef long long ll;

using namespace std;

int ans(int *a, int n){
  if(n == 1) return a[0];
  int b[10];
  REP(i,n-1){
    b[i] = (a[i] + a[i+1]) % 10;
  }
  return ans(b, n-1);
}

int main(){
  char buff[16];
  while(cin>>buff){
    int a[10];
    REP(i,10) a[i] = buff[i] - '0';
    cout << ans(a,10) << endl;
  }
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int inf = 2147483647;
const int mod = 1e9 + 7;
const int N = 2001;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(cr x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(cr x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(cr x) {put(x), putchar(' ');}
I void pr2(cr x) {put(x), puts("");}

int f[N];

int main() {
	reg n = read(), k = read();
	f[n + 1] = 1;
	fo(i, 1, k - 1) {
		reg sum = f[n - i + 2];
		fd(j, n - i + 1, 1) {
			sum = (sum + f[j]) % mod;
			f[j] = sum;
		}
	} f[1] = f[n - k + 2]; fo(i, 2, n - k + 1) f[1] = (f[1] + f[i]) % mod;
	fo(i, 1, n - k - 1) f[1] = 2 * f[1] % mod;
	pr2(f[1]);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

struct xyz {
    int x;
    int y;
    int z;
};

struct abc {
    int a;
    int d;
};

int main() {
    int n;
    cin >> n;
    
    vector<xyz> v(n - 1);
    for(int i = 0; i < n - 1; i++) {
        cin >> v[i].x >> v[i].y >> v[i].z;
    }
    
    vector<vector<abc>> list(n);
    for(int i = 0; i < n - 1; i++) {
        abc tmp;
        tmp.a = v[i].y - 1; tmp.d = v[i].z;
        list[v[i].x - 1].push_back(tmp);
        tmp.a = v[i].x - 1;
        list[v[i].y - 1].push_back(tmp);
    }
    
    bool flag[n];
    int dist[n];
    for(int i = 0; i < n; i++) {
        flag[i] = false;
        dist[i] = 0;
    }
    
    queue<int> que;
    que.push(0);
    flag[0] = true;
    while(!que.empty()) {
        int now = que.front();
        que.pop();
        
        for(int i = 0; i < list[now].size(); i++) {
            if(!flag[list[now][i].a]) {
                que.push(list[now][i].a);
                flag[list[now][i].a] = true;
                
                dist[list[now][i].a] = dist[now] + list[now][i].d;
            }
        }
    }
    
    for(int i = 0; i < n; i++) {
        if(dist[i] % 2 == 0) {
            cout << 0 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }
    
    return 0;
}


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

using namespace std;

int main() {
    int A, B, C, D, E;
    cin >> A >> B;
    int ans = 0;
    for (size_t i = 0; i <= A; i++)
    {
        for (size_t j = 0; j <= A; j++)
        {
            if (B-i-j>=0 && B-i-j<=A)
            {
                ans++;
            //    cout << i << endl;
            //    cout << j << endl;
            }
            
        }
        
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Apr 26 21:11:14 JST 2020
 **/

signed main() {
    Int s, w;
    std::cin >> s >> w;
    std::cout << (s <= w ? "unsafe" : "safe") << std::endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ll t;cin>>t;
	while(t-->0)
    {}*/
    ll n,a=0,b=0,c=0,d=0;
    cin>>n;string s;
    while(n-->0)
    {
        cin>>s;
        if(s[0]=='A')
            a++;
        if(s[0]=='W')
            b++;
        if(s[0]=='T')
            c++;
        if(s[0]=='R')
            d++;
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<b<<"\n";
    cout<<"TLE x "<<c<<"\n";
    cout<<"RE x "<<d<<"\n";
}




Measured memory_bytes: 3668
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=list(input())
ans=0
#print(T)
for i in range(K):
    if T[i]=="r":
        ans+=P
    if T[i]=="s":
        ans+=R
    elif T[i]=="p":
        ans+=S

for i in range(K,N):
    if T[i]!=T[i-K]:
        if T[i]=="r":
            ans+=P
        elif T[i]=="s":
            ans+=R
        elif T[i]=="p":
            ans+=S
    else:
        T[i]=""
print(ans)


Measured memory_bytes: 4084
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll q1,b,c1,c2,q2;
  cin >> q1;
  while(q1!=0){
    cin >> b >> c1 >> c2 >> q2;
    ll x1=0,x2=0,m=min(c1,c2);
    bool f=false;
    //cout << b-min(c1,c2)*q1 << endl;
     
    if(c1<=c2){
      if(b<c1*q2+c2*(q1-q2)) f=true;
      while(b>=c1*(x1+1)&&x1<q2) x1++;
      while(b>=c1*x1+c2*(x2+1)) x2++;
      if(x1==0) f=true;
      if(f) cout << "NA" << endl;
      else cout << x1 << " " << x2 << endl;
      cin >> q1;
    }else{
      if(b<m*q1) f=true;
      ll s=c1-c2,sum=0;
      sum=q1*m;
      while(b-sum>=s*(x1+1)&&x1<q1&&x1<q2) {
        x1++; 
        //cout << b-sum<<":"<<s*x1<<endl;
        //cout << x1<<":"<<c1*x1<<endl;
      }
      if(x1==q1)
        while(b>=c1*(x1+1)&&x1 + 1<=q2) x1++;
      //while(b>=c1*x1+c2*(x2+1)) x2++;
       
      if(x1==0) f=true;
      x2=0;
      while(b>=c1*x1+c2*(x2+1)) x2++;
      if(f) cout << "NA" << endl;
      else cout << x1 << " " << x2 << endl;
      //cout << c1*x1+c2*x2 << endl;
      cin >> q1;
    }
  }
  return 0;
}

Measured memory_bytes: 1156
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = I()
A = III()

l = [0]*N
r = [0]*N

l[0] = A[0]
r[N-1] = A[N-1]

for i in range(1,N):
    l[i] = fractions.gcd(l[i-1],A[i])

for i in range(N-1)[::-1]:
    r[i] = fractions.gcd(r[i+1],A[i])

ans = 0
for i in range(1,N-1):
    temp = fractions.gcd(l[i-1],r[i+1])
    if temp > ans:
        ans = temp

temp1 = gcd_list(A[1:])
temp2 = gcd_list(A[:N-1])

print(max(ans,temp1,temp2))

Measured memory_bytes: 89580
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    string s;
    cin>>s;
    for(int i=0;i<19;i++){

        if((i==5)||(i==13)){
            cout<<" ";
        }else{
        cout<<s[i];
        }
    }
  cout<<endl;
}   



Measured memory_bytes: 256
#include <complex>
#include <cmath>

using Real = long double;

const Real EPS = 1e-10;

// 宇宙船演算子
inline Real compare(Real a, Real b) {
    if (std::abs(a - b) < EPS) return 0;
    return a - b > 0 ? 1 : -1;
}

template <class T>
inline T sq(T x) { return x * x; }


using Point = std::complex<Real>;
using Segment = std::pair<Point, Point>;

inline Real length(Segment l) {
    return std::abs(l.second - l.first);
}

// inner product
inline Real dot(Point x, Point y) {
    return std::real(std::conj(x) * (y));
}

// outer product
inline Real cross(Point x, Point y) {
    return std::imag(std::conj(x) * (y));
}

// lに対するxの正射影
Point proj(Segment l, Point p) {
    Real ratio = dot(l.second - l.first, p - l.first) / sq(length(l));
    return l.first + (l.second - l.first) * ratio;
}

// lを軸としてxに対称な点
Point refl(Segment l, Point p) {
    Point t = proj(l, p);
    return t + (t - p);
}

// lに対するpの位置
// counter clockwise -> 1, clockwise   -> -1
// online front      -> 2, online back -> -2
// on segment        -> 0
int side(Segment l, Point p) {
    Real c = cross(l.second - l.first, p - l.first);
    if (compare(c, 0) != 0) return compare(c, 0);

    Real d = dot(l.second - l.first, p - l.first);
    if (compare(d, 0) < 0) return -2;

    return (compare(length(Segment(l.first, p)), length(l)) > 0 ? 2 : 0);
}


#include <iostream>
#include <string>

using namespace std;

int main() {
    Real x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Segment l(Point(x1, y1), Point(x2, y2));

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; ++q) {
        Real x, y;
        cin >> x >> y;
        Point p(x, y);

        string ans;
        switch (side(l, p)) {
            case 1:
                ans = "COUNTER_CLOCKWISE";
                break;
            case -1:
                ans = "CLOCKWISE";
                break;
            case 2:
                ans = "ONLINE_FRONT";
                break;
            case -2:
                ans = "ONLINE_BACK";
                break;
            case 0:
                ans = "ON_SEGMENT";
                break;
            default:
                terminate();
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3284
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val towns = Array.tabulate(n){_ ⇒ new UnionFindTree}
  val isMerged = Array.tabulate(n){_ ⇒ false}
  for (_ ← 0 until m){
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    towns(a).merge(towns(b))
    isMerged(a) = true
    isMerged(b) = true
  }
  println(
    towns.count(_.isTop).let{city ⇒ isMerged.count(!_).let{town ⇒
      math.abs(city - town * 2)
    }}
  )
  class UnionFindTree{
    private var mParent: Option[UnionFindTree] = None
    private def parent: UnionFindTree = {
      mParent.map{_.parent} match {
        case Some(p) ⇒
          p.also{it ⇒ mParent = Some(it)}
        case None ⇒ this
      }
    }
    def merge(that: UnionFindTree): Unit = {
      if (!isSameUnion(that)) {
        this.parent.mParent = Some(that.parent)
      }
    }
    def isSameUnion(that: UnionFindTree): Boolean = {
      this.parent == that.parent
    }
    def isTop: Boolean = mParent.isEmpty
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


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

#define int long long
#define MAX_N (200005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;


signed main() {
    int N, K;
    cin >> N >> K;

    double ans=0;
    vector<int> v;
    for(int i=1; i<=N; i++){
        if(i>=K) {
            v.push_back(0);
            continue;
        }
        int n=1;
        while(1){
            if(i*pow(2.0,n) >= K) break;
            n++;
        }
        v.push_back(n);
    }

    for(int i=0; i<v.size(); i++){
        //DEBUG(v[i]);
        //DEBUG2(i, abs(v[0]-v[i]));
        ans += pow(2.0,abs(v[0]-v[i]));
    }
    ans /= N*1.0;
    ans /= pow(2.0,v[0]);

    printf("%.12f\n", ans);

}

Measured memory_bytes: 1400
n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())

a = [[0 for j in range(max(m) + 1)] for i in range(n)]

for i in range(n):
    for j in range(max(m) + 1):
        if (i == 0):
            temp = A[i]
            if (temp <= j):
                a[i][j] = temp
            else:
                a[i][j] = 0
        else:
            temp1 = 0
            temp2 = 0
            if (j - A[i] >= 0):
                temp1 = a[i-1][j - A[i]] + A[i]
            temp2 = a[i-1][j]
            a[i][j] = max(temp1, temp2)

for i in range(q):
    if (a[n-1][m[i]] == m[i]):
        print "yes"
    else:
        print "no"

Measured memory_bytes: 7172
/*
 * Author: Utkal Sinha
 * Created on: 2020-08-29, Sat, 18:0
 * Problem:
 * Platfrom: General
 * */
#if USE_BOOST2
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; //int512_t or //int128_t
typedef bst::cpp_bin_float_100 vdouble;
#endif

#include <bits/stdc++.h>
using namespace std;
#define GETTIME std::chrono::system_clock::now()
#define DURATION std::chrono::duration<double>
#ifdef MY_DEV_ENV2
#define LOCALDEV
#endif
typedef long long ll;
typedef std::chrono::system_clock::time_point TPT;
static TPT starttime, endtime, timelimit;
static double problem_tle = 1.5;
static inline void calc_problem_end_time() {timelimit = starttime + std::chrono::milliseconds(int (problem_tle * 1000));}
// template end

ll MD = 1000000007;

void love() {
    ll n;
    cin >> n;
    ll arr[n];
    for(int i= 0; i<n; i++) cin >> arr[i];

    ll ps[n+1];
    ps[0];
    for(int i= 1; i<=n; i++) ps[i] = (ps[i-1] + arr[i-1]) % MD;

    ll ans = 0;
    for(int i= 0; i<n-1; i++) {
        ll ts = (ps[n] - ps[i+1] + MD) % MD;
        ts = (arr[i] * ts) % MD;
        ans = (ans + ts) % MD;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    srand(time(0));
#ifdef LOCALDEV
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
#ifdef LOCALDEV
    starttime = GETTIME;
    calc_problem_end_time();
#endif
    while(t--) love();
#ifdef LOCALDEV
    endtime = GETTIME;
    DURATION elapsed_seconds = endtime - starttime;
    DURATION time_limit_seconds = timelimit - starttime;
    clog << "Elapsed time: " << elapsed_seconds.count() << "s\n";
    clog << "Time limit: " << time_limit_seconds.count() << "s\n";
#endif
    return 0;
}

Measured memory_bytes: 6748
n, m, x, y = map(int,input().split())

x_n = list(map(int,input().split()))
y_m = list(map(int,input().split()))

x_n_max = max(x_n)
y_m_min = min(y_m)


if x > y:
    x_n_max = 1000000000000000000000

ans = 0
for z in range(x+1,y+1):
    if x_n_max < z and y_m_min >= z:
        print('No War')
        ans = -1
        break


if ans == 0:
    print('War')

Measured memory_bytes: 3064
import java.util.*;


import java.io.*;
/**
 * MLASERP
 */
public class Main {

    
    static MyScanner in  = new MyScanner();
   static int mod  = 1000000007;
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      static StringTokenizer st;
      static int []dr  = {1,-1,0,0};
      static int [] dc = {0,0,-1,1};
public static void main(String[] args) {
    int N = in.nextInt();
    int [ ]L= new int[N];
    for(int i=0;i<N;i++){
        L[i] = in.nextInt();
    }
    long cnt =0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                cnt+=isTriangle(L[i],L[j],L[k]);
               
            }
        }
    }
    out.println(cnt);
   out.flush();
   

}

private static long isTriangle(int a, int b, int c) {
    if(a+b>c&&a+c>b&&b+c>a&&a!=b&&b!=c&&a!=c)
        return 1;
    return 0;
}

static int rcToxy(int r, int c, int W) {
    return r*W+c;
}
static class Node{
    int r, c,prev,change;
    Node(int r, int c){
        this.r =r ;
        this.c = c;
    }
}
public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
}

Measured memory_bytes: 33900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int x;cin>>x;
	int dp[x+1][7];
	rep(i,x+1) rep(j,7) dp[i][j]=0;
	rep(i,7) dp[0][i]=1;
	int y[6];y[0]=100;
	for(int i=0;i<5;i++) y[i+1]=y[i]+1;
	

	for(int i=0;i<x+1;i++){
		for(int j=0;j<6;j++){
			if(i>=y[j]) dp[i][j+1]=max(dp[i-y[j]][j+1],dp[i][j+1]);
			dp[i][j+1]=max(dp[i][j+1],dp[i][j]); 
		}
	}
/*
	rep(i,x+1){
		rep(j,7){
			cout<<dp[i][j]<<" ";
		}
		cout<<"\n";
	}
	*/
	cout<<dp[x][6]<<"\n";
	
}
	

Measured memory_bytes: 2944
#include<iostream>

int main() {
    char b;
    std::cin >> b;
    if (b == 'A') std::cout << 'T';
    if (b == 'T') std::cout << 'A';
    if (b == 'C') std::cout << 'G';
    if (b == 'G') std::cout << 'C';
    std::cout << '\n';
}


Measured memory_bytes: 256
function main(input){
  const args=input.split("\n");
  const aiueo=args[0].split(" ");
  const N=parseInt(aiueo[0],10);
  const D=parseInt(aiueo[1],10);

  //入力された二次元配列を、javascriptで使える形にする
  //中身はconsole.log(arr)で確認できる
  var arr=[]
  for(var i=0; i<N; i++){
    arr[i]=[];
    var subArgs= args[i+1].split(" ")
    for(var j=0; j<D+1; j++){
      arr[i].push(parseInt(subArgs[j],10))
    }
  }

  var kakunin=0;

  //二点間の距離を出す関数
  function kyori(arr1,arr2){
    var sum=0;
    for(var i=0; i<D; i++){
      sum=sum+Math.pow(arr1[i]-arr2[i],2)
    }
    //console.log("距離の二乗は"+sum+"です")
    if(Number.isInteger(Math.sqrt(sum))==true){
      return true
    }else{
      return false
    }
  }

  //以下は判定用のfor文。距離が整数ならkakunin++する。
  for(var i=0; i<N; i++){
    for(var j=i+1; j<N; j++){
      if(kyori(arr[i],arr[j])==true){
        kakunin++
      }
    }
  }
  console.log(kakunin)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
c = []
for i in range(3):
  c.append(list(map(int, input().split())))

d = []
for i in range(3):
  sum = 0
  d.append([])
  for j in range(3):
    sum += c[i][j]
  for j in range(3):
    d[i].append(3*c[i][j] - sum)
    
for i in range(3):
  if d[0][i]==d[1][i] and d[0][i]==d[2][i]:
    pass
  else:
    print('No')
    break
else:
  print('Yes')

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

int a, b, c;

int solve(string s) {
  int tmp;
  if(s == "North") tmp = a, a = b, b = 7-tmp;
  if(s == "East")  tmp = c, c = a, a = 7-tmp;
  if(s == "West")  tmp = a, a = c, c = 7-tmp;
  if(s == "South") tmp = b, b = a, a = 7-tmp;
  if(s == "Right") tmp = b, b = c, c = 7-tmp;
  if(s == "Left")  tmp = c, c = b, b = 7-tmp;
  //cout << a << endl;;
  return a;
}

int main() {
  string str;
  int n, sum;
  while(cin >> n, n) {
    a = 1; b = 2; c = 3;
    sum = 1;
    for(int i = 0 ; i < n ; i++) {
      cin >> str;
      sum += solve(str);
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    set<string> st;
    rep(i,n){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}


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

int main() {
	int n; cin >> n;
	int ans;
	if(400<=n&&n<=599) ans=8;
	else if(n<=799) ans=7;
	else if(n<=999) ans=6;
	else if(n<=1199) ans=5;
	else if(n<=1399) ans=4;
	else if(n<=1599) ans=3;
	else if(n<=1799) ans=2;
	else ans=1;
	cout << ans << endl;
}

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

int count(vector<int> &data,int n){
	int res =0;
	for(int i=0;i<data.size();++i){
		if(data[i] >= n) res++;
	}
	return res;
}

int main(){
	int n;
	cin >> n;
	
	vector<int> data(n+1,0);
	for(int i=2;i<=n;++i){
		int ii = i;
		for(int j=2;j<=i;++j){
			while(ii%j==0){
				data[j]++;
				ii = ii/j;
			}
		}
	}
	
	int res = 0;
	
	res += count(data,74);
	res += count(data,24) * (count(data,2)-1);
	res += count(data,14) * (count(data,4)-1);
	res += (int)(count(data,4) * (count(data,4)-1) * (count(data,2)-2)/2) ;

	cout << res <<endl;
	/*
	for(int i=0;i<data.size();++i){
		cout << data[i] << " ";
	}cout << endl;
	cout << count(data,4) <<endl;*/
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h> 

int main(void)
{
	int a,b;

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

	if(a < b)
	{
		printf("a < b\n");
	}
	
	if(a > b)
	{
		printf("a > b\n");
	}
	
	if(a == b)
	{
		printf("a == b\n");
	}


	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define fore(i, b, e)      for(int i = b; i < e; i++)
#define forr(i, b, e)      for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef pair<int, ii>  iii;
typedef vector<int>     vi;

typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double PI = acos(-1);
const double EPS = 1e-9;
int main()
{
    int n;
    cin>>n;
    cout<<(n+1)/2<<endl;
}
// PLUS ULTRA!

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    int n = s.length();

    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << ' ' << i + 2 << endl;
            return 0;
        }
    }
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << ' ' << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
/*input
5
5 6 5 2 1
9817 1108 6890 4343 8704
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
#define version 20190814
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int n;
ll a[maxn],b[maxn];
priority_queue<pll> pq;
bool vis[maxn];
int main(){
	IOS;
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];	

	ll ans=0;

	REP(i,n){
		if(a[i]==b[i]){
			vis[i]=1;
		}
		else if(a[i]<b[i]){
			pq.push(MP(b[i],i));
		}
		else{
			cout<<"-1\n";
			return 0;
		}
	}

	while(SZ(pq)){
		pll cur=pq.top();
		pq.pop();
		ll idx=cur.S;
		ll pre=(idx-1+n)%n;
		ll nxt=(idx+1)%n;

		if(vis[pre]&&vis[nxt]){
			if((b[idx]-a[idx])%(b[pre]+b[nxt])!=0){
				cout<<"-1\n";
				return 0;
			}
			ans+=(b[idx]-a[idx])/(b[pre]+b[nxt]);
			b[idx]=a[idx];
			vis[idx]=1;
		}
		else{
			if(b[idx]<=b[pre]+b[nxt]){
				cout<<"-1\n";
				return 0;
			}
			ans+=b[idx]/(b[pre]+b[nxt]);
			b[idx]%=(b[pre]+b[nxt]);
			if(b[idx]<a[idx]){
				cout<<"-1\n";
				return 0;
			}
			if(b[idx]==a[idx]) vis[idx]=1;
			else pq.push(MP(b[idx],idx));
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 9840
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>

#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807
#define LLMIN       -9223372036854775808
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;

using namespace std;

class RangeAddRangeSum {
    public:
        int N;
        vector<int> dat, sum_dat;
        RangeAddRangeSum(int n) {
            N = 1;
            while(N < n) N <<= 1;
            dat.assign(2*N-1, 0);
            sum_dat.assign(2*N-1, 0);
        }

        void add(int a, int b, int x) { add(a,b,x,0,0,N); }
        int add(int a, int b, int x, int k, int l, int r) {
            if(b <= l or r <= a) return dat[k];
            if(a <= l and r <= b) {
                sum_dat[k] += x;
                return dat[k] += x*(r-l);
            }
            const int m = (l+r)/2;
            return dat[k] = add(a,b,x,2*k+1,l,m)+add(a,b,x,2*k+2,m,r)+sum_dat[k]*(min(r,b)-max(l,a));
        }

        int sum(int a, int b) { return sum(a,b,0,0,N); }
        int sum(int a, int b, int k, int l, int r) {
            if(b <= l or r <= a) return 0;
            if(a <= l and r <= b) return dat[k];
            const int m = (l+r)/2;
            return sum(a,b,2*k+1,l,m)+sum(a,b,2*k+2,m,r)+sum_dat[k]*(min(r,b)-max(l,a));
        }
};

int main(void){
    int N,M;
    cin>>N>>M;
    RangeAddRangeSum R(N);
    REP(i,M){
        int a,b;
        cin>>a>>b;
        a--,b--;
        if(a>b)
            swap(a,b);
        R.add(a,b,1);
        // cout<<endl;
    }
    REP(i,N-1){
        if(R.sum(i,i+1)%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <string>

//using namespace std;
using namespace std;

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

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

int main()
{
    uint32_t aa;
    uint32_t bb;
    uint32_t max = 10000;
    uint32_t min = 10;
    uint32_t atax;
    uint32_t btax;
    std::cin >> aa >> bb;

    for(uint64_t i = min; i < max; i++)
    {
        atax = (i * 108 / 100) - i;
        btax = (i * 110 / 100) - i;
        if((atax == aa) && (btax == bb)){
            std::cout << i << std::endl;
            return 0;
        }
    }

    std::cout << -1 << std::endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    
    edge_str = "#" * W
    middle_str = "#" + "." * (W-2) + "#"
    for i in range(1, H+1):
        if i == 1 or i == H:
            print(edge_str)
        else:
            print(middle_str)
    print("")


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ans += min(a, max(k, 0ll));
  k -= a;
  k -= b;
  ans -= min(c, max(k, 0ll));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
A,B,C,D=map(int,input().split())
A=A-1
# 1<= A-1 patern
AnC=A//C
AnD=A//D
AnCandD=A//lcm(C,D)
Aans=A-(AnC+AnD-AnCandD)
# 1<= B patern
BnC=B//C
BnD=B//D
BnCandD=B//lcm(C,D)
Bans=B-(BnC+BnD-BnCandD)

print(Bans-Aans)

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int k; cin>>n>>k;
    int a[n]; rep(i,0,n-1) cin>>a[i];
    sort(a,a+n);
    rep(i,0,n-k-1) ans+=a[i];
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 1792
s=input()+"O"
tmp=""
ans=[]
for i in s:
  if i in ["A","T","G","C"]:
    tmp=tmp+i
  else:
    ans.append(tmp)
    tmp=""
res=0
for i in ans:
  if len(i)>res:
    res=len(i)
print(res)


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

int main(void) {
    int64_t N;
    int64_t last;
    int64_t sum = 0;
    cin >> N;

    vector<int64_t> A(N,INT_MAX);
    vector<pair<int64_t,int64_t>> B(N-1);
    for(int i=1;i<N;i++) {
        cin >> B[i-1].first;
        B[i-1].second = i-1;
    }

    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    last = 0;
    for(auto b:B) {
        if(A[b.second] > b.first) {
            A[b.second] = b.first;
        }
        if(A[b.second + 1] > b.first) {
            A[b.second + 1] = b.first;
        }
    }

    for(auto a:A) {
        sum += a;
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
    string S;
    cin>>S;
    rep(i,S.size()){
        S.at(i)='x';
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //改行
        String a = sc.nextLine();
        
        Integer[] list = new Integer[8];
        
        for(int i = 0; i < n; i++) {
            String line = sc.nextLine();
            String[] linesp = line.split("");
            for(int j = 0; j < 8; j++) {
                list[j] = Integer.parseInt(linesp[j]);
            }
            Integer max = 0;
            int min = 0;
            Arrays.sort(list);
            int x = 0;
            for(int j = 10000000; j >= 1; j/=10) {
                min += list[x] * j;
                x++;
            }
            Arrays.sort(list, Collections.reverseOrder());
            x = 0;
            for(int j = 10000000; j >= 1; j/=10) {
                max += list[x] * j;
                x++;
            }
            System.out.println(max - min);
        }
    }
}



Measured memory_bytes: 26096