akhauriyash/Code-Regression huggingface dataset:
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

const int check[] = {19120730, 19261225, 19890108};
const int ware[] = {1867, 1911, 1925};
const string gen[] = {"meiji", "taisho", "showa"};

signed main()
{
  //ios::sync_with_stdio(false);
  int y, m, d;

  while (cin >> y >> m >> d){
    int cnt = y * 10000 + m * 100 + d;
    if (cnt < 18680908){
      print("pre-meiji");
    } else {
      bool heisei = true;
      REP(i, 3){
        if (cnt < check[i]){
          printf("%s %d %d %d\n", gen[i].c_str(), y - ware[i], m, d);
          heisei = false;
          break;
        }
      }
      if (heisei){
        printf("heisei %d %d %d\n", y - 1988, m, d);
      }
    }
  }

  return (0);
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
    
        ll n,k;
        cin>>n>>k;
        vector<ll> a(n+1);
        vector<ll> cost(n+1);
        for(ll i=1;i<=n;i++)
        cin>>a[i];
        for(ll i=1;i<=n;i++)
        cin>>cost[i];
        ll mini=-1e16;
        for(ll i=1;i<=n;i++)
        {
            vector<ll> dp;
            vector<ll> visited(n+1,0);
            ll p=a[i];
            dp.push_back(cost[p]);
            visited[p]=1;
            p=a[p];
            //visited[i]=1;
            while(visited[p]==0)
            {
                visited[p]=1;
                dp.push_back(dp[dp.size()-1]+cost[p]);
                p=a[p];
            }
            ll j=dp.size();
            ll ans=0;
            ll uyt=k;
            int flag=0;
            if(k>j)
            {
                if(dp[j-1]>0)
                ans+=(k/j)*dp[j-1];
                k=k%j;
                flag=1;
            }
            // for(ll i=0;i<dp.size();i++)
            // cout<<dp[i]<<" ";
            // cout<<endl;
            ll sum=-1e16;
               
            for(ll re=0;re<k;re++)
            sum=max(sum,dp[re]);
            ans+=sum;

            //cout<<ans<<endl;
            mini=max(mini,ans);
            k=uyt;
            ans=0;
            sum=-1e16;
            if(k>j)
            {
                ll oi=0;
                for(ll re=0;re<j;re++)
                sum=max(sum,dp[re]);
                if(k/j>=2)
                sum+=max(oi,(k/j-1)*dp[j-1]);
                mini=max(mini,sum);
            }


        }
        cout<<mini<<endl;
    
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    const int N_MAX = 100000;
    int N;
    int a[N_MAX];
    int b[N_MAX];
    cin >> N;
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];
    ll op1 = 0;
    ll op2 = 0;
    REP(i, N) {
        if (a[i] > b[i]) {
            op2 += a[i] - b[i];
        } else if (a[i] < b[i]) {
            op1 += (b[i] - a[i]) / 2;
        }
    }
    if (op1 >= op2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 100000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=50005;
//Code begin....

int main ()
{
    int n;
    scanf("%d",&n);
    if (n%10==9||n/10==9) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n,a,b;
    cin>>n>>a>>b;
    int it=n/(a+b);
    cout<<it*a+min(a,n-it*(a+b))<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

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

        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] L = new int[M];
        int[] R = new int[M];
        for (int i = 0; i < M; i++) {
            L[i] = Integer.parseInt(sc.next());
            R[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        int Lmax = 0;
        int Rmin = Integer.MAX_VALUE;
        for (int i = 0; i < M; i++) {
            if (Lmax < L[i]) {
                Lmax = L[i];
            }
            if (R[i] < Rmin) {
                Rmin = R[i];
            }
        }
        out.printf("%d\n", Math.max(0, Rmin - Lmax + 1));
        out.flush();
    }
}


Measured memory_bytes: 61052
N = int(input())
dishes = list(map(int, input().split()))
cost = [0] + list(map(int, input().split()))
bonus = [0] + list(map(int, input().split()))
before = 0
sum_c = 0
for dish in dishes:
  sum_c += cost[dish]
  if before == dish - 1:
    sum_c += bonus[before]
  before = dish
print(sum_c)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
def lower_bound(al, key):
    """
    一般に左側が満たしておらず、右側は満たしている判定基準(境目は一つ)ならlower_boundになる
    (条件を満たすもののうち、最小のインデックスを返す)
    単調にさえなっていれば、左右が逆になっていても検索には使える(ng/okも一緒に逆にする必要がある)
    """
    def isOk(a):
        # alの中でkey以上のアイテムのうち最小のインデックスを返す
        # upper_boundにする時にはa>key
        return a>=key

    ng = -1
    ok = len(al)

    while abs(ok-ng)>1:
        mid = (ok+ng)//2

        if isOk(al[mid]):
            ok = mid
        else:
            ng = mid

    return ok

n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))

