akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n;ll pw[20],num[200005],ans;
string s[200005];
ll t[105][105];
int main()
{
    pw[0] = 1;rep(i,1,18) pw[i] = pw[i - 1] * 10;
    fastio;
    cin>>n;
    rep(i,1,n) {
        cin>>s[i];
        int pos = -1;
        rap(j,0,s[i].size()) if(s[i][j] == '.') pos = j;
        if(pos == -1) pos = s[i].size();
        rap(j,0,pos) num[i] += (s[i][j] - '0') * pw[pos + 8 - j];
        rap(j,pos+1,s[i].size()) num[i] += (s[i][j] - '0') * pw[9 - (j - pos)];
        //cout<<num[i]<<endl;
    }
    rep(i,1,n) {
        int num2 = 0,num5 = 0;
        while(num[i] % 2 == 0) num2++,num[i] /= 2;
        while(num[i] % 5 == 0) num5++,num[i] /= 5;
        if(num2 >= 9 && num5 >= 9) ans--;
        t[num2][num5]++;
    }
    rep(two,0,64) rep(fiv,0,64) {
        int nedtwo = max(18 - two, 0);
        int nedfiv = max(18 - fiv, 0);
        rep(k,nedtwo,64) rep(l,nedfiv,64) ans += t[two][fiv] * t[k][l];
    }
    cout<<ans / 2;
    return 0;
}

Measured memory_bytes: 11452
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void solve(){
    int n;
    cin>>n;
    unordered_map<int,int> occ;
    int t[n];
    for(int i=0;i<n;i++){
        cin>>t[i];
        occ[t[i]]++;
    }
    ll cnt=0;
    for(int i=0;i<n;i++){
            bool ok=1;
       for(int j=1;j<=sqrt(t[i]);j++){
           if(t[i]%j==0){
                if(occ[j]){
                    if(t[i]==j ){
                            if(occ[j]>1){
                            ok=0;
                            break;
                            }
                    }
                    else
                          ok=0;
                }
                int cp=t[i]/j;
                if(occ[cp]){
                    if(t[i]==cp ){
                            if(occ[cp]>1){
                            ok=0;
                            break;
                            }
                    }
                    else
                          ok=0;
                }
           }
       }
       if(ok){
        cnt++;
        //cout<<t[i]<<endl;
       }
    }
    cout<<cnt;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    while(t--){
        solve();
        cout<<endl;
    }
 }


Measured memory_bytes: 32584
#include<stdio.h>

int main(void)
{
  int n,spot[100000],i,sum=0,sum_i=0,temp,temp1,temp2;
  spot[0] = 0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&spot[i]);
    }
  spot[n+1] = 0;

  for(i=0;i<=n+1;i++) //i番目を抜かない時
    {
      if(spot[i+1] - spot[i] >= 0)
	{
	  sum_i = sum_i + (spot[i+1] - spot[i]);
	}
      else
	{
	  sum_i = sum_i - (spot[i+1] - spot[i]);
	}
    }
  
  for(i=1;i<=n;i++)
    {
      
      if(spot[i-1] <= spot[i] && spot[i] <= spot[i+1])
	{
	  printf("%d\n",sum_i);
	}
      else if(spot[i-1] > spot[i] && spot[i] > spot[i+1])
	{
	  printf("%d\n",sum_i);
	}
      else
	{

	  if(spot[i] - spot[i-1] < 0)
	    {
	      temp1 = spot[i-1] - spot[i];
	    }
	  else
	    {
	      temp1 = spot[i] - spot[i-1];
	    }

	  if(spot[i+1] - spot[i] < 0)
	    {
	      temp2 = spot[i] - spot[i+1];
	    }
	  else
	    {
	      temp2 = spot[i+1] - spot[i];
	    }
	  
	  if(temp1 < temp2)
	    {
	      temp = (spot[i] - spot[i-1]) * 2;
	    }
	  else
	    {
	      temp = (spot[i+1] - spot[i]) * 2;
	    }
	  
	  if(temp >=0)
	    {
	      sum = sum_i - temp;
	    }
	  else
	    {
	      sum = sum_i + temp;
	    }
	  
	  printf("%d\n",sum);
	}
      
    }
  return 0;
}


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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

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

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll A[n+1],B[n];
    ll cnt=0;
    rep(i,0,n+1)	cin>>A[i];
    rep(i,0,n)	cin>>B[i];
    rep(i,0,n){
    	ll p = min(A[i],B[i]);
    	cnt += p;
    	A[i] -= p;
    	B[i] -= p;
    	ll q = min(A[i+1],B[i]);
    	cnt += q;
    	A[i+1] -= q;
    	B[i] -= q;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]

#各部屋の通じてる部屋番のリストを作る
l=[[] for _ in range(n)]
for i in range(m):
    a,b=s[i][0],s[i][1]
    l[a-1].append(b)
    l[b-1].append(a)

