akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=200004;
ll fact[N], invFact[N];
ll add(ll x,ll y){x+=y;return x%hell;}
ll mult(ll x,ll y){return (1LL*x*y)%hell;}
ll powMod(ll base,ll expo){
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
ll C(ll a, ll b){
	if(a<0 || b<0 || a<b)return 0;
	return mult(fact[a],mult(invFact[b],invFact[a-b]));
}
bool cmp(pair<ll,ll>& a,pair<ll,ll>& b){
	return a.fi+a.se-2<b.fi+b.se-2;
}
ll f(ll x,ll y){return C(x+y,y);}
void solve(){
	ll h, w, n;
	cin>>h>>w>>n;
	vector<pair<ll,ll> > v(n+1);
	for(auto &u : v)
		cin>>u.fi>>u.se;
	v[n].fi=h;
	v[n].se=w;
	sort(all(v),cmp);
	vector<ll> dp(n+1);
	rep(i,0,n+1){
		dp[i]=f(v[i].fi-1,v[i].se-1);
		rep(j,0,i){
			if(v[j].fi<=v[i].fi && v[j].se <= v[i].se){
				ll tmp=f(v[i].fi-v[j].fi,v[i].se-v[j].se);
				dp[i]=add(dp[i],hell-mult(dp[j],tmp));
			}
		}
	}
	cout<<dp[n]<<endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fact[0]=1;
    rep(i,1,N)fact[i]=mult(fact[i-1],i);
    invFact[N-1]=powMod(fact[N-1],hell-2);
    for(ll i=N-2;i>=0;i--)invFact[i]=mult(invFact[i+1],i+1);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


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

int main(){
    int n;
    int m;
    cin >> n;
    cin >> m;
    int a[m];

    for (int i=0; i < m; i++) {
        cin >> a[i];
    }
    int sum=0;
    for (int i=0; i<m; i++) {
        sum += a[i];
    }

    if (n < sum) {
        cout << -1 << endl;
    } else {
        cout << n - sum << endl;
    }
}

Measured memory_bytes: 3680
#include <iostream>

using namespace std;

int const mmax = 10;
int bad[1 + mmax];

bool good(int n, int m){
  while(n > 0){
    int temp = n % 10;
    for(int i = 1;i <= m;i++){
      if(bad[i] == temp){
        return false;
      }
    }
    n /= 10;
  }
  return true;
}

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 1;i <= m;i++){
      cin >> bad[i];
    }
    while(!good(n, m)){
      n++;
    }
    cout << n;
    return 0;
}


Measured memory_bytes: 256
<?php
list($n, $m) = explode(" ", fgets(STDIN));
$array = [];
$country_array = array_fill(1, $n, 1);
for($i=0;  $i<$m; $i++){
	$ar = explode(" ", trim(fgets(STDIN)));
	$array[] = $ar;
}
asort($array);
foreach ($array as $key=>$value) {
	$num1 = $value[0];
	$num2 = $value[1];
	$num3 = $country_array[$num1];
	$country_array[$num1] +=1;
	$array[$key][] = make_ans_num($num1, $num3);
}
ksort($array);
foreach ($array as $value) {
	echo $value[2] ."\n";
}

// 0うめする関数
function make_ans_num ($num1, $num2){
	$leftnum = sprintf('%06d', $num1);
	$rightnum = sprintf('%06d', $num2);
	return $leftnum . $rightnum;
}


Measured memory_bytes: 101236
from collections import Counter
 
N = int(input())
D = list(input().split())
 
M = int(input())
T = list(input().split())
 
D_count = Counter(D)
T_count = Counter(T)

for k, v in T_count.items():
    if D_count[k] < v:
        print('NO')
        exit()
 
print('YES')
           

Measured memory_bytes: 126164
#include<bits/stdc++.h>
#define append push_back
#define endl "\n"
#define N 9000000
#define M 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define cover(arr,val) memset(arr,val,sizeof(arr)) 
using namespace std;
vector<ll>prime;
//void sieve();
ll solve(ll g);
ll gcd(ll x,ll y);

int main()
{
	IOS;
	/*sieve();*/
	ll x,y;
	cin >> x >> y;
	ll g;
	g = gcd(x,y);
	
	printf("%lld\n",1+solve(g));
	return 0;
}
ll gcd(ll x,ll y)
{
	ll p = max(x,y);
	y = min(x,y);
	x = p;
	while(y>0)
	{
		p = x%y;
		x = y;
		y = p;
	}
	return x;
}
ll solve(ll x)
{
	int i=0;
	int count =0;
	for(int i=2;i<sqrt(x);i++)
	{
		if(x%i==0)
		{	
			while(x%i==0)
				x=x/i;
			count++;
		}
	}
  	if(2<x)
      count++;
	return count;
}
/*void sieve()
{
	bool arr[N];

}
*/


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

