akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

bool DEBUG = false;

long long knapsack_duplicate(int W, vector<int> w, vector<int> v){
    long long ret = 0;
    int n = w.size();


    // デバッグ出力
    if(DEBUG){
        cout << "n : " << n << endl;
        for(int i = 0; i < n; i++) {
            cout << w[i] << " " << v[i] << endl;
        }
    }

    vector<vector<long long> > dp(n);
    for(int i = 0; i < n; i++) {
        dp[i].resize(W+1, 0);
    }

    // 一行目の初期化
    for(int i = 0; i <= W; i++) {
        if(w[0] <= i){
            dp[0][i] = dp[0][i - w[0]] + v[0];
        }else{
            dp[0][i] = 0;
        }
    }

    // dp
    for(int i = 1; i < n; i++) {
        for (int j = 0; j <= W; j++){
            if(j - w[i] < 0){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = max(dp[i][j - w[i]] + v[i], dp[i-1][j]);
            }
        }
    }

    // デバッグ出力
    if(DEBUG){
        for(int i = 0; i < n; i++) {
            for (int j = 0; j <= W; j++){
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }
    }
    
    
    ret = dp[n-1][W];
    return ret;
}

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

    vector<int> shopA(3);
    cin >> shopA[0] >> shopA[1] >> shopA[2];

    vector<int> shopB(3);
    cin >> shopB[0] >> shopB[1] >> shopB[2];
    
    vector<int> w(3);
    vector<int> v(3);
    for(int i = 0; i < 3; i++) {
        w[i] = shopA[i];
        v[i] = shopB[i];
    }
    w.push_back(1);
    v.push_back(1);

    long long M = knapsack_duplicate(N, w, v);

    if(DEBUG){
        cout << "M : " << M << endl;
    }

    for(int i = 0; i < 3; i++) {
        w[i] = shopB[i];
        v[i] = shopA[i];
    }
    
    long long ans = knapsack_duplicate(M, w, v);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 781668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const ll m = 1000000000000001;
const int siz = 12;
ll v[siz];
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<ll>v(n);
	ll xo = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		xo ^= v[i];
	}
	for (int i = 0; i < n; i++) {
		v[i] = xo ^ v[i] ;
	}
	for (auto k : v) {
		cout << k << " ";
	}
	cout << endl;
}

Measured memory_bytes: 4728
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    string s,t;
    while (cin >> s >> t) {
        set<char> x[128],y[128];
        const int n = s.size();
        FOR(i,0,n) {
            const char a = s[i];
            const char b = t[i];
            x[a].insert(b);
            y[b].insert(a);
        }
        bool good = true;
        FOR(i,0,128)
            good &= x[i].size() <= 1 && y[i].size() <= 1;
        if (good)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 916
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i=0; i < n; i++){
		cin >> d.at(i);
	}
	int ans=0;

	for (int i = 0; i < n; i++){
		for (int j = 1; j < n - i; j++){
			ans += d.at(i)*d.at(i + j);
		}
	}
	cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


LL combi(int a) {
  LL dp[a + 1][3];
  REP (i, a) dp[i][0] = 1;
  REP (i, 3) dp[i][i] = 1;

  FOR (i, 2, a + 1) {
    FOR (j, 1, min(3, i)) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
    }
  }

  return dp[a][2];
}

