akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+7;

int a,b,n;
int ans[maxn];
int oo(int x){
    int ins=0;
    while(x>0){
        if(x&1)ins++;
        x>>=1;
    }
    return ins&1;
}
void solve(int x,int y,int a,int b){
    if(x==y-1){
        ans[x]=a;
        ans[y]=b;
        return ;
    }
    int ins=0,mid=x+y>>1;
    while((a&(1<<ins))==(b&(1<<ins)))ins++;
    int aa=((a>>(ins+1))<<ins)+(a%(1<<ins));
    int bb=((b>>(ins+1))<<ins)+(b%(1<<ins));
    int c = aa^1;
    //cout<<x<<" "<<y<<" "<<a<<' '<<b<<' '<<aa<<" "<<bb<<" "<<c<<"\n";
    //cout<<"isn = "<<ins<<"\n";
    solve(x, mid, aa, c);
    solve(mid+1, y, c, bb);
    //for(int i=1;i<=(1<<n);i++)cout<<ans[i]<<" ";cout<<"\n";
    for(int i=x;i<=mid;i++){
        //cout<<i<<" "<<((ans[i]>>ins)<<(ins+1))<<" "<<ans[i]%(1<<ins)<<endl;
        if(b&(1<<ins))ans[i] = ((ans[i]>>ins)<<(ins+1))+(ans[i]%(1<<ins));
        else ans[i] = ((ans[i]>>ins)<<(ins+1))+(ans[i]%(1<<ins))+(1<<ins);
    }
    for(int i=mid+1; i<=y; i++){
        if(b&(1<<ins))ans[i] = ((ans[i]>>ins)<<(ins+1))+(ans[i]%(1<<ins))+(1<<ins);
        else ans[i] = ((ans[i]>>ins)<<(ins+1))+(ans[i]%(1<<ins));
    }
    //for(int i=1;i<=(1<<n);i++)cout<<ans[i]<<" ";cout<<"\n";
}