ll a[2 * INM];
ll cnt[2 * INM] = {};

int main() {
	IOS();
	ll n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	vector<ll> ans;
	bool ok = true;
	for (int i = n; i >= 1; i--) {
		ll sum = 0;
		for (int j = i; j <= n; j += i) {
			sum += cnt[j];
		}
		if ((sum % 2) != a[i]) {
			cnt[i]++;
			ans.push_back(i);
		}
	}
	if (!ok) {
		dump(-1);
		return 0;
	}
	if (ans.empty()) {
		dump(0);
		return 0;
	}
	dump(ans.size());
	reverse(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		if (i) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 4980
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	enum COLOR{
		R=1,
		W=2,
	};
	int N,M;
	cin>>N>>M;
	int *x = new int[M];
	int *y=new int[M];
	int *B=new int[N];
	int *n=new int[N];
	int i;
	B[0]=R;
	n[0]=1;
	for (i=1;i<N;i++){
		B[i]=W;
		n[i]=1;
	}
	for (i=0;i<M;i++){
		cin>>x[i]>>y[i];
		x[i]--;
		y[i]--;
	}
	for (i=0;i<M;i++){
		if (n[x[i]]>0){
			if (B[x[i]]==R){
				B[y[i]]=R;
			}else{
				if (n[y[i]]==0){
					B[y[i]]=W;
				}
			}
			n[y[i]]++;
			n[x[i]]--;
			if (n[x[i]]==0){
				B[x[i]]=W;
			}

		}
	}
	int num=0;
	for (i=0;i<N;i++){
		if (B[i]==R){
			num++;
		}
	}
	cout<<num<<endl;
	delete[] x;
	delete[] y;
	delete[] B;
	delete[] n;
	return 0;
}

Measured memory_bytes: 1792
n=int(input())
s=list(input())
l=[chr(i) for i in range(65, 65+26)]

ans=''
for i in range(len(s)):
    a=l.index(s[i])
    if a+n<=25:
        ans+=l[a+n]
    else:
        ans+=l[a+n-26]
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdbool.h>


int main(void){
    int flag=0;
    int n=0;
    int array[100000]={0};
    int patern=0;
    scanf("%d",&n);
    // 入力
    for(int i=0;i<n;i++){
        scanf("%d",&array[i]);
    }
    for(int i=0;i<n;i++){
        flag=0;
        for(int j=0;j<=30 && flag==0;j++){
            flag=array[i]%2;
            if(flag==0){
                patern+=1;
                array[i]>>=1;
            }
        }
    }
    printf("%d",patern);
    return 0;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7)


n,u,v=map(int, input().split())
u-=1
v-=1

graph = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b=map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

# ab=[list(map(int, input().split())) for _ in range(n-1)]
# for a,b in ab:
#     graph[a-1].append(b-1)
#     graph[b-1].append(a-1)

dist=[[-1, -1] for _ in range(n)]
dist[v][0]=0
dist[u][1]=0

def dfs1(graph,v):
    vv=graph[v]
    for vvv in vv:
        if dist[vvv][0]==-1:
            dist[vvv][0]=dist[v][0]+1
            dfs1(graph,vvv)

def dfs2(graph,v):
    vv=graph[v]
    for vvv in vv:
        if dist[vvv][1]==-1:
            dist[vvv][1]=dist[v][1]+1
            dfs2(graph,vvv)

dfs1(graph,v)
dfs2(graph,u)
dist.sort(reverse=True)

for i in range(10**6):
    if dist[i][0]-dist[i][1]>=1:
        print(dist[i][0]-1)
        break


Measured memory_bytes: 106588
//Greatest Common Divisor
#include <iostream>
#include <cmath>

using namespace std;

int greatestCommonDivisor(int a, int b) {
    if(a < b) swap(a, b);
    while(a%b != 0) {
        int r = a%b;
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int a, b;
    cin >> a >> b;

    cout << greatestCommonDivisor(a, b) << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>

using namespace std;

int main(){
    int n,p;
    cin>>n>>p;
    vl a(n);
    int oc=0,ec=0;
    pan(i,n){
        cin>>a[i];
        a[i]%=2;
        if(a[i]==0) ec++;
        else oc++;
    }
    ll ans=0;
    ll o=0,c=0,e=0;
    if(p==1){ 
        o=(oc>0) ? pow(2,oc-1):1;
        c=(ec>0) ? pow(2,ec):1;
        if(oc>0) ans=o*c;
        else ans=0;
    }
    else{
        // cout<<"oc : "<<oc <<endl;
        o=(oc>0) ? pow(2,oc-1):1;
        e=(ec>0) ? pow(2,ec):1;
        ans=o*e;
    }
    cout<<ans;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a[101];
  if(s[0]=='I'){
    a[0]=1;
  }else{
    a[0]=-1;
  }
  for(int i=1;i<n;i++){
    if(s[i]=='I'){
      a[i]=a[i-1]+1;
    }else{
       a[i]=a[i-1]-1;
    }
  }
  sort(a,a+n);
  if(a[n-1]>=0){
  cout<<a[n-1];
}else{
  cout<<0;
}





}



Measured memory_bytes: 256
var
  i,n,k,s,t:longint;
 begin
  readln(n);
  readln(k);
  s:=0;
  for i:=1 to n do
    begin
      read(t);
      if t<k-t+1 then s:=s+t
	else s:=s+(k-t);
    end;
  writeln(s*2);
 end.



Measured memory_bytes: 128
#define CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	char S[3],T[3];
	int count = 0;
	scanf("%s", S);
	scanf("%s", T);
	for (int i = 0; i <= 2; i++) {
		if (S[i] == T[i]) {
			count++;
		}
	}
	printf("%d\n", count);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d,e,n=0;
  cin>>a>>b>>c>>d>>e;
  if(a%10)n=max(n,10-a%10),a+=10-a%10;
  if(b%10)n=max(n,10-b%10),b+=10-b%10;
  if(c%10)n=max(n,10-c%10),c+=10-c%10;
  if(d%10)n=max(n,10-d%10),d+=10-d%10;
  if(e%10)n=max(n,10-e%10),e+=10-e%10;
  cout<<a+b+c+d+e-n<<endl;
  return 0;
}

Measured memory_bytes: 256
import kotlin.math.floor
import kotlin.math.sqrt

fun main() {
    val n = readLine()!!.toInt()
    var sum = 0L
    for (a in 1..floor(sqrt(n.toDouble())).toInt()) {
        for (b in a..n) {
            if (a*b >= n) {
                break
            }
            sum += if (a == b) 1 else 2
        }
    }
    println(sum)
}

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

int main()
{
	int n;
	cin>>n;
	vector<unsigned long long> a(n);
	unsigned long long pro = 1;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	bool flag = true;
	for(int i=0;i<n;i++){
		if(a[i]==0){
			flag = false;
			pro = 0;
			break;
		}
	}
  	unsigned long long b = (unsigned long long)1000000000000000000;
    long long ans = 0; 
	if(flag){
		for(int i=0;i<n;i++){
			unsigned long long prepro = pro;
          	pro *= a[i];
          	
			if(b<pro || prepro > pro || pro < a[i]){
				ans = -1;
				break;
			}
		}
	}
    if(ans != -1){
      	ans = pro;
    }
	cout<<ans<<endl;
}


Measured memory_bytes: 4040
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    long int res=0;
    long int cnt=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='W'){
            res+=i-cnt;
            cnt++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 640
n = int(input())
count_ans = 0
for i in range(n//2 + 1 if n%2 ==1 else n//2):
  count_y = 0
  for j in range(2*i+2):
    if j > 0:
      if (2 * i + 1)%j == 0:
        count_y += 1
  if count_y == 8:
    count_ans += 1
print(count_ans)

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

const ll mod = 1000000007;

ll pow_mod(ll x, ll y, const ll mod) {
  // return x^y % mod
  if (y == 0) return 1;
  ll a = pow_mod(x, y/2, mod);
  a = (a * a) % mod;
  if (y & 1) a = (a * x) % mod;
  return a;
}

int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  vector<ll> C(k+1);
  for (ll x=k; x>0; x--) {
    ll num;
    num = pow_mod(k / x, n, mod);
    ll i = 2;
    while (i * x <= k) {
      num = (num - C[i*x] + mod) % mod;
      i++;
    }
    C[x] = num;
    ans += num * x % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4052
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, sum;

int main()
{
	in >> N;
	auto N_ = N;
	while (N_ > 0)
	{
		sum += N_ % 10;
		N_ /= 10;
	}
	out << (N%sum == 0 ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;

void J();
void C();
void E();
void A();
void P();
void M();

int n, len;
string data;

int main()
{
    cin >> n;
    rep(state, n) {
        string change;
        cin >> change >> data;
        len = data.length();
        for (int i = change.length()-1; i >= 0; i--) {
            if (change[i] == 'J') {
                J();
            } else if (change[i] == 'C') {
                C();
            } else if (change[i] == 'E') {
                E();
            } else if (change[i] == 'A') {
                A();
            } else if (change[i] == 'P') {
                P();
            } else if (change[i] == 'M') {
                M();
            }
        }
        cout << data << endl;
    }
    return 0;
}

void C()
{
    char tmp = data[0];
    rep(i, len-1) {
        data[i] = data[i+1];
    }
    data[len-1] = tmp;
}

void J()
{
    char tmp = data[len-1];
    for (int i = len - 1; i > 0; i--) {
        data[i] = data[i-1];
    }
    data[0] = tmp;
}

void E()
{
    int odd = len % 2;
    for (int i = 0; i < len/2; i++) {
        char tmp = data[i];
        data[i] = data[i + len / 2 + odd];
        data[i + len / 2 + odd] = tmp;
    }
}

void A()
{
    reverse(data.begin(), data.end());
}

void M()
{
    rep(i, len) {
        if (data[i] == '9') {
            data[i] = '0';
        } else if ('0' <= data[i] && data[i] < '9') {
            data[i]++;
        } 
    }
}

void P()
{
    rep(i, len) {
        if (data[i] == '0') {
            data[i] = '9';
        } else if ('0' < data[i] && data[i] <= '9') {
            data[i]--;
        } 
    }
}

Measured memory_bytes: 3068
n,m=map(int,input().split())
danger=[int(input()) for i in range(m)]
danger=set(danger)
steps=[0]*(n+1)
steps[0]=1

if 1 in danger:
    steps[1]=0
else:
    steps[1]=1

for this_step in range(2,n+1):
    if this_step in danger:
        ap=0
    else:
        steps[this_step]=steps[this_step-1]+steps[this_step-2]

print(steps[-1]%1000000007)

Measured memory_bytes: 460020
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const ll mxN = 1e5;
const ll mod = 1e9 + 7;
 
ll pow(ll a,ll b){
    ll r =1;
    while(b){
        if(b%2!=0) r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return r;
}
 
const int sz = 5e5+20;
ll fact[sz], inv[sz];
void pre(){
	fact[0] = 1;
	inv[0] = pow(fact[0], mod-2);
	for(int i=1;i<sz;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}
 
int spf[10];
void sieve(){
    spf[1]=1;
    for(int i=2;i<mxN;i++) spf[i]=i;
    for(int i=4;i<mxN;i+=2) spf[i]=2;
    for(int i=3;i*i<mxN;i++){
    }
}

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

    ll n;
    cin>>n;

    if(n<2) cout<<0<<endl;
    else{
        ll a = pow((ll)8,n);
        ll b = pow((ll)10,n);
        ll c = (2*pow((ll)9,n))%mod;
        cout<< ((b + a)%mod - c + mod)%mod<<endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    cout << N * M << endl;
}


Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <numeric>
#include <bitset>
#include <array>
#include <cstdint>

template<std::uint_fast64_t Mod>
class ModInt{
    using u64 = uint_fast64_t;
public:
    u64 num;
    constexpr ModInt(const u64 x = 0) noexcept : num(x % Mod) {}
    constexpr u64 &value() noexcept { return num; }
    constexpr const u64 &value() const noexcept { return num; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept {
        return ModInt(*this) += rhs;
    }
    constexpr ModInt operator-(const ModInt rhs) const noexcept {
        return ModInt(*this) -= rhs;
    }
    constexpr ModInt operator*(const ModInt rhs) const noexcept {
        return ModInt(*this) *= rhs;
    }
    constexpr ModInt operator/(const ModInt rhs) const noexcept {
        return ModInt(*this) /= rhs;
    }
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        num += rhs.num;
        if (num >= Mod) {
            num -= Mod;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (num < rhs.num) {
            num += Mod;
        }
        num -= rhs.num;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        num = num * rhs.num % Mod;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Mod - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr ModInt &operator=(const u64 num) noexcept {
        this->num = num % Mod;
        return *this;
    }

    constexpr ModInt pow(u64 k){
        return pow(num, k);
    }

    static constexpr ModInt pow(ModInt x, u64 k){
        if(k == 0) return 1;
        if(k % 2 == 0) return pow((x * x).num % Mod, k / 2);
        else return (x * pow(x, k - 1)).num % Mod;
    }
};

template<std::uint_fast64_t Mod>
std::ostream &operator<<(std::ostream &out, const ModInt<Mod> &m)
{
    out << m.num;
    return out;
}

using namespace std;

unsigned long long calc(unsigned long long l, unsigned long long r){
    return l ^ r;
}

int main(){
    int n;
    cin >> n;
    vector<unsigned long long> a(n);
    array<int, 60> b;
    for(auto&& i : b){
        i = 0;
    }
    for(int i = 1; i <= n; i++){
        cin >> a[i - 1];
        bitset<60> bits(a[i - 1]);
        for(int j = 0; j < 60; j++){
            b[j] += bits[j];
        }
    }
    static const int INF = 1e9 + 7;
    ModInt<INF> ans = 0;
    for(int i = 0; i < 60; i++){
        ans += ModInt<INF>::pow(2, i) * b[i] * (n - b[i]);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2560
#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;

// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int S;
  scanf("%d", &S);
  int h = S / 3600;
  int m = (S - h * 3600) / 60;
  int s = S - h * 3600 - m * 60;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}

Measured memory_bytes: 3180
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
		int [] in = new int [a];
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                             c+=in[i];
                            }
		Arrays.sort(in);
        

        if(4*b*in[a-b]<c){System.out.println("No");}
		else{System.out.println("Yes");}
	}
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main(){
  long Nc;cin>>Nc;
  vector<long>C;
  for(long i=0;i<Nc;i++){
    long c;cin>>c;c--;
    if(i==0||c!=C[C.size()-1])C.push_back(c);
  }
  long N=C.size();Nc=200000;
 
  vector<long>DP(N,1),L(Nc,0);
  for(long i=0;i<N;i++){
    if(i!=0)DP[i]=(DP[i-1]+L[C[i]])%MOD;
    L[C[i]]=(L[C[i]]+(i>0?DP[i-1]:1))%MOD;
  }
  cout<<DP[N-1]%MOD;
}

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

int n;
int m[15][15];

void func(int x, int y, int l) {
  int nx, ny;
  if (!m[x][y]) {
    m[x][y] = l;
    if (l == n*n) return;
    if (x<n-1) nx = x+1;
    else nx = 0;
    if (y<n-1) ny = y+1;
    else ny = 0;
    func(nx, ny, l+1);
  } else {
    if (x<n-1) nx = x+1;
    else nx = 0;
    if (y) ny = y-1;
    else ny = n-1;
    func(nx, ny, l);
  }
}

int main() {
  int c;
  while (1) {
    cin >> n;
    if (!n) break;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        m[i][j] = 0;
      }
    }
    c = 0;
    func(n/2+1, n/2, 1);
    for (int i=0; i<n; ++i) {
      for (int j=0; j<n; ++j) {
        cout << setw(4) << m[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

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

int main() {
vector<int> v;
  int n,vl;
  cin >> n;
  for(int i = 0;i<n;i++)
  {
    cin >> vl;
v.push_back(vl);
  }
sort(v.begin(), v.end());
  int Al,Bo,c,l;
  Al=0;
  Bo=0;
  l=0;
  c=v.size()-1;
  while(c>=0){
    if(l%2==0)
      Al += v[c];
    else
      Bo += v[c];
    c--;
    l++;
  }
  cout << Al-Bo << endl;
	return 0;
}

Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
13
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;
  (N*(N-1)/2).writeln;
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
b = list(map(int, input().split()))

result = deque([])
while b:
    for i in range(len(b) - 1, -1, -1):
        if b[i] == i + 1:
            result.appendleft(b.pop(i))
            break
    else:
        break

if not b:
    print('\n'.join(str(i) for i in result))
else:
    print(-1)


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

using namespace std;
int main(){
    int N;cin>>N;
    int a[N];for(int i=0;i<N;i++)cin>>a[i];

    int max=-1;
    int min=1000000000;

    for(int i=0;i<N;i++){
        if(max<a[i])max=a[i];
        if(min>a[i])min=a[i];
    }
    cout<<abs(max-min)<<endl;

}

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

int main() {
	int t;
	cin>>t;
	int count=0;
	int arr[t],brr[t],crr[t-1];
	for(int i=0;i<t;i++){
		cin>>arr[i];
	}
		for(int i=0;i<t;i++){
		cin>>brr[i];
		count=count+brr[i];
	}
	for(int i=0;i<t-1;i++){
		cin>>crr[i];
	}
	for(int i=0;i<t;i++){
		if(arr[i+1]==arr[i]+1){
			count=count+crr[arr[i]-1];
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    if(a > b) swap(a, b);
    if(a > c) swap(a, c);
    if(c < b) swap(b, c);
    
    cout << a << " " <<b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 3096
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = input()

r = s.count('R')
g = s.count('G')
b = n - r - g
ans = comb(n, 3) - ( comb(r, 2) + comb(g, 2) + comb(b, 2) ) * (n-2) + ( comb(r, 3) + comb(g, 3) + comb(b, 3) ) * 2
for i in range(n):
    d = 1
    j = i + d
    k = j + d
    while k < n:
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
        d += 1
        j += 1
        k += 2
print(ans)

Measured memory_bytes: 10252
from collections  import deque
'''
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    a , b , w = map(int , input().split())
    a -= 1
    b -= 1
    graph[b].append([a,w])
    graph[a].append([b,w])

#print(len(graph.pop()[0]))
#print(graph.pop())
#print(len(graph.pop()))
def dfs():
    q = deque(graph[0])
    color = [0] * N
    corrent_color = 0
    other_color = 1
    searched = [0]
    while q:
        count = len(q)
        #print(count)
        search = q.popleft()
        #print("search : ",search)
        #print("search[0] : ",search[0])
        #print(len(search))
        for i in range(count):

            if not search[0] in searched:
                searched.append(search[0])
                if search[1] % 2 == 0:
                    color[search[0]] = corrent_color
                else:
                    color[search[0]] = other_color
                #print(len(graph[search[0]]))
                #print(graph[search[0]][0])
                for i in range(len(graph[search[0]])):
                    #print("i : ",i)
                    #print(graph[search[0]][i])
                    q.append(graph[search[0]][i])
                #print(q)
        corrent_color = color[search[0]]
        other_color = 1 - corrent_color
    print(*color , sep = "\n")
dfs()
'''

N = int(input())
graph = [[] for _ in range(N)]
cost = [[] for _ in range(N)]
for _ in range(N - 1):
    a , b , w = map(int , input().split())
    a -= 1
    b -= 1
    graph[b].append(a)
    graph[a].append(b)
    cost[b].append(w % 2)
    cost[a].append(w % 2)

color = [-1] * N
color[0] = 0
q = deque()
q.append(int(0))

#print(cost[0])
#print(graph[0])
while q:
    value = q.popleft()
    #print(value)
    for to , c in zip(graph[value] , cost[value]):
        #print(to , c)
        if color[to] != -1:
            continue
        color[to] = color[value]^c
        q.append(to)
print(*color , sep = "\n")

Measured memory_bytes: 36756
#include<stdio.h>
int main(){
int i,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%3==0||i%10==3||i/10%10==3||i/100%10==3||i/1000%10==3)
printf(" %d",i);
}
printf("\n");
return 0;
}


Measured memory_bytes: 2100
use std::io;
use std::str::Chars;

fn checkstr(chars:Chars) -> bool{
    let mut prenumber = None;
    for v in chars {
        match prenumber {
            Some(x) if x == v => {
                return false
            },
            _ => {},
        }
        prenumber=Some(v);
    }
    true
}

fn main() {
    let mut input= String::new();
    io::stdin().read_line(&mut input).expect("read_line err");
    let chars = input.trim().chars();
    if checkstr(chars) {
        println!("Good");
    }else{
        println!("Bad");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

void call(int n);

int main(void)
{
	int n;
	scanf("%d", &n);
	
	call(n);
	return 0;
}

void call(int n)
{
	
	for(int i = 1; i <= n; i++){
		int x = i;
		
		if(x % 3 == 0){
			printf(" %d", i);
			continue;
		}
		
		do{
			if(x % 10 == 3){
				printf(" %d", i);
				break;
			}
			x /= 10;
		
		}while(x);
		
	}
	printf("\n");
}



Measured memory_bytes: 2112
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Person[] persons = new Person[n];
            for (int i = 0; i < n; i++) {
                persons[i] = new Person(in.nextInt(), in.nextInt());
            }
            Arrays.sort(persons);
            int[][] dp = new int[n + 1][n + 1];
            for (int i = 0; i <= n; i++) {
                Arrays.fill(dp[i], Integer.MAX_VALUE);
            }

            dp[0][0] = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= i; j++) {
                    if (persons[i - 1].h >= dp[i - 1][j - 1]) {
                        dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - 1] + persons[i - 1].p);
                    } else {
                        dp[i][j] = dp[i - 1][j];
                    }
                }
            }

            int ans = Integer.MAX_VALUE;
            for (int i = 1; i <= n; i++) {
                if (dp[n][i] < Integer.MAX_VALUE) {
                    ans = i;
                }
            }

            out.println(ans);
        }

        class Person implements Comparable<Person> {
            int h;
            int p;

            public Person(int h, int p) {
                this.h = h;
                this.p = p;
            }


            public int compareTo(Person o) {
                return Integer.compare(h + p, o.h + o.p);
            }

        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(nextLine());
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 167212
#include <bits/stdc++.h>
using namespace std;
int main(){
  string num;
  cin >> num;
  int a[num.size()];
  for(int i = 0;i<num.size();i++){
    a[i] = num.at(i) - '0';
  }
  int mini = 1000;
  for(int k = 0;k<num.size()-2;k++){
    if(mini>abs(a[k]*100+a[k+1]*10+a[k+2]-753)){
      mini = abs(a[k]*100+a[k+1]*10+a[k+2]-753);
    }
  }
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i=1,score=0;
  double n,k,p,sum=0,tmp;
  scanf("%lf %lf",&n,&k);

  for(i=1;i<=n;i++){
    score=i;
    tmp=(double) 1.0/n;
    while(score<k){
      score=score*2;
      tmp/=2.0;
    }
    sum+=tmp;
  }
  printf("%.12f\n",sum);


  return 0;
 }

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007

vector<ll> v[MAXX];

int main()
{
	FAST;
	string s;
	ll ans = 0;
	cin >> s;
	for(ll i = 0; i < s.size(); i ++){
		if(s[i] == '2'){
			ans ++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3812
<?php

$N = trim(fgets(STDIN));
$D_X = trim(fgets(STDIN));

$parts = explode(" ", $D_X);

$D = $parts[0];
$X = $parts[1];

$total = $X;

for ($i = 0; $i < $N; $i++)
{
    $A = trim(fgets(STDIN));

    $count = floor(($D-1) / $A);    
    
    $total++;
    $total += $count;
    
}




echo $total . "\n";


Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=1;i<=n;i++) cin >> a[i];
  for(int i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(i/2!=0) printf("parent key = %d, ",a[i/2]);
    if(2*i<=n) printf("left key = %d, ",a[2*i]);
    if(2*i+1<=n) printf("right key = %d, ",a[2*i+1]);
    cout << endl;
  }
}

Measured memory_bytes: 3224
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        
        int data[200]={};
        rep(i,n){
            cin>>data[i];
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            for(int j=1;j<n-i;j++){
                if(data[j-1]>data[j]){
                    swap(data[j-1],data[j]);
                    sum++;
                }
            }
        }
        cout<<sum<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
# N=4
# G=[[2],[4],[],[3]]
import sys
sys.setrecursionlimit(1000000)

N=int(input())
G=[list(map(int, input().split()))[2:] for _ in range(N)]

v=[False]*N
d=[0]*N
f=[0]*N
timecount=1

def dfs(i):
    global timecount
    if v[i] : return
    v[i] = True
    d[i] = timecount
    # print("D",i+1,timecount)
    timecount += 1
    for p in G[i]:
        dfs(p-1)
    # print("F",i+1,timecount)
    f[i] = timecount
    timecount += 1
    return

for i in range(N):
  if v[i]==0: dfs(i)

for i in range(N):
    print(i+1, d[i], f[i])


Measured memory_bytes: 5656
#include <stdio.h>
#include <stdlib.h>
#define H 2000001
#define K -2000000001

int left(int i){ return i*2; }

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

int parent(int i){ return i/2; }

void swap(int *x, int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int n;

void maxHeapify(int *arr, int i){
  int largest;
  int l = left(i), r = right(i);

  // choice largest key in this and parents
  if(l <= n && arr[l] > arr[i]) largest = l;
  else largest = i;
  if(r <= n && arr[r] > arr[largest]) largest = r;

  if(largest != i){ // if arr[i]'s parent key larger than arr[i]'s key
    swap(&arr[i], &arr[largest]);
    maxHeapify(arr, largest);
  }
}

int extractMax(int *heap){
  if(n<1) printf("heap under flow\n");

  int max = heap[1];
  heap[1] = heap[n];
  n--;
  maxHeapify(heap,1);
  return max;
}

void increseKey(int *arr, int i, int key){
  if(key<arr[i]) printf("New key less than actual key\n");
  arr[i] = key;
  while(i>1 && arr[parent(i)]<arr[i]){
    swap(&arr[i],&arr[parent(i)]);
    i = parent(i);
  }
}

void heapInsert(int *heap, int key){
  n++;
  heap[n] = K;
  increseKey(heap,n,key);
}

int main(void){
  int k;
  int heap[H];
  char inst[10];

  while(1){
    scanf("%s", inst);
    if(inst[0] == 'e'){
      if(inst[1] == 'n') break;
      else printf("%d\n", extractMax(heap));
    }
    if(inst[0] == 'i'){
      scanf("%d", &k);
      heapInsert(heap, k);
    }
  }
  return 0;
}

Measured memory_bytes: 6772
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

int main(void){
    int a,b;
    cin >> a >> b;
    int x = a+b;
    int y = a-b;
    int z = a*b;

    if(x>=y && x>=z){
        cout << x << endl;
    }else if(y>=z && y>=x){
        cout << y << endl;
    }else{
        cout << z << endl;
    }
    
    return 0;
}



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

int main(){
    int K, S;
    cin >> K >> S;
    int res = 0;
    rep(x,K+1){
        rep(y,K+1){
            int z = S - (x + y);
            if(0<=z && z <=K) ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n =  Integer.parseInt(br.readLine());

		String[] tmp;

		Node firstNode = new Node(-1);
		firstNode.next = firstNode;
		firstNode.pre = firstNode;

		for(int i = 0 ; i < n ; i++ ){
			tmp =  br.readLine().split(" ");
			if(tmp[0].equals("insert")){
				Node newNode;
				Node tmpNode;

				newNode = new Node(Integer.parseInt(tmp[1]));
				tmpNode = firstNode.next;

				firstNode.next = newNode;
				newNode.pre = firstNode;
				newNode.next = tmpNode;
				tmpNode.pre = newNode;
			}else if(tmp[0].equals("delete")){
				Node currentNode = firstNode.next;
				int key = Integer.parseInt(tmp[1]);

				while(currentNode.key != key && currentNode.key != -1){
					currentNode = currentNode.next;
				}

				if(currentNode.key != -1){
					Node nextNode = currentNode.next;
					Node preNode = currentNode.pre;

					preNode.next = nextNode;
					nextNode.pre = preNode;
				}

			}else if(tmp[0].equals("deleteFirst")){

				Node deletedNode = firstNode.next;
				Node nextNode = deletedNode.next;

				firstNode.next = nextNode;
				nextNode.pre = firstNode;


			}else if(tmp[0].equals("deleteLast")){
				Node deletedNode = firstNode.pre;
				Node preNode = deletedNode.pre;

				preNode.next = firstNode;
				firstNode.pre = preNode;
			}
		}

		Node currentNode = firstNode.next;
		StringBuilder sb = new StringBuilder();
		while(currentNode.key != -1){
			sb.append(currentNode.key);
			sb.append(" ");
			currentNode = currentNode.next;
		}

		System.out.println(sb.toString().trim());

	}
}

class Node{

	public Node(int key){
		this.key = key;
	}

	int key;
	Node pre;
	Node next;
}

Measured memory_bytes: 188580
/*
AizuOnline A2406
Title Al dente
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int N,T,E;
int x[100];
//
int main()
{
        int i;

        scanf("%d %d %d",&N,&T,&E);

        for(i=0;i<N;i++)
                scanf("%d ",&x[i]);

        for(i=0;i<N;i++)
                if((T % x[i]) <=E || x[i] - (T % x[i]) <= E)
                {
                        printf("%d\n",i+1);
                        goto END;
                }
        printf("-1\n");
END:
        return(0);
}

Measured memory_bytes: 600
N = int(input())
hon = '24579'
pon = '0168'
bon = '3'
n = str(N)[::-1]
for i in n:
    if i in hon:
        print ("hon")
        break
    if i in pon:
        print ("pon")
        break
    if i in bon:
        print ("bon")
        break

Measured memory_bytes: 9184
// 2014/02/08 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string S;
		getline(cin, S);

		if(cin.eof())
			break;

		while(true){
			for(int i=0; i<S.size(); i++){
				if(S[i]=='z'){
					S[i] = 'a';
				}
				else if('a'<=S[i] && S[i]<='y'){
					S[i] = S[i]+1;
				}
			}

			if(S.find("the", 0)!=string::npos || S.find("this", 0)!=string::npos || S.find("that", 0)!=string::npos)
				break;
		}

		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,Count=0;
    long long int a [100010];
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]==0){Count++;}
    }
    if(Count>0){cout<<0<<endl;return 0;}
    long long int sum=1;
    for(int i=0; i<n; i++)
    {
        if(a[i]<=1000000000000000000/sum )
        {
// This condition is equivalent to sum*a[i] <=10ˆ18
            sum=sum*a[i];
        }
        else
        {
           cout<<-1<<endl;
            return 0;
        }
    }
   cout<<sum<<endl;
}


Measured memory_bytes: 4392
var lines = [];

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var A = Number(lines[0].split(" ")[0]);
    var B = Number(lines[0].split(" ")[1]);

    if ((A * B) % 2 === 0) { console.log("No") }
    else{
        console.log("Yes");
    }
});

Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w, n; cin >> h >> w >> n;
    int m = max(h, w);
    cout << n / m + bool(n % m) << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
int uruu(int year);
int main(void)
{
    int y, cnt = 0;
    int from, to;
    while(1){
        scanf("%d %d", &from, &to);
        if(from == 0 && to == 0){
            break;
        }
        if(cnt == 1){
            puts("");
        }
        cnt = 0;
        for(y = from; y <= to; y++) {
            if(uruu(y) == 1) {
                printf("%d\n",y);
                cnt = 1;
            }
        }
        if(cnt == 0){
            printf("NA\n");
        }
        cnt = 1;
    }
    return 0;
}

int uruu(int year) {
    int result = 0;
    if((year % 4) == 0 && (year % 100) != 0){
            result = 1;
    }
    if((year % 400) == 0){
        result = 1;
    }
    return result;
}

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

int main(){
        int k, L, R, temp;
        scanf("%d%d%d", &k,&L,&R);
        temp = R/k;
        if (temp*k >=L){
			printf("\nOK");
		}
		else{
			printf("\nNG");}
        return 0;
}


Measured memory_bytes: 3752