akhauriyash/Code-Regression huggingface dataset:
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=rd())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int rd(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=x*10+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (200010)
#define P (2019)
int n,ans,tmp,p10(1),b[P]{1};
char s[N];
signed main(){
	cin>>s+1,n=strlen(s+1);
	Frn_(i,n,1)tmp=(tmp+p10*(s[i]&15))%P,ans+=b[tmp]++,p10=p10*10%P;
	wr(ans),exit(0);
}


Measured memory_bytes: 3760
#include<iostream> 
using namespace std;
long long mu(long long x,long long y,long long cnt)
{
	if(x>y)
		return cnt;
	else
	{
		x*=2;
		mu(x,y,cnt+1);
	}   
}
int main()
{
	long long x,y;
	cin>>x>>y;
	cout<<mu(x,y,0);
	return 0;
}

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

inline double add(double a, double b){
    return abs(a+b)<(1e-10)*(abs(a)+abs(b)) ? 0.0 : a+b;
}

struct vec{
    double x,y;
    vec operator-(vec b){
        return (vec){add(x,-b.x),add(y,-b.y)};
    }
    vec operator+(vec b){
        return (vec){add(x,b.x),add(y,b.y)};
    }
    vec operator*(double d){
        return (vec){x*d,y*d};
    }
    double dot(vec v){
        return add(x*v.x,y*v.y);
    }
    double cross(vec v){
        return add(x*v.y,-y*v.x);
    }
    double norm(){
        return sqrt(x*x+y*y);
    }
};
typedef vector<vec> polygon;

double area(polygon& g){
    double S=0;
    for(auto i = g.begin()+1; i!=g.end();++i){
        S += (*(i-1)).cross(*i);
    }
    S/=2;
    return S;
}

int main(){
    int n;
    cin >> n;
    polygon g;
    vec v;
    while(n--){
        cin >> v.x >> v.y;
        g.push_back(v);
    }
    g.push_back(g.front());
    cout.precision(1);
    cout << fixed;
    cout << area(g) << endl;
    return 0;
}

Measured memory_bytes: 3224
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    string s;
    cin >> s;
    
    string num = "";
    for(int i = 0; i < s.size(); i++){
        if(s[i] != '/') num += s[i];
    }
    int res = toInt(num);

    if(res <= 20190430) cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x[10000][1440],y[10000],n,m,r,q,i,j,a,b,c,d,s;
int main(){
	while(true){
		memset(x,0,sizeof(x));
		cin>>n>>m>>r;if(n==0){break;}
		for(i=0;i<r;i++){
			cin>>a>>b>>c>>d;
			if(d==1){
				y[c]++;
				for(j=a;j<1440;j++){
					x[c][j]=1;
				}
			}
			else{
				y[c]--;
				if(y[c]==0){
					for(j=a;j<1440;j++){
						x[c][j]=0;
					}
				}
			}
		}
		cin>>q;
		for(i=0;i<q;i++){
			s=0;
			cin>>a>>b>>c;
			for(j=a;j<b;j++){
				if(x[c][j]==1){s++;}
			}
			cout<<s<<endl;
		}
	}
}

Measured memory_bytes: 57456
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;

int main(){
  intl N;
  intl A;
  cin >> N;
  vector <int> BossN (N,0);
  Rep(i,N-1){
    cin >> A;
    BossN.at(A-1) ++;
  }
  
  Rep(i,N-1){
    cout << BossN.at(i) <<endl;
    
  }
  cout << 0;
}
    

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

unsigned long long a[110000];
unsigned long long ppp=1000000000000000000;
int main(){
    ll n;
    unsigned long long ans=1;
    bool p=true;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    if(a[0]==0)cout<<0;
    else{
     
    rep(i,0,n){
       if(ans>ppp/a[i]){p=false;break;}
       else ans*=a[i];
    }
    if(!p)cout<<-1;
    else  cout<<ans;
    }
}


Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<P> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());

    set<int> s;
    s.insert(-1);
    s.insert(N);

    ll ans = 0;

    for(int i=0;i<N;i++){
        int pos = a[i].second;
        ll value = a[i].first;
        auto it = s.upper_bound(pos);
        ll r_small = *it;
        ll l_small = *next(it, -1);
        ans += value * (pos - l_small) * (r_small - pos);
        s.insert(pos);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
A=[0]*N
B=[0]*N
for i in range(N):
    a,b = (int(i) for i in input().split())
    A[i] =(a,b)

#　1本が安い順にソート、安店から順番に買う
A.sort()
num_sum =0
price_sum =0
for i in range(N):
    price,num =A[i]
    if num_sum < M -num:
        num_sum  +=num
        price_sum += price *num
    elif num_sum == M -num:
        price_sum +=price *num
        break
    else:
        price_sum +=price*(M -num_sum)
        break
print(price_sum)

Measured memory_bytes: 23444
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
void print(int x)
{
	if (x >= 10)
		print(x / 10);
	putchar('0' + x % 10);
}
void write(int x, char c)
{
	if (x < 0)
		putchar('-'), x = -x;
	print(x);
	putchar(c);
}
const int P = 998244353;
int add(int a, int b)
{
	return a + b >= P ? a + b - P : a + b;
}
void inc(int &a, int b)
{
	a = add(a, b);
}
int mul(int a, int b)
{
	return 1LL * a * b % P;
}
const int N = 3e3 + 10;
int A, B, C, D, dp[N][N];
int main()
{
	A = read(), B = read(), C = read(), D = read();
	dp[A][B] = 1;
	for (int i = A; i <= C; ++i)
		for (int j = B; j <= D; ++j) if (i != A || j != B)
		{
			dp[i][j] = add(mul(dp[i][j - 1], i), mul(dp[i - 1][j], j));
			if (i > A && j > B)
				inc(dp[i][j], P - mul(mul(i - 1, j - 1), dp[i - 1][j - 1]));
		}
	write(dp[C][D], '\n');
	return 0;
}


Measured memory_bytes: 38860
def main():
    n = int(input())
    # h, w, k = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()

    if n == 1:
        print("Hello World")
    else:
        a = int(input())
        b = int(input())
        print(a+b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61840
#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 ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 100000000001
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0) break;
        a -= d;
        if(a <= 0) break;
    }
    if(a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    ll N,M;
    ll aho[1000];
    ll k=0;
    while(1){
    cin >> N >> M;
    if(N==0&&M==0) break;
    pair<int,int> P[N];
    for(int i=0;i<N;i++){
        cin >> P[i].first >> P[i].second;
    }
    sort(P,P+N);
    int ans = 0;
    int cnt = 0;
    int j=1;
    for(int i=0;i<N;i++){
        if(j==P[i].first){
            cnt = max(cnt,P[i].second);
            if(P[i+1].first!=j){
                j++;
                ans += cnt;
                cnt = 0;
            }
        }
    }
    aho[k] = ans;
    k++;
    }
    for(int i=0;i<k;i++){
        cout << aho[i] << endl;
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long N,D;
    cin>>N>>D;
    
    long ans=0;
    ans+=N/(2*D+1);
    
    if(N%(2*D+1)!=0) ans++;
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	string s;
	cin >> s;
	string t = "keyence";
	for (int i = 0; i < t.size(); i++) {
		if (s[i] != t[i]) {
			reverse(s.begin(), s.end());
			reverse(t.begin(), t.end());
			for (int j = 0; j < t.size(); j++) {
				if (i + j == t.size()) {
					cout << "YES";
					return 0;
				}
				if (s[j] != t[j]) {
					cout << "NO";
					return 0;
				}
			}
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			
			if(m == -1 && f == -1 && r == -1) {
				break;
			}
			
			if(m == -1 || f == -1) {
				System.out.println("F");
			}else if(m+f >= 80) {
				System.out.println("A");
			}else if(m+f >= 65) {
				System.out.println("B");
			}else if(m+f >= 50) {
				System.out.println("C");
			}else if(m+f >= 30) {
				if(r >= 50) {
					System.out.println("C");
				}else {
					System.out.println("D");
				}
			}else {
				System.out.println("F");
			}
		}
	}
}



Measured memory_bytes: 26332
#include <iostream>
using namespace std;
 
int main() {
    int n,count,total;
    while(1){
        cin >> n;
        if(n == 0)break;
        count=0;
        for(int i = 1;i < n;i++){
            total = 0;
            for(int j = i;j < n;j++){
                total += j;
                if(total == n){
                    count++;
                    break;
                }
                else if(total > n){
                    break;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  long long ans = 1;
  for(int i=1; i<N+1; i++){
    ans=(ans*i)%1000000007;
    
  //   cout << ans << endl;
  }
  cout << ans << endl;
 
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define N 21
const ll mod=1e9+7;
ll n;
const ll bit=(1<<21)+2;
ll mat[N+1][N+1];
ll mask[N+1];
ll dp[N+1][bit];
auto addmod(auto a,auto b)
{
	ll res=(a%mod + b%mod)%mod;
	return (res<0)?(res+mod):res%mod;
}
ll go(ll pos=0,ll bitmask=0)
{
	if(pos==n)
	{
		return (__builtin_popcount(bitmask)==n);
	}
	if(dp[pos][bitmask]!=-1)
		return dp[pos][bitmask];
	ll res=0;
	for(int i=0;i<n;i++)
	{
		if(!(bitmask & (1<<i)) and ((1<<i) & mask[pos]))
		{
			res=addmod(res,go(pos+1,bitmask|(1<<i)));
		}
	}
	return dp[pos][bitmask]=res%mod;	
}
int main()
{
	
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			ll x;
			cin>>x;
			if(x)
			{
				mask[i]|=(1<<j);
			}
		}
	}

	cout<<go();
}

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

int main() {

    int N, R;
    cin >> N >> R;

    if (N < 10)
        cout << R + 100 * (10 - N);
    else
        cout << R;

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>

using namespace std;


int dropLeadingZeroes(int n) {

    while (((n % 10) == 0)) {

        n = n / 10;
    }

    return n;
}

int main() {

    int A, B;
    cin >> A >> B;

    int count = 0;

    for (int i = A; i <= B; i++) {

        string s1 = to_string(i);
        string s2 = to_string(dropLeadingZeroes(i));
        reverse(s2.begin(), s2.end());

        if (s1 == s2) {
            count += 1;
        }
    }

    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

# induce sort (internal routine)
def sa_is_induce(s, ls, sum_l, sum_s, lms)
  n = s.size
  sa = [-1]*n

  buf = *sum_s # deep copy
  lms.each{ |lms|
    if lms != n then
      sa[buf[s[lms]]] = lms
      buf[s[lms]] += 1
    end
  }

  buf = *sum_l # deep copy
  sa[buf[s[-1]]] = n-1
  buf[s[-1]] += 1
  sa.each{ |v|
    if v>=1 && !ls[v-1] then
      sa[buf[s[v-1]]] = v-1
      buf[s[v-1]] += 1
    end
  }

  buf = *sum_l # deep copy
  sa.reverse_each{ |v|
    if v>=1 && ls[v-1] then
      buf[s[v-1]+1] -= 1
      sa[buf[s[v-1]+1]] = v-1
    end
  }

  return sa
end

# SA-IS (internal routine)
def sa_is(s, upper)
  n = s.size

  return [] if n == 0
  return [0] if n == 1

  ls = [false]*n
  (n-2).downto(0){ |i|
    ls[i] = s[i]==s[i+1] ? ls[i+1] : s[i]<s[i+1]
  }

  sum_l = [0]*(upper+1)
  sum_s = [0]*(upper+1)
  n.times{ |i|
    if ls[i] then
      sum_l[s[i]+1] += 1
    else
      sum_s[s[i]] += 1
    end
  }
  0.upto(upper){ |i|
    sum_s[i] += sum_l[i]
    sum_l[i+1] += sum_s[i] if i<upper
  }

  lms = (1 ... n).select{ |i| !ls[i-1] && ls[i] }
  m=lms.size
  lms_map = [-1]*(n+1)
  lms.each_with_index{ |lms, id| lms_map[lms] = id }

  sa = sa_is_induce(s, ls, sum_l, sum_s, lms)

  return sa if m == 0

  sorted_lms = sa.select{ |sa| lms_map[sa] != -1 }
  rec_s = [0]*m
  rec_upper = 0
  rec_s[lms_map[sorted_lms[0]]] = 0
  1.upto(m-1){ |i|
    l, r = sorted_lms[i-1, 2]
    end_l = lms[lms_map[l]+1]||n
    end_r = lms[lms_map[r]+1]||n
    same = true
    if end_l-l != end_r-r then
      same = false
    else
      while l < end_l do
        break if s[l] != s[r]
        l+=1
        r+=1
      end
      same = false if l==n || s[l]!=s[r]
    end
    rec_upper += 1 if not same
    rec_s[lms_map[sorted_lms[i]]] = rec_upper
  }

  sa_is(rec_s, rec_upper).each_with_index{ |rec_sa, id|
    sorted_lms[id] = lms[rec_sa]
  }

  return sa_is_induce(s, ls, sum_l, sum_s, sorted_lms)
end

# suffix array for array of integers or string
def suffix_array(s, upper = nil)
  if not upper then
  	case s
  	when Array
      # compression
      n = s.size
      idx = (0 ... n).sort_by{ |i| s[i] }
      t = [0]*n
      upper = 0
      t[idx[0]] = 0
      1.upto(n-1){ |i|
        upper += 1 if s[idx[i-1]] != s[idx[i]]
        t[idx[i]] = upper
      }
      s = t
    when String
      upper = 255
      s = s.bytes
    end
  end
  return sa_is(s, upper)
end

# frozen_string_literal: true

# lcp array for array of integers
def lcp(s, sa)
  n = s.size
  rnk = [0]*n
  sa.each_with_index{ |sa, id|
    rnk[sa] = id
  }
  
  lcp = [0]*(n-1)
  h = 0
  n.times{ |i|
    h -= 1 if h > 0
    next if rnk[i] == 0
    j = sa[rnk[i]-1]
    h += 1 while j+h<n && i+h<n && s[j+h]==s[i+h]
    lcp[rnk[i]-1] = h
  }
  return lcp
end

# lcp array for string
def lcp_array(s, sa)
  return lcp(s.bytes, sa)
end

s = gets.chomp
lcp = lcp_array(s, suffix_array(s))
ans = s.size*(s.size+1)/2
lcp.each{ |lcp| ans -= lcp }
puts ans


Measured memory_bytes: 67372
#include<iostream>
using namespace std;main(){int n,m[20],d[20][31],i,j,a;for(string N[20];cin>>n,n;){int c[31]={0},p[31]={0};for(i=n;i-->0;)for(cin>>N[i]>>m[i],a=j=0;j<m[i];c[d[i][j++]]++)cin>>d[i][j];for(;++i<n;p[a]==p[i]&N[a]>N[i]|p[a]>p[i]&&(a=i))for(j=0;j<m[i];j++)p[i]+=n+1-c[d[i][j]];cout<<p[a]<<" "<<N[a]<<endl;}}

Measured memory_bytes: 0
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

def func(lv, id):
    sz = 4 * 2 ** lv - 3
    num = 2 * 2 ** lv - 1
    mid = (sz + 1) / 2
    if lv == 0:
        return 1
    if id == 1:
        return 0
    if id == mid:
        return (num - 1) / 2 + 1
    if id == sz:
        return num
    if 1 < id < mid:
        return func(lv - 1, id - 1)
    if mid < id < sz:
        return func(lv - 1, id - (sz - 3) / 2 - 2) + (num - 1) / 2 + 1

print func(*map(int, raw_input().split()))


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

// ABC059A Three-letter acronym

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << char(toupper(s1[0])) << char(toupper(s2[0])) << char(toupper(s3[0])) << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions

a, b, c, d = map(int, input().split())
cd = (c * d) // fractions.gcd(c, d)
a = a - 1
ac = a // c
ad = a // d
acd = a // cd
bc = b // c
bd = b // d
bcd = b // cd

ans = (b - a) - (bc + bd - bcd - (ac + ad - acd))
print(ans)

Measured memory_bytes: 5048
/* **********************************JAI SAI RAM ************************************* */
// Help in Codeforces  Round Div2 of Devil.
//Well this is just a mere fun.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> adj[200001];
ll vis[20001];
void  solve()
{
  ll i,j,l,k,m,n,o,p,q,r,t,x,y;
  cin>>p>>q>>r;
  cin>>x;
  o=0;
  while(q<=p)
  {
  q*=2;
  o++;
  }
  while(r<=q)
  {
      r*=2;
      o++;
  }

  if(o<=x)
  cout<<"Yes\n";
  else 
  cout<<"No\n";
  return;
  if(x>=400&&x<=599)
  cout<<"8\n";
  if(x>=600&&x<=799)
  cout<<"7\n";
  if(x>=800&&x<=999)
  cout<<"6\n";
  if(x>=1000&&x<=1199)
  cout<<"5\n";
  if(x>=1200&&x<=1399)
  cout<<"4\n";
  if(x>=1400&&x<=1599)
  cout<<"3\n";
  if(x>=1600&&x<=1799)
  cout<<"2\n";
  if(x>=1800&&x<=1999)
  cout<<"1\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,n,m,k;
    n=1;
     t=n;
    while(t--)
    {
       solve();
       n++;
    }
    return 0;
}
    


Measured memory_bytes: 8300
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
typedef pair<int, int> pii;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 5005
const ll INF = 1e9 + 7;


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

const ll MOD = 1e9 + 7;

int main() {

	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll p = 1e9 + 7;
//const ll p = 998244353;
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//二項係数 mod p
long long modinv(long long n, long long p) {
	long long a = p, u = 1, v = 0;
	while (a) {
		long long t = n / a;
		n -= t * a;
		std::swap(n, a);
		u -= t * v;
		std::swap(u, v);
	}
	u %= p;
	if (u < 0) u += p;
	return u;
}

vll factorial;
vll factorial_inv;
void make_table(ll n, ll p) {
	factorial.resize(n, 1);
	factorial_inv.resize(n, 1);
	for (ll i = 2; i <= n; i++) {
		factorial[i] = factorial[i - 1] * i % p;
	}
	factorial_inv[n] = modinv(factorial[n], p);
	for (ll i = n - 1; i >= 2; i--) {
		factorial_inv[i] = factorial_inv[i + 1] * (i + 1) % p;
	}
}

ll combination(ll n, ll r, ll p) {
	r = min(r, n - r);
	ll ret = factorial[n] * factorial_inv[r] % p;
	ret *= factorial_inv[n - r];
	ret %= p;
	return ret;
}

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

	ll x, y;
	cin >> x >> y;
	if ((x + y) % 3) cout << 0 << endl;
	else {
		ll z = (x + y) / 3;
		if (x < z || y < z) cout << 0 << endl;
		else {
			make_table(1e6, p);
			cout << combination(z, x - z, p) << endl;
		}
	}
}


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};


void Main()
{
	int N,M,K;
	cin>>N>>M>>K;
	vec(A,N);
	vec(B,M);
	vin(A);
	vin(B);

	vector<ll> sumA(N+1,0);
	vector<ll> sumB(M+1,0);
	rep(i,N){
		sumA[i+1]=sumA[i]+A[i];
		dout<<"sumA"<<i<<':'<<sumA[i]<<_n;
	}
		dout<<"sumA"<<N<<':'<<sumA[N]<<_n;
	rep(i,M){
		sumB[i+1]=sumB[i]+B[i];
		dout<<"sumB"<<i<<':'<<sumB[i]<<_n;
	}
		dout<<"sumB"<<M<<':'<<sumB[M]<<_n;

	int ans=0;

	rep(i,N+1){
		if(sumA[i]>K)break;
		ans=max(ans,i);
		int l=-1,r=M+1;
		while(abs(l-r)>1){
			int mid=(l+r)/2;
			if(sumB[mid]<=(K-sumA[i])){ ans=max(ans,i+mid); l=mid;}
			else r=mid;
		}
	}

	cout<<ans<<endl;
}



int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 7956
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	string s, t; cin >> s >> t;


	LL ans = 0;
	int i = 0;
	int mode = 1;
	if (s[0]==t[0]) {
		ans = 3;
		i = 1;
	}
	else {
		ans = 6;
		i = 2;
		mode *= -1;
	}

	while (i<=n-1) {

		if (mode == 1) {
			if (s[i] == t[i]) {
				ans *= 2;
				ans %= MOD;
				i++;
			}
			else {
				ans *= 2;
				ans %= MOD;
				i += 2;
				mode *= -1;
			}
		}
		else {
			if (s[i] == t[i]) {
				i++;
				mode *= -1;
			}
			else {
				ans *= 3;
				ans %= MOD;
				i += 2;
			}
		
		}
		
	}

	cout << ans << endl;


	return 0;
}

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

int main(void) {
  int N, K;
  cin >> N >> K;

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

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

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += l[i];
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{	
	char C;

	scanf("%c",&C);
	if('a'<=C&&'z'>=C){
		if(C=='a'||C=='i'||C=='u'||C=='e'||C=='o'){
		printf("vowel");}
	else{
		printf("consonant");}}

	return 0;}

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

int main(){
    string S;
    cin >> S;
    bool flag=1;
    if(S[0]!='A')
    flag=0;
    int s=S.size(),cnt=0,m;
    for(int i=2;i<s-1;i++){
        if(S[i]=='C'){
        cnt++;
        m=i;
        }
    }
    if(cnt!=1)
        flag=0;
    for(int i=1;i<s;i++)
    if(i!=m){
        if(S[i]>='A'&&S[i]<='Z')
        flag=0;
    }
    if(flag)
    cout << "AC" << endl;
    else
    cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

main(){
  int n, a[N], i, j, minj, conut = 0, b, c;

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &a[i]);
  }
  for(i = 0;i < n;i++){
    minj = i;
    for(j = i;j < n;j++){
      if(a[j] < a[minj]){
	minj = j;
      }
    }
    if(i != minj){
      b = a[i];
      c = a[minj];
      a[i] = c;
      a[minj] = b;
      conut++;
    }
  }
  for(i = 0;i < n-1;i++){
    printf("%d ", a[i]);
  }
  printf("%d\n", a[n-1]);
  printf("%d\n", conut);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,k,r,s,p,ans;
string t;
int main(void){
    cin>>n>>k>>r>>s>>p>>t;
    for(int i=0;i<t.size();i++){
        if(i>=k){
            if(t[i]=='r'){
                if(t[i-k]=='r'){
                    t[i]='x';
                }else{
                    ans+=p;
                }
            }else if(t[i]=='s'){
                if(t[i-k]=='s'){
                    t[i]='x';
                }else{
                    ans+=r;
                }
            }else{
                if(t[i-k]=='p'){
                    t[i]='x';
                }else{
                    ans+=s;
                }
            }
        }else{
            if(t[i]=='r'){
                ans+=p;
            }else if(t[i]=='s'){
                ans+=r;
            }else{
                ans+=s;
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3776
N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
R=[0]*N
L=[0]*N
for i in range(N):
    r,l=0,0
    a=A[i]
    for j in range(N):
        if i<j:
            if a>A[j]:
                r+=1
        else:
            if a>A[j]:
                l+=1
    R[i]=r
    L[i]=l
ans=0
for i in range(N):
    ans+=K*R[i]+(L[i]+R[i])*(K-1)*K//2%mod
    ans%=mod
print(ans)



Measured memory_bytes: 74180
def is_strong_kaibun(s):
    # kaibun
    if not is_kaibun(s):
        return False

    n = len(s)
    subs = s[:(n-1)//2]
    if not is_kaibun(subs):
        return False

    subs = s[((n+3)//2)-1:]
    if not is_kaibun(subs):
        return False

    return True

def is_kaibun(s):
    return s == s[::-1]


s = input()

if is_strong_kaibun(s):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    vector<ll> ct(5,0);
    int n;
    cin>>n;
    rep(i,0,n){
        string s;
         cin>>s;
         if(s[0]=='M')ct[0]++;
         else if(s[0]=='A')ct[1]++;
         else if(s[0]=='R')ct[2]++;
         else if(s[0]=='C')ct[3]++;
         else if(s[0]=='H')ct[4]++;
    }
    
    
    ll ans=0;
    rep(i,0,5){
        rep(j,i+1,5){
            rep(k,j+1,5){
                ans+=ll(ct[i]*ct[j]*ct[k]);
            }
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)
 
typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define vpll vector<pll> 
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

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

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return abs(a); }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q, k, r;

string a, b;

void solve(){
    cin >> n;
    int ans = 9;
    for(int i = 400; i <= 1800; i += 200)
        ans -= n >= i;
    cout << ans << '\n';
}

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

  q = 1;
  // cin >> q;

  for(int i = 1; i <= q; i++)
    solve();
} 

Measured memory_bytes: 3668
#include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  pair<int,int> a;
  map<pair<int,int>,int> store;
  int i,j,n,m,x[210],y[210],x1[1010],y1[1010],k,l,check=0;
  while(1){
  scanf("%d\n",&m);
    if(m==0){
      return 0;
    }
  for(i=0;i<m;i++){
    scanf("%d %d\n",&x[i],&y[i]);
  }
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%d %d\n",&a.first,&a.second);
    x1[i]=a.first,y1[i]=a.second;
    store[a]=1;
  }
  for(i=0;i<n;i++){
    k=x1[i]-x[0],l=y1[i]-y[0];
    for(j=1;j<m;j++){
      a.first=x[j]+k,a.second=y[j]+l;
      if(store[a]!=1){
        check=1;
        break;
      }
    }
    if(check==0){
      printf("%d %d\n",k,l);
      break;
    }
    check=0;
  }
  }
  return 0;
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<char> S(N);
  K--;
  for(int i = 0; i < N; i++) {cin >> S.at(i);}
  if (S.at(K) == 'A') {S.at(K) = 'a';}
  else if (S.at(K) == 'B') {S.at(K) = 'b';} 
  else if (S.at(K) == 'C') {S.at(K) = 'c';}
  else if (S.at(K) == 'D') {S.at(K) = 'd';}
  else if (S.at(K) == 'E') {S.at(K) = 'e';}
  else if (S.at(K) == 'F') {S.at(K) = 'f';}
  else if (S.at(K) == 'G') {S.at(K) = 'g';}
  else if (S.at(K) == 'H') {S.at(K) = 'h';}
  else if (S.at(K) == 'I') {S.at(K) = 'i';}
  else if (S.at(K) == 'J') {S.at(K) = 'j';}
  else if (S.at(K) == 'K') {S.at(K) = 'k';}
  else if (S.at(K) == 'L') {S.at(K) = 'l';}
  else if (S.at(K) == 'M') {S.at(K) = 'm';}
  else if (S.at(K) == 'N') {S.at(K) = 'n';}
  else if (S.at(K) == 'O') {S.at(K) = 'o';}
  else if (S.at(K) == 'P') {S.at(K) = 'p';}
  else if (S.at(K) == 'Q') {S.at(K) = 'q';}
  else if (S.at(K) == 'R') {S.at(K) = 'r';}
  else if (S.at(K) == 'S') {S.at(K) = 's';}
  else if (S.at(K) == 'T') {S.at(K) = 't';}
  else if (S.at(K) == 'U') {S.at(K) = 'u';}
  else if (S.at(K) == 'V') {S.at(K) = 'v';}
  else if (S.at(K) == 'W') {S.at(K) = 'w';}
  else if (S.at(K) == 'X') {S.at(K) = 'x';}
  else if (S.at(K) == 'Y') {S.at(K) = 'y';}
  else {S.at(K) = 'z';}
  for (int i = 0; i < N; i++) {cout << S.at(i);}
}

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

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

	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0)
		cout << "Zero\n";
	else if (b < 0)
	{
		if ((b - a + 1) % 2 == 1)
			cout << "Negative\n";
		else
			cout << "Positive\n";
	}
	else if (a > 0)
		cout << "Positive\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int I, O, T, J, L, S, Z;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> I >> O >> T >> J >> L >> S >> Z;
    ll ans = 0;
    if(I && J && L && I % 2 + J % 2 + L % 2 >= 2){
        I--;
        J--;
        L--;
        ans += 3;
    }
    ans += J / 2 * 2;
    ans += L / 2 * 2;
    ans += I / 2 * 2;
    ans += O;
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;

    class Program
    {
        static void Main()
        {
            var inputList = Console.ReadLine().Split(' ').ToList();
            var a = inputList[0].ToInt32();
            var b = inputList[1].ToInt32();
            var c = inputList[2].ToInt32();
            var k = inputList[3].ToInt32();
            var ans = 0;
            if (k <= a)
            {
                ans = k;
            }
            else if (a < k && k <= a + b)
            {
                ans = a;
            }
            else if (a + b < k)
            {
                ans = a - (k - a - b);
            }

            Console.WriteLine(ans.ToString());
        }
    }
    static class Extentions
    {
        #region 拡張メソッド（string）

        public static string LeftB(this string stTarget, int iByteSize)
        {
            return MidB(stTarget, 1, iByteSize);
        }

        public static string MidB(this string stTarget, int iStart)
        {
            System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8");
            byte[] bBytes = hEncoding.GetBytes(stTarget);

            return hEncoding.GetString(bBytes, iStart - 1, bBytes.Length - iStart + 1);
        }

        public static string MidB(this string stTarget, int iStart, int iByteSize)
        {
            System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8");
            byte[] bBytes = hEncoding.GetBytes(stTarget);

            return hEncoding.GetString(bBytes, iStart - 1, iByteSize);
        }

        public static string RightB(this string stTarget, int iByteSize)
        {
            System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8");
            byte[] bBytes = hEncoding.GetBytes(stTarget);

            return hEncoding.GetString(bBytes, bBytes.Length - iByteSize, iByteSize);
        }

        public static bool IsNullOrEmpty(this string str)
        {
            return string.IsNullOrEmpty(str);
        }

        /// <summary>
        /// カルチャに依存した比較、または大文字と小文字を区別しない比較などの序数による比較を指定できる Contains。
        /// </summary>
        /// <param name="value">対象文字列</param>
        /// <param name="partialValue">部分文字列</param>
        /// <param name="comparison">カルチャ、大文字と小文字の区別、および並べ替え規則を指定する StringComparison</param>
        /// <returns>一致する場合に true を返します。</returns>
        public static bool Contains(this string value, string partialValue, StringComparison comparison = 0)
        {
            return value.IndexOf(partialValue, comparison) >= 0;
        }

        public static bool IsNumeric(this string value)
        {
            return decimal.TryParse(value, out decimal d);
        }
        public static int ToInt32(this String number, int retValue = 0)
        {
            if (!number.IsNumeric()) return retValue;
            return int.Parse(number);
        }

        #endregion
    }


Measured memory_bytes: 18984
import sys
import math

input = sys.stdin.readline
n = int(input())
k = int(input())
t = n
m = 0
while t:
    m += 1
    t //= 10

def comb(n, r):
    if r > n:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 9 ** k * comb(m-1, k)
tk = k

def dfs(i, mt, kt):
    a = i // 10 ** mt
    b = n // 10 ** mt
    if kt < 0:
        return 0
    if mt < kt:
        return 0
    if a < b:
        if mt > 0:
            return 9 ** kt * comb(mt, kt)
        else:
            return 1
    elif a > b:
        return 0
    if i == n and kt == 0:
        return 1
    elif i > n:
        return 0
    ret = 0
    for j in range(10):
        f = 0
        if j != 0:
            f = 1
        ret += dfs(i+j*10**(mt-1), mt-1, kt-f)
    return ret

t_ans = 0
for i in range(1, n // (10 ** (m-1) )+1):
    ti = i * 10 ** (m-1)
    t_ans += dfs(ti, m-1, k-1)

print(int(ans+t_ans))


Measured memory_bytes: 3064
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/

int e_gcd(int x, int y)
{
	if (x < y) e_gcd(y, x);

	int r;
	r = x % y;
	while (r) {
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}

/*ここからmain関数*/

int main()
{
	int N, A[100000];
	cin >> N;
	for (int i = 0;i < N;i++)
		cin >> A[i];

	int Z[100000];
	int mnum = 0;
	int m = max(A[0], A[0] * (-1));
	long int ans = 0;
	for (int i = 0;i < N;i++)
	{
		Z[i] = max(A[i], (-1)*A[i]);
		if (A[i] != Z[i])
			mnum++;
		m = min(m, Z[i]);
		ans += Z[i];
	}

	if (mnum % 2 == 0)
		cout << ans;
	else
		cout << ans - 2 * m;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}


Measured memory_bytes: 640
# coding: utf-8
N = gets.to_i
nums = gets.split.map {|e| e.to_i}

# 偶数だけ抽出
nums_even = nums.select {|e| e.even?}

# 全てが3または5で割り切れるか？
nums_even.each do |e|
  if (e%3 != 0) and (e%5 != 0)
    puts 'DENIED'
    exit 0
  end
end
puts 'APPROVED'



Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>

#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, weight;

	bool operator < (const Edge& obj) const {
		return weight < obj.weight;
	}
	bool operator > (const Edge& obj) const {
		return weight > obj.weight;
	}
};

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int arr[100001];
void Eratosthenes(int N) {//Nまでの素数表
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = i * 2; j <= N; j += i) {
				arr[j] = 0;
			}
		}
	}
}

int main()
{

	Eratosthenes(100000);
	vector<int> sim;
	rep(i, 3, 100001) {
		if (arr[i] && arr[(i + 1) / 2]) sim.push_back(i);
	}

	int q;
	cin >> q;
	REP(i, q) {
		int l, r;
		scanf("%d %d", &l, &r);
	
		cout << upper_bound(ALL(sim), r) - lower_bound(ALL(sim), l) << endl;
	
	}




	return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
	    void solve(IO io, PrintWriter out)
	    {
          int x = io.nextInt();
          int y = io.nextInt();
          int min=-1;
          for(int i=1 ; i<=1250 ; i++)
          {
            int tmp = (int)Math.floor((i*8)/100);
            int tmp1 = (int)Math.floor(i/10);
            if(tmp==x && tmp1==y){
              min=i;
              break;
            }
          }
          out.print(min);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}

Measured memory_bytes: 24788
import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    x = list(IL())
    s = sum(x)
    ans = abs(s-n)
    i = 1
    while True:
        i += 1
        tmp = abs(s-i*n)
        if ans <= tmp: 
            i -= 1
            ans = 0
            break
        ans = tmp
        
    for rep in x:
        ans += (rep-i)*(rep-i)
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9212