akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class COneQuadrillionAndOneDalmatians {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            long n = s.nextLong();
            StringBuilder ans = new StringBuilder();
            while (n > 0) {
                ans.append((char) (((n - 1L) % 26L) + 'a'));
                n = (n - 1L) / 26L;
            }

            out.println(ans.reverse().toString());
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25444
C=str(input())

alph=['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']

for i in range(26):
    if alph[i]==C:
        print(alph[i+1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a;
    int cnt = 0;
    REP(i,n){
        cin >> a;
        if(a % 2 == 0){
            cnt++;
        }
    }
    if(cnt == n){
        cout << "second" << endl;
    }else{
        cout << "first" << endl;
    }
    return 0;
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }



vi mts { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };


void solve(int N, int M, vi& a) {
    vi u(8, -1);
    rep(i,M){
        int m = mts[ a[i] ];
        amax(u[m], a[i]);
    }

    vvi dp(N+10, vi(10, -1));
    dp[0] = vi(10, 0);

    rep(i,N){
        if (dp[i][0] == -1) continue;
        for (int m=2; m<=7; ++m) {
            if (u[m] == -1) continue;
            int p = 1 + (9 - u[m]);
            dp[i][0]++;
            dp[i][p]++;
            dp[i+m] = max(dp[i+m], dp[i]);
            dp[i][0]--;
            dp[i][p]--;
        }
    }
    for (int n=9; n>=1; --n) {
        rep(j, dp[N][1+9-n]) putchar('0'+n);
    }
    putchar('\n');
}

int main() {
    int N, M; cin >> N >> M;
    vi a(M);
    rep(i,M) cin >> a[i];
    solve(N,M,a);
    return 0;
}


Measured memory_bytes: 896
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>A(N+1);
    for (int i = 1; i <= N; i++)cin >> A[i];

    vector<int>l(N+1, 0), r(N+2, 0);
    for (int i = 1; i <= N; i++)l[i] = max(A[i], l[i - 1]);
    for (int i = 0; i < N; i++)r[N - i] = max(A[N - i], r[N - i + 1]);

    for (int i = 1; i <= N; i++)cout << max(l[i - 1], r[i + 1]) << endl;
}


Measured memory_bytes: 3968
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 200010, M = 2000005;
ll a;
double b;
int solve()
{
	cin>>a>>b;
	ll c = round(b*100);
	cout<<(a*c)/100<<endl;
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int ret = solve();
	return 0;
}
/*

*/


Measured memory_bytes: 3724
n, a, b = map(int, input().split())
s = input()
count = 0
fs = 0
for i in range(n):
    if s[i] == 'a' and count < a + b:
        print('Yes')
        count += 1
    elif s[i] == 'b' and count < a + b and fs < b:
        print('Yes')
        count += 1
        fs += 1
    else:
        print('No')

Measured memory_bytes: 9288
#include  <bits/stdc++.h>
using namespace std;
#define    error(args...){string _s=#args;replace(_s.begin(), _s.end(), ',', ' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);err(_it,args);}
void err  (istream_iterator<string> it) {}
template  <typename T, typename... Args>
void err  (istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<" ; ";
    err(++it, args...);
    cout << endl;
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/
/*Let's start.............*/
#define   ll                long long
#define   pb                push_back
#define   ff                first
#define   ss                second
#define   srt(v)            sort(v.begin(),v.end())
#define   inf               200000000000000000
#define   mxn               100009
#define   MOD               1000000007
#define   pi                acos(-1)



int main()
{

    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int cnt = 0;
    for(ll i = 0;i < 3;i++){
        if(s[i] == 'R') cnt++;
    }
    if(cnt == 3) cout << 3 << endl;
    else if(cnt == 2){
        if(s[1] == 'R') cout << 2 << endl;
        else cout << 1 << endl;
    }
    else if(cnt == 1) cout << 1 << endl;
    else  cout <<  0 << endl;
    return 0;
}


Measured memory_bytes: 3648
if __name__ == '__main__':
    arr = list(map(int,input().rstrip().split()))
    cou = 0
    cou_n = 0
    cou_m = 0
    i =1
    j    =1
    N = arr[0]
    M = arr[1]
    n =[]
    m = []
    while cou_n  != N:
        if i % 2 == 0:
            n.append(i)
            cou_n += 1
        i += 1

    while cou_m != M:
        if j % 2 != 0 :
            m.append(j)
            cou_m +=1
        j += 1
    f = n + m
# print(n)
# print(m)
    f.sort()

#start permutation
    for i in range(len(f)):
        for j in range(i+1,len(f)):
            if ((f[i] + f [j]) % 2) == 0:
                cou +=1
    print(cou)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

int main() {
  unsigned N, P;
  std::cin >> N >> P;
  std::vector<unsigned> A(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> A[i];
    A[i] %= 2;
  }
  std::vector<unsigned long long> dp0(N, 0);
  std::vector<unsigned long long> dp1(N, 0);
  if (A[0] % 2 == 0) {
    dp0[0] = 2;
    dp1[0] = 0;
  } else {
    dp0[0] = 1;
    dp1[0] = 1;
  }
  for (unsigned i = 1; i < N; ++i) {
    if (A[i] % 2 == 0) {
      dp0[i] = dp0[i - 1] * 2;
      dp1[i] = dp1[i - 1] * 2;
    } else {
      dp0[i] = dp0[i - 1] + dp1[i - 1];
      dp1[i] = dp0[i - 1] + dp1[i - 1];
    }
  }
  if (P) {
    std::cout << dp1[N - 1] << std::endl;
  } else {
    std::cout << dp0[N - 1] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 888
// AOJ 2666 Arojam's Mask
// 2019.4.3 bal4u

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

//// 高速入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

// 数値のハッシュ関数
#define HASHSIZ 2000081
int hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

int insert(int node, int days, unsigned char event)
{
	int x = ((node + 1) << 16) | (days << 8) | event;
	int *p = hash + x % HASHSIZ;
	while (*p) {
		if (*p == x) return 0;
		if (++p == hashend) p = hash;
	}
	*p = x;
	return 1;
}

//// 本問題関連
typedef struct { int node, days, step; unsigned char event; } Q;
Q que[2000000]; int top, end;

typedef struct { int to; unsigned char cond; } T;  // 移動先、発生するイベント、移動できる条件
T to[102][102]; int hi[102];
int N, E, R;
int goEvent[102];

int bfs(int start, int goal)
{
	int i, node, days, step, event;

	top = 0, end = 1;
	que[0].node = start, que[0].days = 0, que[0].event = 1;
	while (top != end) {
		node = que[top].node, days = que[top].days, step = que[top].step, event = que[top++].event;
		if (node == goal) return step;

//		printf("node=%d, days=%d, step=%d, event=%x\n", node, days, step, event);
		if (!insert(node, days, event)) continue;

		event |= goEvent[node];    // 頂点に到着すると発生するイベント
		if (days < R) {
			for (i = 0; i < hi[node]; i++) {
				int _to = to[node][i].to, _cond = to[node][i].cond;
				if (_cond & event) {
					que[end].node = _to, que[end].days = days + 1, que[end].step = step + 1;
					que[end++].event = event;
				}
			}
		}
		que[end].node = start, que[end].days = 0, que[end].step = step + 1;
		que[end++].event = event;
	}
	return -1;
}

int main()
{
	int i, k, M, S, T, a, b, c;

	N = in(), M = in(), E = in();
	S = in(), T = in(), R = in();
	for (i = 0; i < M; i++) {
		a = in(), b = in();
		k = hi[a]++, to[a][k].to = b, to[a][k].cond = 0xff;
		k = hi[b]++, to[b][k].to = a, to[b][k].cond = 0xff;
	}
	for (i = 1; i <= E; i++) {
		a = in(), b = in(), c = in();
		k = hi[a]++, to[a][k].to = b, to[a][k].cond = 1 << i;  // イベント1 を無条件移動に使う
		k = hi[b]++, to[b][k].to = a, to[b][k].cond = 1 << i;
		goEvent[c] = 1 << i;
	}
	printf("%d\n", bfs(S, T));
	return 0;
}


Measured memory_bytes: 2196
n, a, b = [int(i) for i in input().split()]
sum = 0
for i in range(1, n + 1):
    digitSum = 0
    target = i
    while target > 0:
        digitSum += target % 10
        target = int(target / 10)
    if a <= digitSum <= b:
        sum += i
print(sum)

Measured memory_bytes: 3060
import sys
import heapq

ans = 'Yes'
N = int(input())

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

d.sort(key=lambda x:x[1])
T = 0
for i in range(N):
    T += d[i][0]
    if T > d[i][1]:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 53736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(a-b >= 0) cout << "delicious" << endl;
    else if(b-a-x > 0) cout << "dangerous" << endl;
    else cout << "safe" << endl;     
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq

M = 10 ** 9 + 7

def solve(N):
    if N == 1:
        return 0
    if N == 2:
        return 2
    else:
        ans = pow(10, N, M)
        ans -= pow(9, N, M) * 2
        ans += pow(8, N, M)
    return ans
if __name__ == "__main__":
    N = int(input())
    print(solve(N) % M)



Measured memory_bytes: 9484
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
ll len=1;
ll val=26;
ll x=n;
vector<ll>pow26;
pow26.pb(1);
while((x-val)>0)
{
    pow26.pb(val);
    x=x-val;
    val=val*26;
    len++;
}
string ans="";
for(ll i=0;i<len;i++)
{
    char last='a';
    for(ll j=0;j<26;j++)
    {
        if(x-pow26[len-i-1]>0)
        {
            x=x-pow26[len-i-1];
            last++;
        }
    }
    ans+=last;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 5, P = 998244353;
int n, a, b;
ll k, ans;
ll fac[maxn], inv[maxn], facinv[maxn];
ll C(int n, int m) {
	return fac[n] * facinv[m] % P * facinv[n - m] % P;
}
int main() {
	scanf("%d%d%d%lld", &n, &a, &b, &k);
	fac[0] = 1; inv[0] = inv[1] = 1; facinv[0] = facinv[1] = 1; 
	for(int i = 1; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % P;
		if(i != 1) {
			inv[i] = (P - P / i) * inv[P % i] % P;
			facinv[i] = facinv[i - 1] * inv[i] % P;
		}
	}
	for(int i = 0; i <= n; ++i) {
		ll j = k - 1LL * a * i;
		if(j % b != 0 || j / b < 0 || j / b > n) continue;
		j /= b;
		ans = (ans + C(n, i) * C(n, j) % P) % P; 
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; 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; }



int main()
{
	cout << fixed << setprecision(18);

	ll n, x, y;
	ll d[2005][2005];
	memset(d, 0, sizeof(d));
	ll count[2005];
	memset(count, 0, sizeof(count));

	cin >> n >> x >> y;

	rep(i, n)
		d[i][i + 1] = d[i + 1][i] = 1;
	d[x - 1][y - 1] = 1;

	rep(i, n){
		for (ll j = i + 2; j < n; j++) {
			if (j != y - 1)
				d[i][j] = d[i][j - 1] + 1;
			else if (i != x - 1) {
				if (i < x - 1)
					d[i][j] = d[i][x - 1] + 1;
				else
					d[i][j] = d[i][j - 1] + 1;
			}

			d[j][i] = d[i][j];
		}
	}

	rep(i, n) {
		for (ll j = i + 1; j < n; j++)
		{
			d[i][j] = min(d[i][j], min(d[i][x - 1] + 1 + d[j][y - 1], d[i][y - 1] + 1 + d[j][y - 1]));
		}
	}

	rep(i, n) {
		for (ll j = i + 1; j < n; j++) {
			count[d[i][j]]++;
		}
	}

	rep1(i, n)
		cout << count[i] << endl;

	return 0;
}

Measured memory_bytes: 31616
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  typedef pair<int, int> P;
  int N; cin >> N;
  vector<P> vec(N);
  REP(i, N) cin >> vec[i].first >> vec[i].second;

  int ans = N;
  REP(i, N) REP(j, N){
    if(i == j) continue;
    P diff;
    diff.first = vec[i].first-vec[j].first;
    diff.second = vec[i].second-vec[j].second;
    int cnt = 0;
    REP(k, N) REP(l, N){
      if(k == l) continue;
      P d;
      d.first = vec[k].first - vec[l].first;
      d.second = vec[k].second - vec[l].second;
      if(diff == d) cnt++;
    }
    ans = min(ans, N-cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int

int main(){
	int t, a=0;
	scanf("%d", &t);
	char s[11];
	sprintf(s, "%d", t);
	for(int i=0, g=strlen(s); i<g; i++) {
		a += s[i]-'0';
	}
	printf("%s\n", t%a ? "No" : "Yes");
}

Measured memory_bytes: 3724
n=int(input())
a=list(map(int,input().split()))
a.append(0)
ans=0
t=a[0]
c=1
for i in range(1,n+1):
    if t==a[i]:
        c+=1
    else:
        ans+=c//2
        t=a[i]
        c=1
print(ans)

Measured memory_bytes: 3064
import math

def read_input():
    n = int(input())
    alist = list(map(int, input().split()))
    return n, alist


def calc_se(t, alist):
    return sum([(t - a) ** 2 for a in alist])


def submit():
    n, alist = read_input()
    avg_alist = sum(alist)/n

    cand1 = math.floor(avg_alist)
    cand2 = math.ceil(avg_alist)

    if cand1 == cand2:
        se = calc_se(cand1, alist)
    else:
        se1 = calc_se(cand1, alist)
        se2 = calc_se(cand2, alist)
        se = min(se1, se2)

    print(se)

if __name__ == '__main__':
    submit()


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

const int N = 200100;
const int MOD = (int) 1e9 + 7;
int n, k;
ll dp[N];
ll ans;

int main(){
    cin >> n >> k;
    for (int i=2; i<=n+1; i++) dp[i] = (dp[i-1] + i - 1) % MOD;
    //for (int i=1; i<=n+1; i++) cout << i << " : " << dp[i] << '\n';
    for (int i=k; i<=n + 1; i++){
        //cout << i << " : " << (dp[n+1] - dp[n + 1 - i]) - dp[i] + 1 << '\n';
        ans = (ans + (dp[n+1] - dp[n + 1 - i]) - dp[i] + 1 + MOD) % MOD;
    }
    cout << ans;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n, k ;
    cin >> n >> k ;
    vll ans(n) ;
    REP(i,n){
        cin >> ans[i] ;
    }
    bool f = true ;
    while(f){
        vll zero(n,0) ; 
        if(k<=0){
            break ;
        }
        REP(i,n){
            if(ans[i]!=n){
                break ;
            }
            if(i==n-1){
                f = false ;
            }
        }
        REP(i,n){
            zero[max((ll)0,i-ans[i])]++ ;
            if(i+ans[i]+1<=n-1){
                zero[i+ans[i]+1]-- ;
            }
        }
        REP(i,n-1){
            zero[i+1] += zero[i] ;
        }
        ans = zero ;
        k-- ;
    }
    REP(i,n){
        cout << ans[i] <<" " ;
    }
    cout << endl;

    vll tmp(n) ;




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



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

int main() {
    int n; cin >> n;
    long long seat = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        seat += r - l + 1;
    }

    cout << seat << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;

int main() {
	ll n;
	cin >> n;
	cout << ((1 + n) * n) / 2 - n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, i, tall;
  long long int sum = 0;
  scanf("%d", &n);
  int a[n];

  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  tall = a[0];
  for(i = 1; i < n; i++){
    if(tall <= a[i]){
      tall = a[i];
    }else{
      sum += tall - a[i];
    }
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, cnt=0;
    scanf("%d", &n);
    int arr[n+1];
    for(int i=1; i<=n; i++)
        scanf("%d", arr+i);
    for(int i=1; i<=n; i++)
    {
        if(arr[i]!=i)
            cnt++;
    }
    if(cnt>2)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n, x;
	cin >> n >> x;
	vi m(n);
	rep(i, n)cin >> m[i];
	rep(i, n) {
		x -= m[i];
	}
	sort(all(m));
	int ans = n;
	while (x >= m[0]) {
		x -= m[0];
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
  int n = ri();
  int m = ri();
  int a[n];
  INPUT(a);
  int sum[n];
  INIT(sum);
  sum[0]=a[0]%m;
  FROMTO(i,1,n-1) sum[i]=(((s64)sum[i-1])+a[i])%m;
  
  map<int,int> ar;
  FOR(i,n) {
      ar[sum[i]]++;
  }
  u64 res = 0;
  for (auto i : ar) {
      int ii = i.se;
      if (!i.fi) res += (((u64)ii)*(ii+1))/2;
      else res += (((u64)ii)*(ii-1))/2;
  }
  
  wu64(res);
  
  return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
 
#define int         long long
#define ll          long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
} 
void solve(){
    int x;
    cin >> x;
    if(x <= 599)cout << "8\n";
    else if(x <= 799)cout << "7\n";
    else if(x <= 999)cout << "6\n";
    else if(x <= 1199)cout << "5\n";
    else if(x <= 1399)cout << "4\n";
    else if(x <= 1599)cout << "3\n";
    else if(x <= 1799)cout << "2\n";
    else cout << "1\n";
}
 
signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

Measured memory_bytes: 3656
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    int m = kbd.nextInt();
	    if(n!=0 && m!=0){
		int[] date = new int[101];

		while(n!=0){
		    int s = kbd.nextInt();
		    while(s!=0){
			int a = kbd.nextInt();
			date[a]++;
			s--;
		    }
		    n--;
		}

		int ans = 0;
		for(int i=0; i<date.length; i++){
		    if(date[i]>=m && date[ans]<date[i])
			ans = i;
		}

		System.out.println(ans);
	    }
	}
    }
}

Measured memory_bytes: 63020
import sys
input = sys.stdin.readline
 
N=int(input())
box = [[None]*N for i in range(N)]
for i in range(N):
  A = int(input())
  for j in range(A):
    x,y = map(int,input().strip().split())
    box[i][x-1]=y

ans=0
for bi in range(2 ** N - 1, -1, -1):
  chk=True
  for i,A in enumerate(box):
    if (bi>>i)%2 == 0:
      continue
    for j,y in enumerate(A):
      if y is None:
        continue
      elif y == 0 and (bi>>j)%2 == 1:
        chk=False
        break
      elif y == 1 and (bi>>j)%2 == 0:
        chk=False
        break
      else:
        pass
    if not chk:
      break
  if chk:
    tmp=0
    for c in range(N):
      if (bi>>c)%2 == 1:
        tmp+=1
    ans=max(ans,tmp)
print(ans)


Measured memory_bytes: 46192
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 












int main()
{
     int x,y;
     cin>>x>>y;
     int t1=(y-2*x)/2,rem1=(y-2*x)%2;
     int t2=(4*x-y)/2,rem2=(4*x-y)%2;
     if(rem1==0&&rem2==0&&t1>=0&&t2>=0)
     {
          cout<<"Yes";
     }
     else cout<<"No";
     
}







 
 

















Measured memory_bytes: 3620
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n:Vec<usize> = read_vec();
    let mut a = Vec::new();
    let mut b = Vec::new();
    for _i in 0..n[0] {
        let v:Vec<i32> = read_vec();
        a.push(v);
    }
    for _i in 0..n[1] {
        let x:i32 = read();
        b.push(x);       
    }
    // println!("a {:?}", a);
    // println!("b {:?}", b);

    for i in 0..n[0] {
        let mut sum:i32 = 0;
        for j in 0..n[1] {
            sum += a[i][j] * b[j];
        }
        println!("{}", sum);
    }

}


Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  char f[53][53];
  bool flag=true;
  cin>>h>>w;
  for(int i=0;i<=h+1;i++){
    for(int j=0;j<=w+1;j++){
      if(i==0||j==0||i==h+1||j==w+1){
        f[i][j]='.';
        continue;
      }
      cin>>f[i][j];
    }
  }
  for(int i=1;i<=h&&flag;i++){
    for(int j=1;j<=w&&flag;j++){
      if(f[i][j]=='#'&&f[i-1][j]=='.'&&f[i+1][j]=='.'&&f[i][j-1]=='.'&&f[i][j+1]=='.')
        flag=false;
    }
  }
  cout<<(flag?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int64_t sum = 0; 
	for(int i = 1; i <= N; i++) {
		if(i % 3 != 0 && i % 5 != 0){
			sum += i;
		}
	}
	cout << sum << endl;

}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000009
#define pb push_back 
#define pf push_front
deque <int> q;
int k;
int dist[100005];
int main(){
	cin>>k;
	for(int i=0;i<=k;i++)	dist[i]=INF;
	q.pb(1);
	dist[1]=1;
	while(!q.empty()){
		int x=q.front();
		q.pop_front();
		if(dist[(x*10)%k]>dist[x]){
			dist[(x*10)%k]=dist[x];
			q.pf((x*10)%k);
		}
		if(dist[(x+1)%k]>dist[x]+1){
			dist[(x+1)%k]=dist[x]+1;
			q.pb((x+1)%k);
		}
	}
	cout<<dist[0];
	return 0;
}

Measured memory_bytes: 896
// inputに入力データ全体が入る
function Main(input) {
	var N = input;
	var splited = N.split('');
	var count = 0;
	for (var i = 0; i < 4; i++) {
		if (splited[i] == '2') {
			count++;
		}
	}
	console.log(count);
}

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

/*
int main(){
    int a;
    cin >> a;
    if (a <= 999){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
}

*/

int main(){
    int n; cin >> n;
    if(n >= 1000){
        cout << "ABD" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var K = int.Parse(Console.ReadLine());
            if (K % 2 == 0 || K % 5 == 0)
            {
                Console.WriteLine(-1);
                return;
            }
            var n = 7L;
            var answer = 1L;
            while (n % K != 0)
            {
                n *= 10;
                n += 7;
                n %= K;
                answer++;
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin >> n >>k;
  vl h(n);
  rep(i,n) cin >> h[i];
  if(n<=k){
    cout<<0<<endl;
    return 0;
  }
  sort(h.begin(),h.end(),greater<ll>());

  rep(i,k)h[i] = 0;
  ll sumH=0;
  rep(i,n){
    sumH+=h[i];
  }
  cout<<sumH<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{

    int n=0;
    cin>> n;
    int b[n]={0};

    for(int i=0;i<n-1;i++){
        int a=0;
        cin>>a;
        a=a-1;
        b[a]++;
    }

    for(int j=0;j<n;j++){
        cout<< b[j]<<"\n";
    }
}


Measured memory_bytes: 4384
/*
* All my senses intensify
* Whenever you and I, we dive
*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf ((ll)1e18)
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
const ll nax = 2000006;
ll fact[nax] , inv[nax];
ll power(ll a, ll b, ll m)
{
	if(b == 0) return 1;
	if(b == 1)
		return a % m;
	ll temp = power( a , b / 2 , m );
	temp = ( temp * temp ) % m;
	if(b % 2)
		temp = (a * temp) % m;
	return temp;
} 
void calc_fact(ll n)
{
	fact[0] = 1;
	inv[0] = 1;
    for(ll i = 1 ; i < n ; i++ )
	{
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = power(fact[i] , mod - 2 , mod);
	}
}
ll give(ll x , ll y)
{
	if(min(x , y) < 0) return 0;
	ll res = 0;
	ll t = inv[y];
	for(ll i = 1 ; i <= x + 1 ; i++ )
 	{

 		res = res + ( fact[i + y]  * inv[i] % mod) ;
 		if(res > mod) res -= mod;
 	}
 	return res * t % mod ;
}
int main()
{
    // fast();    
    calc_fact(nax);
    ll r1 ,r2 , c1,c2;
    cin>>r1>>c1>>r2>>c2;
    ll ans = (give(r2 , c2) - give(r2 , c1 - 1) - give(r1 - 1 , c2) + give( r1 - 1 , c1 - 1)) % mod;
    if(ans < 0) ans += mod;
    cout<<ans<<endl;
}


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

int main( void )
{
	register int i, j;

	register bool isPrime[50001 + 1];
	isPrime[2] = true;
	for ( i = 3; i < 50001; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( i = 3; i < 50001; i += 2 )
	{
		for ( j = i + i; j < 50001; j += i )
		{
			isPrime[j] = false;
		}
	}

	int cnt = 1;
	register int primes[5500];
	primes[0] = 2;
	for ( i = 3; i < 50001; i += 2 )
	{
		if ( isPrime[i] )
		{
			primes[cnt] = i;
			cnt++;
		}
	}

	int n;
	while ( cin >> n && n != 0 )
	{
		int kotae = 0;
		for ( i = 0; i < cnt; i++ )
		{
			if ( primes[i] <= n / 2 )
			{
				if ( isPrime[n-primes[i]] )
					kotae++;
			}
		}
		cout << kotae << endl;
	}

	return 0;
}

Measured memory_bytes: 936
#include <iostream>
using namespace std;
int main()
{
    char s[4], b=0;
    for(int i=0; i<4; i++)
        cin >> s[i];
    for(int i=0; i<3; i++)
    {
        for(int a=i+1; a<4; a++)
        {
            if(s[i]==s[a])
                b++;
        }
    }
    if(b==2)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		int result = 0;
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    if(i%2 == 0 && a%2 == 1) result++;
		}
		

		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
	
}



Measured memory_bytes: 25384
from collections import defaultdict
 
N = int(input())
raw_numbers = list(map(int, input().split()))
 
total = sum(raw_numbers)
 
numbers = defaultdict(int)
 
for num in raw_numbers:
    numbers[num] += 1

Q = int(input())

for i in range(Q):
    a, b = map(int, input().split())
    taken = numbers[a]
    total -= numbers[a]*a
    numbers[b] += numbers[a]
    numbers[a] = 0
    total += taken*b
    print(total)

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

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    if(s[k-1] == 'A') s[k-1] = 'a';
    if(s[k-1] == 'B') s[k-1] = 'b';
    if(s[k-1] == 'C') s[k-1] = 'c';

    cout << s << endl;

    return 0;
}


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

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}
ll mod=1e9+7;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
 
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    
    for(int i=0;i<n;i++)
    	cin >> a[i];
    int npos = 0;
    for(int i=0;i<n;i++)
    	if (a[i] >= 0) ++npos;
    int nneg = n - npos;
    bool ok = false;
    if (npos > 0) {
        if (k==n) ok = (nneg%2==0);
        else ok = true;
    }
    else ok = (k%2==0);
    mint ans = 1;
    if (ok) {
        vector<ll> pos, neg;
        for(int i=0;i<n;i++) {
            if (a[i] >= 0) pos.push_back(a[i]);
            else neg.push_back(a[i]);
        }
        sort(neg.begin(),neg.end());
        if (k%2==1) {
            sort(pos.begin(),pos.end());
            ans *= pos.back();
            //ans%=mod;
            pos.pop_back();
            reverse(pos.begin(),pos.end());
        }
        else{ 
        	sort(pos.begin(),pos.end());
        	reverse(pos.begin(),pos.end());
        }
        vector<ll> x;
        for (int i=0; i+1<pos.size(); i+=2) x.push_back((pos[i])*pos[i+1]);
        for (int i=0; i+1<neg.size(); i+=2) x.push_back((neg[i])*neg[i+1]);
        sort(x.begin(),x.end());
        reverse(x.begin(),x.end());
        for(int i=0;i<k/2;i++){
        	ans *= x[i];
        	//ans%=mod;
        }
    }
    else {
        sort(a.begin(),a.end());
        reverse(a.begin(),a.end());
        for(int i=0;i<k;i++){
        	ans *= a[i];
        	//ans%=mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8200
#include<iostream>

using namespace std;

int main() {
  string s = "CODEFESTIVAL2016",t;
  getline(cin,t);
  int mini = 0;
  for(int i=0;i<(int)s.size();++i) if( s[i] != t[i] ) ++mini;
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256