def dfs(now, prev, visited):
    visited.append(now)#行った頂点を追加していって全て行ったなら+1
    if len(visited) == n:
        return 1
 
    ret = 0 #条件を満たす数の初期値
    for edge in l[now-1]:#今の場所からいける頂点がまだ行ったことのない場合そこを同様に再度探索
        if edge == prev:
            continue
        if edge in visited:
            continue
 
        ret += dfs(edge, prev, visited[:])#そこで全ての頂点を網羅したなら+1(dfs文最初の部分)
 
    return ret #総計値を返す

print(dfs(1, 0, []))

Measured memory_bytes: 3064
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (int i = 0; i < N; i++){
			int hoge = sc.nextInt();
			if (hoge % 2 == 0){
				if (hoge % 3 != 0 && hoge % 5 != 0){
					System.out.println("DENIED");
                  	return;
				}
			}
		}
		System.out.println("APPROVED");
	}
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
long long n,d,b,j,k[200005],k2[200005],w,sum,ans,sum1[200005],ii;
pair <long long, long long> a[200005];
int main()
{
	cin>>n>>d>>b;
	for (int i=1; i<=n; i++)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a+1, a+n+1);
	j=1;
	for (int i=1; i<=n;i++)
	{
		
			while(k[j]<a[i].first  && j<=ii)
		{
			sum-=sum1[j];
			j++;
		} 
		
		a[i].second-=sum;  
		if(a[i].second>0){
		ii++;
		k[ii]=a[i].first+2*d; 
		if (a[i].second%b==0)
		{
			w=a[i].second/b;
		}
		else
		w=a[i].second/b+1;
		sum+=w*b;
		sum1[ii]=w*b;
	ans+=w; 
	} }
	cout<<ans<<endl;
}

Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <algorithm>

#include <stdio.h>
using namespace std;

int main(void) {
	string str;
	int q;
	string command;
	cin >> str;
	cin >> q;
	int a, b;
	string p;
	for (int i = 0; i < q; i++) {
		cin >> command;
		if (command == "print") {
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
		} else if (command == "reverse") {
			cin >> a >> b;
			string tmp = str.substr(a, b - a + 1);
			reverse(tmp.begin(), tmp.end());
			str = str.replace(a, b - a + 1, tmp);
//			cout << str << endl;
		} else if (command == "replace") {
			cin >> a >> b >> p;
			str = str.replace(a, b - a + 1, p);
//			cout << str << endl;
		}

	}
	return 0;
}



Measured memory_bytes: 3196
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N =1e5+3;

int a[N],ctr[N]; 
  
