akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
int a[maxn],jc[maxn]={1},inv[maxn],sum[maxn];
int qpow(int a,int b){
	a%=mod;
	int ret=1;
	while(b){
		if(b&1)ret=1ll*ret*a%mod;
		b>>=1;
		a=1ll*a*a%mod;
	}
	return ret;
}
int c(int n,int m){
	return 1ll*jc[n]*inv[m]%mod*inv[n-m]%mod;
}
void init(int x,int y){
	rep1(i,100000)jc[i]=1ll*jc[i-1]*i%mod;
	inv[100000]=qpow(jc[100000],mod-2);
	for(int i=99999;~i;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	//dbg(inv[0]);
	for(int i=x;i<=y;i++){
		sum[i]=c(i,x);
		if(i)sum[i]=(sum[i]+sum[i-1])%mod;
	}
}
void solve(){
	int n,k;scdd(n,k);
	rep1(i,n)scd(a[i]);
	sort(a+1,a+n+1);
	if(k==1){
		printf("0\n");
		return ;
	}
	init(k-2,n-2);
	int ans=0;
	rep1(i,n){
		if(i>=k)ans=(ans+1ll*sum[i-2]*a[i]%mod)%mod;
		if(i<=n-k+1)ans=(ans-1ll*sum[n-i-1]*a[i]%mod)%mod;
	}
	ans=(ans+mod)%mod;
	ac;
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}


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

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

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

int n,k;
cin>>n>>k;
int a[n+2];
rep(i,n){
	cin>>a[i];
}



for(int p=1;p<=min(k,100);p++){
int cnt=0;


int b[n+2];

fill(b,b+n+1, 0);



for(int i=1;i<=n;i++){
b[max(i-a[i],0)]+=1;
b[min(i+a[i]+1,n+1)]-=1;
}

int now=0;
for(int i=0;i<=n;i++){
now+=b[i];
if(i)
 a[i]=now;
}

}

for(int i=1;i<=n;i++){
	if(i<n){cout<<a[i]<<" ";}
	else cout<<a[n]<<endl;
}



return 0;
}




Measured memory_bytes: 5164
#include <iostream>

int main(){
	int N;
	int up[110],down[110];
	std::cin>>N;

	for(int i=0;i<N;++i)std::cin>>up[i];
	for(int i=0;i<N;++i)std::cin>>down[i];

	int count=0,max=0;

	for(int i=0;i<N;++i){
		count = 0;
		for(int j=0;j<=i;++j){
			count += up[j];
		}
		for(int k=i;k<N;++k){
			count += down[k];
		}
		if(count > max)max = count;
	}
	std::cout<<max;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod));
  ll t = longpow(n, a / 2, mod);
  return (t * t);
}
int main() {
  int N, M;
  cin >> N >> M;
  cout << (1900 * M + 100 * (N - M)) * longpow(2, M, MOD) << endl;
}

Measured memory_bytes: 3568
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
     
namespace IO {
	const int maxn(1 << 21 | 1);
     
	char ibuf[maxn], *iS, *iT, c;
	int f;
     
	inline char Getc() {
		return iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, maxn, stdin), (iS == iT ? EOF : *iS++)) : *iS++;
	}
     
	template <class Int> inline void In(Int &x) {
		for (f = 1, c = Getc(); c < '0' || c > '9'; c = Getc()) f = c == '-' ? -1 : 1;
		for (x = 0; c >= '0' && c <= '9'; c = Getc()) x = x * 10 + (c ^ 48);
		x *= f;
	}
}
     
using IO :: In;
     
const int maxn(1e5 + 5);
     
int n;
char s[maxn];
     
int main() {
	scanf(" %s", s + 1), n = strlen(s + 1);
	if (s[1] == '0' || s[n] == '1') return puts("-1"), 0;
	for (int i = 1; i <= n; ++i)
		if (s[i] == '0' && s[n - i] == '1') return puts("-1"), 0;
	for (int i = (n >> 1) + 1; i < n; ++i) printf("%d %d\n", i, n);
	for (int i = (n >> 1), lst = n; i; --i) {
		printf("%d %d\n", i, lst);
		if (s[i] == '1') lst = i;
	}
	return 0;
}

Measured memory_bytes: 1536
N,M=map(int,input().split())
A=list(map(int,input().split()))
l=[]
for i in A:
    l.append([i,1])
for i in range(M):
    B,C=map(int,input().split())
    l.append([C,B])
l.sort(reverse=True)
a,t=0,0
while True:
    if l[t][1]>=N:
        a+=l[t][0]*N
        break
    else:
        a+=l[t][0]*l[t][1]
        N-=l[t][1]
        t+=1
