akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;
constexpr long long int MOD = 1'000'000'007;

int main(void) {
    long long int N;
    cin >> N;
    vector<long long int> num(60);
    for(int i=0; i<N; i++) {
        long long int A;
        cin >> A;
        for(int j=0; j<60; j++) {
            if(A & (1LL << j)) {
                ++num.at(j);
            }
        }
    }

    long long int ans = 0;
    for(int j=0; j<60; j++) {
        // long long int tmp1 = (1LL << j) % MOD;
        // long long int tmp2 = (num.at(j) * (N-num.at(j))) % MOD;
        // ans += (tmp1 * tmp2) % MOD;
        ans = (((((1LL << j) % MOD * num.at(j)) % MOD) * (N-num.at(j)) % MOD) + ans) % MOD;
        // ans =  (ans + ((num.at(j) * ((N-num.at(j))) * ((1LL << j) % 1'000'000'007LL)) % 1'000'000'007LL) % 1'000'000'007LL) % 1'000'000'007LL;
    }

    cout << ans << endl;
    // cout << ans % MOD << endl;
    return 0;
}


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

using namespace std;

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

  int D[N];
  for (int i = 0; i < N; i++) {
    cin >> D[i];
  }

  sort(D, D + N, greater<int>());

  int answer = 0;
  int d = 1000;
  for (int i = 0; i < N; i++) {
    if (d != D[i]) {
      answer += 1;
      d = D[i];
    }
  }

  cout << answer << endl;
}


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

int main() {
	const int MAX_N = 100 + 10;
	const int MAX_W = 10000 + 10;
    int N, W, v[MAX_N], w[MAX_N], dp[MAX_N][MAX_W];
    cin >> N >> W;
    for (int i = 1; i <= N; ++i){
    	cin >> v[i] >> w[i];
    }

    for (int j = 0; j <= W; ++j){
    	dp[0][j] = 0;
    }

    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-1][j], dp[i][j-w[i]] + v[i]);
    	}
    }

    cout << dp[N][W] << endl;


}


Measured memory_bytes: 7052
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
input:
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>>> g(n);
    rep(i, n - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        g[a - 1].push_back(make_pair(b - 1, c));
        g[b - 1].push_back(make_pair(a - 1, c));
    }

    ll q, k;
    cin >> q >> k;
    ll x[q], y[q];
    rep(i, q) { cin >> x[i] >> y[i]; }

calculate:
    ll inf = 1LL << 60;
    ll dist[n];
    rep(i, n) { dist[i] = inf; }
    dist[k - 1] = 0;

    queue<ll> qu;
    qu.push(k - 1);

    while (!qu.empty()) {
        ll num = qu.front();
        qu.pop();
        for (auto p : g[num]) {
            ll to = p.first, cost = p.second;
            if (dist[to] == inf) {
                dist[to] = dist[num] + cost;
                qu.push(to);
            }
        }
    }

    rep(i, q) {
        ll path = dist[x[i] - 1] + dist[y[i] - 1];
        cout << path << endl;
    }
    return 0;
}



Measured memory_bytes: 11520
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//ÄæÔª
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}


ll a[N],arr[N];
ll dp[500][500];
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        arr[i]=arr[i-1]+a[i];
    }
    memset(dp,0x3f,sizeof(dp));
    for(int i=1;i<=n;i++) dp[i][i]=0;
    for(int i=1;i<=n;i++){
        for(int j=i-1;j>=1;j--){
            for(int k=j;k<i;k++){
                dp[j][i]=min(dp[j][k]+dp[k+1][i]+arr[i]-arr[j-1],dp[j][i]);
            }
        }
    }
//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=n;j++) cout<<dp[i][j]<<' ';
//        cout<<endl;
//    }
    printf("%lld\n",dp[1][n]);
    //coinintut << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

#define LL long long
LL N;

