akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int B[MAXN];
int ii[MAXN];
int id[MAXN];
int ans[MAXN];
int tree[MAXN*4];

void update(int tmp,int v)
{
    tree[tmp] = v;
    tmp>>=1;

    while(tmp){
        tree[tmp] = min(tree[tmp<<1],tree[(tmp<<1)|1]);
        tmp>>=1;
    }

    return;
}

int getans(int L,int R)
{
    int res = INF;

    while(L<=R){
        if(L&1){
            res = min(res,tree[L]);
            L++;
        }
        if(!(R&1)){
            res = min(res,tree[R]);
            R--;
        }
        L>>=1; R>>=1;
    }

    return res;
}

int par[MAXN];
int rnk[MAXN];

int root(int x)
{
    if(x==par[x])return x;
    return par[x] = root(par[x]);
}

bool mymerge(int x,int y)
{
    x = root(x);
    y = root(y);

    if(x==y)return false;

    par[y] = x;
    rnk[x]+=rnk[y];

    return true;
}


int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>A[i]>>B[i];
    }

    if(n==1){
        cout<<1<<"\n";
        return 0;
    }

    for(int i=1;i<=n;i++){
        id[A[i]] = B[i];
        ii[B[i]] = A[i];
        par[i] = i;
        rnk[i] = 1;
    }

    int pre = 0;

    vector<pii> val;

    id[0] = INF;

    for(int i=1;i<n;i++){
        if(id[i]>id[i+1]){
            val.push_back(pii(pre+1,i));
            pre = i;
        }
        else {
            mymerge(i,i+1);
        }
    }

    val.push_back(pii(pre+1,n));

    a = b = 0;

    int base = 1;

    for(;base<n;base<<=1);

    for(int i=1;i<(base<<1);i++)tree[i] = INF;

    for(int i=0;i<(int)val.size();i++){

        x = val[i].f;
        y = val[i].s;

        mn = id[x];

        while(true){

            cur = getans(base,base+id[y]-1);

            if(cur==INF)break;

            mn = min(mn,cur);

            mymerge(ii[cur],y);

            update(base+cur-1,INF);
        }

        update(base+mn-1,mn);
    }

    for(int i=1;i<=n;i++){
        cur = A[i];
        cur = root(cur);
        cout<<rnk[cur]<<"\n";
    }


    return 0;
}


