akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

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

using namespace std;

void dump(vector<string> f, int x = -1, int y = -1) {
    REP(i, f.size()) {
        REP(j, f[i].size()) {
            if ( i == y && j == x )
                cout << "#";
            else
                cout << f[i][j];
        }
        cout << endl;
    }
}

/*
0:上
1:右
2:下
3:左
*/
int mx[] = {0, 1, 0, -1},
    my[] = {-1, 0, 1, 0};

vector< vector<int> > closed;

void go(vector<string> &f, int x, int y) {
    // dump(f, x, y);
    // cout << endl;

    while( f[y][x] != '.' ) {
        if ( closed[y][x] ) {
            cout << "LOOP" << endl;
            return;
        }
        closed[y][x] = 1;

        int mv = -1;

        switch(f[y][x]) {
            case '^':
                mv = 0;
                break;
            case '>':
                mv = 1;
                break;
            case 'v':
                mv = 2;
                break;
            case '<':
                mv = 3;
                break;
        }
        if ( mv != -1 ) {
            x += mx[mv];
            y += my[mv];
        }
        // dump(f, x, y); cout << endl;
    }
    cout << x << " " << y << endl;
}

int main() {
    int w, h;

    while( cin >> h >> w, w || h ) {
        vector<string> f(h);
        closed = vector< vector<int> >(h, vector<int>(w, 0));

        REP(i, h) {
            REP(j, w) {
                closed[i][j] = 0;
            }
        }

        REP(i, h) {
            cin >> f[i];
        }

        go(f, 0, 0);
    }

    return 0;
}