al.sort()
bl.sort()
cl.sort()

res = 0
for b in bl:
    na = lower_bound(al, b)
    nc = n - lower_bound(cl, b+1)
    res += na*nc
print(res)

Measured memory_bytes: 23232
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int best;
map<ll, int> memo;

ll encode(const vector<int> &x){
  ll H = 0;
  REP(i, x.size()) H = H * 11 + x[i];
  return H;
}

void dfs1(vector<int> &x, int depth){
  ll h = encode(x);
  if(memo.find(h) == memo.end() || memo[h] > depth){
    memo[h] = depth;
  }else{
    return;
  }
  if(depth == 4) return;

  REP(r, x.size())REP(l, r + 1){
    int d = (r - l + 1) / 2;
    REP(i, d) swap(x[l+i], x[r-i]);
    dfs1(x, depth + 1);
    REP(i, d) swap(x[l+i], x[r-i]);
  }
}

void dfs2(vector<int> &x, int depth){
  ll h = encode(x);
  if(memo.find(h) != memo.end()) best = min(best, memo[h] + depth);
  if(depth == 4) return;
  
  REP(r, x.size())REP(l, r + 1){
    int d = (r - l + 1) / 2;
    REP(i, d) swap(x[l+i], x[r-i]);
    dfs2(x, depth + 1);
    REP(i, d) swap(x[l+i], x[r-i]);
  }
}


int main(){
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  REP(i, N){
    cin >> x[i];
    y[i] = i + 1;
  }

  best = N - 1;
  dfs1(x, 0);
  dfs2(y, 0);
  cout << best << endl;
  return 0;
}

Measured memory_bytes: 17108
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 3568
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, Q): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (a, b): (Vec<usize>, Vec<usize>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..(N - 1) {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };
    let (p, x): (Vec<usize>, Vec<usize>) = {
        let (mut p, mut x) = (vec![], vec![]);
        for _ in 0..Q {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            p.push(iter.next().unwrap().parse().unwrap());
            x.push(iter.next().unwrap().parse().unwrap());
        }
        (p, x)
    };

    // クエリを先読みして根から処理する
    let G = {
        let mut G = vec![std::collections::HashSet::new(); N + 1];
        for i in 0..(N - 1) {
            G[a[i]].insert(b[i]);
            G[b[i]].insert(a[i]);
        }
        G
    };
    let mut c = vec![0; N + 1];
    for i in 0..Q { c[p[i]] += x[i]; }
    let mut reachable = vec![true; N + 1];
    fn f(i: usize, c: &mut Vec<usize>, reachable: &mut Vec<bool>, G: &Vec<std::collections::HashSet<usize>>) {
        reachable[i] = false;
        for &j in &G[i] {
            if reachable[j] {
                c[j] += c[i];
                f(j, c, reachable, G);
            }
        }
    }

    f(1, &mut c, &mut reachable, &G);
    let ans = c[1..].iter()
        .map(|&x| x.to_string())
        .collect::<Vec<_>>()
        .join(" ");

    println!("{}", ans);
}


Measured memory_bytes: 152028
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e5+7;
int dp[1000][N],n,c,w[N],v[N];

int32_t main()
{
	fast;
	cin>>n>>c;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=c;j++)
		{
			dp[i][j] = dp[i-1][j];
			if(j>=w[i])
				dp[i][j] = max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
		}
	}
	cout<<dp[n][c];
	return 0;
}