int main()
{
    
     ll a,b;
     lscf(a),lscf(b);
     
     char c;
     cin>>c;
     
     int d;scf(d);
     
     b*=100;
     b+=d;
     
     ll ans=a*b;
     
     ans/=100;
     
     lprin(ans);
     

}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
bool ok(ll x){
    ll cnt=0;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            cnt+=2;
            if(i==x/i) cnt--;
        }
    }
    if(cnt==8){
        return true;
    }
    else {
        return false;
    }
}
int main() {
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i%2==0) continue;
        if(ok(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
N,C,K = map(int,input().split())
Ts = [int(input()) for i in range(N)]
Ts.sort()

tmp_c = 0
bus_cnt = 0
wait_lmt = 0
for i,T in enumerate(Ts):
    if tmp_c == 0:
        wait_lmt = T + K
    
    if T <= wait_lmt:
        tmp_c += 1
    
    if i == len(Ts)  - 1 or Ts[i+1] > wait_lmt or tmp_c == C:
        tmp_c = 0
        bus_cnt += 1

print(bus_cnt)

Measured memory_bytes: 7484
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	int v[N];
	for(int i = 0; i < N; i++) cin >> v[i];
	sort(v, v + N);
	double res = (double)(v[0] + v[1]) / 2;
	for (int i = 2; i < N; i++)
	{
		res = (res + v[i]) / 2;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


# 整数 x の 2 の次数
def f(x):
    if x < 1:
        return 0
    i = 0
    while True:
        if x % (2 << i):
            break
        i += 1
    return i


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    t = 1
    for a in A:
        if a & 1:
            print(0)
            return
        else:
            t = lcm(t, a//2)

    d = f(A[0])
    for a in A:
        if f(a) != d:
            print(0)
            exit()

    print(-(-(M//t)//2))


if __name__ == '__main__':
    main()


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

string s; int k, n;
ll dp[2][4][105];

ll f(int low, int g, int p)
{
	if (g > k) return 0;
	if (p == n)
		return g == k;
	ll &r = dp[low][g][p];
	if (r != -1) return r;
	r = 0;
	for (int j = 0, to = low ? 9 : (s[p]-'0'); j <= to; ++j)
		r += f(low || j < (s[p]-'0'), g + (j != 0), p + 1);
	return r;
}

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	cin >> s >> k;
	memset(dp, -1, sizeof dp);
	n = s.length();
	cout << f(0, 0, 0) << "\n";

	return 0;
}


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

int main(){
	ios;
	int a[100],n;
	double s,ans;
	s=0.0;
	cin>>n;
	rep(i,n)
	{cin>>a[i];
	 s+=1.0/a[i];
	}
	ans=1.0/s;
	cout<<fixed<<setprecision(5)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
A,B,C,X,Y = map(int, input().split())
result = A*X + B*Y

for c2 in {0, X, Y}:
    a = max(X - c2, 0)
    b = max(Y - c2, 0)
    fee = int(a*A + b*B + c2*C *2)
    # if (fee < result):
    #     print(a,b,c2,fee)
    result = min(fee,result)

print(result)

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

Measured memory_bytes: 3060
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
    int x,y,z,sum=0;
    cin>>x>>y>>z;
    for(int i=x;i<=y;i++)
        if(z%i==0)sum++;
    cout<<sum<<endl;
    return 0;
}



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

#define REP(i,n) for(i=0;i<n;i++)

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int dfs(int v, int n, int *visited, int table[n][n]);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);

//main function
int main() {
    int n = iin(), k = iin();
    char s[n];
    stin(s);
    if (s[k - 1] == 'A') s[k - 1] = 'a';
    else if (s[k - 1] == 'B') s[k - 1] = 'b';
    else if (s[k - 1] == 'C') s[k - 1] = 'c';
    stout(s);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}


Measured memory_bytes: 128
a,b = map(int,input().split())
if b*10 <= a*100/8 < (b+1)*10:
    if int(a*100/8) == a*100/8:
        print(int(a*100/8))
    else:
        print(int(a*100/8)+1)
else:
    if a*100/8 <= b*10 < (a+1)*100/8:
        print(b*10)
    else:
        print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 1000000000


int main() {
    long long int N;
    cin >> N;
    vector<long long int> A(N);
    long long int num = 0;

    rep(i, N) {
        cin >> A[i];
        A[i] -= (i + 1);
        num += abs(A[i]);
    }

    sort(A.begin(), A.end());

    long long int ans = num;
    long long int temp = 0;
    rep(i, N) {
        temp += abs(A[i] - A[(N - 1) / 2]);
    }
    cout << min(ans, temp) << endl;



}

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

//main
bool flag=true;
int k;
int a[100010];
long long fx[100010],fn[100010];
int main(){
	scanf("%d",&k);
	for(int i=k;i>=1;i--)
		scanf("%d",&a[i]);
	fn[0]=fx[0]=2;
	for(int i=1;i<=k;i++){
		fx[i]=fx[i-1]/a[i]*a[i]+a[i]-1ll;
		fn[i]=fn[i-1];
		if(fn[i-1]%a[i]!=0)
		fn[i]+=a[i]-fn[i-1]%a[i];
	}
	if(fx[k]<fn[k]) puts("-1");
	else printf("%lld %lld\n",fn[k],fx[k]);
	return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int price, tmp, sumcash, change;
  int coin[4] = {10, 50, 100, 500};
  bool flag = false;
  while (cin >> price, price) {
    if (flag) cout << el;
    vector<int> curcash;
    sumcash = 0;
    for (int i = 0; i< 4; i++) {
      cin >> tmp;
      curcash.pb(tmp);
      sumcash += coin[i]*tmp;
    }
    change = sumcash - price;
    int changecoin[4] = {(change%50)/10, (change%100)/50, (change%500)/100, change/500};
    for (int i = 0; i < 4; i++) {
      if (curcash[i] > changecoin[i]) {
        cout << coin[i] << " " << curcash[i]-changecoin[i] << el;
      }
    }
    flag = true;
  }
}

Measured memory_bytes: 1216
from collections import deque
N, u, v = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N-1)]

graph = [[] for i in range(N+1)]
for i,j in AB:
    graph[i].append(j)
    graph[j].append(i)
    
r = [-1 for i in range(N+1)] 
Q = deque()
Q.append(u)
r[u] = 0

while Q:
    x = Q.pop()
    for to in graph[x]:
        if r[to] == -1:
            r[to] = r[x] + 1
            Q.append(to)
            
c = [-1 for i in range(N+1)]  
Q=deque()
Q.append(v)
c[v] = 0

while Q:
    x = Q.pop()
    for to in graph[x]:
        if c[to] == -1:
            c[to] = c[x] + 1
            Q.append(to)
ans = 0            
for i in range(N+1):
    if r[i] < c[i]:
        ans = max(ans, c[i])

print(max(0, ans-1))

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vi p(n), a(n), b(n);
    rep(i, n) cin >> p[i];

    vpii pp(n);
    rep(i, n) {
        pp[i].first = p[i];
        pp[i].second = i + 1;
    }
    sort(all(pp));
    rep(i, n) {
        p[i] = n - pp[i].second;
        // cout << p[i] << " ";
    }
    // cout << endl;

    a[0] = 1e9;
    b[0] = 1;

    int base = a[0] + b[0];

    for (int i = 1; i < n; i++) {
        a[i] = a[i - 1] - 1;
        b[i] = b[i - 1] + 1;
        int x = (base + p[0]) - (a[i] + b[i] + p[i]);
        // int x = a[i] + b[i] + (n - p[i]);
        // x -= base;
        // cout << i << " " << x << endl;
        if (x > 0) {
            b[i] += x;
        } else {
            a[i] += x;
        }
    }

    rep(i, n) {
        cout << b[i];
        if (i != n - 1) cout << " ";
    }
    cout << endl;

    rep(i, n) {
        cout << a[i];
        if (i != n - 1) cout << " ";
    }
    cout << endl;

    return 0;
}


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

long long mod = 1000000007;
long long fact[1 << 20], inv[1 << 20];

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 33; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

void init() {
	fact[0] = 1;
	for (int i = 1; i <= 600000; i++) fact[i] = (1LL * i * fact[i - 1]) % mod;
	for (int i = 0; i <= 600000; i++) inv[i] = Div(1, fact[i], mod);
}

long long ncr(long long n, long long r) {
	if (r < 0 || n < r) return 0;
	return (fact[n] * inv[r] % mod) * inv[n - r] % mod;
}

long long N, M, L, R;

long long solve(long long border) {
	long long V1 = ncr(N, M);
	long long V2 = 0;
	for (int i = 0; i <= N - M; i++) {
		long long cl = L - (M + i) * border + (N - 1), el = L - (M + i) * border + (N - M - 1);
		long long cr = R - (M + i) * border + (N - 1), er = R - (M + i) * border + (N - M - 1);
		if (cr < 0) break;
		if (i % 2 == 0) {
			V2 += ncr(N - M, i) * (ncr(cr + 1, N) - ncr(er + 1, N)); V2 = (V2 + mod * mod) % mod;
			V2 -= ncr(N - M, i) * (ncr(cl + 0, N) - ncr(el + 0, N)); V2 = (V2 + mod * mod) % mod;
		}
		if (i % 2 == 1) {
			V2 -= ncr(N - M, i) * (ncr(cr + 1, N) - ncr(er + 1, N)); V2 = (V2 + mod * mod) % mod;
			V2 += ncr(N - M, i) * (ncr(cl + 0, N) - ncr(el + 0, N)); V2 = (V2 + mod * mod) % mod;
		}
	}
	return V1 * V2 % mod;
}

int main() {
	cin >> N >> M >> L >> R;
	init();

	long long Answer = 0;
	for (int i = 1; i <= R; i++) {
		Answer += solve(i);
		Answer %= mod;
	}

	long long Answer2 = (ncr(R + N, N) - ncr(L + N - 1, N) + mod) % mod;
	cout << (Answer2 - Answer + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 12980
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using std::cin;using std::cerr;
using std::max;using std::min;
#define N 200005
#define ll long long
#define db double
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
int n,A[N],ans;
std::map<int,int>mp,mp2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]),mp[A[i]]++;
	std::sort(A+1,A+1+n),std::reverse(A+1,A+1+n);
	for(int i=1,v;i<=n;i++)
	{
		mp[A[i]]--;
		if(mp2[A[i]]) {mp2[A[i]]--;continue;}
		for(int j=0;;j++)
		{
			if((1<<j)>A[i])
			{
				v=(1<<j)-A[i];
				// dbg1(A[i]),dbg1(j),dbg1(v),dbg1(mp[v]),dbg2(mp2[v]);
				if(mp[v]&&mp2[v]<mp[v]) mp2[v]++,ans++;
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 29184
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

def dfs(s, n, m):
    if n > N:
        print(''.join([chr(ss) for ss in s]))
        return True
    for ns in range(97, m+2):
        s[n-1] = ns
        dfs(s, n+1, max(m, ns))

s = [0] * N
dfs(s, 1, 96)


Measured memory_bytes: 4416
import java.lang.Math.*

private fun readLn() = readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints


//var n = 0
//var ar = listOf<Int>()

fun main() {
    val d = readInt()
    val C = readInts()
    var S = mutableListOf<List<Int>>()
    S.add(mutableListOf())

    for (i in 0 until d) {
        S.add(readInts())
    }

    val last = Array(26) {0}
    val chosen = mutableListOf<Int>()

    for (day in 1 until d + 1) {
        var max = Integer.MIN_VALUE
        var maxContest = -1

        for (contest in 0 until 26) {
            var cur = S[day][contest]
            val daysSince = day - last[contest]
            cur -= (C[contest] * daysSince * (daysSince + 1) / 2)

            if (cur > max) {
                max = cur
                maxContest = contest
            }
        }

        chosen.add(maxContest + 1)
    }

    print(chosen.joinToString("\n"))
}


Measured memory_bytes: 39884
// AOJ 2161 Defend the Bases
// 2018.3.9 bal4u

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

#define MAX 210
int  to[MAX][MAX]; char hi[MAX];
char seen[MAX];
int  match[MAX];

int bpm(int u);
int bipartiteMatching(int m, int n, int V)
{
	int u, max;

	memset(match, -1, V << 2);
	max = 0;
	for (u = 0; u < m; u++) {
		memset(seen, 0, V);
		if (bpm(u)) max++;
	}
	return max;
}

int bpm(int u)
{
	int i, v;

	for (i = 0; i < hi[u]; i++) {
		v = to[u][i];
		if (seen[v]) continue;
		seen[v] = 1;
		if (match[v] < 0 || bpm(match[v])) {
			match[u] = v, match[v] = u;
			return 1;
		}
	}
	return 0;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define EPS 1e-8

typedef struct { int from, to; double tm; } EDGE;
EDGE edge[10010];
typedef struct { int x, y, v; } TROOP;
TROOP troop[102];
typedef struct { int x, y; } BASE;
BASE  base[102];
int   N, M, V;

int check(double tm)
{
	EDGE *e;

	memset(hi, 0, V);
	for (e = edge; e->tm < tm+EPS; e++) to[e->from][hi[e->from]++] = e->to;
	return bipartiteMatching(N, M, V) == M;
}

int cmp(EDGE *a, EDGE *b) {
	if (fabs(a->tm - b->tm) < EPS) return 0;
	if (a->tm <= b->tm) return -1;
	return 1;
}

int main()
{
	int i, j;
	double lb, ub, md;
	EDGE *e;

	while (N = in()) {
		M = in(), V = N+M;
		for (i = 0; i < N; i++) troop[i].x = in(), troop[i].y = in(), troop[i].v = in();
		for (i = 0; i < M; i++) base[i].x = in(), base[i].y = in();

		e = edge; for (i = 0; i < N; i++) for (j = 0; j < M; j++) {
			e->from = i, e->to = N+j;
			e->tm = hypot(troop[i].x-base[j].x, troop[i].y-base[j].y) / troop[i].v;
			e++;
		}
		qsort(edge, e-edge, sizeof(EDGE), cmp);
		e->tm = 15000;		// INF
		
		lb = 0, ub = edge[e-edge-1].tm;
		while (ub-lb > EPS) {
			md = 0.5*(lb+ub);
			if (check(md)) ub = md; else lb = md;
		}
		printf("%.20lf\n", ub);
	}
	return 0;
}


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

#define all(x) x.begin(),x.end()
#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline LL read(){
    LL res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

const LL inf = (LL)1e18;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

template<typename T>
void chmin(T a, T b){if(a>b)a=b;}

template<typename T>
void chmax(T a, T b){if(b>a)a=b;}

LL a[MAXN], n;
map<int,long long> H[MAXN];

LL dfs(int idx, int cnt){
    if(idx>=n+1){
        if(cnt==n/2)return 0;
        else return -inf;
    }

    if(H[idx].count(cnt))return H[idx][cnt];

    if((cnt+(n-idx+2)/2)<n/2)return -inf;

    return H[idx][cnt]=max(dfs(idx+1,cnt),dfs(idx+2,cnt+1)+a[idx]);
}

int main(){
    n=read();
    for(int i=1;i<=n;++i)a[i]=read();

    cout<<dfs(1,0);

    return 0;
}


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

using ll = long long;
const int sz = 1e5 + 10;
ll ar[sz], ans, h;
map < ll, ll > mp;
int n;
int fl;
int main() {
    #ifdef CLown1331
        freopen( "in.txt","r",stdin );
    #endif /// CLown1331
    while( scanf( "%d", &n ) == 1 ) {
        mp.clear();
        for( int i=0; i<n; i++ ) {
            scanf( "%lld", &ar[i] );
            mp[ ar[i] ]++;
        }
        ans = 0;
        for( auto xx: mp ) {
            if( xx.second >= 4 ) {
                ans = max( xx.first * xx.first, ans );
            }
        }
        fl = 0;
        for( auto it=mp.rbegin(); it!=mp.rend(); ++it ) {
            if( it->second >= 2 ) {
                if( fl ) {
                    ans = max( ans, it->first * h );
                }
                else {
                    fl = 1;
                    h = it->first;
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j;
  cin >> n;
  int arr[n][3],c[n][3];
  
  for(i=0;i<n;i++)
    for(j=0;j<3;j++)
      cin >> arr[i][j];
  
 c[0][0]=arr[0][0];c[0][1]=arr[0][1];c[0][2]=arr[0][2];
  for(i=1;i<n;i++)
  {
    for(j=0;j<3;j++)
    {
      if(j==0)
        c[i][j]=max(c[i-1][1],c[i-1][2])+arr[i][j];
      else if(j==1)
        c[i][j]=max(c[i-1][0],c[i-1][2])+arr[i][j];
      else if(j==2)
        c[i][j]=max(c[i-1][1],c[i-1][0])+arr[i][j];
    }
  }
  cout<<max(c[n-1][0],max(c[n-1][1],c[n-1][2]));
}

Measured memory_bytes: 2560
x,y=map(int,input().split())
a=0
if x==3:
    a+=1
if y==3:
    a+=1
if x==2:
    a+=2
if y==2:
    a+=2
if x==1:
    a+=3
if y==1:
    a+=3
if x==1 and y==1:
    a+=4
print(a*100000)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for(int i=0; i<n; i++){
            v[i]  = sc.nextInt();
        }
        sc.close();

        int[] num1 = new int[100010];
        int[] num2 = new int[100010];

        for(int i=0; i<n; i++){
            if(i%2 == 0){
                num1[v[i]]++;
            }else{
                num2[v[i]]++;
            }
        }

        int max11 = 0;
        int max12 = 0;
        int max21 = 0;
        int max22 = 0;
        int pos1 = 0;
        int pos2 = 0;

        for(int i=0; i<100010; i++){
            if(num1[i] > max11){
                max12 = max11;
                max11 = num1[i];
                pos1 = i;
            }else if(num1[i] > max12){
                max12 = num1[i];
            }
            if(num2[i] > max21){
                max22 = max21;
                max21 = num2[i];
                pos2 = i;
            }else if(num2[i] > max22){
                max22 = num2[i];
            }
        }

        if(pos1 != pos2){
            System.out.println(n - max11 - max21);
        }else{
            int ans = Math.max(max11 + max22, max12 + max21);
            System.out.println(n - ans);
        }

    }
}

Measured memory_bytes: 51032
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int R = sc.nextInt();

        if(R<1200){
            System.out.println("ABC");
        }
        else if(R>=2800){
            System.out.println("AGC");
        }
        else{
            System.out.println("ARC");
        }
    }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d))
	{
		if(a*b>=c*d) cout<<a*b<<endl;
		else cout<<c*d<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# a = input()
# b = input()
# k = input()
str = input()
str = str.split()
#print(str)
a = int(str[0])
b = int(str[1])
k = int(str[2])
#print("ans")
if b - a >= k*2:
    for i in range(a,a+k):
        print(i)
    #print("ss")
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;
int main()
{
    int F,Le,Z,DD;
    while(scanf("%d %d %d",&F,&Le,&DD)!=EOF)
    {
        int temp=F;
        for(int i=0; i<DD; i++)
        {
            if(temp>Le)
                break;
            printf("%d\n",temp++);
        }
        Z=Le-DD+1;
        if(temp<Z)
            temp=Z;
        for(int i=0; i<DD; i++)
        {
            if(temp>Le)
                break;
            printf("%d\n",temp++);
        }
    }
}


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

using namespace std;

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

    int n, d;
    cin >> n >> d;

    //vector<int> x(n), y(n);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if(sqrt(pow(x, 2) + pow(y, 2)) <= 1.0 * d) {
            ans++;
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

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

int Parent(int n, vector<int> & p) {
	if (p[n] == n)
		return n;
	return p[n] = Parent(p[n], p);
}

int main(void) {
	int num, i, m, k, a, b;
	cin >> num >> m >> k;
	vector<int> p(num + 1), s(num + 1, 1);
	vector<map<int, int>> x(num + 1);
	rep(i, num + 1) {
		p[i] = i;
	}
	rep(i, m) {
		cin >> a >> b;
		x[a][b]++;
		x[b][a]++;
		a = Parent(a, p);
		b = Parent(b, p);
		if (a != b) {
			p[b] = a;
			s[a] += s[b];
		}
	}
	rep(i, k) {
		cin >> a >> b;
		if (Parent(a, p) == Parent(b, p)) {
			x[a][b]++;
			x[b][a]++;
		}
	}
	for (i = 1; i <= num; i++) {
		a = Parent(i, p);
		cout << s[a] - x[i].size() - 1 << " ";
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 25600
#include <cstdio>

using namespace std;
#define int unsigned long long
int n,a,b,x;
signed main(){
    scanf("%lld%lld%lld",&a,&b,&n);
    if(b>n) x=n;
    else{
        x=n/b*b-1;
    }
    printf("%lld",(a*x/b)-a*(x/b));
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  if(s[0] != s[1] || s[0] != s[2]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 */

signed main() {
  int a, b;
  cin >> a >> b;
  cout << a*(a-1)/2 + b*(b-1)/2 << endl;
  return 0;
}



Measured memory_bytes: 256
def knapsack(n,W,v,w):
	dp=[[0 for x in range(W+1)] for x in range(n+1)]
	for i in range(n):
		vl = v[i]
		wt = w[i]
		for j in range(W+1):
			if j < w[i]:
				dp[i+1][j]=dp[i][j]
			else:
				dp[i+1][j]=max(dp[i][j],max(dp[i][j-wt]+vl,dp[i+1][j-wt]+vl))
	return dp[n][W]

n,W = map(int,input().split())
v = [0]*n
w = [0]*n
for i in range(n):
	v[i],w[i] = map(int,input().split())
print(knapsack(n,W,v,w))



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

struct Problem {

    UL N, M;
    UL H[100000];
    vector<UL> E[100000];

    void Solve() {
        scanf("%d%d", &N, &M);
        rep(i, N) scanf("%d", H + i);
        rep(i, M) {
            UL u, v; scanf("%d%d", &u, &v); u--; v--;
            E[u].push_back(v);
            E[v].push_back(u);
        }
        UL ans = 0;
        rep(i, N) {
            bool ok = true;
            for (UL e : E[i]) if (H[i] <= H[e]) ok = false;
            if (ok)ans++;
        }
        cout << ans << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  ll n, k;
  cin >> n >> k;
  ll ans;
  ans = min(n % k, k - n % k);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

int main(void) {
    int N,K,x;
    int ans = 0;
    cin >> N >> K;
    for (int i=0; i<N; i++) {
        cin >> x;
        ans += x < abs(K - x) ? x : abs(K - x);
    }
    cout << ans * 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			if ((n | k) == 0)
				break;
			int[] num = new int[k];
			for (int i = 0; i < k; i++)
				num[i] = scanner.nextInt();
			String ans = "Yes";
			for (int i = 0; i < n; i++)
				for (int j = 0; j < k; j++) {
					int a = scanner.nextInt();
					num[j] -= a;
					if (num[j] < 0)
						ans = "No";
				}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 96936
import java.util.*;

public class Main {
    private static String JOI = "JOI";
    private static String IOI = "IOI";

    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            String str = null;
            while (scn.hasNext()) {
                str = scn.next();

                int joi = 0;
                for (int i = 0; (i = str.indexOf(JOI, i) + 1) > 0; joi++);
                System.out.println(joi);

                int ioi = 0;
                for (int i = 0; (i = str.indexOf(IOI, i) + 1) > 0; ioi++);
                System.out.println(ioi);
            }
        }
    }
}

Measured memory_bytes: 27248
#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 d;
  cin>> d;
  if(d==25) cout << "Christmas" << endl;
  if(d==24) cout << "Christmas Eve" << endl;
  if(d==23) cout << "Christmas Eve Eve" << endl;
  if(d==22) cout << "Christmas Eve Eve Eve" << endl;  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
sequence = list(range(1, N + 1))
for i in range(len(sequence)):
    num = sequence[i]
    if num % 3 == 0 and num % 5 == 0:
        sequence[i] = "FizzBuzz"
    elif num % 3 == 0:
        sequence[i] = "Fizz"
    elif num % 5 == 0:
        sequence[i] = "Buzz"
total = 0
for i in sequence:
    if isinstance(i, int):
        total += i
print(total)

Measured memory_bytes: 48472
#include <cstdio>
#include <algorithm>
#define ll long long
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5,INF=1e9;
int n,i,u,v,c,odd,Min;
int En,fst[N],sz[N],to[N*2],nxt[N*2];
ll ans,l[N*2];
void add(int u,int v,int c) {
	En++; nxt[En]=fst[u]; fst[u]=En; to[En]=v; l[En]=c;
}
void dfs(int x,int lst)
{
	int j,v,a,b,tmp=0,eMin=INF;
	sz[x]=1;
	for (j=fst[x];j;j=nxt[j])
	{
		eMin=min((ll)eMin,l[j]);
		if ((j^1)==lst) continue;
		v=to[j];
		dfs(v,j);
		sz[x]+=sz[v];
		tmp=max(tmp,sz[v]);
	}
	tmp=max(tmp,n-sz[x]);
	a=sz[x]; b=n-sz[x];
	if (tmp<=n/2) Min=eMin;
	if (a>b) swap(a,b);
	if (a==b) ans+=l[lst]*(a*2-1),odd=1;
	else ans+=l[lst]*a*2;
}
int main()
{
//	freopen("hamilton.in","r",stdin);
//	freopen("hamilton.out","w",stdout);
	scanf("%d",&n);
	En=1;
	rep(i,1,n-1)
	{
		scanf("%d%d%d",&u,&v,&c);
		add(u,v,c); add(v,u,c);
	}
	Min=INF;
	dfs(1,0);
	if (!odd) ans-=Min;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9344
from collections import deque

H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

#右上左下
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]


ans = 0

que = deque()

num_white = H * W

paint = 0

for i in range(H):
    for j in range(W):
        if field[i][j] == "#":
            que.append((i, j))
            num_white -= 1

def check(field):
    flag = False
    for i in range(H):
        if "." in field[i]:
            flag = True

    return flag

def one_bsf():
    global paint
    global que
    global ans

    for _ in range(len(que)):
        n = que.popleft()
        ny = n[0]
        nx = n[1]

        for i in range(4):
            nny = ny + dy[i]
            nnx = nx + dx[i]

            if nny < 0 or nny >= H or nnx < 0 or nnx >= W:
                continue

            elif field[nny][nnx] == ".":
                field[nny][nnx] = "#"
                paint += 1
                que.append((nny, nnx))

    ans += 1

while num_white != paint:
    one_bsf()
    
print(ans)

Measured memory_bytes: 114780
/*  CREATED BY
    STREAM_CIPHER
    19-sep-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout<<fixed<<setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;//5*64M bit ->5*8M byte ->40MB size for long long int (64 bit)
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n,a,m;
        cin>>n>>a>>m;
        int aa;
        aa=a%m;
        int ans=0;
        ans+=aa;
        int done=1;
        int bb;
        unordered_map<int,int>taken;
        unordered_map<int,int>taken1;
        unordered_map<int,int>index;
        taken[aa]=ans;
        taken1[aa]=1;
        int gap=0;
        index[aa]=1;
        int index2;
        for(int i=2;i<=n;i++)
        {
        	bb=(aa*aa)%m;
        	// debug2(aa,bb);
        	ans+=bb;
        	done=i;
        	if(taken1[bb]!=0)
        	{
        		gap=ans-taken[bb];
        		index2=i;
        		break;
        	}
        	taken1[bb]=1;
        	index[bb]=i;
        	taken[bb]=ans;
        	aa=bb;
        }
        // debug1(gap);
        int rem=n-done;
        // debug1(rem);
        int len=abs(index[bb]-index2);
        ans+=((rem/len)*gap);
        // debug1(((rem/abs(index[bb]-index2))*gap));
        rem=rem%len;
        // debug1(rem);
        int prev=bb;
        for(int i=1;i<=rem;i++)
        {
        	ans+=(prev*prev)%m;
        	prev=(prev*prev)%m;
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 9204
#include<iostream>
#define MOD (1000000007)
using namespace std;
typedef long long ll;
int main(){
  ll n,m,j=0;
  ll dp[1000000]={};
  cin >> n>>m;
  ll a[m];
  for(int i=0;i<m;i++){
    cin >>a[i];
  }
  j=0;
  dp[0]=1;
  if(a[j]==1) {
    dp[1]=0;
    j++;
  }else dp[1]=1;
  for(int i=2;i<=n;i++){
    if(i!=a[j]){
      dp[i]=(dp[i-1]+dp[i-2])%MOD;
    }else{
      dp[i]=0;
      j++;
    }
  }
  cout << dp[n]<<endl;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define all(x)  x.begin(),x.end()
#define sz(x)   (int)x.size()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1005;
const int   mod = 1e9 + 7;

void add(int&a,int b)   {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int&a,int b)   {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

int f[N];

int Fac[N];
int Inv[N];

typedef pair<int,int>   ii;

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

    Fac[0] = Inv[0] = 1;

    for(int i = 1 ; i < N ; ++i)    Fac[i] = mul(Fac[i - 1],i);     Inv[N - 1] = inv(Fac[N - 1],mod);
    for(int i = N - 2 ; i ; --i)    Inv[i] = mul(Inv[i + 1],i + 1);

    int n;  cin >> n;
    int a, b;   cin >> a >> b;
    int c, d;   cin >> c >> d;

    f[0] = 1;

    for(int i = a ; i <= b ; ++i)   {
        int l = c;
        int r = min(d,n / i);

        for(int s = n ; s >= 0 ; --s)   {
            int x = Pow(Inv[i],l);

            for(int j = l ; j <= r ; ++j)   {
                if (i * j > s)
                    break;

                add(f[s],mul(mul(x,Inv[j]),f[s - i * j]));

                x = mul(x,Inv[i]);
            }
        }
    }

    int ans = f[n];

    for(int i = 1 ; i <= n ; ++i)
        ans = mul(ans,i);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a; cin >> a;
  string b; cin >> b;
  ll ans = 0;
  ans += a * (b[0]-'0')*100;
  ans += a * (b[2]-'0')*10;
  ans += a * (b[3]-'0');
  cout << ans/100;
  cout << "\n";
  return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int a = 100 * r + 10 * g + b;
  if (a % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var list = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        list.Sort((a, b) => b - a);
        if (vals[0] - vals[1] < 0)
        {
            Console.WriteLine(0);
            return;
        }
        for (int i = 0; i < vals[1]; i++)
        {
            list[i] = 0;
        }
        long total = list.Select(x => (long)x).Sum();
        Console.WriteLine(total);
    }
}

Measured memory_bytes: 35260