Measured memory_bytes: 1324
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}


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

	string a,b;
	cin>>a>>b;
	cout<<b<<a<<endl;

}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <stack>
#include <algorithm>
#define MIN(x,y) ((x)<(y)?(x) : (y))
#define MAX(x,y) ((x)>(y)?(x) : (y))
#include <stdlib.h>
#include <time.h>
#include <sstream>
#define mem(a,b) memset(a,b,sizeof(a))
#include <string>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
const ll INF=1e9;
/*坚持不懈，无懈可击*/
int main()
{
    int A=0,B=0;
    char str[maxn];
    scanf("%s",str+1);
    for(int i=1;str[i];i++)
    {
        if(str[i]=='0') A++;
        if(str[i]=='1') B++;
    }
    printf("%d\n",min(A,B)*2);
    return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;

	ll ans = 0;

	rep(i, N) {
		if ((i + 1) % 3 && (i + 1) % 5) {
			ans += i + 1;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long
#define mod 1000000007

signed main(void)
{
	int n; cin >> n;
	int a[200005];
	rep (i, n) cin >> a[i];
	int ans = 0, sum = 0;
	rep (i, n - 1)
	{
		sum += a[i];
		sum %= mod;
		ans += (sum * a[i + 1]) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    map<string,int> mp;
    int i;
    for(i=0;i<n;i++)
    {
        cin >> s;
        mp[s]++;
    }
    map<int,vector<string>> cnt;
    for(auto it = mp.begin();it!=mp.end();it++)
    {
        cnt[it->second].push_back(it->first);
    }
    auto it = cnt.rbegin();
    vector<string> v = it->second;
    for(auto j : v)
        cout << j << '\n';
}

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

#define MAX_N 100
#define MAX_M 16
int N,M,K;

int s[MAX_M];
int t[MAX_N];

vector<int> G[MAX_N];
int d[(1<<MAX_M)];

int main(){
  memset(t,-1,sizeof(t));
  
  cin>>N>>M>>K;
  for(int i=0;i<M;i++){
    cin>>s[i];
    s[i]--;
    t[s[i]]=i;
  }
  
  for(int i=0;i<N;i++){
    G[i].resize(K);
    for(int j=0;j<K;j++){
      cin>>G[i][j];
      G[i][j]--;
    }
  }

  memset(d,-1,sizeof(d));
  d[ (1<<M)-1 ]=0;
  queue<int> Q;
  Q.push( (1<<M)-1 );
  while(!Q.empty()){
    int bit=Q.front();Q.pop();
    if(bit==0){
      cout<<d[bit]<<endl;
      break;
    }
    for(int i=0;i<K;i++){
      int nbit=0;
      for(int j=0;j<M;j++){
        int to=G[s[j]][i];
        if(bit>>j&1)
          if(t[to]!=-1)
            nbit|=(1<<t[to]);
      }
      if(d[nbit]==-1){
        d[nbit]=d[bit]+1;
        Q.push(nbit);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1644
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    for h in range(1, 3501):
        for n in range(1, 3501):
            if (4*h*n) - N*n - N*h == 0:
                continue
            w = N*h*n/((4*h*n) - N*n - N*h)
            if w.is_integer() and w > 0:
                print(h, n, int(w))
                return

if __name__ == '__main__':
    main()


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

int main() {

  int N;
  cin >> N;
  map<int, int> m;

  vector<int> A(N);
  for(int &a : A){
    cin >> a;
    m[a]++;
  }
  long long tmp = 0;
  long long base = 0;
  for(auto iter = m.begin(); iter != m.end(); iter++){
    tmp = iter->second;
    if(tmp >= 2){
      base += tmp * (tmp - 1) / 2;
    }
  }
  for(int a : A){
    if(m.find(a) != m.end()){
      if(m[a] >= 2){
        tmp = m[a] * (m[a] - 1) / 2 - (m[a] - 1) * (m[a] - 2) / 2;
        cout << base - tmp << endl;
      }else{
        cout << base << endl; 
      }
    }
  }

}

Measured memory_bytes: 8320
import sys

input = sys.stdin.readline

S = input().strip()
Q = int(input())
Query = []
for _ in range(Q):
    Query.append(input().strip())

rev = S[::-1]
left = ""
right = ""
count = 0
flag = 'Normal'
for value in Query:
    if value == '1':
        count += 1
    if count % 2 == 1:
        flag = 'Reverse'
    else:
        flag = 'Normal'
    if value != "1":
        if flag == 'Normal':
            if value[2] == '1':
                left += value[4]
            elif value[2] == '2':
                right += value[4]
        elif flag == 'Reverse':
            if value[2] == '1':
                right += value[4]
            elif value[2] == '2':
                left += value[4]

if flag == 'Normal':
    ans = left[::-1] + S + right
elif flag == 'Reverse':
    ans = right[::-1] + rev + left
print(ans)

Measured memory_bytes: 17016
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
 
int main(){
  map<int,bool> memo;
 
  int N;
  cin >> N;
 
  int cnt=0;
 
  for(int i=0;i<N;i++){
    int p[3];
    cin >> p[0] >> p[1] >> p[2];
 
    sort(p,p+3);
 
    int k=((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);
 
    if(memo.find(k)!=memo.end()){
      cnt++;
    }else{
      memo[k] = true;
    }
  }
 
  cout << cnt << endl;
 
  return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	int N, Q;
	cin >> N >> Q;

	string S;
	cin >> S;

	vector<int> L, R;
	for (int i = 0; i < Q; i++) {
		int temp1, temp2;
		cin >> temp1 >> temp2;
		L.emplace_back(temp1);
		R.emplace_back(temp2);
	}

	vector<bool> check(N);
	for (int i = 0; i < N; i++) {
		check[i] = false;
	}
	for (int i = 0; i < N-1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			check[i + 1] = true;
		}
	}

	vector<int> ruiseki(N);
	for (int i = 0; i < N; i++) {
		ruiseki[i] = 0;
	}
	
	for (int i = 1; i < N; i++) {
		ruiseki[i] = ruiseki[i - 1] + int(check[i]);
	}


	for (int i = 0; i < Q; i++) {
		int ans = ruiseki[R[i]-1] - ruiseki[L[i] - 1 ] ;
		cout << ans << endl;

	}




}





Measured memory_bytes: 2372
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
    	
    	String a;
    	String b = "";
    	String c;
    	
    	a = sc.next();
    	b = sc.next();
    	c = sc.next();
    	
    	String bb = b.substring(0,1);
    	String ans = "A" + bb + "C";
    	System.out.println(ans);
    	
    	
    	
    	
    }	
}
    
   

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

int main(void) {
    int n, p1 = 0, p2 = 0;
    string s1, s2;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        if (s1 == s2) {
            p1++;
            p2++;
        }
        else if (s1 > s2) p1 += 3;
        else p2 += 3;
    }
    cout << p1 << " " << p2 << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <vector>
#include <algorithm>

int main (){
    int N,M,X,Y;
    scanf("%d %d %d %d",&N,&M,&X,&Y);
    std::vector<int> x(N);
    std::vector<int> y(M);
    int xmax=-100;
    int ymin=100;
    for (int i = 0; i < N; i++){
        scanf("%d",&x[i]);
        if(x[i]>xmax) xmax=x[i];
    }
    for (int i = 0; i < M; i++){
        scanf("%d",&y[i]);
        if(y[i]<ymin) ymin=y[i];
    }
    X=std::max(X,xmax);
    Y=std::min(Y,ymin);
    if(X<Y) printf("No War");
    else printf("War");
}

Measured memory_bytes: 384
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  105 % lines[0] == 0 && lines[0] != 1 ? console.log("YES") : console.log("NO");
});

Measured memory_bytes: 21704
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int randset(int A,int B,int C,int X)
{
	return (A*X+B)%C;
}

int main()
{
	int N,A,B,C,X;
	while(cin >> N >> A >> B >> C >> X && N)
	{
		int Y[100000]={};
		int count=0;
		int i=1;

		rep(i,N)cin >> Y[i];

		for(i=1;i<=10001;i++)
		{
			if(X==Y[count])count++;
			
			if(count==N)break;
			else X=randset(A,B,C,X);
		}
		if( i>=10001 && count!=N )i=0;
		cout << i-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    //cout.precision(10);
    //int ok=0;
    int a,b,c,ans=0;
    string s,t;
    cin>>a;
    int k[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    cout<< k[--a] <<endl;
}

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

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

int main()
{
    string s, ans;
    cin >> s;
    string x[3] = {"Sunny", "Cloudy", "Rainy"};

    rep(i, 3)
    {
        if (s == x[i])
        {
            ans = x[(i + 1) % 3];
        }
    }
    cout << ans << endl;
    return 0;
}

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

signed main() {
    int n;
    cin >> n;
    vector <int> a(n);
    rep (i, n) cin >> a[i];

    int low = 0, up = -1, sum = 0, xsu = 0, ans = n, prevUp = -1;
    while (true) {
        if (up == n - 1) {
            if (sum == xsu) {
                int va = up + 1 - low;
                int ri = prevUp + 1 - low;
                ans += (((va)*(va - 1))/2) - ((prevUp != -1) * (((ri)*(ri - 1))/2));
                break;
            }
            sum -= a[low];
            xsu ^= a[low];
            low++;
            if (low == n - 1) break;
            continue;
        }

        if (low == up) {
            up++;
            sum += a[up];
            xsu ^= a[up];
            prevUp = -1;
            continue;
        }

        if ((sum + a[up + 1]) == (xsu ^ a[up + 1])) {
            up++;
            sum += a[up];
            xsu ^= a[up];
        }
        else {
            if (sum == xsu) {
                int va = up + 1 - low;
                int ri = prevUp + 1 - low;
                ans += (((va)*(va - 1))/2) - ((prevUp != -1) * (((ri)*(ri - 1))/2));
                prevUp = up;
            }
            sum -= a[low];
            xsu ^= a[low];
            low++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s;
    cin >> s;
    vstr d = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    rep(i, 7) {
        if (s == d[i]) cout << 7-i << endl;
    }
    return 0;
}

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

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(int argc, const char * argv[]) {
    string S; cin >> S;
    
    if(S=="ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-10;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<ll>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

ll popHeap(vector<ll>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  ll i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,cnt=0;
  ll a,b,k;
  cin>>a>>b>>k;
  if(a>=k){
    cout<<a-k<<" "<<b<<endl;
  }
  else if(a+b>=k){
    cout<<0<<" "<<a+b-k<<endl;
  }
  else cout<<0<<" "<<0<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main()
{
  string s;
  int a,b;
  a=0;
  b=0;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    if(i%2==0)
    {
      if(s.at(i)=='1')
        a++;
    }
    else
    {
      if(s.at(i)=='0')
        a++;
    }
  }
  for(int i=0;i<s.size();i++)
  {
    if(i%2==0)
    {
      if(s.at(i)=='0')
        b++;
    }
    else
    {
      if(s.at(i)=='1')
        b++;
    }
  }
  cout<<min(a,b)<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val a = sc.nextInt(); val b = sc.nextInt()

  val x = new Array[Int](n+1)
  for(i <- 1 to n)
    x(i) = sc.nextInt()

  var ans = 0L
  for(i <- 1 to n-1) {
    val now: Long = x(i+1) - x(i)
    ans += Math.min(now * a, b)
  }

  println(ans)
}


Measured memory_bytes: 51980
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	bool t[4];
	for(int i=0;i<4;i++)t[i]=false;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='N')t[0]=true;
		if(s[i]=='S')t[1]=true;
		if(s[i]=='W')t[2]=true;
		if(s[i]=='E')t[3]=true;
	}
	cout<<(t[0]^t[1]||t[2]^t[3]?"No":"Yes")<<endl;
	return 0;
}


Measured memory_bytes: 256
m,d = gets.split.map(&:to_i)
dates = []
2.upto(9) do |i|
  2.upto(9) do |j|
    dates << [i*j,i*10+j]
  end
end
count = 0
dates.each do |date|
  count += 1 if (date[0] <= m) && (date[1] <= d)
end
puts count

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

int main ()
{
    int n; cin >> n;
    vector<int> ss;
    vector<int> counting(n+1);
    for (int i = 0; i < n; i++)
    {
        int x; cin >> x;
        ss.push_back(x);
    }

    for (int i = 0; i < n; i++)
    {
        counting[ss[i]-1] = i + 1;
    }

    for (int i = 0; i < n; i++)
        cout << counting[i] << " ";
    return 0;
}


Measured memory_bytes: 1784
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,(a+b+r*1j*3**.5)/2,b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5924
#include <stdio.h>

#define LEN 10

int main(void) {
    int a;
    char str[LEN];

    scanf("%d", &a);
    scanf("%s", str);

    if (a >= 3200) {
        printf("%s\n", str);
    } else {
        puts("red");
    }

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}

inline void out(int x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
}   
double q[N];
char s[N];
int main(){
	int t;
	ll x;
	x=read();
	ll sum=100;
	int cnt=0;
	while(sum<x){
		sum=sum*0.01+sum;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3624
n = input()
if n == "SAT":
    print(1)
elif n == "MON":
    print(6)
elif n == "TUE":
    print(5)
elif n == "WED":
    print(4)
elif n == "THU":
    print(3)
elif n == "FRI":
    print(2)
else:
    print(7)

Measured memory_bytes: 3060
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val dList = readIntegerList().sorted()
    val m = readInteger()
    val tList = readIntegerList().sorted()
    var i = 0
    for (t in tList) {
        while(true) {
            if (i == dList.size) {
                out.println("NO")
                return
            }

            if (dList[i] == t) {
                i++
                break
            }

            i++
        }
    }
    out.println("YES")
}


fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 83540
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int unit = n % 10;
  if (unit == 2 || unit == 4 || unit == 5 || unit == 7 || unit == 9) {
    puts("hon");
  }
  else if (unit == 0 || unit == 1 || unit == 6 || unit == 8) {
    puts("pon");
  }
  else puts("bon");
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  H = min(H, 2 * Q);
  S = min(S, 2 * H);
  D = min(D, 2 * S);
  long long ans = (N / 2) * D;
  if (N % 2 == 1)
    ans += S;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    int N;
    cin >> N;

    map<int, int> m;
    rep (i, N) {
        int A;
        cin >> A;
        m[A]++;
    }

    int ans = 0;
    for (auto it : m) {
        if (it.second % 2 != 0) {
            ans++;
        }
    }

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

Measured memory_bytes: 4992
from bisect import bisect_left, bisect_right
from itertools import combinations

n = int(input())
l = sorted(map(int, input().split()))
ans = 0

for (i1, a), (i2, b) in combinations(enumerate(l[:-1]), 2):
    i3s = bisect_right(l, b - a, i2 + 1)
    i3e = bisect_left(l, a + b, i3s)
    ans += i3e - i3s

print(ans)


Measured memory_bytes: 47396
#include <iostream>

using namespace std;

int main()
{
    int no_of_apples, no_of_pieces;
    cin >> no_of_apples >> no_of_pieces;

    const int PIECES_FROM_ONE_APPLE = 3, PIECES_IN_ONE_PIE = 2;

    no_of_pieces += no_of_apples*PIECES_FROM_ONE_APPLE;

    int no_of_pies = no_of_pieces/PIECES_IN_ONE_PIE;

    cout << no_of_pies;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
lines = []

for i in range(N-1):
    lines.append(input())

C = []
S = []
F = []

for line in lines:
	c, s, f = line.split()
	C.append(int(c))
	S.append(int(s))
	F.append(int(f))

A = []

for i in range(N-1):
	a = C[i] + S[i]
	for j in range(i + 1, N - 1):
		if a <= S[j]:
			n = S[j] - a
		else:
			mod = a % F[j] 
			n = F[j] - mod if mod != 0 else 0
		a = a + C[j] + n
	A.append(a)

for a in A:
	print(a)
print(0)



Measured memory_bytes: 3188
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
struct SegmentTree{
private:
    int N;
    vector<T> node;
    function<T(T, T)> F;
    T E;
public:
    void init(int n, function<T(T, T)> f, T e, T def){
        F = f;
        E = e;
        N = 1;
        while(N < n) N = (N<<1);
        node.assign(2*N-1, e);
        for(int i=0; i<n; i++) node[N-1+i] = def;
        for(int i=N-2; i>=0; i--) node[i] = F(node[(i<<1)+1], node[(i<<1)+2]);
    }
    T& operator [](int a){
        return node[N-1+a];
    }
    void update(int a, T x){
        a += N-1;
        node[a] = x;
        while(a > 0){
            a = (a-1)>>1;
            node[a] = F(node[(a<<1)+1], node[(a<<1)+2]);
        }
    }
    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r == -1) r = N;
        if(b <= l || r <= a) return E;
        if(a <= l && r <= b) return node[k];
        return F(query(a, b, (k<<1)+1, l, (l+r)>>1), query(a, b, (k<<1)+2, (l+r)>>1, r));
    }
};

int N;
char c[4000];
int a[4000];
int dp[2002][2002];

signed main(){
    cin >> N;
    rep(i, 2*N){
        cin >> c[i] >> a[i];
        a[i]--;
    }
    rep(i, N+2){
        rep(j, N+2){
            dp[i][j] = INT_MAX;
        }
    }
    dp[0][0] = 0;
    rep(i, N+1){
        SegmentTree<int> st;
        st.init(2*N, [](int a, int b){ return a+b; }, 0, 0);
        vector<int> place(N);
        int p;
        rep(j, 2*N){
            if(c[j] == 'W' && a[j] < i){
                st.update(j, 1);
            }
            if(c[j] == 'W' && a[j] == i) p = j;
            if(c[j] == 'B'){
                place[a[j]] = j;
            }
        }
        rep(j, N+1){
            if(i<N) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + p - st.query(0, p));
            if(j<N) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + place[j] - st.query(0, place[j]));
            if(j<N) st.update(place[j], 1);
        }
    }

    /*rep(i, N+1){
        rep(j, N+1){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << dp[N][N] << endl;
}

Measured memory_bytes: 19312
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
 int n; cin>>n;
 int a[n+2];
 ll sum=0;
 a[0]=0;
 a[n+1]=0;
 FOR(i,1,n+1){
   cin>>a[i];
   sum+=abs(a[i]-a[i-1]);
 }
 sum+=abs(a[n]);
 FOR(i,1,n+1){
  int sa=abs(a[i+1]-a[i])+abs(a[i]-a[i-1])-abs(a[i+1]-a[i-1]);
  cout<<sum-sa<<endl;
 }

}

Measured memory_bytes: 1664
///////////////////////////////////////////////////
/* __                                       __   */
/*|  |--.-----.---.-.----.----.-----.-----.|  |_ */
/*|  _  |  -__|  _  |  __|  __|  -__|  _  ||   _|*/
/*|_____|_____|___._|____|____|_____|   __||____|*/
/*                                  |__|         */
///////////////////////////////////////////////////
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < (limit); counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}setupios;
int main() {

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(true){
    c-=b;
    if(c <= 0){
      cout<<"Yes"<<endl;
      return 0;
    }
    a-=d;
    if(a <= 0){
      cout<<"No"<<endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3668
#include "bits/stdc++.h"

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

int a[10];

signed main(){

	for (int i = 0; i < 4; i++){
		int t;
		cin >> t;
		a[t]++;
	}
	if (a[1] == 1 && a[9] == 1 && a[7] == 1 && a[4] == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
for lis in s:
  tmp_list = lis/c
  max_idx = np.argmax(tmp_list)
  print(max_idx + 1)
  

Measured memory_bytes: 27276
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S; cin >> S;
    int N = S.length();
    string s_1 = S.substr(0, (N - 1) / 2), s_2 = S.substr(((N + 3)/ 2) - 1);
    string T(S.rbegin(), S.rend()), s1_t(s_1.rbegin(), s_1.rend()), s2_t(s_2.rbegin(), s_2.rend());
    if (S == T && s_1 == s1_t && s_2 == s2_t) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}

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

map<string, int>mp;
int main() {
	string s; getline(cin, s);
	istringstream iss(s);
	int Max = 0; string Max_st;
	while (getline(iss, s, ' ')) {
		mp[s]++;
		if (s.size() > Max) { Max = s.size(); Max_st = s; }
	}
	int MAX = 0; string MAX_st;
	for (auto i : mp) {
		if (i.second > MAX) { MAX = i.second; MAX_st = i.first; }
	}
	cout << MAX_st << ' ' << Max_st << endl;
	return 0;
}

Measured memory_bytes: 3112
N, A, B, C, D = list(map(int, input().split()))
S = input()
X = [".", "#"]
Ans = ["Yes", "No"]

A -= 1
B -= 1
C -= 1
D -= 1

f = 0
if A < B:
  if B < C and D < C:
    f = 1

a, b = A, C
s = 0
for i in range(a, b + 1):
  if S[i] == X[1]:
    if s == 1:
      print(Ans[1])
      exit()
    s = 1
  else:
    s = 0

a, b = B, D
s = 0
for i in range(a, b + 1):
  if S[i] == X[1]:
    if s == 1:
      print(Ans[1])
      exit()
    s = 1
  else:
    s = 0

if f == 0:
  print(Ans[0])
  exit()

s = 0
for i in range(B - 1, min(D + 2, N)):
  if S[i] == X[1]:
    if s == 1:
      break
    else:
      s = 1
  else:
    if s == 1:
      s = -1
    else:
      s -= 1
      if s == -3:
        print(Ans[0])
        exit()

print(Ans[1])



Measured memory_bytes: 3700
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, p, cnt = 0, m;
    bool f = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        if (f) scanf("%d", &p);
        else scanf("%d", &m);
        if (i == p) {
            ++cnt;
            f = 0;
        } else f = 1;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 128
N=int(input())
P=list(map(str,input().split()))
Q=list(map(str,input().split()))
import itertools
S="".join(map(lambda x:str(x),range(1,N+1)))
A=list(itertools.permutations(S))
#print(A)
P_N = 0
Q_N = 0

QQ = ()
for q in Q:
  QQ += tuple(q)
PP = ()
for p in P:
  PP += tuple(p)
ind=1
for s in A:
  if QQ == s:
    Q_N = ind
  if PP == s:
    P_N = ind
  ind += 1
print(abs(P_N - Q_N))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REPRP(i, n) for (int i = (int)(n); (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORP(i, m, n) for(int i = m; i < n+1; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
const int INF = 2000000000ll;
const long double PI = acosl(-1);
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; }



int power(int a, int b) {return b?power(a*a,b/2)*(b%2?a:1):1;}
int perm(int N, int K){
    int x=1;
    for(int i=1;i<=K;i++)
    {
        x=x*(N-i+1);
    }
    return x;
}
int factorial(int N) {return perm(N,N);}
int comb(int N,int K) {return factorial(N)/factorial(K)/factorial(N-K);}
int hcomb(int N, int K) {return comb(N+K-1, N-1);}

int dtoi(double d) {return round(d);}

int isprime(int n) {
    if (n < 2) return 0;
    for (int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return 0;
    }
    return 1;
}

int mystoi(string S){
    int num = 0;
    for (int i = (int) S.length()-1; i >= 0; i--){
        num += (S[i]-'0') * power(10,S.length()-1-i);
    }
    return num;
}

template<class T>
int SUM(T a) {
    int sum = 0;
    for(auto iter : a) sum += iter;
    return sum;
}

void solve(int N);

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    solve(N);
    return 0;
}

void solve(int N) {
    int ans = 0;
    p(N/2+N%2);
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc157/abc157_a && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/abc157/abc157_a && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/abc157/abc157_a && sh submit.sh
*/


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N;
  scanf("%d",&N);

  int ans = 0;
  if(0 < N%100 && N%100 <= 12) ans++;
  if(0 < N/100 && N/100 <= 12) ans += 2;

  if(ans == 0) printf("NA\n");
  if(ans == 1) printf("YYMM\n");
  if(ans == 2) printf("MMYY\n");
  if(ans == 3) printf("AMBIGUOUS\n");

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG aoj/grl_2_a.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

vector<int> parent;// それぞれのnodeのparent，main内でresize必要
vector<int> tree_rank;// それぞれのnodeの属する木のtree_rank

void init(int n){// 初期化．全てのnodeで親を自分自身に，tree_rankを0にする．nもらわなくてもv.size()でいける
    rep(i, n){
        parent[i] = i;
        tree_rank[i] = 0;
    }
}

int root(int x){// node xのrootを返す．parent[x] = root(parent[x])で親をrootにつなぎ替える
    return x == parent[x] ? x : parent[x] = root(parent[x]);
}

bool same(int x, int y){// 同じ木に属するかどうか判定する
    return root(x) == root(y);
}

void unite(int x, int y){// xの属する木とyの属する木を連結する．rankができるだけ低くなるように処理を行う
    x = root(x);
    y = root(y);

    if(tree_rank[x] < tree_rank[y]){
        parent[x] = y;
    }else{
        parent[y] = x;
        if(tree_rank[x] == tree_rank[y]) tree_rank[x]++;
    }
}

vector<pair<int, pair<int, int> > > edges;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int v, e;
    cin >> v >> e;
    edges.resize(e);
    parent.resize(v);
    tree_rank.resize(v);
    init(v);

    rep(i, e){
        int s, t, w;
        cin >> s >> t >> w;
        edges[i] = make_pair(w, make_pair(s, t));
    }
    sort(edges.begin(), edges.end());

    ll ans = 0;
    rep(i, e){
        int s = edges[i].second.first;
        int t = edges[i].second.second;
        int w = edges[i].first;

        if(same(s, t)) continue;

        unite(s, t);
        ans += w;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4072
n = int(raw_input())
mxs, minm = 0, 21
for i in range(n):
    m, s  = map(int, raw_input().split())
    if s > mxs:
        mxs = s
        minm = m
    elif s == mxs:
        if m < minm:
            minm = m
print minm, mxs

Measured memory_bytes: 4204
#include<iostream>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int cnt=0;
	int m=n;
	while(m>0)
	{
		m/=10;
		cnt++;
	}
	if(cnt==1){
		cout<<n;
	}
	if(cnt==2){
		cout<<"9";
	}
	if(cnt==3){
		int d=9+n-100+1;
		cout<<d;
	}
	if(cnt==4){
		cout<<"909";
	}
	if(cnt==5){
		int d=909+n-10000+1;
		cout<<d;
	}
	if(n==100000){
		cout<<"90909";
	}
	return 0;
}

Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t X;
    intmax_t A = 0, B = 0;

    scanf("%jd", &X);

    for (B = -1000; B < 1000; B++) {
        for (A = B; A < 1000; A++) {
            if (A * A * A * A * A - B * B * B * B * B == X) {
                printf("%jd %jd\n", A, B);
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    long long cnt = 0;
    long long ans = 0;
    int prev;

    REP(i, n)
    {
        int h;
        cin >> h;
        if (i == 0)
        {
            prev = h;
        }
        else
        {
            if (h <= prev)
            {
                cnt++;
            }
            else
            {
                cnt = 0;
            }
            if (ans < cnt)
                ans = cnt;
            prev = h;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
hp = [0]*n
ans = 10 ** 12
for i in range(1,101):
    for j in range(n):
        hp[j] = (i-x[j])**2
    if ans > sum(hp):
        ans = sum(hp)

print(ans)



Measured memory_bytes: 2940
N = int(input())
ans = 0

for i in range(N):
    divisor = 0
    if (i+1) % 2 == 0:
        continue
    for j in range(N):
        if (i+1) % (j+1) == 0:
            divisor += 1
    if divisor == 8:
        ans += 1

print(ans)

Measured memory_bytes: 63952
/*
    Zeolim - An AC a day keeps the bug away
*/
  
//#pragma GCC optimize(2)
//#pragma GCC ("-W1,--stack=128000000")
#include <bits/stdc++.h>
using namespace std;
#define mp(x, y) make_pair(x, y)
#define fr(x, y, z) for(int x = y; x < z; ++x)
#define pb(x) push_back(x)
#define mem(x, y) memset(x, y, sizeof(x))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair <int, int> pii;
typedef std::vector <int> vi;
void re(ll &x){x=0;char s=getchar();while(s<'0'||s>'9')s=getchar();while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}}
void wr(ll x){if(x>9) wr(x/10);putchar(x%10+'0');}
const ld PI = acos(-1.0);
const ld E = exp(1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 386910137;
const ull P = 13331;
const int MAXN = 1e6 + 100;

ll arr[MAXN] = {0};
ll pre[MAXN] = {0};
ll pow(ll x) { return x * x; }

int main()
{  
    //ios::sync_with_stdio(0);
    //cin.tie(0); cout.tie(0);
    //freopen("d:\out.txt","w",stdout);
    //freopen("d:\in.txt","r",stdin);
    
    ll n, m;
    
    cin >> n >> m;
    
    if(n >= 10 || m >= 10)
    {
    	cout << "-1\n";
	}
	else
	{
		cout << n * m << '\n';
	}
    
    return 0;
}

Measured memory_bytes: 768
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

alias real F;
F cross(F[2] a, F[2] b){ return a[0]*b[1]-b[0]*a[1]; }
F[2] sub(F[] a, F[] b){ return [a[0]-b[0],a[1]-b[1]]; }

int solve(immutable int n)
{
    auto ps = iota(n).map!(_=>readln().chomp().split(",").map!(to!F).array()).array();
    if(ps.length<=3) return 0;
    ps.sort;
    auto u=[ps[0]],b=u;
    foreach(p;ps[1..$])
    {
        foreach_reverse(i;1..u.length) if(cross(sub(u[i-1],p),sub(u[i],p))<0) u.popBack();
        u~=p;
        foreach_reverse(i;1..b.length) if(cross(sub(b[i-1],p),sub(b[i],p))>0) b.popBack();
        b~=p;
    }
    return cast(int)(n-(u~b).sort().uniq().array().length);
}

void main()
{
    for(int n; 0!=(n=readln().chomp().to!int()); )
        writeln(solve(n));
}

Measured memory_bytes: 1112
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A[5];int k;
	for(int i=0;i<5;i++){
		cin>>A[i];
	}cin>>k;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			if(A[j]-A[i]>k){
				cout<<":("<<endl;
				return 0;
			}
		}
	}cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256