bool che(int x,int y){
    int ins=0;
    for(int i=0;i<n;i++){
        if((x&(1<<i))!=(y&(1<<i)))ins++;
    }
    return ins==1;
}
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    if(oo(a)==oo(b)){
        printf("NO\n");
        return 0;
    }
    solve(1,(1<<n),a,b);
    printf("YES\n");
    for(int i=1;i<=(1<<n);i++){
        printf("%d%c",ans[i],i==(1<<n)?'\n':' ');
    }
    for(int i=1;i<(1<<n);i++){
        //cout<<i<<endl;
        assert(che(ans[i], ans[i+1]));
    }
    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> l(n), r(n);
    for (auto i : irange(0L, n)) {
        cin >> l[i] >> r[i];
    }

    sort(l.rbegin(), l.rend());
    sort(r.begin(), r.end());

    int64_t ans = 0;
    int64_t s = 0;
    for (auto i : irange(0L, n)) {
        ans = max({ans, s + l[i], s - r[i], s + l[i] - r[i]});
        s += l[i] - r[i];
    }

    ans *= 2;

    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int count = 0;
  rep(i, n){
    if (s[i] == 'A'){
      if (s[i+1] == 'B' && s[i+2] == 'C') count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

#define ms(a, v) memset(a, v, sizeof(a))
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;

#ifdef GONGKUNPENG
#define MAXN 20
#else
#define MAXN 100005
#endif

int main() {
  char buf[200005];
  int n, r = 0, w = 0;
  scanf("%d%s", &n, buf);
  for(int i = 0; buf[i]; ++i) if(buf[i] == 'R') ++r;
  for(int i = 0; i < r; ++i) if(buf[i] == 'W') ++w;
  printf("%d\n", w);
  return 0;
}

Measured memory_bytes: 4012
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin >> n;
    cout << (n/2 + n%2)*(n/2) << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for(int i=a;i<n;i++)
int main()
{     
   int n ;
   cin>>n ;
   string s[n];
   bool f=0,b=0;
   loop(i,0,n)
     cin>>s[i];
    loop(i,0,n)
    {
        loop(j,i+1,n)
         { if (s[i]==s[j])
            f=1;
         }
    }
    loop(i,1,n)
       { 
           if (s[i][0]!=s[i-1][s[i-1].size()-1])
           b=1;
       }
    if(f==0&&b==0)
      cout<<"Yes";
    else
      cout<<"No";
     
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    long long ans = 0;
    for (int bit = 0; bit < (1 << (n- 1)); bit++){

        // example s = 125 , bit = 1 , i = 2
        long long tmp = 0;
        for (int i = 0; i < n - 1; ++i) {
            tmp *= 10; // tmp = 0;
            tmp += s[i] -'0'; // tmp = 5
            if (bit & (1 << i)) ans += tmp, tmp = 0;//cout << i << " " << ans << endl;;
        }   // 0001 & 0010  == false 

        //cout << ans << endl;
        tmp *= 10; // tmp = 50
        tmp += s.back() - '0'; // tmp = 50 + 5
        ans += tmp;
    }

    cout << ans << endl;
}
// ふぁ

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdio>

using namespace std;

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

int main(){
	int n,m,k;
	while(cin>>n>>m>>k && n){
		map<int,double> cur;
		cur[0] = 1;
		rep(i,n){
			map<int,double> ne;
			for(auto &p:cur){
				for(int j=1;j<=m;j++){
					ne[p.first+j] += p.second/m;
				}
			}
			cur=ne;
		}
		double ans=0;
		for(auto &p:cur){
			ans += max(p.first-k, 1) * p.second;
		}
		printf("%.10lf\n", ans);
	}
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    
    vector<int> a(n, -1);
    bool ok = true;
    for (int i = 0; i < m; i++){
        int s, c;
        cin >> s >> c;
        s--;

        if (a[s] != -1 && a[s] != c)
            ok = false;
        else
            a[s] = c;
    }

    if (!ok){
        cout << -1 << '\n';
        return 0;
    }
    
    if (a[0] == -1){
        if (n == 1)
            a[0] = 0;
        else
            a[0] = 1;
    }
    for (int i = 1; i < n; i++){
        if (a[i] == -1)
            a[i] = 0;
    }

    if (n != 1 && a[0] == 0)
        cout << -1 << '\n';
    else{
        for (auto ans: a)
            cout << ans;
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<map>
#include<algorithm>
using namespace std;
long a,b,c,d;
long gcd(long x,long y){
      return (x % y == 0) ? y : gcd(y,x % y);
}
long lcm(long x,long y){
      return x * y / gcd(x,y);
}
long f(long l){
      long t = l / c + l / d - l / lcm(c,d);
      return l - t;
}
int main(void){
      cin >> a >> b >> c >> d;
      cout << f(b) - f(a - 1) << endl;
}


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

unsigned long long gcd(unsigned long long a, unsigned long long b);

int main()
{
	int n, i, j, k;
	unsigned long long a, b, lcm, g;
	cin >> n;
	g=1;
	lcm=1;
	b=1;
	while (n--) {
		cin >> a;
		g = gcd(a,b);
		b*=(a/g);
	}
	lcm=b;
	cout << lcm << endl;
	return 0;
}

unsigned long long gcd(unsigned long long a, unsigned long long b)
{
	unsigned long long t;
	while (b) {
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    int count = 0;

    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;

        count += r - l + 1;
    }

    cout << count << endl;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
vector<ll> n;
void outs(vector<ll> x){
  for(auto x:n)cout<<x;cout<<endl;
}
vector<ll> add(ll x){
  vector<ll> r=n;
  r[0]+=x;
  for(int i=0;i<n.size();i++){
    ll val=r[i];
    if(i+1==r.size()&&val/10)r.push_back(val/10);
    else r[i+1]+=val/10;
    r[i]=val%10;
    x/=10;
  }
  return r;
}
bool BN(ll x){
  vector<ll> r=add(x);
  ll sum=0;
  for(int i=0;i<r.size();i++)sum+=(r[i]);
  //for(int i=0;i<r.size();i++)cout<<r[i]<<" ";cout<<endl;
  bool res=x>=sum;
  res&=(x-sum)%9==0;
  //cout<<x<<" "<<sum<<" "<<res<<endl;
  return res;
}
int main(){
  string s;cin>>s;
  for(int i=0;i<s.size();i++)n.push_back(s[i]-'0');
    reverse(n.begin(),n.end());
    ll kuri=0;
    for(int i=0;i<n.size();i++){
      int val=n[i];
      val=val*9+kuri; kuri=val/10;
      if(i+1==n.size()&&kuri)n.push_back(0);
      n[i]=val%10;
    }
    //cout<<"n:";for(auto x:n)cout<<x;cout<<endl;
    
    ll l=0,r=1e8,m;
    while(l<r-1){
      m=(l+r)/2;
      if(BN(m))r=m;
      else l=m;
    }
    cout<<(r+8)/9<<endl;
    /*
    cout<<BN(10)<<endl;
    for(int i=1;i<=10;i++){
      cout<<i<<":"<<BN(i)<<endl;
    }*/
    return 0;
}


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

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

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> o;
        a.push_back(o);
    }

    cout << *min_element(a.begin(), a.end()) << " " << *max_element(a.begin(), a.end()) << " " << accumulate(a.begin(), a.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 3272
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;
 
enum { TOP=0, FRONT=1, LEFT=2, RIGHT=3, BACK=4, BOTTOM=5 };
enum { WEST = 0, NORTH=1, EAST=2, SOUTH=3 };
 
class Dice
{
private:
  int num[6];
  
public:
   
  int getTop()    { return num[TOP];    }
  int getBottom() { return num[BOTTOM]; }
  int getFront()  { return num[FRONT];  }
  int getBack()   { return num[BACK];   }
  int getLeft()   { return num[LEFT];   }
  int getRight()  { return num[RIGHT];  }
   
  void roll(int dir)
  {
    int tmp;
    switch(dir) {
    case EAST:
      tmp = num[RIGHT];
      num[RIGHT] = num[TOP];
      num[TOP] = num[LEFT];
      num[LEFT] = num[BOTTOM];
      num[BOTTOM] = tmp;
      break;
       
    case WEST:
      tmp = num[LEFT];
      num[LEFT] = num[TOP];
      num[TOP] = num[RIGHT];
      num[RIGHT] = num[BOTTOM];
      num[BOTTOM] = tmp;
      break;
       
    case NORTH:
      tmp = num[BOTTOM];
      num[BOTTOM] = num[FRONT];
      num[FRONT] = num[TOP];
      num[TOP] = num[BACK];
      num[BACK] = tmp;
      break;
       
    case SOUTH:
      tmp = num[BOTTOM];
      num[BOTTOM] = num[BACK];
      num[BACK] = num[TOP];
      num[TOP] = num[FRONT];
      num[FRONT] = tmp;
      break;
       
    }
  }
  
  void rightHandedRoll() {
    int tmp = num[FRONT];
    num[FRONT] = num[RIGHT];
    num[RIGHT] = num[BACK];
    num[BACK] = num[LEFT];
    num[LEFT] = tmp;
  }
   
  Dice() {
  }
  
  Dice(int t, int f, int l, int r, int b, int m)
  {
    num[TOP] = t, num[FRONT] = f, num[LEFT] = l, num[RIGHT] = r, num[BACK] = b, num[BOTTOM] = m;
  }
  Dice(vector<int> v)
  {
    num[TOP] = v[0], num[FRONT] = v[1], num[LEFT] = v[2], num[RIGHT] = v[3], num[BACK] = v[4], num[BOTTOM] = v[5];
  }
  
  bool equals (Dice rhs) const {
    for(int i=0; i<4; i++) {
      rhs.roll(NORTH);
      if(num[TOP] == rhs.getTop()) break;
      rhs.roll(WEST);
      if(num[TOP] == rhs.getTop()) break;
    }
    for(int i=0; i<4; i++) {
      if(check(rhs)) return true;
      else rhs.rightHandedRoll();
    }
    return false;
  }
  
private:
  bool check(const Dice& rhs) const {
    for(int i=0; i<6; i++) {
      if(num[i]!=rhs.num[i]) return false;
    }
    return true;
  }
  
};

map<string, int> mp;

int main() {
  
  mp["Red"]=0, mp["Yellow"]=1, mp["Blue"]=2, mp["Magenta"]=3, mp["Green"]=4, mp["Cyan"]=5;
  int N;
  while(cin >> N && N) {
    vector<Dice> d;
    for(int i=0; i<N; i++) {
      vector<int> v(6);
      for(int j=0; j<6; j++) {
        string s; cin >> s; v[j] = mp[s];
      }
      swap(v[2], v[3]);
      d.push_back(Dice(v));
    }
    
    int cnt = 0;
    bool update = true;
    while(update) {
      update = false;
      for(int i=0; i<d.size(); i++) {
        for(int j=i+1; j<d.size(); j++) {
          if(d[i].equals(d[j])) {
            d.erase(d.begin()+j);
            update = true; cnt ++;
            goto NEXT;
          }
        }
      }
    NEXT:;
    }
    cout << cnt << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define mx 1000000000000000000
#define ll long long int
ll a[40001000];
//ll number[20],used[20];
int main()
{
   ll n,i,j,sum=0;
   cin >> n;
   sum= 0;
   ll divs[n+1]={0};
  // for(i=0;i<n;i++)
    //cout << divs[i] << " " ;
   //cout << endl;
   for(i=1;i<n+1;i++)
   {
       for(j=i;j<n+1;j+=i){
        //cout << j << " ";
        divs[j]++;
        //cout << divs[j] << endl;
       }

   }
   for(i=1;i<n+1;i++)
   {
       //cout << divs[i] << " ";
       sum+=i*divs[i];
   }
   cout << sum << endl;
    return 0;
}


Measured memory_bytes: 81748
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	long N;
	cin >> N;
	if(N%2 == 0) cout << N/2-1 << endl;
	else cout << (N+1)/2-1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  
  vector<vector<int>> a(n, vector<int>(n, 0)), res;
  vector<int> fi(n);
  rep(i, n) fi[i] = i;
  res.push_back(fi);
  int level = 1;
  while (res.size() < n) {
    vector<vector<int>> nxt;
    rep(i, res.size()) {
      vector<int> v = res[i];
      if (v.size() == 1) {
        nxt.push_back(v);
        continue;
      }
      vector<int> u1, u2;
      rep(j, v.size()) {
        if (j % 2 == 0) u1.push_back(v[j]);
        else u2.push_back(v[j]);
      }
      rep(j, u1.size()) {
        rep(k, u2.size()) {
          a[u1[j]][u2[k]] = level;
          a[u2[k]][u1[j]] = level;
        }
      }
      nxt.push_back(u1);
      nxt.push_back(u2);
    }
    res = nxt;
    level++;
  }
  rep(i, n) {
    FOR(j, i + 1, n) {
      cout << a[i][j] << (j == n - 1 ? '\n' : ' ');
    }
  }




  

  
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
double check(double x1,double y1,double x2,double y2,double x3,double y3);
int main(void){
	double ans=0;
	double xa,ya,xb,yb,xc,yc;
        scanf("%lf,%lf",&xa,&ya);
        scanf("%lf,%lf",&xb,&yb);
        scanf("%lf,%lf",&xc,&yc);
        ans+=check(xa,ya,xb,yb,xc,yc);
        xb=xc,yb=yc;
        while(scanf("%lf,%lf",&xc,&yc)!=EOF){
            ans+=check(xa,ya,xb,yb,xc,yc);
            xb=xc,yb=yc;
        }
        printf("%.8lf\n",ans);

	return 0;
}

double check(double x1,double y1,double x2,double y2,double x3,double y3){
    double ab,bc,ca;
    double S,s;
    ab=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    bc=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    ca=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    s=0.5*(ab+bc+ca);
    S=sqrt(s*(s-ab)*(s-bc)*(s-ca));
    return S;
}

Measured memory_bytes: 1240
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

s = input()
t = input()

if s < t:
	print("Yes")
	exit()
tmp = sorted(s)[0] #sの最小の文字

for x in t: #tにおける全ての文字がsの最小文字より大きいか。
	if tmp < x:
		print("Yes")
		break
else:
	print("No")

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


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

  int cnt=0;
  for(int i=0;i<n;i++) {
    if( ((i+1)%2==1) && (a[i]%2==1) ) { cnt++; }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll a,b,t;cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,a,b,x[100005],i,ans=0;
	cin>>n>>a>>b;
	for(i=1;i<=n;i++)
		cin>>x[i]; 
	for(i=1;i<n;i++)
		ans+=min(a*(x[i+1]-x[i]),b); 
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]
	C := list[2]
	K := list[3]

	if A >= K {
		fmt.Printf("%d\n", K)
		return
	}
	K = K - A

	if B >= K {
		fmt.Printf("%d\n", A)
		return
	}
	K = K - B

	if C >= K {
		fmt.Printf("%d\n", A - K)
		return
	}
	fmt.Printf("%d\n", A - C)
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 1724
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			List<Integer> list = new ArrayList<Integer>();
			int counter = 0;
			while(sc.hasNextLine()) {
				if(counter >= 200) {
					System.out.println("you can enter only 200 datasets");
					sc.close();
					break;
				}
				int[] array = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
				if(array.length != 2 || array[0] <= 0 || array[1] >= 1000000) {
					System.out.println("you can enter only 2 numbers");
					sc.close();
					break;
				}
				
				list.add(String.valueOf(array[0] + array[1]).length());
				counter++;	
			}
			for(Integer i : list) {
				System.out.println(i);
			}

	}
}

Measured memory_bytes: 32448
// -*- coding: utf-8 -*-
// Last-Updated : <2014/06/19 18:20:36 by samui>

#include <iostream>
#include <cstdio>
#include <string>

#include <vector>

int main(int argc, char **argv){
  int a;
  std::vector<int> b;
  while(std::cin >>a){
    if(a == 0){
      std::cout<<b[b.size()-1]<<std::endl;
      b.pop_back();
    }else{
      b.push_back(a);
    }

  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, k) for (int i = (s); i < (int)(k); i++)

int main(){
    int n,A,B;
    string s;
    int cnt = 0;
    int cnt2 = 0;
    cin >> n >> A >> B >> s;
    rep(i,0,s.size()){
        if(s.at(i)=='a'){
            if(cnt<A+B){
                cout << "Yes" << endl;
                cnt++;
            }else{
                cout << "No" << endl;
            }
        }else if(s.at(i)=='b'){
            if(cnt<A+B&&cnt2<B){
                cout << "Yes" << endl;
                cnt++;
                cnt2++;
            }else{
                cout << "No" << endl;
            }

        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 3e3 + 5, inf = 1e18, mod = 1e9 + 7;

int n, a[N], dp[N][N];

int go(int L, int R){
    if(L > R)
        return 0;

    int &ans = dp[L][R];
    if(~ans)
        return ans;
    
    int c1 = a[L] - go(L + 1, R);
    int c2 = a[R] - go(L, R - 1);

    return ans = max(c1, c2);
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    memset(dp, -1, sizeof(dp));
    cin >> n;   
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    cout << go(1, n);
}

Measured memory_bytes: 74328
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define eps 1e-67
#define pf printf
#define sf scanf
#define sd(n) scanf("%d",&n)
#define sd2(n1,n2) scanf("%d %d",&n1,&n2)
#define slf(n) scanf("%lf",&n)
#define slf2(n1,n2) scanf("%lf %lf",&n1,&n2)
#define sLf(n1) scanf("%Lf",&n1)
#define sLf2(n1,n2) scanf("%Lf %Lf",&n1,&n2)
#define sl(n) scanf("%lld",&n)
#define sl2(n1,n2) scanf("%lld %lld",&n1,&n2)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define repb(i,a,b) for(long long int i=a;i>=b;i--)
#define repa(i,a,b,c) for(long long int i=a;i<b;i=i+c)
#define reps(i,a,b,c) for(long long int i=a;i>b;i=i-c)
#define asort(a) sort(a.begin(),a.end())
#define asortb(a,comp) sort(a.begin(),a.end(),comp)
#define arev(a) reverse(a.begin(),a.end())
#define all(v) (v).begin(),(v).end()
#define allc(v,comp) (v).begin(),(v).end(),comp
#define allrc(v,a,b,comp) (v).begin()+a,(v).end()-b,comp
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pbb pop_back
#define mp make_pair
#define mt make_tuple
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define tl(c) towlower(c)
#define root(x) sqrt(x)
#define power(a,n) pow(a,n)
#define tu(c) towupper(c)
#define sq(a) ((a)*(a))
#define cube(a) ((a)*(a)*(a))
#define mx 1000
#define MX 100000

using namespace std;

typedef string str;
typedef long long int ll;
const ll mod=1000000007;
typedef double lf;
typedef long double llf;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef char ch;
typedef map<ll,ll> mpl;


int main()
{
     ll n,a,ans=1;
     cin>>n;
     mpl m;

     rep(i,0,n)
     {
         cin>>a;
         m[a]++;
     }
     bool flag=true;
     if(n%2==0){
     repa(i,1,n,2)
     {
         if(m[i]!=2)
         {
             flag=false;
             break;
         }
         ans*=2;
         ans%=mod;
     }
     }
     else{
            if(m[0]!=1)
            {
                flag=false;
            }
        repa(i,2,n,2)
       {
         if(m[i]!=2)
         {
             flag=false;
             break;
         }
         ans*=2;
         ans%=mod;
     }


     }

     if(flag==true)
     {
         cout<<ans<<endl;
     }
     else
     {
         cout<<0<<endl;
     }
     return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 1e5 + 10;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string ss;
    cin >> n >> ss;
    if(n & 1){
        cout << "No\n";
        return 0;
    }
    int ya = 1;
    for(int i = 0; i < n / 2; i++){
        if(ss[i] != ss[n / 2 + i]) ya = 0;
    }
    if(ya) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
"use strict"

const Main =(input)=>{
const Array=input.split(" ")
const A=parseInt(Array[0],10)
const B=parseInt(Array[1],10)
const C=parseInt(Array[2],10)
const Answer= (A+B)>=C ?"Yes":"No"
console.log(Answer)
}




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

Measured memory_bytes: 11340
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <random>

#define ll long long

using namespace std;

int main() {
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    vector<ll> dp(n + 1, INT_MAX);
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = i - 1; j >= 0 && j >= i - k; j--) {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    printf("%d", dp[n]);
    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		int x=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int total=a*(-1)+b;
		
		if(x<total) System.out.println("dangerous");
		else if(total<=0) System.out.println("delicious");
		else System.out.println("safe");
	}
} 

Measured memory_bytes: 21712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;

  vector<string> sub;
  rep(i, s.size()) {
    for(int j = 1; j <= K; j++) {
      if (i + j > s.size()) break;
      sub.push_back(s.substr(i, j));
    }
  }

  std::sort(sub.begin(), sub.end());

  int count = 0;
  string before = "";
  rep(i, sub.size()) {
    if (sub[i] != before) {
      count++;
      before = sub[i];

      if (count == K) {
        cout << sub[i] << endl;
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main(void){
    char a;
    cin>>a;
    if(a=='A') cout<<'T'<<endl;
    if(a=='T') cout<<'A'<<endl;
    if(a=='C') cout<<'G'<<endl;
    if(a=='G') cout<<'C'<<endl;
}


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

int main()
{
  int n;
  cin >> n;
  
  double sum = 0;
  double tmp;
  for (int i = 0; i < n; i ++)
  {
    cin >> tmp;
    sum += 1 / tmp;
  }
  
  cout << setprecision(14) << 1 / sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int n;
  int *a;
  cin>>n;
  a=new int[3*n];
  for(int i=0;i<n*3;i++){
    cin>>a[i];
  }
  long long sum=0;
  sort(a,a+3*n,greater<int>());
  for(int i=0;i<n;i++){
    sum+=a[2*i+1];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = [int(e) for e in input().split()]
flag = True
for i in range(0,n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            flag = False
if flag:
    print("APPROVED")
else:
    print("DENIED")

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, q;
ll t[maxn];

void upd(int i, ll dx) {
    for (; i<=n; i+=i&-i) {
	t[i] += dx;
    }
}


ll qry(int i) {
    ll res = 0;
    for (; i; i-=i&-i) {
	res += t[i];
    }
    return res;
}

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

    cin>>n>>q;
    for (int i=1; i<=n; i++) {
	ll x; cin>>x;
	upd(i,x);
    }

    while (q--) {
	int t;
	cin>>t;
	if (t==0) {
	    int i,dx;
	    cin>>i>>dx;
	    i++;
	    upd(i,dx);
	} else {
	    int l,r;
	    cin>>l>>r;
	    l++;
	    cout<<qry(r)-qry(l-1)<<"\n";
	}
    }
    
    
    return 0;
}


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

int main() {
  long long a, b;
  scanf("%lld %lld", &a, &b);
  long long g = __gcd(a, b);
  int lim = sqrtl(g + 1.0), ans = 1;
  for (int i = 2; i <= lim; i++) {
    if (g % i == 0) {
      ++ans;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1) {
    ++ans;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;


int main()
{
   ll n,i,j,c=0,k,m; string s;
   cin>>s>>k;
   n=s.length();
   for(i=0;i<n;i++)
   {
       if(s[i]=='1')

       {
           if(i==0) c++;
           else if(s[i]==s[i-1]) c++;
           else break;
       }
       else break;
   }
   if(c==0) cout<<s[0];
   else
   {
       if(k<=c) cout<<1;
       else cout<<s[c];
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, z,sum, mn = 999999999, avg, pos, dif,k, mx, xi, yi;
const int MXN=1e5+7;
ll pre[MXN];
bool prime[MXN];

bool PE ( ll x )
{
    for ( ll i = 2; i * i <= x; i+=1+(i&1))
    if ( x % i == 0 )
    return false;
    return true;
}
ll dist[MXN];
void sieve()
{
    memset(prime , 1 , sizeof prime);

    for ( ll i = 2; i * i <= MXN; i+=1+(i&1))
    if (prime[i])
    {
          for (ll j = i * i; j < MXN; j +=i)
         prime[j] = false;
    }
}
bool vis [MXN], talked[MXN];

bool PR ( string s )
{
    int n = s.length();
    for ( ll i = 0; i < n / 2; i++ )
    if ( s[i] != s[n - i - 1] )
    return false;
    return true;
}
ll dsu[MXN];
int FindRoot (int i )
{
    if (dsu[i] == i)
    return i ;
    return dsu[i] = FindRoot(dsu[i]);
}
void fn (int i )
{
    if (i > n)exit (0);
    ll c = 0;
    for (int  x = 1 ; x <= i; x++){
        if (x*x + 2 + 2*x > i)
        break;
    for (int  y = 1 ; y <= i ;y++){
           if (x*x + y*y + 1 + y*x  + y + x > i)
        break;
    for (int z = 1 ; z<=i ; z++)
    {
        if (z*z + x*x + y*y + y*x + y*z + x*z ==i)
        c++;
        if (z*z + x*x + y*y + y*x + y*z + x*z > i)
        break;
        }
    }}
    cout<< c << endl;
    
    i++;
    fn (i);
}
int main (void){
    SpeeD;

cin >> n;
fn (1);




}

Measured memory_bytes: 4008
program l2019
  integer(8) :: l,r,lm,rm
  integer :: i,j,m

  read(*,*) l,r
  m=2020
  if((l/673).ne.(r/673)) then
     m=0
  else
     lm=mod(l,2019)
     rm=mod(r,2019)
     do	i=lm,rm-1
	do j=lm+1,rm
           if(mod(i*j,2019).lt.m) then
	      m=mod(i*j,2019)
	   endif
        enddo
     enddo
  endif
  write(*,'(i0)') m


end program l2019




Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N; cin >> N;
    string S; cin >> S;
    ll ans = 0;
    rep(i, N){
        if(i+2 > N-1) continue;
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ans++;
    }
    
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  string OK = "CODEFESTIVAL2016";

  long ans = 0;

  for (long i = 0; i < OK.size(); i++) if (S[i] != OK[i]) ans++;

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

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

    vi ans; 

    vi seq;
    while (N > 0) {
        if (N%2 == 1) {
            N = (N-1)/2;
            seq.push_back(1);
        } else {
            N = N-1;
            seq.push_back(0);
        }
    }
    reverse(seq.begin(), seq.end());

    vi perm;
    int extra = 0;
    int cur = 1;
    for (int s : seq) {
        if (s == 0) {
            // x+1
            perm.push_back(cur);
            cur++;
        } else {
            //2x+1
            perm.insert(perm.begin(), cur);
            cur++;
        }
    }

    for (int i=cur-1;i>0;i--) ans.push_back(i);
    for (int x : perm) ans.push_back(x);

    // for (int i=1;i<=extra;i++) {
    //     ans.push_back(B+i);
    //     ans.push_back(B+i);
    // }

    

    cout << ans.size() << endl;
    for (int i : ans) cout << i << " ";
    cout << endl;

    return 0;
}


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

typedef long long ll;

ll choose(ll n,ll k){
    ll x = 1, y = 1;
    for(int i=1;i<=k;i++){
        x *= n - (i - 1);
        y *= i;
    }
    return x / y;
}

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

    ll n; cin >> n;
    vector<ll> a(n);
    map<ll,ll> mp;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll sum = 0;
    for(auto x : mp){
        sum += choose(x.second,2);
    }
    for(int i=0;i<n;i++){
        cout << sum-mp[a[i]]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 11136
N = int(input())
a = list(map(int,input().split()))
adic = {}
for c in a:adic[c] = adic.get(c,0) + 1
g = 0
for k in adic.keys():
    if adic[k] > k:g += adic[k] - k
    elif adic[k] == k:pass
    else:g += adic[k]
print(g)

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = a;
  int sum = 0;
  
  for (int i = 0; i < b - a + 1; i++) {
    int man, sen, ju, ichi;
    man = c / 10000;
    sen = c % 10000 / 1000;
    ju = c % 100 / 10;
    ichi = c % 10;
    c++;
    
    if (man == ichi && sen == ju)
      sum++;
    else
      continue;
  }
  
  cout << sum << endl;
}

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

lint n;

// 素因数分解 O(√N)
vector<pair<lint, lint>> pf_vec(long long int n) {
    vector<pair<lint, lint>> res;
    for (long long int i = 2; i * i <= n; i++)
        if (n % i == 0) {
            lint num = 0;
            while (n % i == 0) {
                num++;
                n /= i;
            }
            res.push_back({i, num});
        }
    if (n != 1) res.push_back({n, 1});
    return res;
}

pair<lint, lint> ext_gcd(lint a, lint b) {
    if (a > b) {
        auto temp = ext_gcd(b, a);
        return make_pair(temp.second, temp.first);
    } else {
        if (a == 0) {
            return make_pair(0, 1);
        } else {
            auto temp = ext_gcd(a, b % a);
            int v = temp.first, w = temp.second;
            return make_pair(v - w * (b / a), w);
        }
    }
}

lint f(lint a, lint q) {
    if (q > 0) {
        return -((q - 1) / a);
    } else if (q == 0) {
        return 1;
    } else {
        return (1 - q + a - 1) / a;
    }
}

// ax-by=1なる最小のbyを求める
lint solve(lint a, lint b) {
    auto sol = ext_gcd(a, b);
    lint p = sol.first;
    lint q = -sol.second;
    lint K = max(f(a, q), f(b, p));
    return b * (a * K + q);
}

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

// a^nを計算　O(log n)
long long int powint(long long int a, long long int n) {
    if (n == 0) {
        return 1;
    } else {
        long long int temp = powint(a, n / 2);
        if (n % 2 == 0) {
            return temp * temp;
        } else {
            return temp * temp * a;
        }
    }
}

int main() {
    cin >> n;
    auto pf = pf_vec(2 * n);
    lint num = pf.size();
    lint ans = LLONG_MAX;
    for (lint i = 0; i < (1LL << num); i++) {
        bitset<40> b(i);
        lint A = 1, B;
        for (int j = 0; j < num; j++) {
            if (b[j]) {
                A *= powint(pf[j].first, pf[j].second);
            }
        }
        B = 2 * n / A;
        chmin(ans, solve(A, B));
    }
    cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)
typedef long long ll;

const int N = 300000;
const int mod =  998244353;
const ll inf = 1e18;

ll n, a, b, k;
ll f[N + 10], rf[N + 10];

inline ll bin(ll x, ll k) {
    ll res = 1;
    while(k) {
        if(k & 1) res = res * x % mod;
        x = x * x % mod;
        k >>= 1;
    }
    return res;
}

inline ll C(ll n, ll k) {
    if(k < 0 || k > n) return 0;
    return f[n] * rf[n - k] % mod * rf[k] % mod;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    //a * x + b * y + (a + b) * (n - x - y) = k
    //(a + b) * n - b * x - a * y  = k
    //
    //k + b * x - (a + b) * n = - a * y;
    f[0] = rf[0] = 1;
    for(int i = 1; i <= N; ++i) f[i] = f[i-1] * i % mod;
    rf[N] = bin(f[N], mod - 2);
    for(int i = N - 1; i >= 1; --i) rf[i] = rf[i+1] * (i+1) % mod;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for(ll x = 0; x <= n; ++x) {
        ll red = a * x;
        ll blue = k - red;
        if(blue % b == 0) {
            ll y = blue / b;
            ans += C(n, x) * C(n, y) % mod;
            ans %= mod;
        }
    }
    cout << ans;
    return 0;
}

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


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;

}
Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;

}


Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);
  y=x->parent;
   while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }

  if(x!=NIL){
    x->parent=y->parent;
  }

  if(y->parent==NIL){
    root=x;
  }else{
    if(y==y->parent->left){
      y->parent->left=x;
    }else{
      y->parent->right=x;
    }
  }

  if(y!=z){
    z->key=y->key;
  }
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  int curMin = 1e9;
  rep(i, n) {
    curMin = min(curMin, p[i]);
    if (curMin == p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5;

int N;
ll A[MAX_N+2];
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i+1];
	}
	A[0]=A[N+1]=0;
	ll sm=0;
	REP(i,N+1){
		sm+=labs(A[i+1]-A[i]);
	}
	REP(i,N){
		cout<<sm-labs(A[i+1]-A[i])-labs(A[i+2]-A[i+1])+labs(A[i+2]-A[i])<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
s = input()
if s[0] == "0" or s[-1] == "1":
    print(-1)
    exit()
n = len(s)
if n == 2:
    if s == "10":
        print(1, 2)
        exit()
    else:
        print(-1)
        exit()

m = n // 2
tmp = m + 1
ANS = []
for i in reversed(range(1, m + 1)):
    j = n - i
    if s[i - 1] == "1" and s[j - 1] == "1":
        ANS.append((tmp, i))
        tmp = i
    elif s[i - 1] == "0" and s[j - 1] == "0":
        ANS.append((tmp, i))
    else:
        print(-1)
        exit()
for i in range(m + 2, n + 1):
    ANS.append((m + 1, i))

for a, b in ANS:
    print(a, b)


Measured memory_bytes: 81544