print(a)

Measured memory_bytes: 34624
n, m = gets.chomp.split.map(&:to_i)
isac = Array.new(n, false)
count_wa = Array.new(n, 0)
m.times do
    question, result = gets.chomp.split
    question = question.to_i - 1
    if result == "AC" then
        isac[question] = true
    else
        count_wa[question] += 1 unless isac[question]
    end
end
ans = [0, 0] # AC, WA

n.times do |i|
    if isac[i] then
        ans[0] += 1
        ans[1] += count_wa[i]
    end
end

puts ans.join(" ")

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

int main(){
	long long int a,b;
	while(cin>>a>>b){
		long long int c=a,d=b;
		while(c!=d){
			if(c>d){
				d+=b;
			}else{
				c+=a;
			}
		}
		while(1){
			d=a%b;
			if(d==0)break;
			a=b;
			b=d;
		}
		cout<<b<<' '<<c<<endl;
	}
	return 0;
}

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  vector<int> p(n);
  int one = 0, two = 0, three = 0;
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  for(int i = 0; i < n; i++){
    if(p[i] <= a) one++;
    else if(a + 1 <= p[i] && p[i] <= b) two++;
    else if(p[i] >= b + 1) three++;
  }
  cout << min({one, two, three}) << endl;
}

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

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

    string s;
    cin>>s;

    if(s.size() > 6)
    {
        cout<<"No"<<endl;
        return 0;
    }

    if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int cost; };

signed main() {
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i*i < n; i++) {
		if (n%i == 0) {
			int m = n / i - 1;
			int q = n / m, r = n%m;
			if(q==r)ans += m; 
		}
	}cout << ans << endl;
}

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

int main(){
    int N;
    vector<string> S(200);
    string ans="Yes";
    cin >> N;

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

    for(int i=1; i<N; i++){
	if(S[i-1][S[i-1].size()-1] != S[i][0])
	    ans = "No";
    }

    sort(S.begin(), S.end(), greater<string>());
    for(int i=1; i<N; i++){
	if(S[i-1] == S[i])
	    ans = "No";
    }

    cout << ans << endl;    
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

struct Cmp {
  bool operator()(const pll& lhs, const pll& rhs) {
    return lhs.first > rhs.first;
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i, n) cin >> h[i];
  sort(ALL(h), greater<int>());
  int ans = INT_MAX;
  for (int i = 0; i <= n - k; i++) {
    int hmax = h[i];
    int hmin = h[i + k - 1];
    // cout << hmax << "," << hmin << endl;
    ans = min(ans, hmax - hmin);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
inpl = lambda: list(map(int,input().split()))
N = int(input())
ans = 0
BA  = [[0, 0], [0, 0]]
for i in range(N):
    s = input()
    ans += s.count('AB')
    h = 1 if s[0]=='B' else 0
    t = 1 if s[-1]=='A' else 0
    BA[h][t] += 1
if BA[1][0]==BA[0][1]==0 and BA[1][1]>0:
    ans += BA[1][1]-1
else:
    ans += min(BA[1][0],BA[0][1]) + BA[1][1]

print(ans)

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int rcount = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'g')
            rcount++;
    }
    cout << rcount - n / 2 - n % 2 << endl;
}


Measured memory_bytes: 3740
#include<iostream>

using namespace std;

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

    long long n,m;
    cin>>n>>m;

    long long rez=0;
    for(int i=40; i>=0; i--)
    {
        long long val=rez+(1LL<<i);
        long long nec=2LL*val;

        if(val>n)
            nec=nec+(val-n)*2LL;

        if(nec<=m)
            rez+=(1LL<<i);
    }

    cout<<rez<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    char op;
    while(true){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?') break;
        switch(op){
        case '+':
            printf("%d\n",a+b);
            break;
        case '-':
            printf("%d\n",a-b);
            break;
        case '/':
            printf("%d\n",a/b);
            break;
        case '*':
            printf("%d\n",a*b);
            break;
        }
    }
}


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

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

using namespace std;

vector<ll> c, ans;
vector<vector<ll>> graph;
int pt=0;