int main(){
  int n;

  scanf("%d", &n);

  vector<LL> v(n + 1);

  v[0] = 0;

  REP (i, n) {
    LL a;
    scanf("%lld", &a);
    v[i + 1] = v[i] + a;
  }

  map<LL, int> m;

  for (auto x : v) {
    if (m.count(x)) m[x] += 1;
    else m.insert(make_pair(x, 1));
  }

  LL ans = 0;
  for (auto x : m) {
    if (x.second > 1) {
      ans += combi(x.second);
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, a, b;
    cin >> x >> a >> b;

    if (b <= a) {
        cout << "delicious" << endl;
    } else if (a < b && b <= (a + x)) {
        cout << "safe" << endl;
    } else if (a + x < b) {
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        String[] a = new String[n];
        String[] b = new String[m];
        for (int i = 0; i < n; i++) {
            a[i] = sc.next();
        }
        for (int i = 0; i < m; i++) {
            b[i] = sc.next();
        }
        boolean ans = false;
        for (int i = 0; i <= n-m; i++) {
            for (int j = 0; j <= n-m; j++) {
                boolean t = true;
                for (int k = 0; k < m; k++) {
                    if(!a[i+k].substring(j, j+m).contains(b[k])) t = false;
                }
                if(t){
                    ans = true;
                    break;
                }
            }
            if(ans) break;
        }
        System.out.println(ans ? "Yes" : "No");
        sc.close();

    }

}


Measured memory_bytes: 22996
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    a, b = map(int, input().split())

    ans = list()
    ans.append(a + b)
    ans.append(a + a - 1)
    ans.append(b + b - 1)

    print(max(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int gcd(int a,int b){
	if(!b) return a;
	return gcd(b,a%b);
}

int n,k;

int main(){
	cin>>n>>k;
	int g=0,M=0;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		M=max(M,A);
		g=gcd(g,A);
	}
	if(k<=M&&k%g==0) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int d;
int c[27];
int s[366][27];
int calc(vector<int> t){
    int last[26]={};
    vector<int> ret(d);
    int ans=0;
    for(int i=0; i<d; i++){
        ans+=s[i][t[i]];
        last[t[i]]=i+1;
        for(int j=0; j<26; j++){
            ans-=c[j]*(i+1-last[j]);
        }
        ret[i]=ans;
    }
    return ans;
}
mt19937 mt(334);

int main()
{
    cin>>d;
    for(int i=0; i<26; i++) cin>>c[i];
    for(int i=0; i<d; i++) for(int j=0; j<26; j++) cin>>s[i][j];
    vector<int> t(d);
    
    int last[26]={};
    for(int i=0; i<d; i++){
        int kmx=0, mx=-1e9;
        for(int k=0; k<26; k++){
            int sum=s[i][k];
            int myon=last[k];
            last[k]=i+1;
            for(int j=0; j<26; j++){
                sum-=c[j]*(i+1-last[j]);
            }
            last[k]=myon;
            if(mx<sum) kmx=k, mx=sum;
        }
        t[i]=kmx;
        last[kmx]=i+1;
    }

    set<int> st[26];
    for(int i=0; i<d; i++) st[t[i]].insert(i);

    uniform_int_distribution<> rndk(0, d-1), rndq(0, 25);
    uniform_real_distribution<> rndp(0.0, 1.0);
    clock_t start = clock();
    int ans=calc(t);
    double start_temp=10000, end_temp=500;
    while(1){
        int k, q;
        k=rndk(mt), q=rndq(mt);
        if(t[k]==q){
            continue;
        }
        int pr=t[k], ansp=ans;
        ans-=s[k][pr];
        ans+=s[k][q];
        int l1=-1, l2=-1, r1=d, r2=d;
        auto itr1=st[pr].find(k);
        if(itr1!=st[pr].begin()){
            itr1--;
            l1=*itr1;
            itr1++;
        }
        itr1=st[pr].erase(itr1);
        if(itr1!=st[pr].end()){
            r1=*itr1;
        }
        auto itr2=st[q].insert(k).first;
        if(itr2!=st[q].begin()){
            itr2--;
            l2=*itr2;
            itr2++;
        }
        itr2++;
        if(itr2!=st[q].end()){
            r2=*itr2;
        }
        ans+=c[q]*(k-l2)*(r2-k);
        ans-=c[pr]*(k-l1)*(r1-k);
        t[k]=q;
        auto now=clock();
        double temp=start_temp+(end_temp-start_temp)*(double)(now-start)/CLOCKS_PER_SEC/1.9;
        double prob=exp((ans-ansp)/temp);
        if(prob<rndp(mt)){
            st[pr].insert(k);
            st[q].erase(k);
            t[k]=pr;
            ans=ansp;
        }
        if((double)(now-start)/CLOCKS_PER_SEC>1.9) break;
    }
    for(int i=0; i<d; i++){
        cout<<t[i]+1<<endl;
    }
	return 0;
}


Measured memory_bytes: 4372
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

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

	int n;
	cin >> n;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	reverse(h.begin(), h.end());
	vector<int> cnt(n);
	rep(i, n - 1) {
		if (h[i + 1] >= h[i]) {
			cnt[i + 1] = cnt[i] + 1;
		}
		else cnt[i + 1] = 0;
	}
	int ans = 0;
	rep(i, n) ans = max(ans, cnt[i]);
	cout << ans << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int ans = Integer.MAX_VALUE;
		for(int i = -100 ; i <= 100 ; i++) {
			int sum = 0;
			for(int j = 0 ; j < n ; j++) {
				sum += Math.pow(i - a[j], 2);
			}
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}


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


int main()
{
	string s;
	getline(std::cin, s);
	for (int i = 0; i < s.length(); i++){
		if ('a' <= s[i] && s[i] <= 'z'){
			s[i] = s[i] + ('A' - 'a');
		}
		else if ('A' <= s[i] && s[i] <= 'Z'){
			s[i] = s[i] - ('A' - 'a');
		}
	}
		cout << s << endl;

	return 0;
}

Measured memory_bytes: 1176
import numpy as np

N, D = map(int, input().split())
X = []
for _ in range(N):
  row = list(map(int, input().split()))
  X.append(np.array(row))

count = 0
for i in range(N):
  for j in range(i+1, N):
    d = np.linalg.norm(X[i] - X[j])
    if np.round(d) == d:
      count += 1
print(count)

Measured memory_bytes: 12396
def prime(n,s):
    import math
    l = []
    sum=0
    for i in range(n):
        while True:
            flag = True
            for i in range(2, int(math.sqrt(s))+1):
                if s % i == 0:
                    flag = False
                    break
            if flag is True and s % 10 == 1:
                l.append(s)
                s += 1
                sum+=s
                break
            s += 1
    if sum%2==1:
        print(sum)
    nf=False
    for i in range(2, int(math.sqrt(sum))):
        if sum % i == 0:
            nf = True
            break
    if nf is True :
        return l
    else:
        return None
if __name__ == '__main__':
    N=int(input())
    s=11
    while True:
        l=prime(N,s)
        if l is not None:
            break
        else:
            s+=1
    for i in l:
        print("%d "%i, end="")

Measured memory_bytes: 3064
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,k,a[101];
int dp[101][100010];

signed main(){
    I(n); I(k);
    REP(i,n) I(a[i]);
    dp[0][k] = 1;
    REP(i,n){
        REP(j,k+1){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
            if (j-a[i] > 0) {
                dp[i+1][j-a[i]-1] -= dp[i][j];
                dp[i+1][j-a[i]-1] %= mod;
            }
        }
        REPN(j,k+1) {
            dp[i+1][j] = (dp[i+1][j+1] + dp[i+1][j]) % mod;
        }
    }
    if (dp[n][0] < 0 ) dp[n][0] += mod;
    cout << dp[n][0] << endl;
}

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

int main(){
    int N;
    int A[2][102];
    int Aup[102] = {};
    int Adown[102] = {};

    cin >> N;
    for(int i=0;i<N;i++) cin >> A[0][i];
    for(int i=0;i<N;i++) cin >> A[1][i];

    for(int i=1;i<=N;i++){
        Aup[i] = Aup[i-1] + A[0][i-1];
    }
    for(int i=N-1;i>=0;i--){
        Adown[i] = Adown[i+1] + A[1][i];
    }

    long maxcandy = 0;
    for(int i=1;i<=N;i++){
        maxcandy = max(maxcandy, (long)(Aup[i] + A[1][i-1] + Adown[i]));
        // cout << maxcandy << endl;
    }
    cout << maxcandy << endl;
    return 0;
}

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

visited = [False for i in range(n)]

lst = list(map(int,input().split()))
mod = 1000000007
occur = [0]*(n+1)
occur[-1] = 3
count = 1
for i in range(n):
    count = count * occur[lst[i]-1] % mod
    occur[lst[i]-1] -= 1
    occur[lst[i]] += 1

print(count)

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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define MOD 1000
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n;

int digitSum(int x) {
    if (x == 0) return 0;
    return x%10 + digitSum(x/10);
}

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

    int ans = 100005;
    fto(a, 1, n-1) {
        int x = digitSum(a) + digitSum(n-a);
        ans = min(ans, x);
    }
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=100100,P=1000000007;
int i,j,k,n,m,ch,ff,fgA,fgB,lA,lB,ans;
ll A,B,a[N];
struct tree { int sum,fg;} T0[N<<2],T1[N<<2];
struct cc { int o,x,y;tree *T;} O[N];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void R(ll &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void down(tree *T,int k) {
	if (T[k].fg) {
		T[k<<1].sum=T[k<<1|1].sum=0;
		T[k<<1].fg=T[k<<1|1].fg=1;
		T[k].fg=0;
	}
}
void T_add(tree *T,int L,int R,int x,int y,int k) {
	T[k].sum=(T[k].sum+y)%P;
	if (L==R) return;
	down(T,k);
	int mid=(L+R)>>1;
	if (x<=mid) T_add(T,L,mid,x,y,k<<1);
	else T_add(T,mid+1,R,x,y,k<<1|1);
}
void T_clear(tree *T,int L,int R,int l,int r,int k) {
	if (L==l && R==r) {
		T[k].fg=1;
		T[k].sum=0;
		return;
	}
	down(T,k);
	int mid=(L+R)>>1;
	if (r<=mid) T_clear(T,L,mid,l,r,k<<1);
	else {
		if (l>mid) T_clear(T,mid+1,R,l,r,k<<1|1);
		else T_clear(T,L,mid,l,mid,k<<1),T_clear(T,mid+1,R,mid+1,r,k<<1|1);
	}
	T[k].sum=(T[k<<1].sum+T[k<<1|1].sum)%P;
}
int T_query(tree *T,int L,int R,int l,int r,int k) {
	if (L==l && R==r) return T[k].sum;
	down(T,k);
	int mid=(L+R)>>1;
	if (r<=mid) return T_query(T,L,mid,l,r,k<<1);
	if (l>mid) return T_query(T,mid+1,R,l,r,k<<1|1);
	return (T_query(T,L,mid,l,mid,k<<1)+T_query(T,mid+1,R,mid+1,r,k<<1|1))%P;
}
void Add(tree *T,int x,int y) {
	m++;
	O[m].T=T;
	O[m].o=0;
	O[m].x=x;
	O[m].y=y;
}
void Clear(tree *T,int x,int y) {
	m++;
	O[m].T=T;
	O[m].o=1;
	O[m].x=x;
	O[m].y=y;
}
void work() {
	for (int i=1;i<=m;i++) if (O[i].o==1) T_clear(O[i].T,1,n,O[i].x,O[i].y,1);
	for (int i=1;i<=m;i++) if (O[i].o==0) T_add(O[i].T,1,n,O[i].x,O[i].y,1);
}
int main() {
	R(n);R(A);R(B);
	for (i=1;i<=n;i++) R(a[i]);
	fgA=fgB=1;
	lA=lB=0;
	for (i=1;i<n;i++) {
		m=0;
		if (fgA) Add(T1,i,1);
		if (fgB) Add(T0,i,1);
		if (a[i+1]-a[i]<A) {
			fgA=0;
			Clear(T0,1,i);
		}
		if (a[i+1]-a[i]<B) {
			fgB=0;
			Clear(T1,1,i);
		}
		while (a[i+1]-a[lA+1]>=A) lA++;
		while (a[i+1]-a[lB+1]>=B) lB++;
		if (lA) Add(T0,i,T_query(T1,1,n,1,lA,1));
		if (lB) Add(T1,i,T_query(T0,1,n,1,lB,1));
		work();
	}
	ans=(fgA+fgB+T0[1].sum+T1[1].sum)%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 7168
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
        String[] line = new String[num];
        String[][] s = new String[num][10];
        for(int i=0; i<num; i++){
          line[i] = sc.next();
          s[i] = line[i].split("");
        }
        int count = 0;
        int aNum = 0;
        int bNum = 0;
        int baNum= 0;
        int check = 0;
        for(int i=0; i<num; i++){
          for(int j=0; j<line[i].length()-1; j++){
            if(s[i][j].equals("A") && s[i][j+1].equals("B")) count++;
            if(j == 0 && s[i][j].equals("B")) {
              bNum++;
              check = 1;
            }
            if(j == line[i].length()-2 && s[i][j+1].equals("A")) {
              if(check == 1){
                baNum++;
                aNum++;
              }
              else aNum++;
            }
          }
          check = 0;
        }
        int plus = (aNum <= bNum) ? aNum : bNum;
        //if(aNum == num && bNum == num) plus--;
        if(baNum > 0 && baNum == aNum && baNum == bNum) plus -= 1;
		System.out.println(count+plus);
        //System.out.println(aNum);
        //System.out.println(bNum);
	}
}

Measured memory_bytes: 47312
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
int main()
{
    boost;
    ll n,i,j,x,t,y;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes";
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No";
			return 0;
		}
	}
}

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main(){
    int N;
    cin >> N;
    string S;
    vi count(4,0);

    for(int i=0;i<N;i++){
        cin >> S;
        if(S[0]=='A') count[0]++;
        if(S[0]=='W') count[1]++;
        if(S[0]=='T') count[2]++;
        if(S[0]=='R') count[3]++;
    }

    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3] << endl;

    return 0;

}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(x) (int)x.size() 
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ****************************************/
const int N = 2e5 + 7;
vector <int> tree[N];
int A[N];
vector <vector <int> > seq;
vector <int> ans(N);

int bi_search(int x){
    int lo = 0, hi = sz(seq)-1;
    if(hi < 0) return 0;
    while(lo < hi){
      int mid = (lo + hi + 1) >> 1;
      if(seq[mid].back() <= x)
        lo = mid;
      else hi = mid-1;
    }
    return (seq[lo].back() >= x ? lo: lo+1);
}


void dfs(int u = 1, int p = 0){
  int idx = bi_search(A[u]);
  if(idx >= sz(seq)){
    seq.push_back({A[u]});
  }
  else seq[idx].push_back(A[u]);
  ans[u] = sz(seq);
  
  for (int v: tree[u]){
    if(v == p) continue;
    dfs(v, u);
  }
  seq[idx].pop_back();
  if(sz(seq[idx]) == 0)
    seq.pop_back();
}

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

    int n; cin >> n;
    for (int i = 1; i <= n; ++i)
      cin >> A[i];
    for (int i = 1, x, y; i < n; ++i){
      cin >> x >> y;
      tree[x].push_back(y);
      tree[y].push_back(x);
    }

    dfs();
    for (int i = 1; i <= n; ++i)
      cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 36820
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION  
 
//solve

void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  for (int i = 0; i < N; i++)
  {
    int X = vec[i];
    if(i + 1 >= vec[i])
    {
      for (int j = 0; j < X-1; j++)
      {
        swap(vec[i-1-j],vec[i-j]);
      }

    }
    else
    {
      cout<<-1<<endl;
      return;
    }
        // DEBUG(vec);

  }
  for (int i = N-1; i >= 0; i--)
  {
    cout<<vec[i]<<endl;
  }
  
  
  
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

class node {
  public:
    int key;
    node *p;
    node *l;
    node *r;
};
node *NIL, *root;

void insert(int k) {
    node *y = NIL;
    node *x = root;
    node *z = new node;
    z->key = k;
    z->l = NIL;
    z->r = NIL;
    while(x != NIL) {
        y = x;
        if(z->key < x->key)
            x = x->l;
        else
            x = x->r;
    }

    z->p = y;

    if(y == NIL) {
        root = z;
    } else if(z->key < y->key) {
        y->l = z;
    } else {
        y->r = z;
    }
}

void traverse(node *now, int order) {

    if(order == 0) cout << " " << now->key; // preorder
    if(now->l != NIL) traverse(now->l, order);
    if(order == 1) cout << " " << now->key; // inorder
    if(now->r != NIL) traverse(now->r, order);
    if(order == 2) cout << " " << now->key; // postorder
}

void print() {
    traverse(root, 1);
    cout << endl;
    traverse(root, 0);
    cout << endl;
}

int main() {
    int n, a;
    string o;
    cin >> n;

    rep(i, n) {
        cin >> o;
        if(o == "insert") {
            cin >> a;
            insert(a);
        } else if(o == "print") {
            print();
        }
    }
}



Measured memory_bytes: 26588
import atexit
import io
import sys
from math import *

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())


