akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int gcd(int i, int j, int k) {
    int div;
    while (true) {
        if (i == j && j == k) {
            break;
        }
        div = min ({i, j, k});
        if (i != div) {
            i = i % div + div;
            if (div < i) {
                i -= div;
            }
        }
        if (j != div) {
            j = j % div + div;
            if (div < j) {
                j -= div;
            }
        }
        if (k != div) {
            k = k % div + div;
            if (div < k) {
                k -= div;
            }
        }
    }
    return i;
}

int main() {
    int K;
    cin >> K;
    int ans = 0;
    for (int i = 1; i < K + 1; i++) {
        for (int j = 1; j < K + 1; j++) {
            for (int k = 1; k < K + 1; k++) {
                ans += gcd(i, j, k);
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    if(A%K==0 || B%K==0){
        cout << "OK" << endl;
        return 0;
    }
    int a = A / K;
    int b = B / K + 1;

    if(b - a > 1){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3632
import math

a,b,h,m = map(int,input().split())

n = h*60 + m
p = math.pi

xa = a * math.sin(n*2*p/720)
ya = a * math.cos(n*2*p/720)

xb = b * math.sin(m*2*p/60)
yb = b * math.cos(m*2*p/60)

l = ((xa-xb)**2+(ya-yb)**2)**(1/2)

print(l)


Measured memory_bytes: 9500
/**
 *    author:  FromDihPout
 *    created: 2020-09-01
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<deque>
#include<cmath>
#include<cstring>
#include<map>
#include<algorithm>
#include<vector>
#include<ios>
#include<sstream>
#include<locale>
using namespace std;
#define ive(cris) int long long 
#define in(out) long double
#define INF 100000007
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b){
    cout<<"YES"<<'\n';
  }
  else{
    cout<<"NO"<<'\n';
  }
  return 0;
}


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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct Item{
    ll w;
    ll v;
    Item(ll w, ll v):w(w), v(v){}
    bool operator<(const Item &another) const
    {
        return v * another.w < w * another.v;
    }
    bool operator>(const Item &another) const
    {
        return v * another.w > w * another.v;
    }
    string ToString(){
        stringstream ss;
        ss << w << ' ' << v;
        return ss.str();
    }
};

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

    // input
    ll N, W;
    cin >> N >> W;

    vector<Item> A;
    FOR(i, 0, N){
        ll v, w; cin >> v >> w;
        A.push_back(Item(w, v));
    }
    sort(ALL(A), greater<Item>());
    
    double sum = 0;
    for(auto item : A){
        if(item.w <= W){
            W -= item.w;
            sum += item.v;
        }else{
            double r = (double)item.v / item.w;
            sum += r * W;
            W = 0;
        }
    }

    cout << setprecision(20);
    p(sum);

    return 0;
}


Measured memory_bytes: 4944
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int main()
{
    int a,b,k; cin >> a >> b >> k;
    int cnt=0;
    for(int i=max(a,b);i>0; i--){
        if(a%i==0 and b%i==0){
            cnt++;
        }
        if(cnt==k){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    const int mod=1000000007;
    string k;
    int d;
    cin >> k >> d;
    int n=k.size();
    vector<int> now(d,0);
    int val=0;
    for(int i=0;i<n;i++)
    {
        vector<int> nxt(d,0);
        int x=(k[i]-'0');
        for(int a=0;a<x;a++) nxt[(val+a)%d]=(nxt[(val+a)%d]+1)%mod;
        val=(val+x)%d;
        for(int j=0;j<d;j++)
        {
            for(int a=0;a<=9;a++) nxt[(j+a)%d]=(nxt[(j+a)%d]+now[j])%mod;
        }
        now=nxt;
    }
    cout << (now[0]+(val==0)-1+mod)%mod << "\n";
    return 0;
}


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

int main() {
	int N;
	int amari;
	cin >> N;
	amari = N % 3;
	
	if (amari == 0) cout << N / 3;
	if (amari == 1)cout << (N - 1) / 3;
	if (amari == 2)cout << (N - 2) / 3;
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

def main():
    n = int(input())
    balls = [int(i) for i in input().split()]

    # v - value written on ball
    # b - ball index in [0, n)
    # ct - number of times a value occurs

    # hist[v] = ct
    hist = Counter(balls)
    diff_counts = set(hist.values())
    combos1 = { ct: 0 if ct == 1 else (ct-1) * (ct-2) // 2 for ct in
            diff_counts }
    combos = { ct: ct * (ct-1) // 2 for ct in diff_counts  }

    tot = sum(combos[hist[v2]] for v2 in hist.keys())

    for b in range(n):
        v = balls[b]
        ct = hist[v]
        print(tot - combos[ct] + combos1[ct])

main()


Measured memory_bytes: 34028
#58 A - Kenken Race
import sys
sys.setrecursionlimit(10**7)
N,A,B,C,D = map(int,input().split())
S = input()
A,B,C,D = A-1,B-1,C-1,D-1

# A が B を抜かせるエリア
if B == 1:
    a = S.find('...') + 1
else:
    a = S.find('...',3) + 1

dx = [1,2]

# 先に移動させる方の関数
def dfs_ini(v,seen_ini,X):
    seen_ini[v] = True# v を訪問済みにする
    for i in range(2):
        next_v = v + dx[i]
        # next_v が範囲外 or 壁の場合 or 他方が存在する場合
        if not(-1<next_v<N):
            continue
        if (S[next_v] == '#') or (next_v == X):
            continue
        if seen_ini[next_v] == True:# next_v が探索済みならスルー
            continue
        dfs_ini(next_v,seen_ini,X)

# 後に移動させる方の関数
def dfs_fin(w,seen_fin,Y):
    seen_fin[w] = True# w を訪問済みにする
    for j in range(2):
        next_w = w + dx[j]
        # next_w が範囲外 or 壁の場合 or 他方が存在する場合
        if not(-1<next_w<N):
             continue
        if (S[next_w] == '#')  or (next_w == Y):
             continue
        if seen_fin[next_w] == True:# next_w が探索済みならスルー
             continue
        dfs_fin(next_w,seen_fin,Y)

# A を先に動かした方がいいとき
# B を 先に a まで移動させる
if C>D:
    seen_ini_A = [False]*N
    seen_fin_B = [False]*N
    # B を抜かせるエリアがないとき、B の位置はスタート位置
    if (a < B) or (a > D):
        a = B
    dfs_ini(A,seen_ini_A,a)
    dfs_fin(B,seen_fin_B,C)
    result = 'No'
    if seen_ini_A[C] and seen_fin_B[D]:
        result = 'Yes'

# B を先に動かした方がいいとき
else:
    seen_ini_B = [False]*N
    seen_fin_A = [False]*N
    dfs_ini(B,seen_ini_B,A)
    dfs_fin(A,seen_fin_A,D)
    result = 'No'
    if seen_ini_B[D] and seen_fin_A[C]:
        result = 'Yes'

print(result)

Measured memory_bytes: 119208
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+5;
const int MAX2=2e6+4;
const int MAAX=2e9+5;
const int MOD=1e9+7;
in main()
{
   int n,m;
   cin>>n>>m;
   vector<int>v;
   while(m--) v.pb(1);
   while(n--) v.pb(0);
   int ans=0;
   for(int i=0;i<v.size();i++)
   {
       for(int j=i+1;j<v.size();j++)
       {

           ans+=((v[i]+v[j])%2==0);
       }
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long K, long long C, std::string S){
    vll posFromLeft, posFromRight;
    ll i=0;
    while(i < N){
        if(S[i]=='o') {
            posFromLeft.push_back(i);
            i += C+1;
        }
        else i++;
        if(posFromLeft.size()>= K) break;
    }
    i = N-1;
    while(i >= 0){
        if(S[i]=='o'){
            posFromRight.push_back(i);
            i -= C+1;
        }
        else i--;
        if(posFromRight.size()>= K) break;
    }
    reverse(ALL(posFromRight));

    vll ans;
    REP(i, K){
        if(posFromLeft[i]==posFromRight[i]) ans.push_back(posFromLeft[i]+1);
    }
    for(auto x: ans) cout<<x<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long C;
    scanf("%lld",&C);
    std::string S;
    std::cin >> S;
    solve(N, K, C, S);
    return 0;
}


Measured memory_bytes: 6772
N = int(input())
SPs = [[i for i in input().split()] for j in range(N)]
SPs = [[i+1, sp[0], int(sp[1])] for i, sp in enumerate(SPs)]
SPs = sorted(SPs, key=lambda x: (x[1], -x[2]))
[print(sp[0]) for sp in SPs]


Measured memory_bytes: 3060
n = int(input())
h = [int(i) for i in input().split(' ')]

for i, e in enumerate(h[-2::-1]):
    if h[len(h) - i - 1] - e == -1:
        h[len(h) - i - 2] -= 1
    elif h[len(h) - i - 1] - e < -1:
        print('No')
        exit(0)

print('Yes')


Measured memory_bytes: 14396
package main

import "fmt"

func main() {

	var s string
	fmt.Scan(&s)
	isS := true
	for i, _ := range s {
		if i % 2 == 0  {
			if string(s[i])== "R" ||  string(s[i]) == "U" ||  string(s[i]) == "D"{

			}else{
				isS =false
			}
		}else {
			if string(s[i])== "L" ||  string(s[i]) == "U" ||  string(s[i]) == "D"{

			}else{
				isS =false
			}
		}
	}
	if isS {
		fmt.Println("Yes")
	}else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll s;
ll ans;
int ten[8]={1,10,100,1000,10000,100000,1000000,10000000};
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll one(ll val){
	ll ans = 0;
	for(int i=1;i*i<=val;i++){
		if(val%i == 0){
			ll V = val/i;
			if(i < 9 && ten[i-1]*9 < V);
			else{
				ans += modpow(10LL,i-1) * 9LL % mod - V;
				ans ++;
			}
			
			if(i*i != val){
				ll V = i;
				if(val/i < 9 && ten[val/i-1]*9 < V);
				else{
					ans += modpow(10LL,val/i-1) * 9LL % mod - V;
					ans ++;
				}
			}
		}
	}
	return ans % mod;
}
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	if(b==0) return a;
	else return gcd(b,a%b);
}
ll extgcd(ll a,ll b,ll &x,ll &y){
	ll g = a; x = 1; y = 0;
	if(b != 0) g = extgcd(b,a%b,y,x),y-=(a/b)*x;
	return g;
}
ll AxB(ll A,ll B,ll C){
	//minimum non-negaitive x such that Ax godo b (mod C)
	if(B%gcd(A,C) != 0) return -1;
	ll x,y;
	extgcd(A,C,x,y);
	x = x*B/gcd(A,C)%(C/gcd(A,C));
	ll f = C/gcd(A,C);
	if(x > 0){
		x %= abs(f);
	}
	else{
		x = (x%abs(f)+abs(f))%abs(f);
	}
	return x;
}
ll two(ll val){
	ll ans = 0;
	for(int i=1;i<=7;i++){
	    for(int j=1;j<=ten[i-1]*9;j++){
	        ll zan = val - i*j;
	        if(zan < 0 || zan%(i+1) != 0) continue;
	        zan /= (i+1);
	        if(zan == 0) continue;
	        if(zan > 9*ten[i]) continue;
	        ans++;
	    }
	}
	for(int i=8;i<=100000;i++){
		//i*x = val mod (i+1)
		ll v = AxB(1LL*i,val,1LL*(i+1));
		v %= (i+1);
		ll u = (val-v*i) / (i+1);
		if(v == 0) u -= i;
		if(u <= 0) continue;
		ll w = AxB(1LL*(i+1),val,1LL*i);
		assert(w>=0 && w*(i+1)%i == val%i);
		w %= i;
		ll u2 = (val-w*(i+1))/i;
		if(w == 0){
		    u2 -= (i+1);
		    w += i;
		}
		if(u2 <= 0) continue;
		assert(u >= w);
		assert(u%i == w%i);
		ans += (u-w)/i+1;
	}
	for(int a=1;a<=2000;a++){
		for(int b=1;b<a;b++){
			if(val < b) continue;
			if((val-b)%a != 0) continue;
			ll y = (val-b)/a;
			if(y <= 100000) continue;
			ans++;
		}
	}
	return ans % mod;
}
int main(){
	cin>>s;
	ans += one(s);
	ans += two(s);
	for(int beg=1;beg<=6;beg++){
		for(int en=beg+2;en<=8;en++){
			ll sum = 0;
			for(int i=beg+1;i<en;i++){
				sum += 1LL*i*9*ten[i-1];
			}
			if(sum >= s) continue;
			for(int use=1;use<=9*ten[beg-1];use++){
				ll zan = s-sum-beg*use;
				if(zan <= 0) continue;
				if(zan % en != 0) continue;
				ll need = zan/en;
				if(need < 0 || need > 9*ten[en-1]) continue;
				ans++;
			}
		}
	}
	cout << ans % mod << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main(){
    int a,b; cin>>a>>b;
    bool ans=false;
    for(int i=1;i<4;i++){
        if((a*b*i)%2==1) ans=true;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    switch (N % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
}

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

static const int MAX = 100;
#define INF 2000000000000ll
int V, E;
long long dp[MAX][MAX];

void Warshall_Floyd() {
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j =0 ; j < V; j++) {
				if (dp[i][k] == INF || dp[k][j] == INF) {
					continue;
				}
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
}


int main() {
	cin >> V >> E;
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			if (i == j) {
				dp[i][j] = 0;
			}
			else {
				dp[i][j] = INF;
			}
		}
	}
	for (int i = 0; i < E; i++) {
		int from, to, cost;
		cin >> from >> to >> cost;
		dp[from][to] = cost;
	}
	Warshall_Floyd();
	bool minus = false;
	for (int i = 0; i < V; i++) {
		if (dp[i][i] < 0) {
			minus = true;
		}
	}

	if (minus) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				if (j != 0) {
					cout << " ";
				}
				if (dp[i][j] == INF) {
					cout << "INF";
				}
				else {
					cout << dp[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}










Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    long long a,b,x;
    cin >> a >> b >> x;
    if(a != 0) cout << b/x - (a-1)/x << endl;
    else cout << b/x + 1 << endl;
    }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	string S;
	cin >> S;
	int ans = 1 << 30;
	for (int i = 0; i + 3 <= S.size(); i++) {
		string x = S.substr(i, 3);
		ans = min(ans, abs(atoi(x.c_str()) - 753));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


template<typename T,T MOD = 1000000007>
struct Mint{
    T v;
    vector<Mint> fact;
    vector<Mint> fact_inv;
    Mint():v(0){}
    Mint(signed v):v(v){}
    Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

    Mint pow(long long k){
        Mint res(1),tmp(v);
        while(k){
            if(k&1) res*=tmp;
            tmp*=tmp;
            k>>=1;
        }
        return res;
    }

    static Mint add_identity(){return Mint(0);}
    static Mint mul_identity(){return Mint(1);}

    Mint inv(){return pow(MOD-2);}

    Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
    Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
    Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
    Mint& operator/=(Mint a){return (*this)*=a.inv();}

    Mint operator+(Mint a) const{return Mint(v)+=a;};
    Mint operator-(Mint a) const{return Mint(v)-=a;};
    Mint operator*(Mint a) const{return Mint(v)*=a;};
    Mint operator/(Mint a) const{return Mint(v)/=a;};

    Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

    bool operator==(const Mint a)const{return v==a.v;}
    bool operator!=(const Mint a)const{return v!=a.v;}
    bool operator <(const Mint a)const{return v <a.v;}
    
    Mint comb(long long n,int k){
        Mint res(1);
        for(int i=0;i<k;i++){
            res*=Mint(n-i);
            res/=Mint(i+1);
        }
        return res;
    }
};

Mint<ll> P[2000010];
void make(){
    P[0] = P[1] = 1;
    for(ll i=2;i<=2000009;i++){
	P[i] = P[i-1]*Mint<ll>(i);
    }
}
Mint<ll> C(ll n , ll k ){
    return (P[n]/P[k])/P[n-k];
}
Mint<ll> func(ll r, ll c ){
 	return C(r+c,r);
}
int main(){
    make();
    ll r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    Mint<ll> res(0);
    Mint<ll> a;
 /*   for(ll i=r1;i<=r2;i++){
	for(ll j=c1;j<=c2;j++){
	   // a.comb(i+j,i);
	 //   cout<<i<<' '<<j<<' '<<C(i+j,i).v<<endl;
	  //  res += C(i+j,i);
	    res += func(i,j);
	}
    }*/
    
   /* for(ll i=r1;i<=r2;i++){
     //res += C(i+r2+1 , i+1 ) - C(i+r1 , i+1);
     res += func( i+1 , c2 ) - func( i+1  , c1-1 ); 
    }*/
    res += func( r2 + 1 , c2 + 1 ) - func( r1 , c2 + 1) + func( r1 , c1 ) - func( r2 + 1 , c1 ) ; 
    //res += func( r2 + 1 , c2 + 1 ) - func( r1 , c2 + 1) - func( r2 + 1 , c1 ) + func( r1 , c1 ); 
    //res += C( r2+c2+2 , r2+2 ) - C( r1+c2+1, r2+2 ) -  C( r2 + c1 +1 , c1 + 2 ) + C( r1+c1 , c1+2
    cout<<res.v<<endl;
    return 0;
}


Measured memory_bytes: 109568
n = int(input())
a = list(map(int,input().split()))
division = {str(i):0 for i in range(9)}
for i in a:
    x = i // 400
    if x > 8:
        x = 8
    division[str(x)] += 1
ans = 0
check = 1
for i in range(8):
    if division[str(i)] != 0:
        ans += 1
        check = 0
min_ans = ans + check
max_ans = ans + division['8']
print(min_ans,max_ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

func main() {
	defer stdout.Flush()

	N := readInt()
	g := make([][]int, N+1)
	for i := 0; i < N-1; i++ {
		a := readInt()
		b := readInt()
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	q := make([]int, 0)
	push := func(x int) {
		q = append(q, x)
	}
	pop := func() int {
		res := q[0]
		q = q[1:]
		return res
	}
	cost := make([]int, N+1)
	for i := range cost {
		cost[i] = math.MaxInt32
	}
	cost[1] = 0
	push(1)
	for len(q) != 0 {
		v := pop()
		for _, u := range g[v] {
			if cost[v]+1 < cost[u] {
				cost[u] = cost[v] + 1
				push(u)
			}
		}
	}

	prev := N
	v := N
	for cost[v] > cost[N]/2 {
		for _, u := range g[v] {
			if cost[u] < cost[v] {
				prev = v
				v = u
				break
			}
		}
	}
	ves := make([]int, 0)
	for _, u := range g[v] {
		if u == prev {
			continue
		}
		ves = append(ves, u)
	}
	g[v] = ves

	var bnodes int
	visited := make([]bool, N+1)
	push(1)
	for len(q) != 0 {
		v := pop()
		if visited[v] {
			continue
		}
		visited[v] = true
		bnodes++
		for _, u := range g[v] {
			push(u)
		}
	}

	if N-bnodes < bnodes {
		println("Fennec")
	} else {
		println("Snuke")
	}
}


Measured memory_bytes: 13184
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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

int N;
VS S(2);
VB vert;
bool pre;

ll calc(int i) {
  if (i >= vert.size()) {
    return 1;
  }

  if (i == 0) {
    if (vert[i]) {
      return 3 * calc(i + 1) % MOD;
    } else {
      return 6 * calc(i + 1) % MOD;
    }
  } else {
    if (vert[i - 1]) {
      return 2 * calc(i + 1) % MOD;
    } else if (vert[i]) {
      return calc(i + 1);
    } else {
      return 3 * calc(i + 1) % MOD;
    }
  }
}


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

  cin >> N >> S[0] >> S[1];

  REP(i, N) {
    if (S[0][i] == S[1][i]) {
      vert.push_back(true);
    } else {
      vert.push_back(false);
      i++;
    }
  }

  cout << calc(0) << endl;

  return 0;
}

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 25.06.2020 13:29:29
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    ll n,x,tmp;
    vector<ll> v;

    cin>>n>>x;

    REP(i,n)
    {
        cin>>tmp;
        v.push_back(tmp);
    }

    SORT(v);

    ll cnt=0;

    REP(i,n)
    {
        if((x>=v[i] && i!=n-1) || x==v[i]) 
        {
            x-=v[i];
            cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
using namespace std;

int H = 0;
int A[2000010];

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

void maxHeapify(int i) {
  int l = left(i);
  int r = right(i);

  int largest;
  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= H && A[r] > A[largest]) largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

void buildMaxHeap() {
  rep1R(i, H / 2) maxHeapify(i);
}

void heapIncreaseKey(int i, int key) {
  if (key < A[i]) cout << "エラー" << endl;
  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    swap(A[i], A[parent(i)]);
    i = parent(i);
  }
}

void insert(int key) {
  ++H;
  A[H] = INT_MIN;
  heapIncreaseKey(H, key);
}

int heapExtractMax() {
  if (H < 1) cout << "エラー" << endl;
  int max = A[1];
  A[1] = A[H];
  --H;
  maxHeapify(1);

  return max;
}

int main() {
  while (true) {
    string com;
    cin >> com;
    if (com == "insert") {
      int key;
      cin >> key;
      insert(key);
    } else if (com == "extract") {
      cout << heapExtractMax() << endl;
    } else if (com == "end") {
      break;
    } else {
      cout << "error" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 7016
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b ;
    cin >> a >> b ;
    
    if(a>8 || b>8)
      cout << ":(" << endl ;    
    else
      cout << "Yay!" << endl ;        
    return 0;
}


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

int main(void) {
  ll A, B;
  cin >> A >> B;

  if(A * B == 15) cout << "*" << endl;
  else if(A + B == 15) cout << "+" << endl;
  else cout << "x" << endl;
}


Measured memory_bytes: 256
let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let parent i = int_of_float ((float_of_int (i - 1)) /. 2.)

let left i = 2*i + 1

let right i = 2*i + 2

let to_pow_of_2 n =
  let rec doit i =
    if i >= n then i
    else doit (i * 2) in
  doit 1

let update (s : int array) n i x =
  let j = n + i - 1 in
  s.(j) <- x;
  let rec doit j =
    if j > 0 then begin
      let j = parent j in
      s.(j) <- if s.(left j) < s.(right j) then s.(left j) else s.(right j);
      doit j
    end in
  doit j

let find s n a b =
  let rec doit a b k l r =
    if r <= a || b <= l then 2147483647
    else if a <= l && r <= b then s.(k)
    else min (doit a b (left k) l ((l + r) / 2)) (doit a b (right k) ((l + r) / 2) r) in
  doit a b 0 0 n

let solve n q =
  let n = to_pow_of_2 n in
  let s = Array.make (2*n-1) 2147483647 in
  let rec doit i =
    if i < q then begin
      begin match List.map int_of_string (split (read_line ()) ' ') with
      | 0 :: x :: y :: _ -> update s n x y
      | 1 :: x :: y :: _ -> Printf.printf "%d\n" (find s n x (y + 1))
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; q] -> solve n q
  | _ -> ()

Measured memory_bytes: 6472
#include <iostream> 
using namespace std;
typedef long long int ll;
int sum = 0,n;
void dfs(ll x,int a,int b,int c) {
    if (x > n) return;
    if (a & b & c) sum++;
    dfs(x * 10 + 3, 1, b, c);
    dfs(x * 10 + 5, a, 1, c);
    dfs(x * 10 + 7, a, b, 1);
}
int main() {
    cin >> n;
    dfs(0, 0,0,0);
    cout << sum << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

vector<pii> prime(int n){ // n以下の素数を要素に持つvectorを返す
  vector<bool> isprime(n+1,true);
  vector<pii> ans;
  isprime[0] = isprime[1] = false;
  FOR(i,2,n+1)
    if(isprime[i]){
      ans.pb(pii(i,0));
      for(int j = 2 * i; j <= n; j += i) isprime[j] = false;
    }
  return ans;
}


main(){
  int n; cin >> n;
  ll ans = 1;
  vector<pii> p = prime(n);

  FOR(i,2,n+1) rep(j,p.size()){
    int x = i;
    while(1){
      if(x % p[j].fst == 0){
	p[j].snd++;
	x /= p[j].fst;
      }else break;
    }
  }
  
  rep(i,p.size()){
    //cout << p[i].fst << " " << p[i].snd << endl;
    ans *= p[i].snd + 1;
    ans %= 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

        ll pow(ll base, ll q, ll mod){
            ll answer = 1;
            while(q > 0){
                if(q & 1LL)
                    answer = (answer * base) % mod;

                q = q >> 1LL;
                base = (base*base) % mod;
            }
            return answer % mod;
        }


        
       
        
        void solve(){
            cin >> n;
            vector<int> squares;
            for(int i=1; i <= sqrt(2*n); i++){
                squares.pb(i*i);
            }

            int sz = squares.size();
            for(int i=1; i <= n; i++){
                int cnt = 0;
                
                for(int i1=0;i1<sz;i1++){
                    int val1 = squares[i1];
                    if(val1 >= 2*i) break;
                    for(int i2=i1;i2<sz;i2++){
                        int val2 = squares[i2];
                        if( (val2 + val1) >= 2*i) break;

                        int val3 = 1;
                        int sum = val1 + val2;
                        sum = 2*i - sum;
                        int t = sqrt(sum);
                        if( (t*t) == sum) val3 = sum;
                        else continue;
                        if(val3 < val1 || val3 < val2) continue;
                        //if(i == 20) cout << val1 << " " << val2 << " " << val3 << endl;
                        int f1 = sqrt(val1);
                        int f2 = sqrt(val2);
                        int f3 = sqrt(val3);
                        if( (f1+f2+f3)%2) continue;
                        sum = (f1+f2+f3)/2;
                        int x,y,z;

                                
                        x = sum - f3;
                        y = sum - f2;
                        z = sum - f1;
                        //if(i == 20) cout << x << " " << y << " " << z << endl;
                        if(x > 0 && y > 0 && z >0 && x < i && z < i && y < i){
                            if(x == y && y == z) cnt++;
                            else if(x == y || x == z || y == z) cnt+=3;
                            else cnt += 6;
                        }
                            
                        
                    }
                }
                printf("%d\n",cnt);
            }

        }
            
            
        



            



        int main(){
            ios_base::sync_with_stdio(false);

            

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define N 103
#define MAXV 100005
using namespace std;

int n, W, w[N], v[N];
long long f[N][MAXV];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n >> W;
    int sum = 0;
    for (int i = 1; i <= n; ++i)
        scanf("%d%d", w + i, v + i), sum += v[i];
    memset(f, 0x3f, sizeof f);
    f[0][0] = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= sum; ++j) {
            f[i][j] = f[i - 1][j];
            if (j >= v[i])
                f[i][j] = min(f[i][j], f[i - 1][j - v[i]] + w[i]);
        }
    for (int i = sum; i >= 0; --i)
        if (f[n][i] <= W) {
            cout << i << endl;
            return 0;
        }
    return 0;
}



Measured memory_bytes: 80768
while True:
    a,op,b=map(str,input().split())
    if op == '?':
        break
    elif op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(a) // int(b))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 2e5 + 20;
int a[MAXN], b[MAXN];
priority_queue<pii> p_q;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	rep (i, 1, n) {
		cin >> a[i];
	}
	rep (i, 1, n) {
		cin >> b[i];
		if (b[i] != a[i]) {
			p_q.push(pii(b[i], i));
		}
	}
	lint tot = 0;
	int flag = 0;
	while (p_q.size()) {
		pii tp = p_q.top();
		p_q.pop();
		if (tp.fst == a[tp.sed]) continue;
		if (tp.fst < a[tp.sed]) {
			flag = 1; break;
		}
		int l = tp.sed - 1, r = tp.sed + 1;
		if (l == 0) l = n;
		if (r == n + 1) r = 1;
		int sub = b[l] + b[r];
		if (sub > tp.fst) {
			flag = 1; break;
		}
		if (tp.fst % sub == a[tp.sed] % sub) {
			tot += (tp.fst - a[tp.sed]) / sub;
			b[tp.sed] = a[tp.sed]; continue;
		} else if (tp.fst % sub < a[tp.sed]) {
			flag = 1; break;
		} else {
			tot += tp.fst / sub;
			b[tp.sed] = (tp.fst %= sub);
			p_q.push(tp);
		}
	}
	if (p_q.size() || flag) {
		cout << -1 << endl;
	} else {
		cout << tot << endl;
	}
	return 0;
}

Measured memory_bytes: 3828
#include <stdio.h>
#include <string.h>

#define min(A, B) ((B) > (A) ? (A) : (B))

/*
int min(int a, int b)
{
    return (b > a ? a : b);
}
*/

int main(void)
{
    int i, j, k;
    int n;
    int div[10001];
    static int dp[2][5001][2];
    
    scanf("%d", &n);
    
    for (i = 1; i <= n - 1; i++){
        scanf("%d", div + i);
    }
    memset(dp, 1, sizeof(dp));
    dp[0][0][0] = dp[0][0][1] = 0;
    
    for (i = 0; i <= n / 2; i++){
        for (j = 0; j <= n / 2; j++){
            if (i > 0){
                dp[i & 1][j][0] = dp[(i - 1) & 1][j][0];
                dp[i & 1][j][1] = dp[(i - 1) & 1][j][0] + div[i + j];
            }
            if (j > 0){
                dp[i & 1][j][0] = min(dp[i & 1][j][0], dp[i & 1][j - 1][1] + div[i + j]);
                dp[i & 1][j][1] = min(dp[i & 1][j][1], dp[i & 1][j - 1][1]);
            }
        }
    }
     
    printf("%d\n", min(dp[0][n / 2][0], dp[0][n / 2][1]));
     
    return (0);
}

Measured memory_bytes: 484
data = input().split(" ")
data = list(map(int, data))

count=0

for x in range(data[0]+1):
    for y in range(data[0]+1):
        if data[0] >= (data[1]-(x+y)) >= 0:
            z = data[1]-(x+y)
            
            if x + y + z == data[1]:
                count+=1
print(count)

Measured memory_bytes: 41196
N, K = map(int, input().split())

sunuke = list(range(1, N+1))

for i in range(K):
  _ = int(input())
  for okashi in map(int, input().split()):
    #print(sunuke)
    if okashi in sunuke:
      sunuke.remove(okashi)

print(len(sunuke))


Measured memory_bytes: 67444
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int u, v, cost; };

signed main() {
	string s; cin >> s;
	int flg = 0;
	if (s[0] == 'A')flg++;
	int c=0;
	int pos=0;
	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C') {
			c++;
			pos = i;
		}
	}
	if (s[s.size() - 1] == 'C')c = 0;
	if (c == 1)flg++;
	for (int i = 1; i < s.size(); i++) {
		if (i != pos) {
			if ('A' <= s[i] && s[i] <= 'Z')flg--;
		}
	}
	if (flg == 2)puts("AC");
	else puts("WA");
}


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

int main(){
  int N, i, j, tmp, diff=0;
  scanf("%d", &N);
  int a[N];
  for(i=0;i<N;i++)scanf("%d", &a[i]);

  for(i=0;i<N-1;i++)
    for(j=0;j<N-i-1;j++){
      if(a[j]<a[j+1]){
        tmp=a[j];a[j]=a[j+1];a[j+1]=tmp;
      }
    }
  
  for(i=0;i<N;i++)
    if(i%2)
      diff-=a[i];
    else
      diff+=a[i];
  
  printf("%d\n", diff);
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;
 

int main(){
  
  	int a;
  	int answer;
	cin >> a;
  
  	answer = a+ a*a+ a*a*a;
  
  	cout << answer <<endl;
  
  
  return 0;
  
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using std::cout;
using std::endl;
using std::cin;
using std::vector;
using pii = std::pair<int,int>;
using std::make_pair;
using std::abs;

int cost_between(pii &prev, pii &next) {
	return abs(next.first-prev.first) + abs(next.second-prev.second);
}

int main() {
	// Input
	int H, W, D;
	cin >> H >> W >> D;
	const int SIZE = H * W;
	// squares[A] = pair(x, y)
	vector<pii> squares(SIZE+1);
	for(int h = 0; h < H; ++h) {
	for(int w = 0; w < W; ++w) {
		int A; cin >> A;
		squares[A] = make_pair(w, h);
	}
	}
	// Preparation
	vector<int> cumulative(SIZE+1);
	for(int a = D+1; a <= SIZE; ++a) {
		pii ps = squares[a-D];
		pii ns = squares[a];
		cumulative[a] = cumulative[a-D] + cost_between(ps, ns);
	}
	// Input Calculation, and Output
	int Q; cin >> Q;
	for(int i = 0; i < Q; ++i) {
		int L, R; cin >> L >> R;
		cout << (cumulative[R] - cumulative[L]) << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#define F(i,n) for(int (i)=0;(i)!=(n);(i)++)
long long M=1e9+7,n,k,dp[102][9999],si=1;
int main()
{
    std::cin>>n>>k,k++;
    F(i,n-1) si=si*k%M;
    si=si*n*k*(k-1)/2%M;
    dp[n+1][0]=1;
    F(i,n) F(a,k) F(h, 4000) if(dp[h]>0)
        if(a<=n-i) dp[n-i][h+(h+a)/(n-i)]=(dp[n-i][h+(h+a)/(n-i)]+dp[n-i+1][h])%M;
        else dp[n-i][h]=(dp[n-i][h]+dp[n-i+1][h])%M;
    F(i, 4000) si=(si-dp[1][i]*i);
    std::cout<<(si%M+M)%M;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,m,e,j;
    char z;
    while(true){
    cin>>n;
    if(n==0)
        break;
    for(int i=0;i<n;i++){
        cin>>m>>e>>j;
        z='C';
        if(m+e+j>=210)
            z='B';
        if(m+e+j>=150&&(m>=80||e>=80))
            z='B';
        if(m==100||e==100||j==100)
            z='A';
        if(m+e>=180)
            z='A';
        if(m+e+j>=240)
            z='A';
        cout<<z<<endl;
    }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int t;
ll a,b,c,d;

void solve();

void input() {
    cin >> t;
    while (t--) {
        cin >> a >> b >> c >> d;
        solve();
    }
}

void solve() {
    if (a < b) {
        cout << "No" << endl;
        return;
    }

    if (d < b) {
        cout << "No" << endl;
        return;
    }

    if (c >= b) {
        cout << "Yes" << endl;
        return;
    }

    //a >= b, c < b, d >= b
    ll g = __gcd(b,d);
    cout << (b - g + (a % g) > c ? "No":"Yes") << endl;
}

int main(int argc, char *argv[]){
    input();
    // solve();
    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int x[n];
    for(int i=0;i<n;i++) cin >> x[i];
    int minsum = 1e9;
    for(int c=1;c<=100;c++){
        int sum = 0;
        for(int i=0;i<n;i++){
            sum += (c - x[i])*(c - x[i]);
        }
        minsum = min(sum, minsum);
    }
    cout << minsum << endl;
}

Measured memory_bytes: 256
import math

def main():
    n,d = [int(x) for x in input().split()]

    count = 0
    array = []
    for i in range(n):
        array.append([int(x) for x in input().split()])

    for i in range(n-1):
        for j in range(i+1, n):
            sumary = 0
            for k in range(d):
                sumary += (array[i][k] - array[j][k])**2
            distance = math.sqrt(sumary)
            if distance.is_integer():
                count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

template <typename T> struct Edge {
    int f, t;
    T c;
    Edge() {}
    Edge(int f, int t, T c) : f(f), t(t), c(c) {}
};

struct UF {
	int n, c;
	vector<int> p;

	UF(int n): n(n), c(n), p(n, -1) {}

	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
		c--;
		return true;
	}
	int find(int x) { return (p[x] < 0 ? x : p[x] = find(p[x])); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -p[find(x)]; }
	int count() { return c; }
};

// the cost of MST
template <typename T> T kruskal(vector<Edge<T>>& es, int n) {
    sort(es.begin(), es.end(), [](const Edge<T>& a, const Edge<T>& b) {
        return (a.c < b.c);
    });
    UF uf(n);
    T res = 0;
    for (auto& e : es) {
        if (uf.unite(e.f, e.t)) res += e.c;
    }
    return res;
}

int N, M;
int x[10010], y[10010];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    cin >> N >> M;
    REP (i, N) cin >> x[i] >> y[i];
    vector<Edge<double>> es;
    double sum = 0;
    REP (i, M) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        double dis = hypot(x[p] - x[q], y[p] - y[q]);
        es.emplace_back(p, q, -dis);
        sum += dis;
    }
    sum += kruskal<double>(es, N);
    cout << sum << endl;
}


Measured memory_bytes: 3988
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
  var line = chunk.toString().split(' ');
  var a = Number(line[0]);
  var b = Number(line[1]);
  
 if(a > b){
 console.log("a > b");
}else if (a < b){
 console.log("a < b");
}else{
 console.log("a == b");
}

});

Measured memory_bytes: 15524
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    A.push_back(K+A[0]);
    adjacent_difference(A.begin(), A.end(), A.begin());

    cout << K - *max_element(A.begin(), A.end()) << endl;
    return 0;
}


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

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

    ll cnt = N / (A + B);
    ll mod = N % (A + B);
    ll ans = A * cnt;
    ans += min(A, mod);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[3];

int solve(){
    int res=0;
    if(nums[0]!=nums[2]) res++;
    if(nums[1]!=nums[2]) res++;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,3) cin>>nums[i];
    sort(nums,nums+3);
    
    int cnt=0;
    while(1){
        int n=solve();
        if(n==0) break;
        if(n==1) nums[0]+=2;
        if(n==2) nums[0]++,nums[1]++;
        sort(nums,nums+3);
        cnt++;
    }
    cout1(cnt)
}

Measured memory_bytes: 256