Measured memory_bytes: 80128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        String ans = "";
        
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String Alphabet[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        int min = 25;
        
        for (int i = 0; i < Alphabet.length; i++){
            int result = str.indexOf(Alphabet[i]);
            
            if(result == -1){
                if (min >= i){
                    min = i;
                    ans = Alphabet[min];
                }
            }
        }

        if ("".equals(ans))
            System.out.println("None");
        else
            System.out.println(ans);
        
        sc.close();
    }
}

Measured memory_bytes: 25788
#include <iostream>

using namespace std;

int main()
{
    int m, n;
	char a[50][50], b[50][50];
	bool flag2 = 0;
	
	cin >> n >> m;
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			cin >> b[i][j];
		}
	}
	
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			bool flag = 1;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (a[i+k][j+l] != b[k][l]) flag = 0;
				}
			}
			if (flag) flag2 = 1;
		}
	}
	
	if (flag2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << 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 = int64_t;
using P = pair<int, int>;

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

  ll r = b / x;
  ll l = a / x;
  ll ans = r - l;

  if (a % x == 0) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
    int N; cin>>N;
    vi A(61);
    rep(i,0,N){
        int X; cin>>X;
        bitset<61> B(X);
        rep(j,0,61){
            if(B.test(j)) A[j]++;
        }
    }
    int ans=0;
    rep(i,0,61){
        ans+=(1ll<<i)%MOD*A[i]%MOD*(N-A[i])%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define FOR(i, m, n) for(int i = (int)m; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;
ll mod = 1000000007;
using namespace std;

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
k = int(input())
st = [[0 for _ in range(10)] for _ in range(11)]
for j in range(1, 10):
	st[1][j] = 1
for i in range(2, 11):
	st[i][1] = sum(st[j][1] for j in range(1, i)) + 1 + st[i-1][2]
	for j in range(2, 9):
		st[i][j] = st[i-1][j-1] + st[i-1][j] + st[i-1][j+1]
	st[i][9] = st[i-1][8] + st[i-1][9]

zero = [0 for _ in range(11)]
zero[1] = 1
for i in range(2, 11):
	zero[i] = sum(st[j][1] for j in range(1, i)) + 1
#print(zero)

cum = [0 for _ in range(11)]
cum[1] = 9
for i in range(2, 11):
	cum[i] = cum[i-1] + sum(st[i])


cnt = 0
ans = ""

flg = False
for i in range(1, 11):
	for j in range(1, 10):
		if cnt < k <= cnt+st[i][j]:
			x, y = i, j
			ans += str(y)
			k -= cnt
			flg = True
			break
		else:
			cnt += st[i][j]
	if flg:
		break
x -= 1

#print(x, y, k)
while x > 0:
	if 2 <= y:
		cnt = 0
		for j in range(y-1, min(y+2, 10)):
			if cnt < k <= cnt + st[x][j]:
				y = j
				x -= 1
				ans += str(y)
				k -= cnt
				break
			else:
				cnt += st[x][j]
	else:
		if k <= zero[x]:
			y = 0
			x -= 1
			ans += str(y)
		else:
			cnt = zero[x]
			for j in range(1, y+2):
				if cnt < k <= cnt + st[x][j]:
					y = j
					x -= 1
					ans += str(y)
					k -= cnt
					break
				else:
					cnt += st[x][j]

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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

class modInt{
    ll value;
    static const ll mod = 1000000007;

public:
    modInt(ll x=0): value{x % mod}{}

    inline modInt& operator+=(modInt x){
        value = (value + x.value) % mod;
        return *this;
    }

    inline modInt& operator-=(modInt x){
        value = (value + mod - x.value) % mod;
        return *this;
    }

    inline modInt& operator*=(modInt x){
        value = (value * x.value) % mod;
        return *this;
    }


    inline modInt operator/=(modInt x){
        *this *= x.inv();
        return *this;
    }

    inline modInt pow(modInt x, int n){
        modInt res = modInt(1LL);
        while(n > 0){
            if(n & 1)   res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }

    inline modInt inv(){
        modInt res = pow(value, mod-2);
        return res;
    }

    inline ll get(){
        return value;
    }
};

modInt operator+(modInt x, modInt y){
    return x += y;
}

modInt operator-(modInt x, modInt y){
    return x -= y;
}

modInt operator*(modInt x, modInt y){
    return x *= y;
}

modInt operator/(modInt x, modInt y){
    return x /= y;
}

ostream& operator<<(ostream& os, modInt x){
    return os << x.get();
}


class modIntCombinations{
    vector<modInt> factArray;

    void make_fact(ll x){
        for(auto i = factArray.size(); i <= x+1; i++){
            modInt y = factArray[i-1] * i;
            factArray.push_back(y);
        }
    }

public:
    modIntCombinations(){
        factArray.emplace_back(1);
    }

    modInt fact(ll x){
        if(factArray.size() < x+1){
            make_fact(x);
        }
        return factArray[x];
    }

    modInt comb(ll n, ll k){
        if(n < k){
            return modInt{0};
        }
        else{
            return fact(n) / fact(k) / fact(n - k);
        }
    }

    modInt perm(ll n, ll k){
        if(n < k){
            return modInt{0};
        }
        else{
            return fact(n) / fact(k);
        }
    }
};


int main(){
    ll r1, c1, r2, c2;  cin >> r1 >> c1 >> r2 >> c2;
    modIntCombinations mic;

    modInt res{0LL};
    for(ll i = c1; i <= c2; i++){
        res += mic.comb(r2 + i + 1, r2) - mic.comb(r1 + i, r1-1);
//        cout << mic.comb(r2 + i + 1, r2) - mic.comb(r1 + i, r1-1) << endl;
    }

    cout << res << endl;


    return 0;
}


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    double T, X; cin >> T >> X;
    double ans = T / X;
    cout << scientific << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      if(N%2==0){
        System.out.println(N/2);
      }else{
        System.out.println(N/2+1);
      }
    }
}

Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
int a,b,deg[5];
int main()
{
    for (int i=0;i<3;++i) {
        scanf("%d%d",&a,&b);
        ++deg[a];
        ++deg[b];
    }
    for (int i=1;i<=4;++i) if (deg[i]==0||deg[i]==3) {
        return 0*puts("NO");
    }
    puts("YES");
    return 0;
}


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a,b;
  cin >> a ;
  cout << pow(a,2) << endl;
}

Measured memory_bytes: 3800
#include<iostream>
#include<map>
#include<cstring>
#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define INIT(a) memset(a,0,sizeof(a))
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> P;
const int INF = 1e9+7;

int v;
P seg[4004000];

void init(int n){
  v = 1;
  while(v<n)v<<=1;
  rep(i,2*v-1)seg[i] = P(INF,INF);
}

void update(int x, P a){
  x += v-1;
  seg[x] = a;
  while(x){
    x = (x-1)/2;
    seg[x] = min(seg[2*x+1],seg[2*x+2]);
  }
}

P query(int a, int b, int k ,int l, int r){
  if(b<=l || r<=a)return P(INF,INF);
  if(a<=l && r<=b)return seg[k];
  P ql = query(a,b,2*k+1,l,(l+r)/2);
  P qr = query(a,b,2*k+2,(l+r)/2,r);
  return min(ql,qr);
}

int main(){
  int n,r,l;
  int d,t,x,prv=0;
  int len[1001000];

  INIT(len);
  cin >> n >> r >> l;
  init(n);
  rep(i,n)update(i,P(0,i));

  rep(i,r){
    cin >> d >> t >> x;
    P tmp = query(0,n,0,0,v);
    len[tmp.sc] += t-prv;
    prv = t;
    update(d-1,P(seg[d-1 +v-1].fs-x,d-1));
  }
  len[query(0,n,0,0,v).sc] += l-prv;

  int ans = 0;
  rep(i,n){
    if(len[ans] < len[i])ans = i;
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 36356
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define REFOR(i,m,n) for(int i=int(n-1); i>=int(m); i--)
#define ALL(obj) (obj).begin(),(obj).end()
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

#define PB push_back
#define Cout(str) cout << str << endl

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const ll EPS = (ll)1e-8;

int main(){
	int n,m;
	int a,b,c,d;
	int sum;
	string str;
	string s,t;
	char ch;
	VI vi;
	vector<char> vc;
	VS vs;
	int reserve_vi = 100;
	map<int, int> table; 
	string str2, str3;
	map<char, string> vowel;
	vector<char> vowel_vec = {'a', 'e', 'i', 'o', 'u'};

	//cin >> n >> m;
	//cin >> a >> b;
	//cin >> a >> b >> c;
	//cin >> a >> b >> c >> d;
	//cin >> str;
	//cin >> str >> str2 >> str3;
	cin >> n;
	
	//cin >> s >> t;
	//cin >> ch;
	//cin >> a >> ch >> b;
	

	if(n < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;

	//cout << accumulate(vi.begin(), vi.begin()+n, 0) << endl;
	//replace(ALL(str), ',', ' ');

	//swap(a, b);
	//vi.resize(N);
	//fill(vi.begin(), vi.end(), 1);
	//vi.reserve(reserve_vi);
	//vi.PB(n);

	//vc.resize(5);
	//vc[i] = (str[i]);

	//sort(vc.begin(), vc.end(), greater<char>());
	//sort(vc.begin(), vc.end());

	//for(auto itr = table.begin(); itr != table.end(); ++itr) {
	return 0;
}



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

int main(){
    string S;
    cin >> S;
    string result = "Yes";

   for(int i = 0; i < S.size() && result == "Yes"; i++){
        if(i % 2 == 0 && S[i] == 'L')
            result = "No";
        else if(i % 2 == 1 && S[i] == 'R')
            result = "No";
   }

    cout << result << endl;
    
}

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

int main()
{
	int n;
	cin >> n;
	int t[100], all = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> t[i];
		all += t[i];
	}
	int m;
	cin >> m;
	int p[100], x[100];
	for (int i = 0; i < m; ++i)
	{
		cin >> p[i] >> x[i];
		--p[i];
	}
	for (int i = 0; i < m; ++i)
	{
		cout << all - t[p[i]] + x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T>
inline bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template <class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) { return (a * b) / GCD(a, b);}

int main() {
    string n;
    cin >> n;
    char a = n[n.size() - 1];
    if (a=='3'){
        cout << "bon" << endl;
    }
    else if (a=='0' || a=='1' || a=='6' || a=='8'){
        cout << "pon" << endl;
    }
    else{
        cout<<"hon"<<endl;}
}


Measured memory_bytes: 3628
#include<iostream>
#define MOD 1000000007
long modpow(long a, long n){
    if(n == 0) return 1;
    long p;
    if(n%2 == 0){
        p = modpow(a, n/2);
        return p*p % MOD;
    }
    p = modpow(a, n-1);
    return p*a % MOD;
}

int main(){
    long n; std::cin >> n;
    long all = modpow(10,n);
    long comp = 2*modpow(9,n) - modpow(8,n);
    comp %= MOD;
    std::cout << (all - comp + MOD)%MOD << std::endl;
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORS(i,a,b) for(int i=a+1;i<=b;i++)
#define REP(i,N) FOR(i,0,N)
#define REPS(i,N) FORS(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){REP(i,N){REP(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
const int INF=100000000;
//--------------------------------------//
int main(){
	cint3(a,b,c);
	cint(d);
	if(abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d){
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define uint unsigned int
using namespace std;


inline int gcd(int a, int b) {

	int tmp;
	/* 自然数 a > b を確認・入替 */
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	int r;
	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int main() {
	int N;
	cin >> N;
	vector<int> raw_data(N);
	vector<int> to_right(N), to_left(N);
	// to left/right at(i) dont includ infomation at i
	for (int i = 0; i < N; i++) {
		cin >> raw_data.at(i);
	}
	// to right ruisekiwa
	to_right.at(0) = raw_data.at(0);
	to_left.at(N - 1) = raw_data.at(N - 1);
	for (int j = 1; j < N; j++) {
		to_right.at(j) = gcd(to_right.at(j - 1), raw_data.at(j - 1));
	}

	for (int j = N - 2; j >= 0; j--) {
		to_left.at(j) = gcd(to_left.at(j + 1), raw_data.at(j + 1));
	}
	int ans = max(to_left.at(0), to_right.at(N-1));
	for (int k = 1; k < N -1; k++) {
		ans = max(ans, gcd(to_right.at(k), to_left.at(k)));
	}

	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define MAXN 100
#define MAXT 200
using namespace std;
int main(void) {
  int n, t[MAXN + 1], v[MAXN + 1];
  int val[MAXT * MAXN * 2 + 1];
  cin >> n;
  t[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    t[i] += t[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  int time = 0;
  int maxtime = t[n] * 2;
  for (int i = 1; i <= n; i++) {
    for (; time < t[i] * 2; time++) {
      val[time] = v[i] * 2;
    }
  }
  for (int i = 1; i <= n; i++) {
    val[t[i] * 2] = min(val[t[i] * 2], val[t[i] * 2 - 1]);
  }
  val[0] = val[maxtime] = 0;
  for (int i = 1; i <= maxtime; i++) {
    val[i] = min(val[i - 1] + 1, val[i]);
  }
  for (int i = maxtime - 1 ; i >= 0; i--) {
    val[i] = min(val[i + 1] + 1, val[i]);
  }
  int ans = 0;
  for (int i = 0; i < maxtime; i++) {
    ans += val[i] + val[i + 1];
  }
  printf("%.15f\n", (double)ans / 8);
  //cout << (double)ans / 8 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll N,K,C;

vc<bool> work(string& S){
    ll rest = 0, cnt = 0;
    vc<bool> B(N);
    rep(i,N){
        if(S[i]=='o' and rest==0){
            cnt++;
            rest = C;
            B[i] = true;
        }
        else if(rest>0)
            rest--;

        if (cnt == K) break;
    }
    return B;
}
int main() {
    init();
    cin >> N >> K >> C;
    string S;
    cin >> S;
    string RS = S;
    reverse(all(RS));
    vc<bool> gl = work(S), gr = work(RS);
    reverse(all(gr));

    vl ans;
    ll l = 0, r = 0;
    rep(i, N){
        if (gl[i]) l++;
        if (gr[i]) r++;
        if (gl[i] and gr[i] and l == r) ans.eb(i + 1);
    }

    for (auto &a : ans) cout << a << endl;
}

Measured memory_bytes: 3848
import java.util.*;
import java.math.BigInteger;

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

		while(true){
			s = sc.next();
			BigInteger I = sc.nextBigInteger();
			if(s.equals("0") && I.equals(BigInteger.ZERO)) break;

			tree = new ArrayList<Node>();
			tree.add(new Node(' ',new ArrayList<Edge>()));
			idx = 0;
			makeMap(0);

			BigInteger sum = BigInteger.ZERO;
			for(Edge e : tree.get(0).eds) sum = sum.add(e.cost);
			System.out.println(sum.compareTo(I) <= 0 ? '0' : solve(I,0));
		}
	}

	private static String s;
	private static ArrayList<Node> tree;
	private static int idx;

	private static char solve(BigInteger rem,int pos){
		if(tree.get(pos).ch != ' '){
			return tree.get(pos).ch;
		}

		ArrayList<Edge> tmp = tree.get(pos).eds;
		int npos = 0;
		BigInteger sum = BigInteger.ZERO;
		int i = 0;
		for(;sum.compareTo(rem) <= 0 && i<tmp.size();i++){
			sum = sum.add(tmp.get(i).cost);
		}
		i--;
		rem = rem.subtract(sum).add(tmp.get(i).cost);

		return solve(rem.remainder(tmp.get(i).cost.divide(new BigInteger(Integer.toString(tmp.get(i).d)))), tmp.get(i).to);
	}

	private static BigInteger makeMap(int pos){
		BigInteger res = BigInteger.ZERO;
		BigInteger mul = BigInteger.ONE;

		for(;idx<s.length();idx++){
			char ch = s.charAt(idx);

			if('A' <= ch && ch <= 'Z'){
				tree.add(new Node(ch,new ArrayList<Edge>()));
				tree.get(pos).eds.add(new Edge(tree.size()-1,mul,1));
				res = res.add(mul);
			}
			else if(ch == '('){
				idx++;
				tree.add(new Node(' ',new ArrayList<Edge>()));
				int npos = tree.size() - 1;
				BigInteger cost = makeMap(npos);
				tree.get(pos).eds.add(new Edge(npos,cost.multiply(mul),Integer.parseInt(mul.toString())));
				res = res.add(cost.multiply(mul));
				mul = BigInteger.ONE;
			}
			else if(ch == ')'){
				return res;
			}
			else{
				String muls = "";
				for(;'0'<=s.charAt(idx) && s.charAt(idx)<='9';idx++)
					muls += s.charAt(idx);
				mul = new BigInteger(muls);
				idx--;
			}
		}
		return res;
	}
}

class Node{
	char ch;
	ArrayList<Edge> eds;

	Node(char ch,ArrayList<Edge> eds){
		this.ch = ch;
		this.eds = new ArrayList<Edge>(eds);
	}

	public String toString(){
		return String.format("[%c,"+eds+"]",ch);
	}
}

class Edge{
	int to;
	BigInteger cost;
	int d;

	Edge(int to,BigInteger cost,int d){
		this.to = to;
		this.cost = cost;
		this.d = d;
	}

	public String toString(){
		return String.format("[to%d,%s/%d]",to,cost.toString(),d);
	}
}

Measured memory_bytes: 13000
#include <string>
#include <iostream>
using namespace std;
string s, t; int n, a, b;
int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s >> t;
        if(s > t) a += 3;
        if(s < t) b += 3;
        if(s == t) a++, b++;
    }
    printf("%d %d\n", a, b);
    return 0;
}


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

int gcd(int A, int B){
  if(A==0){
    return B;
  }
  return gcd(B%A, A);
}

long long int lcm(int A, int B){
  return (((long long int)A * (long long int)B) / gcd(A, B));
}

int main(){
  int A, B;
  cin >> A >> B;
  cout << lcm(A, B) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vt vector
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

ll fp(ll a,ll n)
{
  ll ans=1;
  while(n)
  {
    if(n&1)
    {
      ans*=a;
      ans%=MOD;
    }
    a*=a;
    a%=MOD;
    n/=2;
  }
  return ans%MOD;
}

int main()
{
  fastio;
 
  
  int n;
  cin>>n;
  vt<ll> a(n);
  vt<ll> sum(n);
  range(i,0,n)
  {
    cin>>a[i];
  }  

 sum[0]=a[0]%MOD;
 range(i,1,n)sum[i]=(sum[i-1]+a[i])%MOD;
 ll b=0;
 range(i,0,n)
 {
 // cout<<(sum[n-1]-sum[i])<<' ';
    b+=a[i]*(sum[n-1]-sum[i]+MOD);
    b%=MOD;
 }
 cout<<b;

  
}


Measured memory_bytes: 6352
main()
{
	int N,X,Y;
	scanf("%d%d%d",&N,&X,&Y);
	int loop=Y-X+1;
	for(int k=1;k<N;k++)
	{
		int ans=0;
		int z=X<k?X-1:k-1;
		if(k-z<=loop/2)
		{
			int t=2*k-loop-1>0?2*k-loop-1:0;
			ans+=(z-t/2)*2;
			ans-=!(loop&1)&&loop/2<k&&k-loop/2<X;
		}
		z=N-Y<k-1?N-Y:k-1;
		if(k-z<=loop/2)
		{
			int t=2*k-loop-1>0?2*k-loop-1:0;
			ans+=(z-t/2)*2;
			ans-=!(loop&1)&&loop/2<k&&k-loop/2<N+1-Y;
		}
		if(N+1+X-Y>k)ans+=N+1+X-Y-k;
		if(k==1)ans--;
		else
		{
			ans-=X>=k;
			ans-=N-Y>=k-1;
		}
		if(k*2<loop)ans+=loop;
		else if(k*2==loop)ans+=loop/2;
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
const int Max = 1e5;
const int MOD = 1e9 + 7;

int n;
int main()
{
	scanf("%d", &n);
	printf("ABC%d\n", n);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char str[110];
int main(){
	ll k;
	scanf("%s%lld",str,&k);
	int len=strlen(str);
	for(int i=0;i<len;i++){
		if(str[i]=='1') k--;
		if(k==0 || str[i]!='1'){
			printf("%c\n",str[i]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let a: i64 = input();
    println!("{}", if n % 500 <= a { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
import bisect
N = 10**6
dp = [1] * (N+1)
dp[0] =  dp[1] =  0
prime = []
for i in range(2,N+1):
    if dp[i]:
        for j in range(i*i, N+1, i):
            dp[j] = 0
like2017 = [0] * (N+1)
for n in range(N+1):
    if dp[n]==0:
        continue
    query = (n+1)//2
    if dp[query]==1:
        like2017[n] = 1


for n in range(N):
    like2017[n+1] += like2017[n]

Q = int(input())
for q in range(Q):
    l, r = map(int,input().split())
    print (like2017[r]-like2017[l-1])


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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  string S;
  ll Q;
  cin >> S >> Q;

  string rev;
  int isrev = 0;
  rep(q, Q){
    int t;
    cin >> t;
    if(t == 1){
      isrev = 1 - isrev;
    }
    else{
      int f;
      char c;
      cin >> f >> c;
      if((!isrev && f == 1) || (isrev && f == 2)) rev.push_back(c);
      else S.push_back(c);
    }
  }
  if(!isrev){
    reverse(rev.begin(), rev.end());
    cout << rev << S << endl;
  }
  else{
    reverse(S.begin(), S.end());
    cout << S << rev << endl;
  }
  return 0;
}


Measured memory_bytes: 960
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,count_one=0,count_two=0,count_three=0,count_four=0;
  cin>>N;
  vector<string> S(N);
  for(int i=0; i<N; i++){
    cin>>S.at(i);
  }
  for(int i=0; i<N; i++){
    if(S.at(i)=="AC"){
      count_one++;
    }
    else if(S.at(i)=="WA"){
      count_two++;
    }
    else if(S.at(i)=="TLE"){
      count_three++;
    }
    else{
      count_four++;
    }
  }
  cout<<"AC"<<" "<<"x "<<count_one<<endl<<"WA"<<" "<<"x "<<count_two<<endl<<"TLE"<<" "<<"x "<<count_three<<endl<<"RE"<<" "<<"x "<<count_four<<endl;
}
    

Measured memory_bytes: 6400
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
  int d,t,s;
  double time;
  cin>>d>>t>>s;
  time = double(d)/double(s);
  //cout<<time<<"\n";
  if(time<=t){
    cout<<"Yes"<<"\n";
  }
  else{
    cout<<"No"<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3128
x, k, d = map(int, input().split())
x = abs(x)
res = x // d
if k <= res:
    print(abs(x - k * d))
elif (res + k) % 2 == 0:
    print(abs(x - res * d))
else:
    print(abs(x- (res + 1) * d))

Measured memory_bytes: 9080
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  map<int, int> w;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    w[a]++;
  }
  int res = 0;
  for (auto it : w) {
    if (it.second >= it.first) res += it.second - it.first;
    else res += it.second;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 4000+5;

int n;

int main(){
	ri(n);
	int edges = n * (n-1) / 2;
	if(n & 1){
		for(int i=1; i<n-i; i++){
			edges -= 1;
		}
		printf("%d\n",edges);
		for(int i=1; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				if(j == n - i) continue;
				printf("%d %d\n",i,j);
			}
		}
	}
	else{
		for(int i=1; i<n+1-i; i++){
			edges -= 1;
		}
		printf("%d\n",edges);
		for(int i=1; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				if(j == n + 1 - i) continue;
				printf("%d %d\n",i,j);
			}
		}
	}
	return 0;
}


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

using str = string;
using ss = stringstream;

using ll = long long;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

    ll n,m;cin>>n>>m;

    str s,t;cin>>s>>t;

    ll g=gcd(n,m);
    ll l=lcm(n,m);

    bool ans=true;

    for(int i=0;i<g;i++)
    {
        if(s[i*n/g]!=t[i*m/g]){ans=false;break;}
    }

    cout<<(ans?l:-1)<<"\n";

    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int h, w;
  std::cin >> h >> w;
  string hf(w + 2, '#');
  std::cout << hf << std::endl;
  REP(i, h) {
    string tmp = readString();
    std::cout << '#';
    std::cout << tmp;
    std::cout << '#' << endl;
  }
  std::cout << hf << std::endl;
}


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

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

	int cnt = 0;
	for (int i = 0; i < s.size() / 2; i++)
	{
		if(s[i] != s[s.size()-1-i])cnt++;
	}

	cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 256