n = input()
l = []
for i in xrange(5):
	l.append(input())
l.sort()
trips = int(ceil(n/float(l[0])))
print 5 + trips-1

Measured memory_bytes: 28396
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int[] dx = new int[] { 0, 0, 1, -1 };
    static int[] dy = new int[] { 1, -1, 0, 0 };

    static void Solve()
    {
        var n = sc.Int();

        pr.WriteLine(n / 3);
    }

    static int[,] Mul(int[,] a, int[,] b)
    {
        const int d = 2;
        var ret = new int[d, d];
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < d; j++)
            {
                for (int k = 0; k < d; k++)
                {
                    ret[i, j] += a[i, k] * a[k, j];
                }
            }
        }

        return ret;
    }

    class Coord
    {
        public int x;
        public int y;
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 11092
from sys import maxsize

n, k = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

time = maxsize
for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    val = min(abs(l)+abs(r-l), abs(r)+abs(l-r))
    if val < time:
        time = val

print(time)


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

int main() {
	int value;
	string input;
	
	cin >> input;
	value = 700;
	
	if(input[0] == 'o'){
		value += 100;
	}
	if(input[1] == 'o'){
		value += 100;
	}
	if(input[2] == 'o'){
		value += 100;
	}
	
	cout << value << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
	int N,K;
	cin >> N >> K;
	double ans = 0;
	int cnt,temp;
	for (int i = 1; i <= N; ++i)
	{
		cnt = 0;
		temp = i;
		while(temp < K)
		{
			cnt += 1;
			temp *= 2;
		}

		ans += 1 / ((pow(2,cnt)) * N);
	}

	cout << fixed;
	cout << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    TSTART();
    int ans = 0;
    REP(i,n){
      int l,r;
      cin >> l >> r;
      ans += r-l+1;
    }
    
    cout << ans << endl;
    TSTOP();
  }
  return 0;
}



Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