int main(){
    cin>>N;
    if(N==0){cout<<0<<endl;return 0;}
    LL L=1,R=N,Ans=0;
    while(L<=R){
        LL mid=(L+R)>>1;
        if(mid*(mid+1LL)>=2LL*N){Ans=mid;R=mid-1;}
        else L=mid+1;
    }
    cout<<Ans<<endl;
    return 0;
}

Measured memory_bytes: 256
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math

s = input().split()
p = [int(w) for w in s] #これで勝手にNまで拾ってくれます
S = p[0]
W = p[1]
if(S>W):
    print('safe')
else:
    print('unsafe')

Measured memory_bytes: 9916
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for ( int i = g; i < n; i++ ) {
    int v = A[i];
    int j = i - g;
    while ( j >= 0 && A[j] > v ) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  for ( int h = 1; ; ) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i-- )
    insertionSort(A, n, G[i]);
}

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  printf("%d\n", G.size());
  for ( int i = G.size() - 1; i >= 0; i-- ) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}


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

using namespace std;

int main()
{
  int l, r, d;
  cin>>l>>r>>d;
  int res = 0;
  for (int i=1; i<101; i++) {
    if (d * i >= l && d * i <= r) res++;
    if (d * i > r) break;
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct S {
    bool operator<(const S& s) const {
        return l != s.l ? l < s.l : i < s.i;
    }
    int l, r, i;
};

struct BIT {
    BIT(int n) : b(n + 1), n(n) {}
    void add(int i, int v) {
        for (int k = i + 1; k <= n; k += k & -k) b[k] += v;
    }
    int sum(int k) {
        int s = 0;
        for (; k > 0; k -= k & -k) s += b[k];
        return s;
    }
    vector<int> b;
    int n;
};

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

    int n, m, Q;
    cin >> n >> m >> Q;

    vector<S> s(m + Q);
    BIT bt(n);
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        l--; r--;

        bt.add(r, 1);
        s[i] = { l, r, Q };
    }
    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        p--; q--;

        s[m + i] = { p, q, i };
    }
    sort(s.begin(), s.end());

    vector<int> r(Q);
    for (const auto& o : s) {
        if (o.i < Q) {
            r[o.i] = bt.sum(o.r + 1);
        } else {
            bt.add(o.r, -1);
        }
    }

    for (int i = 0; i < Q; i++) {
        cout << r[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<vector>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)

// 2*k * 2*kのグリッド上でk * kのグリッドによる区間可算を行う
// 累積和を使う
int main(){
    int n, k;
    cin >> n >> k;

    vector<vector<int>> sum(2*k, vector<int>(2*k, 0));
    for(int i = 0; i < n; i++){
        int x, y;   char c;
        cin >> x >> y >> c;
        if(c == 'W')    y += k;
        x %= 2*k, y %= 2*k;
        x -= k-1, y -= k-1;
        for(int a = -2; a <= 2; a++){
            for(int b = -2; b <= 2; b++){
                if((abs(a)+abs(b))%2)   continue;
                // 全て閉区間、左下(si,sj)右上(ti,tj)の1辺kの正方形
                int si = x+a*k, sj = y+b*k;
                int ti = si+k-1, tj = sj+k-1; 
                if(si > 2*k || sj > 2*k || ti < 0 || tj < 0)    continue;
                si = max(si, 0);    ti = min(ti, 2*k-1);
                sj = max(sj, 0);    tj = min(tj, 2*k-1);
                if(inRange(si,0,2*k)&&inRange(sj,0,2*k))    sum[si][sj]++;
                if(inRange(ti+1,0,2*k)&&inRange(sj,0,2*k))    sum[ti+1][sj]--;
                if(inRange(si,0,2*k)&&inRange(tj+1,0,2*k))    sum[si][tj+1]--;
                if(inRange(ti+1,0,2*k)&&inRange(tj+1,0,2*k))    sum[ti+1][tj+1]++;
            }
        }
    }
    for(int i = 0; i < 2*k; i++){
        for(int j = 1; j < 2*k; j++){
            sum[i][j] += sum[i][j-1];
        }
    }
    for(int j = 0; j < 2*k; j++){
        for(int i = 1; i < 2*k; i++){
            sum[i][j] += sum[i-1][j];
        }
    }
    
    int ans = 0;
    for(int i = 0; i < 2*k; i++){
        for(int j = 0; j < 2*k; j++){
            ans = max(ans, sum[i][j]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16000
from operator import itemgetter
N=int(input())
table=[]
for i in range(N):
    s,p=input().split()
    table.append((s,int(p),i+1))
C=sorted(table,key=itemgetter(1),reverse=True)
D=sorted(C,key=itemgetter(0))
#print(table,C,D)
for s,p,i in D:
    print(i)

Measured memory_bytes: 38524
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			int n = sca.nextInt();
			if(n == 0) break;
			
			int[] houx = new int[n];
			int[] houy = new int[n];
			int[] got = new int[n];
			int i;
			for(i = 0;i < n;i++)
			{
				houx[i] = sca.nextInt();
				houy[i] = sca.nextInt();
				
				if(houx[i] == 10 && houy[i] == 10)
					got[i] = 1;
				else
					got[i] = 0;
			}
			
			int m = sca.nextInt();
			
			char[] muki = new char[m];
			int[] idouryou = new int[m];
			for(i = 0;i < m;i++)
			{
				muki[i] = sca.next().charAt(0);
				idouryou[i] = sca.nextInt();
			}
			
			int x = 10;
			int y = 10;
			int j, k;
			for(i = 0;i < m;i++)
			{
				for(j = idouryou[i];j > 0;j--)
				{
					switch(muki[i])
					{
					case 'N': y++; break;
					case 'E': x++; break;
					case 'S': y--; break;
					case 'W': x--; break;
					}
					
					for(k = 0;k < n;k++)
					{
						if(got[k] == 1) continue;
						
						if(houx[k] == x && houy[k] == y) got[k] = 1;
					}
				}
			}
			
			for(i = 0;i < n;i++)
			{
				if(got[i] == 0) break;
			}
			if(i == n)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 35760
package main

import "fmt"

func main() {
	var K, S int
	fmt.Scan(&K, &S)
	count := 0
	for x := 0; x <= K; x++ {
		for y := 0; y <= K; y++ {
			z := S - x - y
			if 0 <= z && z <= K {
				count++
			}
		}
	}
	fmt.Println(count)
}


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

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

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool f[100001];//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      f[i]=false;
    //}
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[101][101];
bool fl=true;

//-------------------------↓↓↓↓↓↓----------------------------

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

       cin >> h >> w;
       rep(i,h){
           rep(j,w){
               cin>>s[i][j];
               //w[i][j]=s[i][j];
               }
       }
       rep(i,h){
           rep(j,w){
               cout << s[i][j];
           }
           cout << endl;
           rep(k,w){
               cout<< s[i][k];
           }
           cout << endl;
       }
       
return 0;
}


Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

L =  list(map(int, sys.stdin.readline().split()))
L.sort(reverse=True)

d1 = L[0] - L[1]
d2 = L[0] - L[2]

if (d1 % 2 == 0 and d2 % 2 == 0) or (d1 % 2 != 0 and d2 % 2 != 0):
    print((d1 + d2) // 2)
else:
    print((d1 + d2 + 1) // 2 + 1)

Measured memory_bytes: 64108
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int64_t; using ld = long double;
 
// -----------------------------------------------------------------------------

void solve() {
    int n, r; cin >> n >> r;
    int d = r;
    if (n < 10) d += 100 * (10 - n);
    cout << d << '\n';
}


int main() {
    fast_io; cin_exception;
    int t = 1; // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 1010;
const int H = 10010;
const int INF = (int)1e9 + 7;
int f[H], n, h, a[N], b[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> h >> n;
	Foz(i, n) cin >> a[i] >> b[i];
	Foz(i, h + 1) f[i] = INF;
	f[h] = 0;
	Doz(i, h + 1) if (f[i] != INF) {
		Foz(j, n) ckmin(f[max(0, i - a[j])], f[i] + b[j]);
	}
	cout << f[0] << '\n';
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=21;
const int MAXL=(1<<21)+2;
const int MOD =1e9+7;
int dp[MAXN][MAXL],mascara[MAXN],N;
int solve(int pos,int mask){
	if(pos==N) return (__builtin_popcount(mask)==N);
	if(dp[pos][mask]!=-1) return dp[pos][mask];
	int ans=0;
	for(int i=0;i<N;i++){
		if(!(mask & (1<<i)) and ((1<<i)&mascara[pos])){
			ans=(ans+solve(pos+1,mask|(1<<i)))%MOD;
		}
	}
	return dp[pos][mask]=ans;
}
int main(){
	memset(dp,-1,sizeof dp);
	cin>>N;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			int x; cin>>x;
			if(x) mascara[i]|=(1<<j);
		}
	}
	cout<<solve(0,0)<<endl;
}

Measured memory_bytes: 172288
// A. 

#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL a, b, c, k;
	cin >> a >> b >> c >> k;
	LL mx = k % 2;
	for (LL i = 0; i < mx; ++i) {
		LL p = b + c, q = a + c, r = a + b;
		a = p, b = q, c = r;
	}
	LL ans = a - b;
	if (abs(ans) > 1e18) {
		cout << "Unfair" << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

const int MAX = 1000000000;

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int csL[n], csR[n];
    csL[0] = a[0];
    for (int i = 1; i < n; i++) {
        csL[i] = __gcd(csL[i - 1], a[i]);
    }
    csR[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        csR[i] = __gcd(csR[i + 1], a[i]);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int t = 0;
        if (i == 0) {
            t = csR[i + 1];
        } else if (i == n - 1) {
            t = csL[i - 1];
        } else {
            t = __gcd(csL[i - 1], csR[i + 1]);
        }
        ans = max(ans, t);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    return 'Yes' if '7' in set(N) else 'No'


def main():
    N = read_str()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10412
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll A[7];

int main() {
    rep(i, 7) cin>>A[i];

    int e = 0;

    if(A[0]%2 == 0) e++;
    if(A[3]%2 == 0) e++;
    if(A[4]%2 == 0) e++;

    ll answer = 0;

    if(e == 3 || e == 0) answer += A[0]+A[3]+A[4];
    else if(e == 2) answer += A[0]+A[3]+A[4]-1;
    else {
        if(A[0] == 0 || A[3] == 0 || A[4] == 0) answer += A[0]+A[3]+A[4]-2;
        else answer += A[0]+A[3]+A[4]-1;
    }

    cout<<answer+A[1];

    return 0;
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int X = one.get(0);
      int Y = one.get(1);
      int Z = one.get(2);
      int output = X / (Y + Z);
      if(X % (Y + Z) < Z){
        output--;
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32892
N,M=map(int,input().split())
L,R=map(int,input().split())
a,b=L,R
for i in range(1,M):
  L,R=map(int,input().split())
  a=max(a,L)
  b=min(b,R)
if a>b:
  print(0)
else:
  print(b-a+1)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#define FAST ios::sync_with_stdiO(false)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 9;
const int maxn = (int)1e5 + 5;
using namespace std;

int main()
{
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'o') cnt++;
	}
	int ans = cnt * 100 + 700;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cout(n % 2 ? 2*n : n);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i;
    cin>>n;
    ll ar[n];
    for(i=0;i<n;i++)
    cin>>ar[i];
    
    ll dp[n];
    
    dp[0]=0;
    dp[1]=abs(ar[0]-ar[1]);

    for(i=2;i<n;i++)
    {
        dp[i]=min(abs(ar[i]-ar[i-2])+dp[i-2],abs(ar[i]-ar[i-1])+dp[i-1]);
    }
    
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const long long MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
ll com[200005];
const int MAX = 200005;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  COMinit();
  com[0] = 1;
  ll n,a,b;cin >> n >>a >> b;
  FOR(i,1,200005){
    com[i] = com[i-1] * (n+1-i) % MOD * inv[i];
    com[i] %= MOD;
  }
  ll ans = 1;
  ll tmp = 2;
  rep(i,40){
    if((n>>i)&1)ans *= tmp;
    ans %= MOD;
    tmp *= tmp;
    tmp %=MOD;
  }
  ans--;
  ans -= com[a] + com[b];
  ans += 2 * MOD;
  ans %= MOD;
  cout << ans << endl;

}

Measured memory_bytes: 6528
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            x = int.Parse(Console.ReadLine());
            Console.WriteLine((x+1)*x /2);
        }

    }
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 1e3 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int arr[N], n, Q, sum[N];
int dp[N][N];

int getsum(int s, int e)
{     
      int sum = 0;
      lop(i,s,e+1) sum += arr[i];
      return sum;
}

int getans(int s, int e)
{     
      if( s >= e ) return 0;
      int &mafia = dp[s][e];
      if( mafia != -1 ) return mafia;

      int ans = INF;
      
      for(int i = s; i < e; i++)
      {
            int a1 = getans(s,i), a2 = getans(i+1, e);
            int sum1 = getsum(s, i), sum2 = getsum(i+1, e);
            int res = a1 + a2 + sum1 + sum2;
            ans = min(ans, res);
      }

      return mafia = ans;
}
void solve()
{
      cin >> n;
      lop(i,1,n+1) cin >> arr[i];
      memset(dp, -1, sizeof dp);
      cout << getans(1, n) << endl ;
}


int32_t main()
{
      
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
     // INP(); 
      int t = 1;
      //cin >> t;
      while(t--) solve();

}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //




      

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == b){
    cout << "a == b" << endl;
  }else if(a < b){
    cout << "a < b" << endl;
  }else{
    cout << "a > b" << endl;
  }
return 0;
}


Measured memory_bytes: 3088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		String str[];
		
		int n, x1, x2, y1, y2;
		while(true){
			if((n = Integer.valueOf(reader.readLine())) == 0) break;
			x1 = x2 = 0;
			y1 = y2 = 0;
			
			HashMap<Integer, Pair> map = new HashMap<Integer, Pair>();
			map.put(0, new Pair(0, 0));
			for(int i = 1; i < n; i++){
				str = reader.readLine().split(" ");
				map.put(i, app.flag(Integer.valueOf(str[1]), map.get(Integer.valueOf(str[0]))));
				Pair p = map.get(i);
				if(x1 < p.x) x1 = p.x;
				if(x2 > p.x) x2 = p.x;
				if(y1 < p.y) y1 = p.y;
				if(y2 > p.y) y2 = p.y;
			}
			System.out.println((x1 - x2 + 1) + " " + (y1 - y2 + 1));
		}
		reader.close();
	}
	public Pair flag(int n, Pair p){
		switch(n){
		case 0 : return new Pair(p.x - 1, p.y);
		case 1 : return new Pair(p.x, p.y - 1);
		case 2 : return new Pair(p.x + 1, p.y);
		case 3 : return new Pair(p.x, p.y + 1);
		}
		return null;
	}
}

class Pair{
	int x;
	int y;
	Pair(int x, int y){
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 29800
#include <stdio.h>

main()
{

int sum=0,n,m,r;
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
    scanf("%d",&r);
    sum=sum+r;
}
if(sum>n)
    printf("-1");
else if(sum<=n)
    printf("%d",n-sum);






}


Measured memory_bytes: 1732
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
using namespace std;

#define EPS (1e-10)
#define INF (P(999999999,999999999))

typedef complex<double> P;

double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

int is_intersected_ls(P a1, P a2, P b1, P b2) {
	return
		( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
		( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

P intersection_ls(P a1, P a2, P b1, P b2) {
	P b = b2-b1;
	double d1 = abs(cross(b, a1-b1));
	double d2 = abs(cross(b, a2-b1));
	if(d1 + d2 == 0) return INF;
	double t = d1 / (d1 + d2);

	return a1 + (a2-a1) * t;
}

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

	while(n--){
		P sa,sb;
		cin>>sa.real()>>sa.imag()>>sb.real()>>sb.imag();

		int m;
		cin>>m;

		vector< pair<double,bool> > s,r;
		while(m--){
			bool flgRS,flg; //flgRS : 0 - Co 1 - ©ª
			P a,b;
			cin>>a.real()>>a.imag()>>b.real()>>b.imag()>>flgRS>>flg;

			if(is_intersected_ls(a,b,sa,sb)){
				P its = intersection_ls(a,b,sa,sb);
				if(its == INF) continue;

				double dist = abs(sa - its);
				if(flgRS)
					s.push_back(pair<double,bool>(dist,flg));
				else
					r.push_back(pair<double,bool>(dist,flg));
			}
		}

		sort(s.begin(),s.end());
		sort(r.begin(),r.end());

		bool flg = false, firstFlg = true;
		int ans = 0, i = 0, j = 0;

		while(i < r.size() || j < s.size()){
			if(j == s.size() || i != r.size() && r[i].first < s[j].first){
				if(!firstFlg && flg != !r[i].second) ans++;
				flg = !r[i].second;
				i++;
			}
			else{
				if(!firstFlg && flg != s[j].second) ans++;
				flg = s[j].second;
				j++;
			}

			firstFlg = false;
		}

		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 984
#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 1e5 + 1;
bool visited[N];
vector<ll> adj[N];
void dfs(ll a){
    visited[a] = true;
    for(auto u : adj[a]){
        if(!visited[u]){
            dfs(u);
        }
    }
} 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n, m;
        cin >> n >> m;
        for(i = 0; i < m; i++){
            ll a, b;
            cin >> a >> b;
            adj[a].pb(b);
            adj[b].pb(a);
        }
        ll cnt = 0;
        for(i = 1; i <= n; i++){
            if(!visited[i]){
                cnt++;
                dfs(i);
            }
        }
        cout << cnt - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10440
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N;

ll T[MAX_N];

ll gcd(ll a, ll b);

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

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }

    ll lmn = T[0];
    for (int i = 1; i < N; i++) {
        ll tgcd = gcd(lmn, T[i]);
        lmn = (lmn / tgcd) * (T[i] / tgcd) * tgcd;
    }

    cout << lmn << "\n";

    return 0;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

Measured memory_bytes: 3588
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e6 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<int> v(n), t(n);
	for (auto &x : t)
	{
		cin >> x;
		x *= 2;
	}
	for (auto &x : v)
	{
		cin >> x;
		x *= 2;
	}
	MEM(a, 0x3f);
	int l = 0, r = 0;
	for(int i = 0; i < n; i++)
	{
		r += t[i];
		for (int j = l; j <= r; j++) a[j] = min(a[j], v[i]);
		l = r;
	}
	a[0] = 0, a[r] = 0;
	for (int i = 1; i < r; i++)
	{
		a[i] = min(a[i], a[i - 1] + 1);
	}
	for (int i = r - 1; i >= 0; i--)
	{
		a[i] = min(a[i], a[i + 1] + 1);
	}
	double ans = 0;
	for (int i = 1; i <= r; i++)
	{
		ans += (a[i] + a[i - 1]) / 2.0;
	}
	printf("%.15f\n", ans / 4.0);
	return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>

int main()
{
    int x,y,a;
    int i;
    int tu,ka;
    int flag=0;
    scanf("%d %d",&x,&y);
    for(i=0;i<=x;i++)
    {
        tu=i;
        ka=x-i;
        if(2*tu+4*ka==y)flag=1;
    }
	if(flag)printf("Yes");
	else printf("No");
}


Measured memory_bytes: 1732
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }               
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int pri[N]; bool vis[N];
void init (int n)
{
	for (int i=2; ; i++)
	{
		if (!vis[i]) pri[++pri[0]]=i;
		if (pri[0]==n) break;
		for (int j=1; j<=pri[0]; j++)
		{
			int p=pri[j],k=i*p;
			if (k> 10000) break;
			vis[k]=1;
			if (i%p==0) break;
		}
	}
}
LL lcm (LL x,LL y) { return (!x||!y)?(x+y):(x/__gcd (x,y)*y); }
int n; LL a[1010][1010];
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n); init (1000);
	if (n==2) return puts("4 7\n23 10"),0;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++) if ((i+j+1)&1)
			a[i][j]=pri[(i+j)/2]*pri[n+(i-j)/2+(n+1)/2];
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++) if (!a[i][j])
			a[i][j]=lcm (lcm (a[i-1][j],a[i][j-1]),lcm (a[i+1][j],a[i][j+1]))+1;
	for (int i=1; i<=n; i++,putchar('\n'))
		for (int j=1; j<=n; j++,putchar(' '))
			print(a[i][j]);

    return 0;
}


Measured memory_bytes: 11264
public class Main {

  private static void solve() {
    int n = ni();
    int k = ni();

    if (k == 0) {
      System.out.println((long) n * n);
      return;
    }
    long ret = 0;
    for (int b = k + 1; b <= n; b++) {
      for (int t = 0; t * b + k <= n; t++) {
        // t*b + k <= a <= n
        // a - t * b < b
        // a < (t+1) * b

        int max = Math.min((t + 1) * b - 1, n);
        int min = t * b + k;

        ret += Math.max(0, max - min + 1);
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 21204
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int H, W;
  cin >> H >> W;
  int white = -2;
  vector<vector<char>> G(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> G[i][j];
      if (G[i][j] == '.') white++;
    }
  }

  // BFS
  queue<tuple<int, int, int>> que;
  vector<vector<int>> visit(H, vector<int>(W, H * W + 1));
  que.emplace(0, 0, 0);
  visit[0][0] = 0;
  while (!que.empty()) {
    int step, cx, cy;
    tie(step, cx, cy) = que.front();
    que.pop();
    if (cx == W - 1 && cy == H - 1) {
      cout << white - (step - 1) << endl;
      return 0;
    }

    const vector<pair<int, int>> dirs = {{+1, 0}, {-1, 0}, {0, +1}, {0, -1}};
    for (auto& d : dirs) {
      int nx = cx + d.first;
      int ny = cy + d.second;
      if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
      if ((G[ny][nx] == '#') || (visit[ny][nx] <= (step + 1))) continue;
      visit[ny][nx] = step + 1;
      que.emplace(step + 1, nx, ny);
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

#define MOD 1000000007

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

  vll lst(N);
  for (int i = 0; i < N; i++) {
    cin >> lst[i];
  }
  const int Nmax = 50;
  vector<vector<vll> > dp(N + 1,
                          vector<vll>(N + 1, vll(Nmax * (Nmax + 1) + 1, 0)));

  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= N; j++) {
      for (int k = 0; k <= Nmax * Nmax; k++) {
        dp[i + 1][j][k + lst[j - 1]] += dp[i][j - 1][k];
        dp[i][j][k] += dp[i][j - 1][k];
      }  // k
    }    // j
  }      // i

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += dp[i][N][i * A];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 53248
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define MXL 1000000000000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first

int main(){
    startt
    int x;
    cin >> x;
    if(x == 0)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3648
#include <stdio.h>

#define N 200000
#define M 1000000000

int main(){
  int n,i,minv,maxv,R[N];
  
  while(1){
    scanf("%d",&n);
    if(2 <= n && n <= N) break;
  }
  for(i = 0;i < n;i++){
    scanf("%d",&R[i]);
    if(R[i] < 1 || M < R[i]) i = i - 1;
  }
  minv = R[0];
  maxv = (-1)*M;
  for(i = 1;i < n;i++){
    if(maxv < R[i]-minv) maxv = R[i]-minv;
    if(minv > R[i]) minv = R[i];
  }
  printf("%d\n",maxv);

  return 0;
}

Measured memory_bytes: 1376