akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
int main() {
    string s;
    cin >> s;
    int m = stoi(s);
    int a, b, c, d;
    a = m / 1000;
    b = (m / 100) % 10;
    c = (m / 10) % 10;
    d = m % 10;
    if(a+b+c+d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a-b+c+d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a+b-c+d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a-b-c+d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a+b+c-d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a-b+c-d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a+b-c-d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a-b-c-d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("O3")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
  int a, b, c, k;
  cin >> a >> b >> c;
  cin >> k ;
  int i = 0;
  for(i = 0; i < k; i++){
    if(!(a < b)){
      b *=2;
    }else if(!(b < c)){
      c *= 2;
    }
   }
   if ((a < b) && (b < c))
    cout << "Yes";
   else 
     cout << "No";
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000

int main()
{
  string S;
  int N, ans = 0;
  cin >> N >> S;
  for (int i = 0; i < N - 2; ++i)
  {
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C')
    {
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	vector<string> v(2);
	cin >> v[0] >> v[1];

	reverse(v[1].begin(), v[1].end());
	cout << (v[0] == v[1] ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
"""MILOY"""
n,m,x,y=list(map(int,input().split()))
line1=list(map(int,input().split()))
line2=list(map(int,input().split()))
t=0
try:
    for i in range(x+1,y+1):
        c=0
        s=0
        for j in line1:
            if (i<=j):
                c+=1
            
        for j in line2:
            if(i>j):
                s+=1
              
        if ( c==0 and s==0):
            t=t+1
           
    
    if(t==0):
        print('War')
    if(t!=0):
        print('No War')
        
except:
    print('War')


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

main(){
	int x,k,d,val; cin>>x>>k>>d;
	
	if(x == 0){
		if(k%2) cout<<d;
		else cout<<x;
	}
	else if(x > 0){
		if(k > (x+d-1)/d){
			val = x - ((x+d-1)/d) * d;
			k -= (x+d-1)/d;
			if(k%2) cout<<abs(val+d);
			else cout<<abs(val);
		}
		else{
			cout<<abs(x - d*k);
		}
	}
	else{
		if(k > (abs(x)+d-1)/d){
			val = x + ((abs(x)+d-1)/d) * d;
			k -= (abs(x)+d-1)/d;
			if(k%2) cout<<abs(val-d);
			else cout<<abs(val);
		}
		else{
			cout<<abs(x + d*k);
		}
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout << (s.substr(0,(s.length())-8))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    while(1)
    {
        int H,W;
        cin >> H >>W;
         
        if(H==0 && W==0)break;
         
        for(int y=0;y<H;y++){
            for(int x=0;x<W;x++)
            {
                if((x+y)%2==0)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
     
    return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
const int inf=1e5+9;
long long  dp[inf],a[inf];
 
int main(){
 
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++){
        long long  x=dp[i-1]+abs(a[i]-a[i-1]);
        long long  y=dp[i-2]+abs(a[i-2]-a[i]);
        dp[i]=min(x,y);
    }
    cout<<dp[n]<<endl;
}


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

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)


using namespace std;



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

	/*0が白、1が黒*/
	lli data[100][100];
	REP(i,100)REP(j,100)data[i][j]=i/50;

	a--;
	b--;
	lli y=0;
	lli x=0;
	REP(i,b){
		data[y][x]=1;
		x+=2;
		if(x>=100){
			x=0;
			y+=2;
		}
	}
	y=99;
	x=0;
	REP(i,a){
		data[y][x]=0;
		x+=2;
		if(x>=100){
			x=0;
			y-=2;
		}
	}
	char ans[2]={'.','#'};

	cout<<100<<" "<<100<<endl;;
	REP(i,100){
		REP(j,100){
			cout<<ans[data[i][j]];
		}
		cout<<endl;
	}

	return 0;

}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    int x, y;
    cin >> x >> y;
    int add = x + y;
    int sub = x - y;
    int into = x * y;
    if (add >= sub && add >= into) {
        cout << add << "\n";
    } else if (sub >= add && sub >= into) {
        cout << sub << "\n";
    } else {
        cout << into << "\n";
    }

}












Measured memory_bytes: 3636
/*
 * Pawan Harendra Mishra
 */

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

#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> pll;

ll m1, d1, m2, d2;

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);

    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 != m2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main() {
    long x, y;
    cin >> x >> y;
    if(x == y){
        cout << 0 << endl;
    }
    if(x < 0 && y < 0 ){
        if(x > y){
            cout << abs(y-x)+2 << endl;
        } else if(x < y){
            cout << abs(x-y) << endl;
        }
    }
    if(x > 0 && y > 0){
        if(x > y){
            cout << x-y+2 << endl;
        } else if(x < y){
            cout << y-x << endl;
        }
    }
    if(x > 0 && y < 0){
        cout << abs(x+y)+1 << endl;
    }
    if(x < 0 && y > 0){
        cout << abs(x+y)+1 << endl;
    }
    if(x == 0){
        if(x > y){
            cout << x-y+1 << endl;
        } else if(x < y){
            cout << y << endl;
        }
    }
    if(y == 0){
        if(x > y){
            cout << x+1 << endl;
        } else if(x < y){
            cout << y-x << endl;
        }
    }
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", std::cmp::min(a * n, b));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(void){
    int A[2][101];
    int N;
    cin >> N;


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

    
    int ans = 0;
    
    for (int n =0; n < N ; n++){
        int temp =0;

        for(int i = 0; i<=n ; i++) temp += A[0][i];
        for(int i = n; i<N ; i++) temp += A[1][i];
       

        ans = max(temp, ans);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n, l;
   cin >> n >> l;
   vector<int> taste;
   rep(i, n) { taste.push_back(l + i); }
   int m = inf;
   int mi = -1;
   rep(i, n) {
      if (m > abs(taste[i])) {
         m = abs(taste[i]);
         mi = i;
      }
   }
   int ans = 0;
   rep(i, n) {
      if (mi == i) continue;
      ans += taste[i];
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
/**
 
coded by - pathakcodes  //revamped
**/


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


int main(){
    int n , k ;
    cin >> n >> k  ;
    
    vector<int> a(n+1,0) ;
    
    for(int i = 1 ; i < n+1 ; i++)
        cin >> a[i] ;
    
    vector<int> dp(n+1,0) ;
    dp[0] = 0 ;
    dp[1] = 0 ;
    dp[2] = abs(a[2] - a[1]) ;
    
    for(int i = 3 ; i < n+1 ; i++){
        int min = INT_MAX ;
        
        for(int j = 1 ; j <= k&&( i-j > 0); j++){
            if(abs(a[i]-a[i-j]) + dp[i-j] < min)
                min = abs(a[i]-a[i-j]) + dp[i-j] ;
              
            
        }
        dp[i] = min ;
    }

    cout << dp[n] <<endl ;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

ll rmemo[100005];
ll lmemo[100005];
ll ans[100005];

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

	ll num = 0;
	rep(i, S.size() - 1) {
		if(S[i] == 'R') {
			num++;
		} else {
			num = 0;
		}
		if(S[i+1] == 'L') {
			rmemo[i] = num;
		}
	}

	num = 0;
	for(ll i = S.size() - 1; i > 0; i--) {
		if(S[i] == 'L') {
			num++;
		} else {
			num = 0;
		}
		if(S[i-1] == 'R') {
			lmemo[i] = num;
		}
	}

	rep(i, S.size()) {
		if(rmemo[i]) {
			ll odd, even;
			even = rmemo[i] / 2;
			odd = rmemo[i] / 2;
			if(rmemo[i] % 2 == 1) even++;
			ans[i] += even;
			ans[i+1] += odd;

		}
	}

	rep(i, S.size()) {
		if(lmemo[i]) {
			ll odd, even;
			even = lmemo[i] / 2;
			odd = lmemo[i] / 2;
			if(lmemo[i] % 2 == 1) even++;
			ans[i] += even;
			ans[i-1] += odd;

		}
	}

	rep(i, S.size()) {
		cout << ans[i];
		if(i != S.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}



}

Measured memory_bytes: 6004
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
ll d[100005];
struct wtf {
  int ds, x, d;
  const bool operator<(const wtf &e) const {
    return ds == e.ds ? d > e.d : ds > e.ds;
  }
};
int main() {
  ll n;
  cin >> n;
  fill(d, d + 100005, INF);
  priority_queue<wtf> q;
  for (int i = 1; i <= 9; i++)
    q.push({i, i, 1}), d[i] = i;
  d[0] = INF;
  while (!q.empty()) {
    wtf u = q.top();
    q.pop();
    for (int i = 0; i <= 9; i++) {
      int nds = u.ds + i, nnum = (u.x * 10 + i) % n, nd = u.d + 1;
      wtf nu = {nds, nnum, nd};
      if (d[nu.x] > d[u.x] + i) {
        q.push(nu);
        d[nu.x] = d[u.x] + i;
      }
    }
  }
  cout << d[0] << endl;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    LL x, y;
    cin >> x >> y;

    int ans = 0;

    while(x <= y)
        ans++, x <<= 1;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    Int n; cin >> n;
    vector<Int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];

    Int ans = 0;
    for(int i = 1; i < n; i++)
    {
        if(A[i] < A[i - 1])
        {
            int tmp = A[i - 1] - A[i];
            ans += tmp;
            A[i] = A[i - 1];
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 4752
n,m=map(int,input().split())
a=list(map(int,input().split()))
import copy
b=copy.deepcopy(a)
t=0
while b[0]%2==0:
    b[0]//=2
    t+=1

def div2():
    for i in range(1,n):
        cnt=0
        while b[i]%2==0:
            b[i]//=2
            cnt+=1
        if t!=cnt:
            print(0)
            exit()
div2()
for i in range(n):
    a[i]=a[i]//2
import fractions
lcm=a[0]
for i in range(n-1):
    tmp=lcm*a[i+1]//fractions.gcd(lcm,a[i+1])
    lcm=max(lcm,tmp)
if m//lcm%2==0:
    print(m//lcm//2)
else:
    print(((m//lcm)+1)//2)

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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll n,count=0;
    cin >> n;
    for(int i=1;i<n;i++)
    {
        count += (n/i);
        if((n%i) == 0)
        {
            count-=1;
        }
        //cout << count << endl;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	int H, W;
    	cin >> H >> W;
    	vector<string> vec (H);
    	for(int i = 0;i < H;i++){
    		cin >> vec.at(i);
    	}
    	int dh, dw;
    	for(int i = 0;i < H*W;i++){
    		dh = i/W;
    		dw = i%W;
    		if(vec.at(dh).at(dw) == '.'){
    			int minecount = 0;
    			if(dh != 0 && dw != 0 && vec.at(dh-1).at(dw-1) == '#'){
    				minecount++;
    			}
    			if(dh != H-1 && dw != 0 && vec.at(dh+1).at(dw-1) == '#'){
    				minecount++;
    			}
    			if(dh != 0 && dw != W-1 && vec.at(dh-1).at(dw+1) == '#'){
    				minecount++;
    			}
    			if(dh != H-1 && dw != W-1 && vec.at(dh+1).at(dw+1) == '#'){
    				minecount++;
    			}
    			if(dh != 0 && vec.at(dh-1).at(dw) == '#'){
    				minecount++;
    			}
    			if(dh != H-1 && vec.at(dh+1).at(dw) == '#'){
    				minecount++;
    			}
    			if(dw != 0 && vec.at(dh).at(dw-1) == '#'){
    				minecount++;
    			}
    			if(dw != W-1 && vec.at(dh).at(dw+1) == '#'){
    				minecount++;
    			}
    			if(minecount == 0){
    				vec.at(dh).at(dw) = '0';
    			}
    			else if(minecount == 1){
    				vec.at(dh).at(dw) = '1';	
    			}
    			else if(minecount == 2){
    				vec.at(dh).at(dw) = '2';
    			}
    			else if(minecount == 3){
    				vec.at(dh).at(dw) = '3';
    			}
    			else if(minecount == 4){
    				vec.at(dh).at(dw) = '4';
    			}
    			else if(minecount == 5){
    				vec.at(dh).at(dw) = '5';
    			}
    			else if(minecount == 6){
    				vec.at(dh).at(dw) = '6';
    			}
    			else if(minecount == 7){
    				vec.at(dh).at(dw) = '7';
    			}
    			else if(minecount == 8){
    				vec.at(dh).at(dw) = '8';
    			}
    		}
    	}
    	for(int i = 0;i < H;i++){
    		cout << vec.at(i) << endl;
    	}
    }

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

int main(){
  int d,n,ans;
  cin>>d>>n;

  if(d==0){
    if(n==100){
     cout<<"101"<<endl;
    }
    else cout<<n<<endl;
    return 0;
  }
  else if(d==1){
    ans=100*n;
    if(n==100) ans=100*(n+1);
    cout<<ans<<endl;
    return 0;
  }
  else if(d==2){
    ans=10000*n;
    if(n==100) ans=10000*(n+1);
    cout<<ans<<endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int i,count=0;
    char a[100];
    
    scanf("%s",a);
    if(a[0]=='Y')count++;
    if(a[1]=='A')count++;
    if(a[2]=='K')count++;
    if(a[3]=='I')count++;
    if(count==4)printf("Yes\n");
    else printf("No\n");

    return 0;
}

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

struct token{
    bool is_num;
    int64_t value;
    token *next;
};

token *tokenize(char *code){
    token head = {false, 0, nullptr};
    token *cur = &head;
    while(*code){
        if(isdigit(*code)){
            int64_t val = strtoll(code, &code, 10);
            cur->next = new token{true, val, nullptr};
            cur = cur->next;
            continue;
        }
        cur->next = new token{false, *code, nullptr};
        ++code;
        cur = cur->next;
    }
    return head.next;
}

token *tok;
constexpr char ops[] = "+-*";
constexpr int pri[][3] = {
    {0, 0, 0},
    {1, 0, 0},
    {0, 1, 0},
    {0, 0, 1},
    {1, 1, 0},
    {1, 0, 1},
    {0, 1, 1},
    {0, 1, 2},
    {0, 2, 1},
    {1, 0, 2},
    {1, 2, 0},
    {2, 0, 1},
    {2, 1, 0}
};
int64_t op(int p, int state);
int64_t primary(int state){
    if(tok->is_num){
        int64_t val = tok->value;
        tok = tok->next;
        return val;
    }
    assert(tok->is_num == false && tok->value == '(');
    tok = tok->next;
    int64_t val = op(2, state);
    assert(tok->is_num == false && tok->value == ')');
    tok = tok->next;
    return val;
}
int64_t op(int p, int state){
    auto sub = [&](int state){
        if(p == 0) return primary(state);
        else return op(p-1, state);
    };
    auto val = sub(state);
    while(tok){
        assert(!tok->is_num);
        for(int i=0;i<3;++i){
            if(tok->value == ops[i] && pri[state][i] == p){
                tok = tok->next;
                auto v = sub(state);
                if(i == 0) val += v;
                if(i == 1) val -= v;
                if(i == 2) val *= v;
                goto l_next;
            }
        }
        break;
        l_next:;
    }
    return val;
}

int main(){
    char s[201];
    scanf("%s", s);
    token *t = tokenize(s);
    int64_t ans = INT64_MIN;
    for(int i=0;i<13;++i){
        tok = t;
        ans = max(ans, op(2, i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#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 oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n; ci(n);
  vll h(n);
  FOR(i,0,n){
    ci(h[i])
  }
  vll dp(n);
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  FOR(i,2,n){
    dp[i]=rM(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }
  co(dp[n-1])
}


Measured memory_bytes: 1792
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define YES_ cout<<"Yes"<<endl;
#define NO_ cout<<"No"<<endl;


int main(){
 
    int A,B,C;
    cin>>A;
    cin>>B;
    cin>>C;
    A-=B;
    cout<<A%C<<endl;
    
    



}


Measured memory_bytes: 768
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

def make_divisors(n): #約数列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = onem()
co = 0

nnn = make_divisors(n)

mp = make_divisors(n-1)


for i in nnn:
    nn = n
    if i == 1:
        continue
    while True:
        if nn == 1:
            co += 1
            break
        elif nn <= 0:
            break
        if nn % i:
            nn = nn % i if nn//i else 0
        else:
            nn //= i
for i in mp:
    if i != 1:
        co += 1
print(co)


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

int main(){
    int N,M; cin >> N >> M;
    vector<int> cnt(M);
    rep(i,N){
        int K; cin >> K;
        rep(j,K){
            int A; cin >> A;
            A--;
            cnt[A]++;
        }
    }
    
    int ans=0;
    rep(i,M){
        if (cnt[i]==N) ans++;
    }
    cout << ans;
}

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

d = {}
for i in range(2, n+1):
    j = 2
    while i >= j:
        if i % j == 0:
            i //= j
            if d.get(j):
                d[j] += 1
            else:
                d[j] = 1
        else:
            j += 1
            
ans = 1
for k, v in d.items():
    ans *= (v+1)

print(ans % (10**9 + 7))

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int64_t> A(N), B(N), C(M), D(M);
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  for (int i = 0; i < M; i++) cin >> C[i] >> D[i];

  for (int i = 0; i < N; i++) {
    int64_t min_dist = numeric_limits<int64_t>::max();
    int answer = -1;
    for (int j = 0; j < M; j++) {
      int64_t dist = abs(A[i] - C[j]) + abs(B[i] - D[j]);
      if (dist < min_dist) {
        answer = j + 1;
        min_dist = dist;
      }
    }
    cout << answer << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
H = list(map(int, input().split()))
C = [1]*n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] <= H[b]:
        C[a] = 0
    if H[b] <= H[a]:
        C[b] = 0
ans = sum(C)
print(ans)

Measured memory_bytes: 19984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll k;cin>>k;
    ll s;cin>>s;
    vector<ll> a(n);
    ll fill=(s>10000000?1:1000000000);
    For(i,0,n) a[i]=fill;
    For(i,0,k) a[i]=s;
    For(i,0,n) cout<<a[i]<<" ";
    cout<<endl;

}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  string S; cin >> S;
  
  string T = "ATGC";
  

  
  int ans = 0;		// ATGC文字列の最大長
  int cnt = 0;		// 今見ている文字列を末尾にしてる
  
  for (int i = 0; i < S.size(); ++i) {
      bool check = false;
    for (int j = 0; j < T.size(); ++j) {
      if (S[i] == T[j]) {
        check = true;
      }
    }
      if (!check) {
        cnt = 0;
      }
      else {
        cnt++;
      }
    ans = max(ans, cnt);
  }
  
  cout << ans << endl;
}
        

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

int main(void){

    string S,T; cin>>S>>T;

    map<char, char> Smap,Tmap;
    bool ok=true;
    for (int i = 0; i < S.length(); ++i) {
        char s=S[i], t=T[i];
        if(Smap.count(s)){
            if(Smap[s]!=t){
                ok = false;
                break;
            }
        }
        if(Tmap.count(t)){
            if(Tmap[t]!=s){
                ok=false;
                break;
            }
        }
        Smap[s] = t;
        Tmap[t] = s;
    }
    if(ok){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 904
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m, q, x, y;

bool ng[20][20];
long long dp[20][20];

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        cin >> q;
        memset(ng, 0, sizeof(ng));
        for (int i = 0; i < q; ++i) {
            cin >> x >> y;
            ng[x][y] = true;
        }
        memset(dp, 0, sizeof(dp));
        dp[1][1] = 1;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                if (ng[i][j]) continue;
                dp[i][j] += dp[i-1][j] + dp[i][j-1];
            }
        }
        cout << dp[n][m] << endl;
    }
    return 0;
}


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

int h, n;
int A[100100];

int main(){
	cin >> h >> n;
	long long sum = 0LL;
	rep(i, n){
		cin >> A[i];
		sum += A[i];
	}
	if(sum >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 110000, inf = 1e9;

int n, m, k, a[N], b[N];

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	int x, y, w;
	read(n), read(m), read(k);
	int minA = inf, minB = inf;
	for (R int i = 1; i <= n; ++i) read(a[i]), minA = min(minA, a[i]);
	for (R int i = 1; i <= m; ++i) read(b[i]), minB = min(minB, b[i]);
	int ans = minA + minB;
	while (k--) {
		read(x), read(y), read(w);
		ans = min(ans, a[x] + b[y] - w);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

const long long mod = 1e9 + 7;

long long dp[64][3] = {};

int main()
{
    long long N;

    cin >> N;

    int n[64];

    long long d = (long long)log2(N) + 1;

    for (int i = 0; N != 0; N = N >> 1, i++)
    {
        n[i] = N % 2;
    }

/*
    for(int i = d - 1;i >= 0;i--)
    {
        cout << n[i];
    }

    cout << endl;
*/

    if(n[d - 1] == 0)
    {
        dp[d - 1][0] = 1;
    }
    else if (n[d - 1] == 1)
    {
        dp[d - 1][0] = 1;
        dp[d - 1][1] = 1;
    }

    for (int i = d - 2; i >= 0; i--)
    {
        
        if(n[i] == 1)
        {
            dp[i][0] = 1 * dp[i + 1][0] + 0 * dp[i + 1][1] + 0 * dp[i + 1][2];
            dp[i][1] = 1 * dp[i + 1][0] + 1 * dp[i + 1][1] + 0 * dp[i + 1][2];            
            dp[i][2] = 0 * dp[i + 1][0] + 2 * dp[i + 1][1] + 3 * dp[i + 1][2];
        }
        else
        {
            dp[i][0] = 1 * dp[i + 1][0] + 1 * dp[i + 1][1] + 0 * dp[i + 1][2];
            dp[i][1] = 0 * dp[i + 1][0] + 1 * dp[i + 1][1] + 0 * dp[i + 1][2];
            dp[i][2] = 0 * dp[i + 1][0] + 1 * dp[i + 1][1] + 3 * dp[i + 1][2];
        }

        dp[i][0] %= mod;
        dp[i][1] %= mod;
        dp[i][2] %= mod;
        
    }

    long long ans = (dp[0][0] + dp[0][1] + dp[0][2]) % mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        for(;;){
                char c;
                scanf("%c",&c);
                if(c=='\n'){
                        printf("\n");
                        break;
                }else if(islower(c)){
                        c=toupper(c);
                }else{
                        c=tolower(c);
                }
                printf("%c",c);
        }
        return 0;
}

Measured memory_bytes: 1100
#include <iostream>
#include <algorithm>

using namespace std;

int dp[100001];
int A[100];
int n;

int f(int i) {
  if(i < A[0]) return 2;
  if(dp[i]) return dp[i];
  int mx = 2;
  for(int j = 0; j < n; ++j)
    if(i - A[j] >= 0 && f(i - A[j]) == 2) mx = 1;
  return dp[i] = mx;
}

int main() {
  int k; cin >> n >> k;
  for(int i = 0; i < n; ++i)
    cin >> A[i];
  
  sort(A, A + n);
  
  if(f(k) == 1) cout << "First";
  else cout << "Second";
  
  return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
  int h,a;
  int i;
  scanf("%d %d",&h,&a);
  int sum=0;
  for(i=0;sum<h;i++){
    sum+=a;
  }
  printf("%d",i);
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], K = l[1];

            var array = Console.ReadLine().ToCharArray();
            var acum = new List<int>();
            if (array[0] == '0') acum.Add(0);

            for (var i = 0; i < array.Count();)
            {
                var count = i;
                while (count < array.Count() && array[count] == array[i]) count++;
                acum.Add(count - i);
                i = count;
            }
            if (array[N - 1] == '0') acum.Add(0);

            var sum = new long[acum.Count()+1];
            for (var i = 0; i < acum.Count(); i++) sum[i + 1] = sum[i] + acum[i];

            var res = 0L;
            for (var left = 0; left < sum.Count(); left += 2)
            {
                var right = left + K * 2 + 1;
                if (right >= sum.Count()) right = sum.Count() - 1;
                res = Math.Max(res, sum[right] - sum[left]);
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 15584
#include<iostream>
int main()

{
    int x,y,a,b; //a:clain,b:turtle
    std::cin >> x >> y;
    for(int i=0;i<=x;i++){
        a=i;
        b=x-i;
        if(y==2*a+4*b)
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }//｛｝内を繰り返す
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    set<ll> S;

    if(n > k) {
        if(n%k == 0) {
            cout << 0 << "\n";
            return 0;
        }
        n = n%k;
        cout << k - n << "\n";

    }
    else {
        while(1) {
            n = min(n, abs(n-k));
            if(S.count(n)) {
                cout << n << "\n";
                break;
            }
            S.insert(n);
        }
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1001001001;


int main()
{
int n,m;
  cin>>n>>m;
  int a,b;
  vector<int> to[100005];
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  vector<int> dist(n,INF);
  vector<int> pre(n,-1);
  dist[0]=0;
  q.push(0);
  while(!q.empty())
  {
    int v=q.front();
    q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF) continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++){
    if(i==0) continue;
    int ans=pre[i];
      ans++;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 10660
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	char lc1Buf[1024];

	// 値 - 取得
	long long llX, llK, llD;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld%lld%lld", &llX, &llK, &llD);
	llX = llabs(llX);

	// D未満への回数
	long long llCnt = llX / llD;

	// 届かない
	if (llK < llCnt) {
		return llX - llD * llK;
	}

	// D未満へ
	llX %= llD;
	llK -= llCnt;

	// D or -D
	if (llK % 2) {
		return llD - llX;
	}
	else {
		return llX;
	}
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1776
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

N = int(raw_input())
tree = [[] for _ in xrange(N)]

for i in range(N-1):
    a, b, c = map(int, raw_input().split())
    a -= 1; b -= 1;
    tree[a].append((b, c))
    tree[b].append((a, c))

Q, K = map(int, raw_input().split())
K -= 1

depth = [0 for _ in xrange(N)]

def dfs(v, p = -1, d = 0):
    St = []
    St.append([v, p, d])
    while len(St) != 0:
        cur = St.pop()
        depth[cur[0]] = cur[2]
        for i, j in tree[cur[0]]:
            if i == cur[1]:
                continue
            St.append([i, cur[0], cur[2] + j])

dfs(K)

for i in range(Q):
    x, y = map(int, raw_input().split())
    x -= 1; y -= 1
    print depth[x] + depth[y]

Measured memory_bytes: 49532
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
		if(u.contentEquals(s)) {
			a-=1;
		}else {
			b-=1;
		}
		System.out.println(a);
		System.out.println(b);

	}

}


Measured memory_bytes: 22996
#include <stdio.h>
int main(void){
    int n, a, b;
    int i;
    int sum = 0;
    scanf("%d %d %d\n", &n, &a, &b);
    
    for (i=0; i<n; i++) {
        sum += a;
    }
    
    if (sum < b) printf("%d", sum);
    else printf("%d", b);
    
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 3e5 + 5; 
typedef long long ll;
const ll INF = 1e15; 
using namespace std;

int n, m, t[N], stk[N], top; 
ll s[N], f[N], g[N], h[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

ll y1(ll *p, int x) { return p[x] * 2 + s[x] * 2 + 1ll * x * x + x; }

ll x1(int x) { return x; }

double slope1(ll *p, int a, int b) { return 1.0 * (y1(p, b) - y1(p, a)) / (x1(b) - x1(a)); }

ll y2(ll *p, int x) { return p[x] * 2 - s[x - 1] * 2 + 1ll * x * x - x; }

ll x2(int x) { return x; }

double slope2(ll *p, int a, int b) { return 1.0 * (y2(p, b) - y2(p, a)) / (x2(b) - x2(a)); }

void DP(ll *p)
{
	for(int i = 1; i <= n; i++) s[i] = s[i - 1] + t[i];
	stk[top = 1] = 0;
	for(int j, i = 1; i <= n; i++)
	{
		while(top > 1 && slope1(p, stk[top - 1], stk[top]) <= 2.0 * i) top--; 
		j = stk[top], p[i] = max(1ll * p[i - 1], p[j] + 1ll * (i - j) * (i - j - 1) / 2 - (s[i - 1] - s[j])); 
		while(top > 1 && slope1(p, stk[top - 1], stk[top]) <= slope1(p, stk[top], i)) top--;
		stk[++top] = i; 
	}
}

void solve(int l, int r)
{
	if(l == r) return (void) (h[l] = 1ll - t[l]); 
	int mid = (l + r) >> 1; solve(l, mid), solve(mid + 1, r); 
	top = 0; 
	for(int i = l - 1; i <= mid; i++)
	{
		while(top > 1 && slope1(f, stk[top - 1], stk[top]) <= slope1(f, stk[top], i)) top--; 
		stk[++top] = i; 
	}
	ll mx = -INF, hd = 1; 
	for(int j, i = r + 1; i > mid + 1; i--)
	{
		while(hd < top && slope1(f, stk[hd], stk[hd + 1]) > 2.0 * i) hd++;
		j = stk[hd], mx = max(mx, g[i] + f[j] + 1ll * (i - j - 1) * (i - j) / 2 - (s[i - 1] - s[j]));
		h[i - 1] = max(h[i - 1], mx); 
	}
	top = 0;
	for(int i = mid + 1; i <= r + 1; i++)
	{
		while(top > 1 && slope2(g, stk[top - 1], stk[top]) <= slope2(g, stk[top], i)) top--;
		stk[++top] = i; 
	}
	mx = -INF;
	for(int j, i = l - 1; i < mid; i++)
	{
		while(top > 1 && slope2(g, stk[top - 1], stk[top]) <= 2.0 * i) top--;
		j = stk[top], mx = max(mx, f[i] + g[j] + 1ll * (j - i - 1) * (j - i) / 2 - (s[j - 1] - s[i]));
		h[i + 1] = max(h[i + 1], mx); 
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> ();
	for(int i = 1; i <= n; i++) t[i] = read <int> ();
	DP(f), reverse(t + 1, t + n + 1), DP(g);
	reverse(t + 1, t + n + 1), reverse(g + 1, g + n + 1);
	for(int i = 1; i <= n; i++) s[i] = s[i - 1] + t[i]; 
	solve(1, n), m = read <int> (); 
	for(int pos, v, i = 1; i <= m; i++)
	{
		pos = read <int> (), v = read <int> ();
		printf("%lld\n", max(f[pos] + g[pos], h[pos] + t[pos] - v)); 
	}
	return 0; 
}

Measured memory_bytes: 14328
# 最大値と最小値を調べておいて、それを掛け合わせる

n = int(input())
left_heights = list(map(int, input().split()))
right_heights = list(map(int, input().split()))

minimum = [-1] * n
maximum = [10**10] * n

l_max = 0
for i in range(n):
    if left_heights[i] > l_max:
        maximum[i] = left_heights[i]
        minimum[i] = left_heights[i]
    else:
        maximum[i] = left_heights[i]
        minimum[i] = 1
    l_max = left_heights[i]

r_max = 0
for i in reversed(range(n)):
    if right_heights[i] > r_max:
        if minimum[i] <= right_heights[i] <= maximum[i]:
            maximum[i] = right_heights[i]
            minimum[i] = right_heights[i]
        else:
            print(0)
            exit()
    else:
        if r_max >= minimum[i]:
            maximum[i] = min(right_heights[i], maximum[i])
        else:
            print(0)
            exit()

    r_max = right_heights[i]

mod = 10**9 + 7
ans = 1
for mi, ma in zip(minimum, maximum):
    ans *= ma - mi + 1
    ans %= mod
print(ans)


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  double r1, r2;
  cin >> r1 >> r2;
  cout << r1 * r2 / (r1 + r2) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
E = S.count("E")
W = N - E

s = N
re = E
lw = 0
  

for i in S:
  if i == "E":
    re -= 1
    s = min(s, re + lw)
  else:
    s = min(s, re + lw)
    lw += 1
print(s)

Measured memory_bytes: 42200