while (h != 0 || w != 0)

h.times{|i| w.times{|j|
 if (i + j) % 2 == 0
 print "#"
else
 print "."
end 
}
puts ""
}
puts ""
  
 h, w = gets.split.map(&:to_i)
end

    



Measured memory_bytes: 8868
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

ll G(ll a,ll b)
{
    if(a<b)
    {
        ll tm=a;
        a=b;
        b=tm;
    }
    if(b==0)
    return a;
    return G(b,a%b);
}

void solve()
{
    ll x;
    cin  >> x;
    ll lcm=360*x/(G(360,x));
    //cout << lcm << endl;
    cout << lcm/x << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

int main() {
  string input;
  cin >> input;
  
  long sum = 0;
  for (int bitSrc = 0; bitSrc < (1 << input.size() - 1); bitSrc++) {
    bitset<10> op(bitSrc);
    string buf = "0";
    for (int bitIdx = input.size() - 1; bitIdx >= 0; bitIdx--) {
      if (op.test(bitIdx)) {
        sum += stol(buf);
        buf = "0";
      }
      buf += input.at(input.size() - bitIdx - 1);
    }
    sum += stol(buf);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	ll K;
	cin >> K;
	vector<ll>v[51], sa[51][51];
	for (int i = 2;i <= 50;i++) {
		for (int j = 1;j <= i;j++) {
			v[i].eb(100);
			sa[i][0].eb(0);
		}

		for (int j = 1;j <= i;j++) {
			int maxit = -1, ma = 0;
			for (int k = 0;k < i;k++) {
				if (ma < v[i][k])ma = v[i][k], maxit = k;
			}
			for (int k = 0;k <= i;k++) {
				if (k == maxit) {
					sa[i][j].eb(v[i][k] - i - 100);
					v[i][k] -= i;
				}
				else {
					sa[i][j].eb(v[i][k] + 1 - 100);
					v[i][k]++;
				}
			}
		}
	}

	

	for (ll i = 2;i <= 50;i++) {
		ll l = K / i, r = K / i + 1, mod = K % i;
		if (l + (i - 1) > (ll)1e16 + 100LL)continue;
		if (mod == 0) {
			cout << i << endl;
			for (int j = 0;j < i;j++) {
				cout << l + i-1 << ' ';
			}
			cout << endl;
			return 0;
		}
		ll x = r+i-1;
		//cout << x << endl;
		cout << i << endl;
		for (int j = 0;j < i;j++) {
			cout << x + sa[i][i-mod][j] << ' ';
		}
		cout << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    int n;
    cin>>n;
    int sum=0;
    int j=n;
    while(j!=0)
    {
        sum+=j%10;
        j/=10;
    }
    if(n%sum==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
tscore = 0
hscore = 0

for i in range(n):
    t, h = map(str, input().split())

    if t > h:
        tscore += 3
    elif t < h:
        hscore += 3
    else:
        tscore += 1
        hscore += 1

print(tscore, hscore)


Measured memory_bytes: 5592
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

LL a[200000], n;

int f(vector<LL>& v, int player) {
  LL s = 0;
  for (auto x : v) s += x;
  if ((n & 1) ^ (s & 1)) return player;
  if (s == n) return player ^ 1;
  int cnt = 0, idx = -1;
  rep(i, n) if (v[i] % 2 == 0) {
    cnt ++;
  } else idx = i;
  if (cnt == n - 1 && v[idx] > 1) {
    v[idx] --;
    LL x = v[0];
    rep(i, 1, n) x = __gcd(x, v[i]);
    auto newv = v;
    rep(i, n) newv[i] /= x;
    return f(newv, 1 ^ player);
  }
  return player ^ 1;
}
int main() {
  cin >> n;
  vector<LL> v;
  rep(i, n) cin >> a[i], v.pb(a[i]);

  cout << (vector<string>({"First", "Second"})[f(v, 0)]) << endl;

  return 0;
}


Measured memory_bytes: 19956
#include <bits/stdc++.h>
#define N 1005
 
using namespace std;
long long n, W;
long long w[N];
long long v[N];
long long F[N][100005];
 
 
int main()
{
    cin>>n>>W;
    for(long long i=1; i<=n; i++)
    {
        cin>>w[i]>>v[i];
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=W; j++)
        {
            if(j>=w[i])
            F[i][j]=max(F[i-1][j], F[i-1][j-w[i]]+v[i]);
            else F[i][j]=F[i-1][j];
        }
    }
    cout<<F[n][W];
    return 0;
}

Measured memory_bytes: 81796
#include<iostream>
#include <math.h>
#include <algorithm>
#include<queue>
#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)

main(){
    int N;
    cin >> N;
    if(N >= 1000){
        cout << "ABD"  << endl;
    }   
    else{
        cout << "ABC"  << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  REP(i,N)cin>>A[i];
  sort(ALL(A));
  int mi=INF,ans;
  REP(i,N){
    if(mi>abs(A[N-1]-A[i]*2)){
      mi=abs(A[N-1]-A[i]*2);
      ans=i;
    }
  }
  cout<<A[N-1]<<" "<<A[ans]<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int a,b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,k;
int main() {
	scanf("%d%d%d",&a,&b,&k);
	for(int i=100; i>=1; i--) {
		if(a%i==0 && b%i==0) {
			k--;
			if(k==0) {
				printf("%d\n",i);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int H, W, i, j, k;
    
    for(k=0; ; k++){
    scanf("%d%d", &H, &W);
    if (H==0 && W==0) break;
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                if(i==0 || i==H-1){printf("#");}
                else if(j==0 || j==W-1){printf("#");}
                else printf(".");
            }
        printf("\n");
        }
    printf("\n");
    }
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int count1 = 0;
    int count2 = 0;
    rep(i,n){
        int k;
        cin >> k;
        if(k%2 == 0){
            count1++;
            if(k%3 == 0 || k%5 == 0){
                count2++;
            }
        } 
    }
    if(count1 == count2){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
string a;
int main()
{
	cin>>a;
	string b="C",c="F";
	int na=a.find_first_of(b);
	int nb=a.find_last_of(c);
	if(na==string::npos||nb==string::npos)
		cout<<"No";
	else
	{
		if(na<nb) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int N; cin >> N;
    bool yellow = false;
    rep(i, N) {
        char c; cin >> c;
        if (c == 'Y') yellow = true;
    }
    cout << (yellow ? "Four" : "Three") << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int n;

int maxsqrtnumber(int n) {
  int ret;
  for (int i = 1; i * i <= n; ++i) ret = i;
  ret *= ret;
  return ret;
}

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  cout << maxsqrtnumber(n) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
a,b=map(int,input().split())

if a%2==0:
  lower1=int(a*100/8)
  upper1=(a+1)*100/8
  upper1=max(lower1,int(upper1)-1)  
else:
  lower1=a*(100/8)
  upper1=int((a+1)*100/8)
  if (upper1)-int(lower1)<=1:
    print(-1)
    sys.exit()
  else:
    lower1=int(lower1)+1
    if lower1==upper1:
      print(-1)
      sys.exit()
    else:
      pass
  
lower2=(b)*10
upper2=(b+1)*10

lower=max(lower1,lower2)
upper=min(upper1,upper2)
if upper-lower<1:
  print(-1)
else:
  print(lower)

Measured memory_bytes: 3064
/*
ID: jerrymo4
TASK:
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

long long x,y;
int ans;

int main(){
	cin>>x>>y;
	while (x<=y){
		ans++;
		x*=2;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
	string S;
	int P = 0;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'p') P++;
	}
	cout << S.size() / 2 - P;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
    }

    let range = ((n as f64).sqrt().ceil()) as usize;
    let mut cnt = 0;

    for i in 1..n+1 {
        for x in 1..range+1 {
            for y in x..range+1{
                for z in y..range+1 {
                    if x*x+y*y+z*z+x*y+y*z+z*x==i {
                        if x==y && y==z && z==x{
                            cnt += 1;
                        } else if x!=y && y!=z && z!=x {
                            cnt += 6;
                        } else {
                            cnt += 3;
                        }
                    }
                }
            }
        }
        println!("{}", cnt);
        cnt = 0;
    }
}

Measured memory_bytes: 2596