void dfs(int s, int f){
  for(auto p:graph[s]){
    if(p!=f)dfs(p, s);
  }
  ans[s] = c[pt];
  pt++;
}

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

  ll a[n-1],b[n-1];
  rep(i,n-1)cin>>a[i]>>b[i];

  graph.resize(n+1);
  rep(i,n-1){
    graph[ a[i] ].push_back( b[i] );
    graph[ b[i] ].push_back( a[i] );
  }

  c.resize(n);
  ans.resize(n+1);
  rep(i, n)cin>>c[i];
  sort(c.begin(), c.end());

  dfs(1, -1);

  int sum=0;
  rep(i, n-1)sum+=c[i];
  cout<<sum<<endl;

  rep(i,n)cout<<ans[i+1]<<' ';
  cout<<endl;

  return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    r, d, x = map(int, input().split())
    for i in range(10):
        x = r * x - d
        print(x)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29292
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
int main(){
    int n;cin>>n;
    int a[5]={};
    ll ans = 0,buf=1;
    string s,t="MARCH";char in;
    fol(i,n){
        cin>>s;
        fol(j,5){
            if(s[0]==t[j]) a[j]++;
        }
    }
    fol(i,2){
        fol(j,2){
            fol(k,2){
                fol(l,2){
                    fol(m,2){
                        if(i+j+k+l+m==3){
                            buf = 1;
                            if(i) buf*=a[0];
                            if(j) buf*=a[1];
                            if(k) buf*=a[2];
                            if(l) buf*=a[3];
                            if(m) buf*=a[4];
                            ans += buf;
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int kuku(int x,int num){
  float box = (float)x/num;
  if(box>9) return 0;
  if(box-(int)box>0) return kuku(x,num-1);
  else return 1;
}

main(){
  int x;
  scanf("%d",&x);
  printf("%s",kuku(x,9)?"Yes":"No");
}

Measured memory_bytes: 128
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
#include <math.h>

int main() {
  double a, b, x;
  scanf("%lf%lf%lf", &a, &b, &x);
  double ans;
  if (x<a*a*b/2) {
    ans = 180*atan(2*x/(a*b*b))/M_PI;
  } else {
    ans = 180*atan(a*a*a/(2*a*a*b-2*x))/M_PI;
  }
  printf("%lf\n", 90.0-ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    bool a[105] = {};
    for (int i = 0; i < k; i++) {
        int d;
        scanf("%d", &d);
        for (int j = 0; j < d; j++) {
            int t;
            scanf("%d", &t);
            a[t] = true;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!a[i]) {
            ans++;
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int mod=1e9+7;
ll fun(ll x, ll y){
    if(y==0) return 1;
    ll g=fun(x,y/2);
    g*=g;
    g%=mod;
    if(y&1) g*=x;
    return g%mod;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int t=1;
    while(true){
        if(t&1){
            c-=b;
            if(c<=0){
                cout<<"Yes\n";
                return 0;
            }
        }
        else{
            a-=d;
            if(a<=0){
                cout<<"No\n";
                return 0;
            }
        }
        t++;
    }
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		Set<String> set = new HashSet<>();
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String[] str = br.readLine().split(" ");
			if (str[0].equals("insert")) {
				set.add(str[1]);
			} else if (set.contains(str[1])) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}
}


Measured memory_bytes: 190516
#include <stdio.h>

int main(){

int A[100];
  int i,j,minj,swap,n,count=0;

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

  for(i=0; i<=n-1; i++){
    minj=i;
    for(j=i; j<=n-1; j++){
      if (A[j] < A[minj])
	    minj = j;
    }
    swap=A[i];
    A[i] = A[minj];
    A[minj] = swap;
    if(i!=minj)
    count++;
  }
  
for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i!=n-1)
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);


  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

int main() {
    ll x;
    cin >> x;
    x = 2000 - x;
    cout << x / 200 + (x % 200 != 0) << endl;
}


Measured memory_bytes: 3612
def main():
    import sys
    input = sys.stdin.readline

    N, W = map(int, input().split())
    wv = []
    for _ in range(N):
        wv.append(list(map(int, input().split())))

    inf = W+1
    dp = [[inf] * (10**5+1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        w, v = wv[i]
        for j in range(10**5+1):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            if dp[i][j] + w <= W:
                dp[i+1][j+v] = min(dp[i+1][j+v], dp[i][j] + w)
    for v in range(10**5, -1, -1):
        if dp[-1][v] <= W:
            print(v)
            exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 119408
# include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;

const ll mod=1000000007;

int main(){
  ll L,R,d;
  cin >> L >> R >> d;
  int res=0;
  for(ll i=L;i<=R;i++){
    if(i%d==0) res++;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 100005;
const int mod = 1e9+7;

int L,n,T,a[maxn],w[maxn],x[maxn];LL cur;
int main()
{
	#ifdef Amberframe
		freopen("agc013c.in","r",stdin);
		freopen("agc013c.out","w",stdout);
	#endif
	scanf("%d %d %d",&n,&L,&T);
	for (int i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&w[i]);
		if (w[i]==1) {
			x[i]=(a[i]+T)%L;
			cur+=(a[i]+T)/L;
		}
		else {
			x[i]=(a[i]-T)%L;
			cur+=(a[i]-T)/L;
			if (x[i]<0) x[i]+=L,cur--;
		}
	}
	cur=(cur%n+n)%n;sort(x,x+n);
	for (int i=cur;i<n;i++) printf("%d\n",x[i]);
	for (int i=0;i<cur;i++) printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#define N 45
int a[N];
  
int f(int n){
  int i;
 
  for(i=0;i<=n;i++){
    if(i<2){
      a[i]=1;
    }
    else a[i]=a[i-1]+a[i-2];
  }
  return a[n];
}
main(void){
  int i,n,x;
 
  scanf("%d",&n);
  x=f(n);
  printf("%d\n",x);
  return 0;
}

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


int main()
{ 
    int x,y,z;
    cin >> x >> y >> z;
    x -= z;
    int count = 0;
    while(true) {
        int tmp = y + z;
        if (x - tmp >= 0) {
            x -= tmp;
            count++;
            continue;
        }
        break;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int[] d = new int[6];
		for(int i = 0; i < 6; i++){
			d[i] = scan.nextInt();
		}
		Dice dice = new Dice(d);
		for(int i = 0; i < 6; i++){
			d[i] = scan.nextInt();
		}
		Dice dice2 = new Dice(d);
		boolean flag = false;
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				flag = Arrays.equals(dice.d_, dice2.d_);
				if(flag == true)break;
				dice2.rollEast();
			}
			for(int j = 0; j < 4; j++){
				flag = Arrays.equals(dice.d_, dice2.d_);
				if(flag == true)break;
				dice2.rollSouth();
			}
			flag = Arrays.equals(dice.d_, dice2.d_);
			if(flag == true)break;
			dice2.rollRight();
		}
		System.out.println(flag? "Yes" : "No");
	}
}

class Dice{
	int[] d_ = new int[6];
	public static final int
		TOP = 0, SOUTH = 1, EAST = 2,
		WEST = 3, NORTH = 4, BOTTOM = 5;

	public Dice(int[] d){
		for(int i = 0; i < 6; i++){
			d_[i] = d[i];
		}
	}

	public void setTop(int num){
		if(num == d_[EAST]){
			this.rollWest();
		} else if(num == d_[WEST]){
			this.rollEast();
		} else if(num == d_[SOUTH]){
			this.rollNorth();
		} else if(num == d_[NORTH]){
			this.rollSouth();
		} else if(num == d_[BOTTOM]){
			this.rollEast();
			this.rollEast();
		}
	}

	public void setSouth(int num){
		if(num == d_[EAST]){
			this.rollRight();
			this.rollRight();
			this.rollRight();
		} else if(num == d_[WEST]){
			this.rollRight();
		} else if(num == d_[NORTH]){
			this.rollRight();
			this.rollRight();
		}
	}

	public int show(int side){
		return d_[side];
	}

	public void rollEast(){
		int work = d_[TOP];
		d_[TOP] = d_[WEST];
		d_[WEST] = d_[BOTTOM];
		d_[BOTTOM] = d_[EAST];
		d_[EAST] = work;
	}

	public void rollWest(){
		int work = d_[TOP];
		d_[TOP] = d_[EAST];
		d_[EAST] = d_[BOTTOM];
		d_[BOTTOM] = d_[WEST];
		d_[WEST] = work;
	}

	public void rollSouth(){
		int work = d_[TOP];
		d_[TOP] = d_[NORTH];
		d_[NORTH] = d_[BOTTOM];
		d_[BOTTOM] = d_[SOUTH];
		d_[SOUTH] = work;
	}

	public void rollNorth(){
		int work = d_[TOP];
		d_[TOP] = d_[SOUTH];
		d_[SOUTH] = d_[BOTTOM];
		d_[BOTTOM] = d_[NORTH];
		d_[NORTH] = work;
	}

	public void rollRight(){
		int work = d_[SOUTH];
		d_[SOUTH] = d_[WEST];
		d_[WEST] = d_[NORTH];
		d_[NORTH] = d_[EAST];
		d_[EAST] = work;
	}
}

Measured memory_bytes: 26260
#include <iostream>

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    string s = to_string(n);
    if(s[0]=='7' || s[1]=='7' || s[2]=='7')
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>S>>T;
	
	ll g=__gcd(N,M);
	ll ma=N/g*M;
	for(ll L=N;L<=ma;L+=N) if(L%M==0) {
		ll a=L/N;
		ll b=L/M;
		
		int ok=1;
		FOR(i,N) {
			if(i*a%b==0 && S[i]!=T[i*a/b]) ok=0;
		}
		if(ok==1) {
			cout<<L<<endl;
			return;
		}
	}
	cout<<-1<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 640
sx, sy, tx, ty = map(int, input().split())

print('U' * (ty - sy) + 'R' * (tx - sx) \
          + 'D' * (ty - sy) + 'L' * (tx - sx) \
          + 'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'D' \
          + 'R' + 'D' * (ty - sy + 1) + 'L' * (tx - sx + 1) + 'U' )

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

int main() {
    int n, m;
    cin >> n >> m;
    int count[m+1] = {}, k, a, ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> a;
            count[a]++;
        }
    }
    for (int i = 1; i <= m; i++) {
        if (count[i] == n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)

{

  int a,b,d,r;

  double f;

  scanf("%d %d",&a,&b);

  d=a/b;

  r=a%b;

  f=(double)a/(double)b;

  printf("%d %d %lf",d,r,f);

  return 0;

}
 

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

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

    int n, ans = 0;
    cin >> n;

    string a, b, c;
    cin >> a >> b >> c;

    for(int i = 0; i < n; i++){
        if(a[i] == b[i] and b[i] == c[i]);
        else if(a[i] == b[i] or b[i] == c[i] or c[i] == a[i]) ans += 1;
        else ans += 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*input
3 2 3
*/
/**
    Author: Kristopher Paul
    Date Created: 09-06-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 0x3f3f3f3f //0x3f3f3f3f = 63
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int p,q,r;
    cin >> p >> q >> r;
    cout << p+q+r-max(p,max(q,r)) << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
# これは逆元を用いてやる？
# この問題の場合、逆元をうまく設定するのが難しいので
# 左右からのmergeになりそう
from collections import deque
import sys

input = sys.stdin.buffer.readline


n, m = map(int, input().split())
# 各々の頂点の次数
deg = [0] * (n + 1)
# 隣接リストにグラフをまとめる
graph = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)
    deg[x] += 1
    deg[y] += 1

# dp1は葉向きに見たときの塗り方
# 自身が黒い時、下の候補はどうなるか？
dp1 = [0] * (n + 1)

# dp2は根向きに見たときの塗り方
# 自身が黒い時、親側の候補はどうなるか？
dp2 = [0] * (n + 1)

# 1回目
start = 1
par = [-1] * (n + 1)
que = deque([start])
topo = []
while que:
    v = que.popleft()
    topo.append(v)
    for i in range(deg[v]):
        u = graph[v][i]
        if par[v] == u:
            continue
        par[u] = v
        que.append(u)

# dpするついでにi=0からの積とi=deg[v]-1からの積を取っておくか。
dpl = [[] for _ in range(n + 1)]
dpr = [[] for _ in range(n + 1)]

# 頂点番号から何番目かがわかるようにしたいから辞書で持っておく？
edge_num = [{} for _ in range(n + 1)]

for v in topo[::-1]:
    temp = 1
    for i in range(deg[v]):
        u = graph[v][i]
        edge_num[v][u] = i  # edge_num[v]で頂点vに関する辞書。頂点uからidxが欲しいので記録
        if u == par[v]:
            dpl[v].append(temp)
            continue
        temp *= dp1[u] + 1
        temp %= m
        dpl[v].append(temp)
    dp1[v] = temp
    temp = 1
    for i in range(deg[v] - 1, -1, -1):
        u = graph[v][i]
        if u == par[v]:
            dpr[v].append(temp)
            continue
        temp *= dp1[u] + 1
        temp %= m
        dpr[v].append(temp)
# これで普通の木DPに加えて
# 左右からの累積積
# 頂点番号からidxへの辞書
# を獲得したはず

# dpは欲しい答えとしておく
# dp1とdp2から求める
dp = [0] * (n + 1)

for v in topo:
    # dp2の計算
    p = par[v]
    if p == -1:  # 例外、親がいない
        dp[v] = dp1[v]
        dp[v] %= m
        continue
    # 根側の処理
    # 自分以外の積を作りたい
    idx = edge_num[p][v]
    num = deg[p]
    dp2[v] = 1
    if idx - 1 >= 0:
        dp2[v] *= dpl[p][idx - 1]
        dp2[v] %= m
    if num - 2 - idx >= 0:
        dp2[v] *= dpr[p][num - 2 - idx]
        dp2[v] %= m
    # 根側の根側の処理
    pp = par[p]  # 親の親
    if pp != -1:  # 親の親がいるならば
        dp2[v] *= dp2[p] + 1  # 白=1か黒=dp2[pp]か
        dp2[v] %= m
    # dpの計算
    dp[v] = dp1[v] * (dp2[v] + 1)
    dp[v] %= m
print(*dp[1:], sep="\n")


Measured memory_bytes: 108160
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
// 104, 79, 118, 87
// 169, 133, 17, 98
// 180, 106, 125, 39
// 171, 42, 159, 14
// 45, 76, 101, 56
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	long long ret2=0;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		if(i==0)ret2=(ret2+ks)%d;
		ks=ks*2%d;
	}
	int sz=d%200;
	char *p = new char[sz*1000000];
	for(int i=0;i<sz*1000000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;

    if(s[0] == s[1] && s[0] != s[2] && s[2] == s[3]){
        cout << "Yes" << endl;
    }
    else if(s[0] == s[2] && s[0] != s[1] && s[1] == s[3]){
        cout << "Yes" << endl;
    }
    else if(s[0] == s[3] && s[0] != s[1] && s[1] == s[2]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;

typedef long long LL;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Slient_voice

#define ordered_set tree<LL, null_type, less<LL>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 10 + 1e5;

LL n, a[MaxN], k, d[MaxN];
char s[MaxN];
vector<LL> ans;

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    cin >> s;
    n++;
    reverse(s, s + n);
    for(int i = 0 ; i < n ; ++i)
    if(s[i] == '0') d[i] = i;
    else d[i] = d[i - 1];
    LL i = 0;
    // for(int i = 0 ; i < n ; ++i) cout << d[i] << " ";
    // cout << endl;
    while(i < n - 1){
        if(d[min(n - 1, i + k)] == i){
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(d[min(n - 1, i + k)] - i);
        i = d[min(n - 1, i + k)];
    }
    for(int i = ans.size() - 1 ; i >= 0 ; --i) cout << ans[i] << " ";

    return 0;
}

Measured memory_bytes: 2296
import java.util.Arrays;
import java.util.Scanner;






// B
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int T = Integer.parseInt(sc.next());

		int[] array = new int[N];
		Arrays.fill(array, 9999);

		for(int i = 0; i < N; i++) {
			int Ci = Integer.parseInt(sc.next());
			int Ti = Integer.parseInt(sc.next());
			if(Ti <= T) {
				array[i] = Ci;
			}
		}
		Arrays.sort(array);
		if(array[0] == 9999) {
			System.out.println("TLE");
		}else {
			System.out.println(array[0]);
		}


	}
}

Measured memory_bytes: 22736
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
pair<int, int> p[N];
LL ans[N];

int dis(int i, int j)
{
	return abs(p[i].first - p[j].first) + abs(p[i].second - p[j].second);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	int k;
	cin >> k;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			int x;
			cin >> x;
			p[x] = { i,j };
		}
	}
	for (int i = n * m - k; i > 0; i--)
	{
		ans[i] += ans[i + k] + dis(i, i + k);
	}
	int q;
	cin >> q;
	while (q--)
	{
		int l, r;
		cin >> l >> r;
		cout << ans[l] - ans[r] << '\n';
	}
	return 0;
}


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

int main(){
	long long int N, A, B;
	cin >> N >> A >> B;
	
	long long int ans = N/(A+B)*A;
	long long int add = N-N/(A+B)*(A+B);
	if(add > A)	add = A;
	ans += add;
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#define MOD 1000000007
using namespace std;

int n, l;
priority_queue<string, vector<string> , greater<string> > a;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>l;
	for (int i = 0; i < n; ++i){
		string b;
		cin>>b;
		a.push(b);
	}
	while(!a.empty()){
		cout<<a.top();
		a.pop();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

/* 60度回転 */
const double th = M_PI / 3;
static const std::vector< std::vector<double> > R{{cos(th), -sin(th)}, {sin(th), cos(th)}};

void koch(int d, std::vector<double> &p1, std::vector<double> &p2)
{
    if (d == 0)
        return;
    std::vector<double> s, t, u;
    s = {(2.0 * p1[0] + p2[0]) / 3, (2.0 * p1[1] + p2[1]) / 3};
    t = {(p1[0] + 2.0 * p2[0]) / 3, (p1[1] + 2.0 * p2[1]) / 3};
    u = {R[0][0] * (t[0] - s[0]) + R[0][1] * (t[1] - s[1]) + s[0],
         R[1][0] * (t[0] - s[0]) + R[1][1] * (t[1] - s[1]) + s[1]};

    koch(d - 1, p1, s);
    std::cout << s[0] << " " << s[1] << std::endl;
    koch(d - 1, s, u);
    std::cout << u[0] << " " << u[1] << std::endl;
    koch(d - 1, u, t);
    std::cout << t[0] << " " << t[1] << std::endl;
    koch(d - 1, t, p2);
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<double> p1{0, 0}, p2{100.0, 0};
    std::cout << std::fixed << std::setprecision(8);
    std::cout << p1[0] << " " << p1[1] << std::endl;
    koch(n, p1, p2);
    std::cout << p2[0] << " " << p2[1] << std::endl;
}


Measured memory_bytes: 3276
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, D;
unordered_map<int, set<pii>> y2x, x2y;
unordered_map<int, vi> Y2X, X2Y;
vi X, Y;
ll ans = 0;

ll f(unordered_map<int, vi> &S, int z, int lb, int ub) {
    return distance(lower_bound(all(S[z]), lb), lower_bound(all(S[z]), ub));
}

void dfs(int v) {
    y2x[Y[v]].erase(mp(X[v],v));
    x2y[X[v]].erase(mp(Y[v], v));

    for(int x : {X[v] + D, X[v] - D}) {
        ans += f(X2Y, x, Y[v] - D, Y[v] + D + 1);
        while(1) {
            auto it = x2y[x].lower_bound(mp(Y[v] - D, 0));
            if(it != x2y[x].end() && it->first <= Y[v] + D)dfs(it->second);
            else break;
        }
    }

    for(int y : {Y[v] + D, Y[v] - D}) {
        ans += f(Y2X, y, X[v] - D + 1, X[v] + D);
        while(1) {
            auto it = y2x[y].lower_bound(mp(X[v] - D, 0));
            if(it != y2x[y].end() && it->first <= X[v] + D)dfs(it->second);
            else break;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> N >> a >> b;
    --a; --b;
    X = Y = vi(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        X[i] = x - y;
        Y[i] = x + y;
    }

    D = max(abs(X[a] - X[b]), abs(Y[a]-Y[b]));

    rep(i, N) {
        y2x[Y[i]].insert(mp(X[i],i));
        x2y[X[i]].insert(mp(Y[i], i));
        Y2X[Y[i]].push_back(X[i]);
        X2Y[X[i]].push_back(Y[i]);
    }
    each(z, Y2X)sort(all(z.second));
    each(z, X2Y)sort(all(z.second));

    dfs(a);
    ans /= 2;
    cout << ans << endl;
}

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

int main() {
  int n, m; cin >> n >> m;
  vector<int> out(n, -1);
  for(int i = 0; i < m; i++){
    int s, c; cin >> s >> c;
    s--;
    if(out.at(s) != -1){
      if(out.at(s) != c){
        cout << -1; return 0;
      }
    }
    out.at(s) = c;
  }
  if(out.size()>1){
    if(out.at(0) == 0){
      cout << -1; return 0;
    }
  }
  if(out.size() == 1){
    if(out.at(0) == 0){
      cout << 0; return 0;
    }
  }
  if(out.size() == 1){
    if(out.at(0) == -1){
      cout << 0; return 0;
    }
  }
  for(int i = 0; i < n; i++){
    if(i == 0){
      if(out.at(i) == -1) out.at(i) = 1;
    }
    if(out.at(i) == -1) out.at(i) = 0;
    cout << out.at(i);
  }
}


Measured memory_bytes: 256
open System
open System.Collections.Generic
open System.Linq
open System

let Puts = Console.WriteLine : 'a -> unit
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])

let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)

let ReadIntDouble () = ReadDouble () |> FuncDouble int int

let ensmallen l = l % 1000000007L

let manhattan x y = abs (fst x - fst y) + abs (snd x - snd y)


// main code

let a = Console.ReadLine()
let b = Console.ReadLine()
let l = max a.Length b.Length
let a1 = Seq.append (Seq.replicate (l - a.Length) '0') a |> String.Concat
let b1 = Seq.append (Seq.replicate (l - b.Length) '0') b |> String.Concat

(if a1 < b1 then "LESS" else if a1 > b1 then "GREATER" else "EQUAL") |> Puts


Measured memory_bytes: 14432
#include<iostream>
using namespace std;
#define ll long long

int main()
{
  ll n;
  cin>>n;
  ll a[4]={0};
  for(ll i=0;i<n;i++)
  {
     string s;
     cin>>s;
     if(s=="AC")
     a[0]++;
     else if(s=="WA")
     a[1]++;
     else if(s=="TLE")
     a[2]++;
     else
     a[3]++;
  }
  cout<<"AC x "<<a[0]<<"\n";
  cout<<"WA x "<<a[1]<<"\n";
  cout<<"TLE x "<<a[2]<<"\n";
  cout<<"RE x "<<a[3]<<"\n";
  
  
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define lowbit(x) ((x)&-(x))
#define debug(x) cout << #x " = " << x << endl;
namespace IO{
	const int L = 1 << 15;
	char ibuf[L|1],*iS=ibuf,*iT=ibuf;
	char obuf[L|1],*oS=obuf,*oT=obuf+L;
	char c,st[66];int tp=0,f;
	inline char gc(){
		if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);
		return (*iS++);
	}
	inline void flush() {
		fwrite(obuf,sizeof(char),oS-obuf,stdout);
		oS = obuf;
	}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){
		ll x=0;f=1,c=gc();
		for(;!isdigit(c);c=gc())if(c=='-')f=-1;
		for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);
		return x*f;
	}
	void write(ll x){
		if(!x) pc('0');if(x<0) pc('-'),x=-x;
		while(x) st[++tp]=x%10+'0',x/=10;
		while(tp) pc(st[tp--]);
	}
	void wri(ll x){write(x);pc(' ');}
	void writeln(ll x){write(x);pc('\n');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}
using IO::read;
using IO::writeln;
using IO::wri;
inline void gg(string s){cout << s << endl;exit(0);}
inline void gg(ll x){writeln(x);exit(0);}
const int maxn = 2e6+233;
int n,b[maxn];
ll a[maxn],c[maxn];
int s[maxn],top;
inline bool invalid(int u,int v,int w){
	return (a[v] - a[u]) * (w-v) <= (a[w]-a[v]) * (v-u);
}
void rebuild(){
	int k = max_element(a+1,a+1+n) - a;
	rotate(a+1,a+k,a+1+n);
	rotate(b+1,b+k,b+1+n);
	a[++n]=a[1],b[n]=b[1];
}
void init(){
	rep(i,2,n) c[i+1] = 2 * (b[i] + c[i]) - c[i-1];
	Rep(i,1,n) a[i] -= c[i];
}
double solve(){
	rebuild();init();
	Rep(i,1,n){
		while(top>1&&invalid(s[top-1],s[top],i))--top;
		s[++top]=i;
	}ll ans=0;
	rep(i,1,top){
		int d=(s[i+1]-s[i]);
		ans += a[s[i]]*(d+1)+a[s[i+1]]*(d-1);
	}
	rep(i,1,n) ans += c[i]*2;
	return ans/(2.0*(n-1));
}
int main(){
	n = read();
	Rep(i,1,n) a[i] = read();
	Rep(i,1,n) b[i] = read();
	printf("%.12lf\n",solve());
	return 0;
}

Measured memory_bytes: 8432
import sys
input = lambda : sys.stdin.readline().rstrip()

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        ret = power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        ret = n * power(n, r-1, mod) % mod
    return ret


M = 10 **9 + 7
n = int(input())
out = power(10, n, M)  - 2*  power(9, n, M) + power(8, n, M)
out = out %M

print(out)

Measured memory_bytes: 64240
program main;
var
	s, t : string;
    count, i, len : integer;
begin
	readln(s);
	readln(t);
    len := length(t);
    count := 0;
    for i := 1 to len do begin
    	if s[i] <> t[i]
        	then count := count + 1;
    end;
    if count <> 1
    	then writeln('No')
        	else writeln('Yes');
end.
    

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


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

    ans = list()
    ans.append([i % 2 for i in range(len(n))])
    ans.append([i % 2 for i in range(1, len(n) + 1)])

    a = list()
    for i in ans:
        count = 0
        for j in range(len(n)):
            if i[j] == n[j]:
                count += 1

        a.append(count)

    print(min(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5532
#include <iostream>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int k;
  cin >> k;
  queue<ll> que;
  repd(i, 1, 10) que.push(i);
  rep(i, k-1){
    ll a = que.front(); que.pop();
    a = a * 10 + a % 10;
    if(a % 10 != 0) que.push(a-1);
    que.push(a);
    if(a % 10 != 9) que.push(a+1);
  }
  cout << que.front() << endl;
  return 0;
}


Measured memory_bytes: 1792
from itertools import permutations
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

l=[i+1 for i in range(n)]
perm = permutations(l)
perm=list(perm)
p=[]
for i in perm:
    k=(''.join(map(str,i)))
    p.append(int(k))
a=''.join(map(str,a))
b=''.join(map(str,b))
idx1=p.index(int(a))
idx2=p.index(int(b))
print(abs(idx1-idx2))

Measured memory_bytes: 15424