Measured memory_bytes: 10700
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S;
    int point;
    vector<pair<pair<string, int>, int>> T(N);
    pair<string, int> t;
    for(int i = 0; i < N; i++){
        cin >> S >> point;
        T[i] = make_pair(make_pair(S, -point), i + 1);
    }
    sort(T.begin(), T.end());
    for(vector<pair<pair<string, int>, int>>::iterator it = T.begin(); it != T.end(); it++){
        pair<pair<string, int>, int> a = *it;
        int b = a.second;
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll x, y, z, a, b, c;
int n;
ll num[1000];

void Cube(ll xx, ll yy, ll zz){
	if(xx <= 0 || yy <= 0 || zz <= 0) return;
	if(yy > zz) swap(yy,zz);
	if(xx > yy) swap(xx,yy);
	if(yy > zz) swap(yy,zz);
	if(zz > xx+yy){
		for(ll i = 1; i < xx; i++) num[(i+2)%n] += i*(i+1)/2;
		for(ll i = xx; i < yy; i++) num[(i+2)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2;
		for(ll i = yy; i < xx+yy-1; i++) num[(i+2)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2-(i-yy)*(i-yy+1)/2;
		for(ll i = xx+yy-1; i <= zz; i++) num[(i+2)%n] += xx*yy;
		ll j = xx+yy+zz+1;
		for(ll i = 1; i < xx; i++) num[(j-i)%n] += i*(i+1)/2;
		for(ll i = xx; i < yy; i++) num[(j-i)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2;
		for(ll i = yy; i < xx+yy-1; i++) num[(j-i)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2-(i-yy)*(i-yy+1)/2;
		
	} else{
		for(ll i = 1; i < xx; i++) num[(i+2)%n] += i*(i+1)/2;
		for(ll i = xx; i < yy; i++) num[(i+2)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2;
		for(ll i = yy; i < zz; i++) num[(i+2)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2-(i-yy)*(i-yy+1)/2;
		for(ll i = zz; i <= xx+yy-1; i++) num[(i+2)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2-(i-yy)*(i-yy+1)/2-(i-zz)*(i-zz+1)/2;
		ll j = xx+yy+zz+1;
		for(ll i = 1; i < xx; i++) num[(j-i)%n] += i*(i+1)/2;
		for(ll i = xx; i < yy; i++) num[(j-i)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2;
		for(ll i = yy; i < zz; i++) num[(j-i)%n] += i*(i+1)/2-(i-xx)*(i-xx+1)/2-(i-yy)*(i-yy+1)/2;
		
	}
}

void Square(ll xx, ll yy){
	if(xx <= 0 || yy <= 0) return;
	if(xx > yy) swap(xx,yy);
	for(ll i = 1; i < xx; i++) num[(i+1)%n] += i;
	for(ll i = xx; i <= yy; i++) num[(i+1)%n] += xx;
	ll j = xx-1;
	for(ll i = yy+1; i <= xx+yy-1; i++){
		num[(i+1)%n] += j;
		j--;
	}
}

void Line(ll xx){
	if(xx <= 0) return;
	for(ll i = 1; i <= xx; i++) num[i%n]++;
}

int main(){
	cin >> x >> y >> z >> a >> b >> c >> n;
	Cube(a,b,c);
	Cube(a,b,z-c-1);
	Cube(a,y-b-1,c);
	Cube(x-a-1,b,c);
	Cube(a,y-b-1,z-c-1);
	Cube(x-a-1,b,z-c-1);
	Cube(x-a-1,y-b-1,c);
	Cube(x-a-1,y-b-1,z-c-1);
	
	Square(a,b);
	Square(a,y-b-1);
	Square(a,c);
	Square(a,z-c-1);
	Square(x-a-1,b);
	Square(x-a-1,y-b-1);
	Square(x-a-1,c);
	Square(x-a-1,z-c-1);
	Square(b,c);
	Square(b,z-c-1);
	Square(y-b-1,c);
	Square(y-b-1,z-c-1);
	
	
	Line(a);
	Line(x-a-1);
	Line(b);
	Line(y-b-1);
	Line(c);
	Line(z-c-1);
	
	num[0] += 1;
	
	rep(i,n){
		cout << num[i];
		if(i != n-1) cout << " ";
		else cout << endl;
	}
}

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

public static class Program
{
    public static void Main(string[] args)
    {
        var vals = Enumerable.Range(0, 2).Select(x => int.Parse(Console.ReadLine())).ToArray();
        switch (vals[0] + vals[1])
        {
            case 3:
                Console.WriteLine(3);
                return;
            case 4:
                Console.WriteLine(2);
                return;
            case 5:
                Console.WriteLine(1);
                return;
        }
    }
}

Measured memory_bytes: 13268
s = input()
t = input()

sList = []
for index in range(0,len(s)):
    sList.append(s[index])

tList = []
for index in range(0,len(t)):
    tList.append(t[index])

sList.sort()
tList.sort()
tList.reverse()

newS = ""
for word in sList:
    newS = newS + word

newT = ""
for word in tList:
    newT = newT + word

list = [newS, newT]
list.sort()

if list[0] == list[1]:
    print("No")
elif list[0] == newS:
    print("Yes")
else:
    print("No")

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<int mod> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % mod) {
        if (val < 0) val += mod;
    }
    constexpr int getmod() { return mod; }
    constexpr Fp operator - () const noexcept {
        return val ? mod - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= mod) val -= mod;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % mod;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % mod;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<mod>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<mod> modpow(const Fp<mod> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
	friend constexpr Fp<mod> modfac(long long l, long long r) noexcept
	{
		auto res = Fp<mod>(1);
		for (Fp<mod> i = l; i < r; ++i) res *= i;
		return res;
	}
};
using mint = Fp<1000000007>;


int main(int argc, char **argv)
{
	string L; cin >> L;

	mint res{0};
	ll num{0};
	REP(i, L.size())
	{
		ll len = L.size()-1-i;
		if (L[i] == '1')
		{
			res += modpow(mint(2), num) * modpow(mint(3), len);
			++num;
		}
	}

	res += modpow(mint(2), num);
	std::cout << res << std::endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
	const int MOD = 1000 * 1000 * 1000 + 7;
	int N;
	cin >> N;
	long long power = 1;
	for (int i = 1; i <= N; ++i) {
		power = (power * i) % MOD;
	}
	cout << power << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void prime(ll n,vl &v){
    rep(i,n){
        ll d=i+1;
        if(d==1)continue;
        bool check=true;
        for(auto x:v){
            if(d%x==0)check=false;
            if(x*x>d)break;
        }
        if(check)v.pb(d);
    }
}
int main(){
    ll n;cin >> n;
    vl v;prime(55555,v);
    vl ans;
    for(auto x:v){
        if(x%5==1)ans.pb(x);
    }
    rep(i,n)cout << ans[i] <<" ";
}

Measured memory_bytes: 384
n,m=map(int,input().split())
h=[0]*n
r=[1]*n
h[:]=map(int,input().split())
for ii in range(m):
  a,b=map(lambda x: int(x)-1,input().split())
  if h[a]>=h[b]:
    r[b]=0
  if h[b]>=h[a]:
    r[a]=0
print(sum(r))
  

Measured memory_bytes: 21604
import math
N = int(input())
A = list(map(int, input().strip().split()))


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

    # divisors.sort()
    return divisors


A1 = make_divisors(A[0])
A2 = make_divisors(A[1])
experiment = []
for i in range(0, len(A1)):
    experiment.append([A1[i], 1])

flag = 1
for i in range(0, len(A2)):
    for j in range(0, len(A1)):
        if A2[i] == A1[j]:
            experiment[j][1] = 2
            flag = 0
    if flag == 1:
        experiment.append([A2[i], 1])
    flag = 1

for i in range(2, N):
    for j in range(0, len(experiment)):
        if A[i] % experiment[j][0] != 0:
            experiment[j][1] -= 1
max = experiment[0][0]
for i in range(0, len(experiment)):
    if experiment[i][1] > 0 and experiment[i][0] > max:
        max = experiment[i][0]

print("{}".format(max))


Measured memory_bytes: 14588
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#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--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(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 mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int const H_MAX = 500;

int H, W;
int a[H_MAX + 1][H_MAX + 1];
vector<pair<P, P>> ans;

int main() {
  scanf("%d %d", &H, &W);
  rep(i, H) {
    rep(j, W) {
      scanf("%d", &a[i + 1][j + 1]);
    }
  }

  FOR(i, 1, H + 1) {
    if (i % 2 == 1) {
      FOR(j, 1, W + 1) {
        if (i == H && j == W) break;

        if (a[i][j] % 2 == 1) {
          pair<P, P> move;
          if (j == W) {
            a[i + 1][j]++;
            move.first.first = i;
            move.first.second = j;
            move.second.first = i + 1;
            move.second.second = j;
          } else {
            a[i][j + 1]++;
            move.first.first = i;
            move.first.second = j;
            move.second.first = i;
            move.second.second = j + 1;
          }
          ans.push_back(move);
        }
      }
    } else {
      FORR(j, W, 1) {
        if (i == H && j == 1) break;

        if (a[i][j] % 2 == 1) {
          pair<P, P> move;
          if (j == 1) {
            a[i + 1][j]++;
            move.first.first = i;
            move.first.second = j;
            move.second.first = i + 1;
            move.second.second = j;
          } else {
            a[i][j - 1]++;
            move.first.first = i;
            move.first.second = j;
            move.second.first = i;
            move.second.second = j - 1;
          }
          ans.push_back(move);
        }
      }
    }
  }

  printf("%ld\n", ans.size());
  rep(i, ans.size()) {
    printf("%d %d %d %d\n", ans[i].first.first, ans[i].first.second, ans[i].second.first, ans[i].second.second);
  }
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define ll unsigned long long

using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); cout.tie(NULL);
	ll n,k,val,ans=0;
	cin>>n>>k;
	ans = log(n)/log(k) + 1;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
vvi adj;
stack<int> st;
vector<bool> vis;
void topo(int u)
{
    vis[u] = true;
    for(auto x : adj[u])
    {
        if(!vis[x])
        {
            topo(x);
        }
    }
    st.push(u);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    adj.resize(n);
    vis.resize(n);
    for(int i = 0; i < m; ++i)
    {
        int x,y;
        cin >> x >> y;
        --x,--y;
        adj[x].push_back(y);
    }

    for(int i = 0; i < n; ++i)
    {
        if(!vis[i])topo(i);
    }

    vi dis(n);
    
    while(!st.empty())
    {
        int x = st.top();
        st.pop();
        for(auto z : adj[x])
        {
            dis[z] = max(dis[z],dis[x] + 1LL);
        }
        
    }
    
    cout << (*max_element(all(dis)));
}

Measured memory_bytes: 9472
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int n;
char s[101];

int main() {
  cin >> n;
  rep(i,n) cin >> s[i];

  rep(i,n) {
    if (s[i] == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }

  cout << "Three" << endl;
}


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

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

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


Measured memory_bytes: 3632
def solve(N, As):
    money = 1000
    stock = 0
    for i in range(len(As)):
        if i == N - 1:
            money += stock * As[i]
            stock = 0
            continue
        if As[i] > As[i + 1]:
            money += stock * As[i]
            stock = 0
        if As[i] < As[i + 1]:
            stock += money // As[i]
            money = money % As[i]
    print(money)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, As)

Measured memory_bytes: 9196
#include <iostream>

using namespace std;

int main(void){
  string s;
  cin>>s;
  
  bool f = false;
  f |= s[0] == s[1] && s[1] == s[2];
  f |= s[3] == s[1] && s[1] == s[2];
  cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
/*input
10
5 3
5 7
8 9
1 9
9 10
8 4
7 4
6 10
7 2

*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
void solve()
{
	lld n;
	cin >> n;
	lld val=0;
	rep(i,1,n){
		lld x,y;
		cin >> x >> y;
		if(x>y){
			swap(x,y);
		}
		val=val+x*(n-y+1);
	}
	lld add=0;
	add=(n+1)*(n*(n+1)/2)-(n*(n+1)*(2*n+1))/6;
	cout << add-val << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 3540
/*
 * main.c
 *
 *  Created on: 2019/03/24
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

char S[100001] = {0};
int l[100001] = {0};
int r[100001] = {0};
int d[100001] = {0};

void checkAC(int n)
{
    int i;
    int count = 0;
    for(i = 0; i < n; i++){
        if((S[i] == 'A') && (S[i+1] == 'C')){
            count++;
        }
        d[i] = count;
        //printf("%d",d[i]);
    }
    //printf("\n");
    return;
}

int main()
{
    int N, Q;
    int i = 0;
    int start = 0;
    int end = 0;
    int ans = 0;
    scanf("%d %d", &N, &Q);
    scanf("%s",S);
    for(i = 0; i < Q; i++) {
        scanf("%d %d", &l[i], &r[i]);
    }

    // AC確認
    checkAC(N);
    for(i = 0; i < Q; i++) {
        start = l[i]-1;
        end = r[i]-2;
        ans = d[end];
        if(start > 0) {
            ans -= d[start-1];
        } else {
            //
        }
        //printf("end=%d start=%d\n",d[end], d[start]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M;
  cin >> N >> M;
  vvl G(N + 1);
  ll A, B;
  rep(i, M){
    cin >> A >> B;
    G[A].push_back(B);
    G[B].push_back(A);
  }

  vl vis(N + 1, 0);
  vl mark(N + 1, -1);
  vis[0] = 1;
  queue<ll> que;
  que.push(1);

  while(!que.empty()){
    ll room = que.front();
    que.pop();
    if(vis[room] == 1) continue;
    vis[room] = 1;

    rep(i, G[room].size()){
      ll next = G[room][i];
      if(vis[next] == 1) continue;
      if(mark[next] != -1) continue;
      mark[next] = room;
      que.push(next);
    }
  }

  cout << "Yes" << endl;
  rep2(i, 2, N + 1) cout << mark[i] << endl;
  
  return 0;
}


Measured memory_bytes: 13728
#include<stdio.h>
#define L 100
#define INF 1<<21
int G[L][L], n, labels[L], d[L], p[L];
 
int min(int a, int b){
    return (a>=b) ? b: a;
}
 
 
void dijkstra(int s) {
    int i;
    for(i=0; i<n; i++) {
    d[i]=INF;
    labels[i]=0;
    }
    d[s]=0;
    while (1){
    int u,v=-1;
    for(u=0; u<n; u++){
        if(labels[u]==0 && (v == -1 || d[u] < d[v])) v=u;
    }
    if (v==-1) break;
    labels[v]=1;
    for(u=0; u<n; u++){
        if(labels[u]!=1) d[u] = min(d[u], d[v]+G[v][u]);
    }
    }
 
}
 
int main(){
    int i,j,k,v,c,u;
    scanf("%d",&n);
 
    for(i=0;i<n; i++){
    for(j=0;j<n;j++){
        G[i][j]=INF;
    }
    }
     
    for(i=0;i<n;i++){
    scanf("%d %d",&u, &k);
    for(j=0;j<k;j++){
        scanf("%d %d",&v, &c);
        G[u][v]=c;
    }
    }
     
    dijkstra(0);
    for(i=0;i<n;i++){
    printf("%d %d\n",i, d[i]);
    }
 
    return 0;
  }



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


Measured memory_bytes: 1628
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <map>
#include <deque>
#include <queue>
#include <set>
using namespace std;
int main(){
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	if(s=="abc") cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int N, i1 = -1, m1 = 0, m2 = 0;
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    int A;
    scanf("%d", &A);
    if(m1 < A){
        i1 = i;
        m1 = A;
    } else if(m2 < A)
        m2 = A;
  }
  for(int i = 0; i < N; i++)
    printf("%d\n", i == i1 ? m2 : m1);
  return 0;
}


Measured memory_bytes: 1536
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
s = Counter(A)
t=[0]*(10**5+1)
for i in range(10**5+1):
    t[i] = s[i]*i

sumnum=sum(t)
for i in range(Q):
    B, C = map(int, input().split())
    num = t[B]//(B)
    t[B] = 0
    t[C] += num*(C)
    sumnum=sumnum-num*B+num*C
    print(sumnum)


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

int main(){
  double n;
  cin >> n;
  vector <double> a(n);
    double ans =0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    ans+=1/a.at(i);
  }
  cout << 1/ans << endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=2005,inf=1e9+5;
int N,K,Q;
int id[MN],a[MN];
bool cmp(int x,int y){return a[x]<a[y];}
int bel[MN],len[MN],cnt,bl;bool in[MN];
int solve(int pos)
{
	memset(in,0,sizeof in);
	cnt=bl=0;reg int i,j,k;
	for(i=1;i<=N;++i)
	{
		for(;i<=N&&a[i]<a[pos];++i);
		for(j=i;j<=N&&a[j]>=a[pos];++j);--j;
		for(len[++bl]=j-i+1,k=i;k<=j;++k)
			bel[k]=bl,in[k]=true;
		i=j;
	}
	for(i=1;i<=N;++i)if(in[id[i]]&&len[bel[id[i]]]>=K)
	{
		--len[bel[id[i]]];
		if(++cnt==Q)return a[id[i]]-a[pos];
	}
	return inf;
}


int main()
{
	N=read();K=read();Q=read();
	reg int i;
	for(i=1;i<=N;++i)a[id[i]=i]=read();
	sort(id+1,id+N+1,cmp);
	int ans=inf;
	for(i=1;i<=N;++i) ans=min(ans,solve(i));
	return 0*printf("%d\n",ans);
}

Measured memory_bytes: 3772
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	char buf[512];
	while (cin.getline(buf, sizeof(buf)), *buf != '0')
	{
		stringstream ss(buf);
		int total = 0;
		int one = 0;
		int c;
		while (ss >> c)
		{
			if (c == 1)
			{
				total += 11;
				++one;
			}
			else if (c >= 10)
				total += 10;
			else
				total += c;
		}
		while (total > 21 && one--)
			total -= 10;

		if (total <= 21)
			printf("%d\n", total);
		else
			puts("0");
	}

	return 0;
}

Measured memory_bytes: 0
use proconio::{input, fastout};
use permutohedron::LexicalPermutation as _;

#[fastout]
fn main() {
    input!{
        n: usize,
        xy: [(isize, isize); n]
    }
    let mut distance = vec![vec![0.0f64; n];n];
    for i in 0..n {
        for k in 0..n {
            let d = {
                let (cix, ciy) = xy[i];
                let (ckx, cky) = xy[k];
                (((cix - ckx) * (cix - ckx) + (ciy - cky) * (ciy - cky)) as f64).sqrt()
            };
            dbg!(d);
            distance[i][k] = d;
        }
    }
    let mut prm = vec![0;n];
    for i in 0..n {
        prm[i] = i;
    }
    let mut sum = 0.0;
    let mut perm_num = 0;
    loop {
        perm_num += 1;
        for i in 0..n-1 {
            sum += distance[prm[i]][prm[i + 1]];
        }
        if !prm.next_permutation() {
            break;
        }
    }
    let avr = sum / (perm_num as f64);
    println!("{}", avr);
}


Measured memory_bytes: 2184
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_vector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_vector(int n, Ts ... ts){
        return vector<decltype(make_vector(ts...))>(n, make_vector(ts...));
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    void run(){
        ll A, B;
        is >> A >> B;
        if(!is) return;
        int con = 1;
        int ans = 0;
        while(con < B){
            con += A-1;
            ans++;
        }
        cout << ans << endl;



    }
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_B.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    N = int(input())
    A = input().split()
    a = [int(v) for _, v in enumerate(A)]
    print(len([v for i, v in enumerate(a) if (i+1) % 2 != 0 and v % 2 != 0]))


Measured memory_bytes: 61796
#include <iostream>
#include <string>

using namespace std;

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

	int diff[1000];
	int count = 0;

	int N = S.size() - T.size(); // 先頭の選び方
	for (int i =0; i <= N; i++) {
		for (int j =0; j < T.size(); j++) {
			// cout << "S[" << i+j << "] = " << S[i+j] << " ";
			// cout << "T[" << j << "] = " << T[j] << "\n";
			if(S[i+j] == T[j]) {
				count++;
			}
		}
		diff[i] = count;
		count = 0;
	}

	int max = diff[0];
	for (int i = 0; i < N; i++) {
		if(diff[i] > max) {
			max = diff[i];
		}
	}
	cout << T.size() - max << "\n";
	return 0;
}

Measured memory_bytes: 3596
def main():
    n = int(input())
    v = [int(i) for i in input().split()]
    c = [int(i) for i in input().split()]
    ans = 0
    for i in range(n):
        if v[i]-c[i] > 0:
            ans += v[i]-c[i]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n;
  string s;
  cin >> n >> s;
  s = '0' + s;

  vector<int> r(n+1), g(n+1), b(n+1);
  r[0] = 0; g[0] = 0; b[0] = 0;
  REP(i, 1, n){
    if(s[i] == 'R') r[i] = r[i-1] + 1;
    else r[i] = r[i-1];
    if(s[i] == 'G') g[i] = g[i-1] + 1;
    else g[i] = g[i-1];
    if(s[i] == 'B') b[i] = b[i-1] + 1;
    else b[i] = b[i-1];
  }

  ll sum = 0;
  REP(i, 1, n-1){
    REP(j, i+1, n){
      if(s[i] == 'R'){
        if(s[j] == 'G'){
          sum += b[n] - b[j];
          if(2*j-i <= n && s[2*j-i] == 'B') sum--;
        }
        if(s[j] == 'B'){
          sum += g[n] - g[j];
          if(2*j-i <= n && s[2*j-i] == 'G') sum--;
        }
      }

      if(s[i] == 'G'){
        if(s[j] == 'B'){
          sum += r[n] - r[j];
          if(2*j-i <= n && s[2*j-i] == 'R') sum--;
        }
        if(s[j] == 'R'){
          sum += b[n] - b[j];
          if(2*j-i <= n && s[2*j-i] == 'B') sum--;
        }
      }

      if(s[i] == 'B'){
        if(s[j] == 'R'){
          sum += g[n] - g[j];
          if(2*j-i <= n && s[2*j-i] == 'G') sum--;
        }
        if(s[j] == 'G'){
          sum += r[n] - r[j];
          if(2*j-i <= n && s[2*j-i] == 'R') sum--;
        }
      }
    }
  }

  cout << sum << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  for(;N>=10;){
    N=N%10;
  }
  
  if(N==3){
    cout << "bon" << endl;
    return 0;
  }
  else if(N==0||N==1||N==6||N==8){
    cout << "pon" << endl;
    return 0;
  }
  else{
    cout << "hon" << endl;
    return 0;
  }
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2000010;
int n;
int a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	unsigned long long suma=0,sumb=0,ans=0;
	int j=1;
	for(int i=1;i<=n;i++){
		while(j<=n+1&&suma==sumb){
			suma^=a[j];
			sumb+=a[j];
			j++;
		}
		suma^=a[j-1];
		sumb-=a[j-1];
		suma^=a[i];
		sumb-=a[i];
		ans+=j-i-1;
		j--;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#define NN 300000
using namespace std;

int flg[300001];
int li[300001];
int main(void)
{
	int n,q,i,j,k,c,mx,qq,xx,ama;
	
	scanf("%d %d",&n,&q);
	for(i=1;i<=NN;i++)	flg[i]=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&c);
		flg[c]=1;
	}
	xx=0;
	for(i=0;i<=NN;i++)	{
		if(flg[i]==1)	{
			xx=i;
		}
		li[i]=xx;
	}
	
//	for(i=1;i<=10;i++)	{
//		printf("li=%d\n",li[i]);
//	}
	
	for(i=0;i<q;i++)	{
		scanf("%d",&qq);
		mx=0;
		j=NN;
		xx=li[NN];
		while(1)	{
			ama=xx%qq;
			mx=max(mx,ama);
			if(mx==qq-1)	break;
			xx=li[xx-ama-1];
			if(xx==0)	break;
		}
		printf("%d\n",mx);
	}
	return 0;
}


Measured memory_bytes: 3368
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	int N;
	cin >> N;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	if (N == 2) {
		cout << 11 << endl;
		return 0;
	}
	vector<int>adis(N, MOD);
	Calculate_Depth(edge, adis, 0);
	int tp = 0;
	for (int i = 1; i < N; i++) {
		if (adis[i] > adis[tp])tp = i;
	}
	vector<int>bdis(N, MOD);
	Calculate_Depth(edge, bdis, tp);
	int bt = 0;
	for (int i = 0; i < N; i++) {
		if (bdis[i] > bdis[bt])bt = i;
	}
	for (auto &i : adis)i = MOD;
	Calculate_Depth(edge, adis, bt);
	vector<int>rdis(N, MOD);
	queue<int>Q;
	for (int i = 0; i < N; i++) {
		if (adis[i] + bdis[i]==adis[tp]) {
			Q.push(i);
			rdis[i] = 0;
		}
	}
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (rdis[i] > rdis[cn]+1) {
				rdis[i] = rdis[cn] + 1;
				Q.push(i);
			}
		}
	}
	int L = 2, R = N;
	while (R - L > 1) {
		int mid = (R + L) / 2;
		bool flag = true;
		for (int i = 0; i < N; i++) {
			if (!rdis[i])continue;
		//	cout << "mid " << mid << "  " << adis[i] << " " << bdis[i] << endl;
			if (max(adis[i], bdis[i]) >= mid  && rdis[i] * 2 != mid)flag = false;
		}
		if (flag)R = mid;
		else L = mid;
	}
	cout << 11 << string(R - 3, '0') << string(N - R + 1, '1') << endl;
}


Measured memory_bytes: 10252
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string ans = "No";
            if ((Math.Abs(p[0] - p[2]) <= p[3]) || (Math.Abs(p[0] - p[1]) <= p[3] && Math.Abs(p[1] - p[2]) <= p[3]))
            {
                ans = "Yes";
            }
            Console.WriteLine(ans);

            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 11348
#include<iostream>

using namespace std;
int main()
{
    int n,r;
    cin>>n>>r;
    int v,s;
    if(n<10){
       v = 100*(10-n);
       s = r+v;
       cout<<s<<endl;
    }
    else{
        cout<<r<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int r;	cin >> r;
	if(r < 1200){
		cout << "ABC" << "\n";
	}else if(r < 2800){
		cout << "ARC" << "\n";
	}else{
		cout << "AGC" << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
const main = input => input.split('\n').slice(1).filter(x => x).map(line => line.split('')).map((vs, i, matrix) => vs.map((v, j) => v === '#' ? '#' : [].concat(...[i - 1, i, i + 1].map(x => [j - 1, j, j + 1].map(y => [x, y]))).map(t => (matrix[t[0]] && matrix[t[0]][t[1]]) === '#' ? 1 : 0).reduce((a, b) => a + b)).join('')).join('\n');

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

int main() {
    float n;
    cin>>n;
    float curr=ceil(n/1000);
   // cout<<curr<<endl;
    ll ret=(curr*1000-n);
    cout<<ret<<endl;
    // your code goes here
	return 0;
}

Measured memory_bytes: 3724
/*
ID: tohoast1
TASK: gymnastics
LANG: C++
*/
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("gymnastics.in", "r", stdin)
#define fout freopen("gymnastics.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define MIN_INT -999999999
#define MOD 1000000007
#define d109 1000000000
# define basay break
using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
int k, x;

int main() {
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin >> k >> x;
    k *= 500;
    if (k >= x) cout << "Yes";
    else cout << "No";
    ///time;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		int n=int.Parse(Console.ReadLine());
		int pt=0;
		int px=0;
		int py=0;
		bool yes=true;
		for(int i=0;i<n;i++)
		{
			string[]kk=Console.ReadLine().Split();
			int t=int.Parse(kk[0]);
			int x=int.Parse(kk[1]);
			int y=int.Parse(kk[2]);
			
			int dist=Math.Abs(x-px)+Math.Abs(y-py);
			if((t-pt)%2!=dist%2)
			{
				yes=false;
				break;
			}
			if(dist>t-pt)
			{
				yes=false;
				break;
			}						
			pt=t;
			px=x;
			py=y;
		}
		if(yes)Console.WriteLine("Yes");
		else Console.WriteLine("No");
	}
}


Measured memory_bytes: 15292
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    int n,m;
    cin >> n >> m;
    int a[210000],b[210000];
    REP(i,m){
        cin >> a[i] >> b[i];
    }
    bool ans = false;
    
    int check[210000]={};
    REP(i,m){
        if(a[i]==1) check[b[i]]++;
        if(b[i]==n) check[a[i]]++;
    }
    REP(i,n) if(check[i]>=2) ans = true;
    
    if(!ans) cout << "IM";
    cout << "POSSIBLE" << ENT;
    return 0;
}

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


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  ll h, w; cin >> h >> w;
  if(h == 1 || w == 1) {
    cout << 1 << endl;
  } else if(h % 2 == 0 || w % 2 == 0) {
    cout << h * w / 2 << endl;
  } else {
    cout << h * w / 2 + 1 << endl;
  }

}








Measured memory_bytes: 3592
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>=b && a>=c){
        printf("%d",a*10+b+c);
    }
    else if(b>=a && b>=c){
        printf("%d",b*10+a+c);
    }
    else{
        printf("%d",c*10+a+b);
    }
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i!=n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int N,L;
    cin >> N >> L;
    int l,r;
    l=L;r=L+N-1;
    int eat;
    if(l>=0)eat=l;
    else if(r<=0)eat=r;
    else eat =0;
    cout << (l+r)*N/2-eat << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Program {

    static void Main (string[] args) {
        int N = int.Parse (Console.ReadLine ());
        string[] strtemp1 = Console.ReadLine ().Split (' ');
        var narray = new int[1000001];
        for (int i = 0; i < N; i++) {
            narray[int.Parse (strtemp1[i])]++;
        }

        long ans = 0;
        for (int i = 0; i < 1000001; i++) {
            if (narray[i] == 1) {
                bool temp = true;
                var factor = Divisor (i);
                foreach (var value in factor) {
                    if (value != i && narray[value] > 0) {
                        temp = false;
                        break;
                    }
                }
                if (temp) {
                    ans++;
                }
            }
        }

        Console.WriteLine (ans);
    }

    static HashSet<int> Divisor (int N) {
        var ans = new HashSet<int> ();
        for (int i = 1; i * i <= N; i++) {
            if (N % i == 0) {
                ans.Add (i);
                if (i * i != N) {
                    ans.Add (N / i);
                }
            }
        }
        return ans;
    }
}

//dotnet run --project test

Measured memory_bytes: 64636
#include<stdio.h>

char board[3][4];

int check(char c1) {
	int i, j,flag=1;

	for (i = 0; i < 3; i++) {
		flag = 1;
		for (j = 0; j < 3; j++) {
			if (board[i][j] != c1) {
				flag = 0;
				break;
			}
		}
		if (flag)
		return 1;
	}

	for (i = 0; i < 3; i++) {
		flag = 1;
		for (j = 0; j < 3; j++) {
			if (board[j][i] != c1) {
				flag = 0;
				break;
			}
		}
		if (flag)
		return 1;
	}
	flag = 1;
	for (i = 0; i < 3; i++) {
			if (board[i][i] != c1) 
				flag = 0;
	}
	if (flag)return 1;
	flag = 1;
	for (i = 2,j=0; i >= 0; i--) {
		if (board[j++][i] != c1) 
			flag = 0;
	}
	if (flag)return 1;
	return 0;
}

int main(void)
{
	int n = 0;
	
	while (scanf("%s", board[n]), board[0][0] != '0') {
		n++;
		if (n == 3) {
			n = 0;
			if (check('b'))printf("b\n");
			else if (check('w'))printf("w\n");
			else printf("NA\n");
		}
	}
	return 0;
}

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

int n,m,l,q;
int d[305][305];

inline void floyd(){
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                d[i][j]=min(d[i][k]+d[k][j],d[i][j]);
            }
        }
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    memset(d,0x3f,sizeof(d));
    cin>>n>>m>>l;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        d[a][b]=d[b][a]=c;
    }
    floyd();
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(d[i][j]<=l)d[i][j]=1;
            else d[i][j]=1e9;
        }
    }
    floyd();
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(d[i][j]==1e9)d[i][j]=-1;
            else d[i][j]--;
        }
    }
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        cout<<d[s][t]<<endl;
    }

    return 0;
}

Measured memory_bytes: 896
#include <cstdio>

using namespace std;

int n,num[100];
long long int dp[100][21];

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

  for(int i=1;i<n;i++){
    for(int j=0;j<21;j++){
      if(dp[i-1][j]!=0){
        if(0<=j+num[i] && j+num[i]<=20){
          dp[i][j+num[i]]+=dp[i-1][j];
        }
        if(0<=j-num[i] && j-num[i]<=20){
          dp[i][j-num[i]]+=dp[i-1][j];
        }
      }
    }
  }

  long long int ans=dp[n-2][num[n-1]];

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 2720