akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Control.Applicative
import Data.List


-- [a] <- map read . words <$> getLine => [1] -> a == 1
-- 1
-- a <- readLn
-- 1 2 3
-- lst <- map read . words <$> getLine => [1, 2, 3]
-- 1 2 3
-- [l, m, n] <- map read . words <$. getLine :: IO [Int] => [1, 2, 3]
-- 'a'
-- c <- getChar => c == 'a'
--
-- slst <- replicateM h getLine

getBysplit = map read . words <$> getLine

main :: IO()
main = do
  n <- readLn :: IO Int
  lst <- getBysplit :: IO [Int]
  print $ count $ reverse lst

check :: Int -> [Int] -> Bool
check h = all (<=h) 

count :: [Int] -> Int
count [] = 0
count [x] = 1
count (x:xs) = if check x xs
              then 1 + count xs
              else count xs


Measured memory_bytes: 636
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
n = int(input())
#n, k = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

q = int(input())
l = [0 for i in range(10 ** 5 + 2)]
for i in range(n):
    l[a[i]] += 1

ans = sum(a)
for i in range(q):
    b, c = map(int, sys.stdin.readline().split())
    ans += (c-b) * l[b]
    l[c] += l[b]
    l[b] = 0
    print(ans)

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> a(N), b(N);
    rep(i, N) cin >> a[i] >> b[i];

    vector<P> v(N);
    rep(i, N) v[i] = P(a[i], b[i]);

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

    ll cnt = 0;
    int ans = 0;
    rep(i, N) {
        cnt += v[i].second;
        if (K <= cnt) {
            ans = v[i].first;
            break;
        }
    }

    cout << ans << endl;
}

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

#define SHEEP 0
#define WOLF 1

const char OUT[] = "SW";

int N;
char S[114514];
int ans[114514];

int main() {
  scanf("%d", &N);
  scanf("%s", S);

  for (int a=0; a<2; a++) {
    for (int b=0; b<2; b++) {
      ans[0] = a;
      ans[1] = b;
      for (int i=1; i<N-1; i++) {
        ans[i+1] = ans[i-1] ^ (ans[i] == SHEEP) ^ (S[i] == 'o');
      }

      bool failed = false;
      for (int i=0; i<N; i++) {
        int t = ans[(i+N-1)%N] ^ ans[(i+1)%N];
        int s = (ans[i] == SHEEP) ^ (S[i] == 'o');
        if (s != t) {
          failed = true;
          break;
        }
      }

      if (!failed) {
        for (int i=0; i<N; i++) {
          printf("%c", OUT[ans[i]]);
        }
        puts("");
        return 0;
      }
    }
  }
  puts("-1");
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void) {
	int a,b,c,max=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a*10+b+c>=max)max=a*10+b+c;
	if(b*10+a+c>=max)max=b*10+a+c;
	if(c*10+a+b>=max)max=c*10+a+b;
	
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
object Main extends App {
	val n = scala.io.StdIn.readInt
	val x = scala.io.StdIn.readLine.split(" ").map(_.toLong)
	val y = x.sorted

	val a = y(n/2)
	val b = y(n/2 - 1)

	for(i<-0 until n){
		if(x(i) < a){
			println(a)
		}else{
			println(b)
		}
	}
 
}

Measured memory_bytes: 87516
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

int main(){
    int n;
    cin >> n;
    vector<ll> num(n);
    rep(i, n) cin >> num[i];
    ll ans = num[0];
    rep(i, n-1) {
        ans = gcd(ans, num[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 1e5 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;

void solve() {
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	double ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += 1.0/a[i];
	}
	// cout << ans;
	ans = 1.0/ans;
	cout << setprecision(12) << ans;
}
int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int AB = Integer.parseInt(sc.next());
		int BC = Integer.parseInt(sc.next());
		int CA = Integer.parseInt(sc.next());
		sc.close();

		int triangle = AB * BC / 2;
		System.out.println(triangle);
	}
}

Measured memory_bytes: 22612
//code by lynmisakura.wish to be accepted
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;

#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main(void){
	
	int n;cin >> n;
	vector<double> a(n);
	double m = 1.0000000000;
	double  s = 0.0000000000;
	rep(i,n){
		cin >> a[i]; m *= a[i];
	}
	rep(i,n){
		s +=  (m / a[i]);
	}
	cout << (double)m / (double)s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;

#define _(x) {cout << #x << " = " << x << " ";}
#define fast ios::sync_with_stdio(false);cin.tie(NULL)

#define fi first 
#define se second 
#define mp make_pair
#define pb push_back

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define clr(v,d) memset(v,d,sizeof(v))
#define sz(v) ((int)((v).size()))

const int MAXN = 1e5 + 10;
ll n,m,j,k,s,t,e,q,l,r,d,cou=0,i;
int a[100][100];
int main()
{   
    
    fast;
    cin>>n>>d;
    rep(i,0,n)
      rep(j,0,d)
        cin>>a[i][j];
    rep(i,0,n)
    {
        rep(j,i+1,n)
        {
            ll ans=0;
            rep(k,0,d)
            {
                ans+=(abs(a[i][k]-a[j][k]))*(abs(a[i][k]-a[j][k]));
            }
            double val = sqrt(ans);
            if(!(val-floor(val)))
                cou++;
        }
    } 
    cout<<cou;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0) 
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int inf = ~0u >> 1;
ll a[maxn];
map<ll, ll> m;
int main() {
    IO;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        m[a[i] + i]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += m[i - a[i]];
        //cout << "i = " << i << " cnt[" << i - a[i] << "]: " << m[i - a[i]] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27960
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ca=1;
		while(n-->0)
		{
			System.out.println("Case "+ca+":");
			int x = sc.nextInt();
			for(int i=0; i<10; i++)
			{
				x*=x;
				String str = String.valueOf(x);
				// str = x+"";
				while(str.length()<8)
				{
					str = "0"+str;
				}
				x = Integer.valueOf(str.substring(2,6));
				System.out.println(x);
			}
			ca++;
		}
	}
}

Measured memory_bytes: 11000
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    set<string> c;
    lli n;
    cin >> n;
    char rec;
    rep(i, n) {
        string w;
        cin >> w;
        if(i==0)
        {
            rec = w[w.size() - 1];
            c.insert(w);
        }
        else
        {
            if(c.count(w)||rec!=w[0])
            {
                out("No");
                return 0;
            }
            c.insert(w);
            rec = w[w.size() - 1];
        }
    }
    out("Yes");
}

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

int main() {
    vector<int> a(3, 0);
    for (int i = 0; i < 3; i++) cin >> a[i];
    swap(a[0], a[1]);
    swap(a[0], a[2]);
    for (int i = 0; i < 3; i++) {
        if (i != 3) cout << a[i] << " " << endl;
        else cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ff(i,s,n) for(int i=s;i<n;i++)
#define fr(i,s,n) for(int i=n-1;i>=s;i--)
#define llu long long int

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	llu n,x,t,res=0;
	cin>>n>>x>>t;
	while(n>=x){
		res+=t;
		n-=x;
	}
	if(n!=0)
		res+=t;
	cout<<res;
}

//1
//7 2
//3 5 4 5 1 1 1


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    cin >> N;
    string S[N];
    rep(i, N) cin >> S[i];
    map<string, int> mp;
    rep(i, N){
        if(mp.count(S[i]) == 0){
            mp[S[i]] = 0;
        }
        mp[S[i]]++;
    }
    int mx = 0;
    for(auto p : mp) mx = max(mx, p.second);
    for(auto p : mp){
        if(p.second == mx) cout << p.first << endl;
        else continue;
    }
    return 0;
}

Measured memory_bytes: 26752
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*w+(j))

int calc(char *s,int h,int w){
  int cnt[26]={0};
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cnt[s[POS(i,j)]-'a']++;
    }
  }
  int c2=0;
  int c1=0;
  for(i=0;i<26;i++){
    c2+=cnt[i]%4;
    c1+=cnt[i]%2;
  }
  if(h%2==0 && w%2==0) return c2==0 && c1==0;
  if(h%2==1 && w%2==1) return c1==1 && c2-c1<=h-1+w-1;
  if(h%2==1) return c1==0 && c2<=w;
  return c1==0 && c2<=h;
}

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  char *s=(char *)malloc(sizeof(char)+(h*w+1));
  int i;
  for(i=0;i<h;i++) scanf("%s",s+POS(i,0));
  printf("%s\n",calc(s,h,w)?"Yes":"No");
}

int main(void){
  run();
  return 0;
}


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

int main()
{
ll t;
t=1;
while(t--)
{

ll a,b,t,s=0,i;
cin>>a>>b>>t;
if(t>=a)
{

for(i=a;i<=(t+0.5);i=i+a)
{
s=s+b;
}
cout<<s<<endl;
}
else
cout<<0<<endl;

}
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int N, X ,Y;
pair <int, int> Array[200005];
int Fact[200005], InvFact[200005];
const int MOD = 1000000007;
int MinW[200005];
set <pair <int, int> > S;
int Colour[200005], total;
int powerLog(int n, int p)
{
    int sol = 1;
    while(p)
    {
        if((p & 1))
        {
            sol = (1LL * sol * n) % MOD;
        }
        n = (1LL * n * n) % MOD;
        p /= 2;
    }
    return sol;
}
void precalcFact()
{
    Fact[0] = InvFact[0] = 1;
    for(int i = 1; i <= N; i++)
    {
        Fact[i] = (1LL * Fact[i - 1] * i) % MOD;
        InvFact[i] = powerLog(Fact[i], MOD - 2);
    }

}

void Read()
{
    cin >> N >> X >> Y;
    total = N;
    for(int i = 1; i <= N; i++)
    {
        cin >> Array[i].first >> Array[i].second;
        Colour[Array[i].first]++;
        MinW[i] = 1000000005;
    }
}

void precalcMinW()
{
    for(int i = 1; i <= N; i++)
    {
        MinW[Array[i].first] = min(MinW[Array[i].first], Array[i].second);
    }
    for(int i = 1; i <= N; i++)
    {
        if(Array[i].second + MinW[Array[i].first] <= X)
            Array[i].second = MinW[Array[i].first];
        S.insert(make_pair(MinW[Array[i].first], Array[i].first));
    }
}

void Solve()
{
    for(int i = 1; i <= N; i++)
    {
        S.erase(make_pair(MinW[Array[i].first], Array[i].first));
        if(S.size() != 0)
        {
            auto it = S.begin();
            if(it -> first + Array[i].second > Y)
            {
                Colour[Array[i].first]--;
                --total;
            }
        }
        else
            Colour[Array[i].first]--, total--;
        S.insert(make_pair(MinW[Array[i].first], Array[i].first));
    }
    int ans = Fact[total];
    for(int i = 1; i <= N; i++)
        ans = (1LL * ans * InvFact[Colour[i]]) % MOD;
    cout << ans << "\n";
}


int main()
{
    Read();
    precalcFact();
    precalcMinW();
    Solve();
    return 0;
}


Measured memory_bytes: 11520
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double d = sc.nextDouble();
        int t = sc.nextInt();
        double s = sc.nextDouble();

        int re = (int)(d/s + (double)(s-1)/(double)s);

        if(re>t){
          System.out.println("No");
        }else{
            System.out.println("Yes");
        }


    }
}

Measured memory_bytes: 37248
//1.read question_2.read I/O_3.read test cases_4.read constraints(to decide TC of solution)_5.decide method_6.dry run_
//7.code_8.test_9.submit
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli mod=1e9+7;
#define F first
#define S second
#define _READ freopen("input.txt","r", stdin);
#define pb push_back
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
lli mul(lli a,lli b)
{
    return (lli) a*b % mod;
}

lli power(lli a,lli b)
{
    if(a==1 || b==0)
        return 1;
    if(b==1)
        return a;
    lli k=power(a,b/2);
    lli g=mul(k,k);
    if(b%2==0)
        return g;
    return mul(g,a);
}
lli inv(lli n)
{
    return power(n,mod-2);
}
lli LCM(lli a,lli b)
{
    return a*b/(__gcd(a,b));
}
int main()
{
    
    lli n;cin>>n;vector<lli> ar(n);
    for(auto &i:ar)
        cin>>i;
    map<lli,lli> ans;
    for(auto i:ar)
    {
        map<lli,lli> mp;
        for(lli j=2;j*j<=i;j++)
            while(i%j==0)
            {
                i/=j;
                mp[j]++;
            }
        if(i!=1)
            mp[i]++;
        for(auto p:mp)
            ans[p.F]=max(ans[p.F],p.S);
    }
    lli lcm=1,sum=0;
    for(auto i:ans)
        lcm=mul(lcm,pow(i.F,i.S));
    //cout<<lcm<<"\n";
    for(auto i:ar)
    {
        sum+=mul(lcm,inv(i));
        //cout<<mul(lcm,inv(i))<<"\n";
        sum%=1000000007;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 896
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    int N;
    int par[], rank[];

    public static void main(String[] args) {
        new Main().compute();
    }

    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }

    boolean same(int x, int y) {
        return find(x) == find(y);
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        par = new int[N];
        rank = new int[N];
        int[] x = new int[N];
        int[] y = new int[N];
        Integer[] index = new Integer[N];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            index[i] = i;
        }
        int E = 2 * N - 2;
        Edge[] es = new Edge[E];
        Arrays.sort(index, (o1, o2) -> x[o1] - x[o2]);
        for (int i = 0; i < N - 1; i++) {
            es[i] = new Edge(index[i], index[i + 1], Math.min(Math.abs(x[index[i]] - x[index[i + 1]]), Math.abs(y[index[i]] - y[index[i + 1]])));
        }
        Arrays.sort(index, (o1, o2) -> y[o1] - y[o2]);
        for (int i = 0; i < N - 1; i++) {
            es[i + N - 1] = new Edge(index[i], index[i + 1], Math.min(Math.abs(x[index[i]] - x[index[i + 1]]), Math.abs(y[index[i]] - y[index[i + 1]])));
        }
        Arrays.sort(es, (o1, o2) -> o1.cost - o2.cost);
        init(N);
        int res = 0;
        for (int i = 0; i < E; i++) {
            Edge e = es[i];
            if (!same(e.u, e.v)) {
                unite(e.u, e.v);
                res += e.cost;
            }
        }
        System.out.println(res);

    }

    class Edge {

        int u, v, cost;

        Edge(int u, int v, int cost) {
            this.u = u;
            this.v = v;
            this.cost = cost;
        }
    }
}


Measured memory_bytes: 100408
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

#define ll long long

using namespace std;

int main() {
    ll n;
    ll a[5];
    ll b[5];
    ll i,j,k;
    ll ans=1;
    ll cullentmin;
    ll temp;

    cin>>n;

    for(i=0;i<5;i++){
        cin>>a[i];
        if(i>0)cullentmin=min(a[i],cullentmin);
        else cullentmin=a[i];
    }
   // cout << cullentmin << endl;

        if(n<=cullentmin)temp=1;
        else {
            temp=n/cullentmin;
            if(n%cullentmin!=0)temp++;
        }




    std::cout << temp+4 << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        if (u.equals(s)) {
            System.out.println((a - 1) + " " + b);
            return;
        }
        System.out.println(a + " " + (b - 1));
    }


}


Measured memory_bytes: 21844
int check[30];

int c, n, a;

int main() {
  n = 0;
  while (1) {
    c = getchar_unlocked();
    if ('0' <= c && c <= '9')
      n = n * 10 + c - '0';
    else
      break;
  }

  int xor_sum = 0;
  for (int i = 0; i < n; i++) {
    a = 0;
    while (1) {
      c = getchar_unlocked();
      if ('0' <= c && c <= '9')
        a = a * 10 + c - '0';
      else
        break;
    }
    xor_sum ^= a;
    a = a ^ (a - 1);

    check[__builtin_popcount(a) - 1] = 1;

    // switch (a) {
    // case 1073741823:
    //   check[29] = 1;
    //   break;
    // case 536870911:
    //   check[28] = 1;
    //   break;
    // case 268435455:
    //   check[27] = 1;
    //   break;
    // case 134217727:
    //   check[26] = 1;
    //   break;
    // case 67108863:
    //   check[25] = 1;
    //   break;
    // case 33554431:
    //   check[24] = 1;
    //   break;
    // case 16777215:
    //   check[23] = 1;
    //   break;
    // case 8388607:
    //   check[22] = 1;
    //   break;
    // case 4194303:
    //   check[21] = 1;
    //   break;
    // case 2097151:
    //   check[20] = 1;
    //   break;
    // case 1048575:
    //   check[19] = 1;
    //   break;
    // case 524287:
    //   check[18] = 1;
    //   break;
    // case 262143:
    //   check[17] = 1;
    //   break;
    // case 131071:
    //   check[16] = 1;
    //   break;
    // case 65535:
    //   check[15] = 1;
    //   break;
    // case 32767:
    //   check[14] = 1;
    //   break;
    // case 16383:
    //   check[13] = 1;
    //   break;
    // case 8191:
    //   check[12] = 1;
    //   break;
    // case 4095:
    //   check[11] = 1;
    //   break;
    // case 2047:
    //   check[10] = 1;
    //   break;
    // case 1023:
    //   check[9] = 1;
    //   break;
    // case 511:
    //   check[8] = 1;
    //   break;
    // case 255:
    //   check[7] = 1;
    //   break;
    // case 127:
    //   check[6] = 1;
    //   break;
    // case 63:
    //   check[5] = 1;
    //   break;
    // case 31:
    //   check[4] = 1;
    //   break;
    // case 15:
    //   check[3] = 1;
    //   break;
    // case 7:
    //   check[2] = 1;
    //   break;
    // case 3:
    //   check[1] = 1;
    //   break;
    // case 1:
    //   check[0] = 1;
    //   break;
    // }
  }

  int ans = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (((1 << bit) & xor_sum) == 0) {
      continue;
    }
    int x = (1 << (bit + 1)) - 1;

    if (check[bit] > 0) {
      xor_sum ^= x;
      ans += 1;
    }
  }

  if (xor_sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 128
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh = sorted(xyh, reverse = True, key = lambda z: z[2])
# print(xyh)

for i in range(101):
    for j in range(101):
        x_0, y_0, h_0 = xyh[0]
        H = h_0 + abs(y_0-i) + abs(x_0-j)
        valid = True
        for x, y, h in xyh[1:]:
            if max(H-abs(y-i)-abs(x-j), 0) != h:
                valid = False
                break
        if valid:
            ans = str(j)+' '+str(i)+' '+str(H)
            print(ans)
            exit()

Measured memory_bytes: 3064
let comp x y = 
    if x > y then 1 else if x < y then -1 else 0

let () = Scanf.scanf "%d\n" @@ fun n ->
    let as_ = Array.make n 0 in
    let bs_ = Array.make n 0 in
    let substitute i = 
        Scanf.scanf "%d %d\n" @@ fun a b ->
            Array.set as_ i a;
            Array.set bs_ i b;
    in
    ignore @@ Array.map substitute @@ (Array.init n @@ fun i -> i);
    ignore @@ Array.sort comp as_;
    ignore @@ Array.sort comp bs_;
    let res = 
        if n mod 2 == 0
        then
            (Array.get bs_ @@ n / 2) + (Array.get bs_ @@ n / 2 - 1)
            - (Array.get as_ @@ n / 2) - (Array.get as_ @@ n / 2 - 1) + 1
        else
            (Array.get bs_ @@ n / 2) - (Array.get as_ @@ n / 2) + 1
    in
    ignore @@ Printf.printf "%d\n" @@ res


Measured memory_bytes: 12340
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define sc second
typedef pair<int,int> P;
int N,K;
int C[5003],R[5003];
int A,B;
vector<int>G[5003];int s1[5003];
vector<P>G2[5003];
int main()
{
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%d%d",&C[i],&R[i]);
	}
	for(int i=0;i<K;i++){
		scanf("%d%d",&A,&B);A--;B--;
		G[A].pb(B);
		G[B].pb(A);
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			s1[j]=N+1;
		}
		priority_queue<P,vector<P>,greater<P> >que;que.push(P(0,i));
		while(!que.empty()){
			P p=que.top();que.pop();
			if(s1[p.sc]<=p.fi)continue;
			s1[p.sc]=p.fi;
			for(int j=0;j<(int)G[p.sc].size();j++){
				if(s1[G[p.sc][j]]>p.fi+1){
					que.push(P(p.fi+1,G[p.sc][j]));
				}
			}
		}
		for(int j=0;j<N;j++){
			if(i==j)continue;
			if(s1[j]<=R[i]){
				G2[i].pb(P(j,C[i]));
				//printf("%d %d\n",i,j);
			}
		}
	}
	for(int j=0;j<N;j++){
		s1[j]=10000*N+1;
	}
	priority_queue<P,vector<P>,greater<P> >que;que.push(P(0,0));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(s1[p.sc]<=p.fi)continue;
		s1[p.sc]=p.fi;
		for(int i=0;i<(int)G2[p.sc].size();i++){
			if(s1[G2[p.sc][i].fi]>p.fi+G2[p.sc][i].sc){
				que.push(P(p.fi+G2[p.sc][i].sc,G2[p.sc][i].fi));
			}
		}
	}
	printf("%d\n",s1[N-1]);
	return 0;
}

Measured memory_bytes: 195412
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def resolve():
    n = int(input())
    T = list(int(input()) for _ in range(n))

    res = 1
    for i in range(n):
        res = lcm(res, T[i])

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1
ans = 0
for i in d:
    if d[i] < i:
        ans += d[i]
    if d[i] > i:
        ans += d[i] - i
print(ans)

Measured memory_bytes: 17780
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int check(string X, string Y) {
    set<char> x, y;
    rep(i, X.size()) { x.insert(X[i]); }
    rep(i, Y.size()) { y.insert(Y[i]); }
    int ret = 0;
    for(char c : x) {
        if(y.count(c))
            ret++;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int res = 0;
    for(int len = 1; len <= N - 1; len++) {
        string X = S.substr(0, len), Y = S.substr(len, N - len);
        res = max(res, check(X, Y));
    }
    cout << res << endl;
    return 0;
}

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


void solve(std::string S){
    string A="";
    if (S=="Sunny") A="Cloudy";
    if (S=="Cloudy") A="Rainy";
    if (S=="Rainy") A="Sunny";
    cout << A << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int	
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T>inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T>inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int p, q, r;
	cin >> p >> q >> r;
	int ans = 0;

	int maxval = 0;
	chmax(maxval, p);
	chmax(maxval, q);
	chmax(maxval, r);

	ans = p + q + r - maxval;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int n,m,k,P;
int f[201][201],C[201][201],_mul[201],invmul[201];
inline int mul(const int &a,const int &b){return 1ll*a*b%P;}
inline int add(int a,const int &b){a+=b;return(a>=P)?a-P:a;}
int calc(int n,int m,int k){
	if(n>k+1||m>k)return 0;
	--n;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=m;j++)
			f[i][j]=-1;
	for(int i=1;i<=n;i++)
		for(int j=std::max(0,i+m-k);j<=k-n+i&&j<=m;j++){ 
			f[i][j]=0;
		}
	for(int i=0;i<=m;i++)f[0][i]=0;
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)f[i-1][j]=add(f[i-1][j],f[i-1][j-1]);
		for(int j=0;j<=m;j++)
			if(!f[i][j]){
				f[i][j]=f[i-1][j];
			}
			else f[i][j]=0;
	}
	int cnt=0;
	for(int i=1;i<=m;i++)cnt=add(cnt,f[n][i]);
//	printf("%d %d %d %d\n",n,m,k,cnt);
	return cnt;
}
int g(int n,int k){
	int tot=0;
	for(int i=2;i<n;i++)
		tot=add(tot,mul(mul(mul(C[n-1][i-1],_mul[i-1]),_mul[n-i]),calc(i,n-i,k)));
//	printf("g %d %d %d\n",n,k,tot);
	return tot;
}
int main(){
	scanf("%d%d%d",&n,&k,&P);
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=add(C[i-1][j],C[i-1][j-1]);
	}
	_mul[0]=_mul[1]=invmul[0]=invmul[1]=1;
	for(int i=2;i<=n;i++)_mul[i]=mul(_mul[i-1],i);
	for(int i=2;i<=n;i++)invmul[i]=mul(P-P/i,invmul[P%i]);
	for(int i=2;i<=n;i++)invmul[i]=mul(invmul[i],invmul[i-1]);
	int ans=(k==n-1)?_mul[n]:0;
	for(int i=3;i<=n;i++){
		ans=add(ans,mul(C[n][i],mul(_mul[n-i],g(i,k-n+i))));
	}
	printf("%d\n",ans);
}

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

using namespace std;

int main ()
{
  int count = 0;
  int i = 0;
	string s, t;
  cin >> s;
  cin >> t;
  while(s[i] != '\0')
  {
    if(s[i] == t[i])
      count++;
    i++;
  }
	cout << count << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>

#define abs(a) (a>0?(a):-(a))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

using namespace std;

const long long maxn=1e5+10;

long long n,ans;
long long x[maxn];

int main()
{
    scanf("%lld",&n);
    for(long long i=1;i<=n;i++)
        scanf("%lld",&x[i]);
    
    for(long long i=1;i<=n+1;i++)
        ans+=abs(x[i]-x[i-1]);

    for(long long i=1;i<=n;i++)
        printf("%lld\n",ans-abs(x[i+1]-x[i])-abs(x[i]-x[i-1])+abs(x[i+1]-x[i-1]));

   // getchar();getchar();

    return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

#define TRUE 1
#define FALSE 0
#define LEN 100005

typedef struct q{
  int y;
  int x;
}QUEUE;

//int x = 0;
QUEUE *Q;
//P Q[LEN + 1];
int head = 0;
int tail = 0;
int n;

void initialize(int a){
  head = 0;
  tail = 0;
  Q = (QUEUE *)calloc(a, sizeof(QUEUE));
  if(Q == NULL){
    printf("メモリが確保できません\n");
    exit(EXIT_FAILURE);
  }
}

void finalize(){
  if(Q != NULL){
    free(Q);
    Q = NULL;
  }
}

int isEmpty(){
  if(head == tail){
    return TRUE;
  }else{
    return FALSE;
  }
}

int isFull(){
  if(head == (tail + 1) % LEN){
    return TRUE;
  }else{
    return FALSE;
  }
}

void enqueue(QUEUE x){
  fprintf(stderr, "enqueue() point.y:%d point.x:%d\n", x.y, x.x);
  if(isFull() != FALSE){
      printf("Overfllow\n");
  }else{
    Q[tail] = x;
    if((tail + 1) == LEN){
      tail = 0;
    }else{
      tail++;
    }
  }
}

QUEUE dequeue(){
  QUEUE x;
  //  fprintf(stderr, "-> dequeue\n");
  if(isEmpty() != FALSE){
    printf("Undrtfllow\n");
  }else{
    x = Q[head];
    if((head + 1 == LEN)){
      head = 0;
    }else{
      head++;
    }
  }
  return x;
}


// min
int main(void){
  char s[10001];
  int ans = 0;
  int n = 0;
  
  scanf("%d%s", &n, s);
  
  for(int i = 0; i < strlen(s); i++)
  {
  	if(s[i] + n > 'Z')
  	{
  	  printf("%c", s[i] + n - 26);
  	}else{
  	  printf("%c", s[i] + n);
  	}
  }

  printf("\n");
  return 0;

}



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

struct PushRelabel {
	struct Edge {
		int from, to;
		long long cap, flow, index;
		Edge(int from, int to, long long cap, long long flow,long long index) :
			from(from), to(to), cap(cap), flow(flow), index(index) {}
	};
	int N;
	vector<vector<Edge> > G;
	vector<long long> excess;
	vector<int> dist, active, count;
	queue<int> Q;

	PushRelabel(int N) : N(N), G(N), excess(N), dist(N), active(N), count(2*N) {}

	void AddEdge(int from, int to, long long cap) {
		G[from].push_back(Edge(from, to, cap, 0, G[to].size()));
		if (from == to) G[from].back().index++;
		G[to].push_back(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v) { 
		if (!active[v] && excess[v] > 0) { active[v] = true; Q.push(v); } 
	}

	void Push(Edge &e) {
		long long amt = min(excess[e.from], (long long)(e.cap - e.flow));
		if (dist[e.from] <= dist[e.to] || amt == 0) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;    
		excess[e.from] -= amt;
		Enqueue(e.to);
	}
  
	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k) continue;
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		for (int i = 0; i < G[v].size(); i++) 
			if (G[v][i].cap - G[v][i].flow > 0)
		dist[v] = min(dist[v], dist[G[v][i].to] + 1);
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		for (int i = 0; excess[v] > 0 && i < G[v].size(); i++) Push(G[v][i]);
		if (excess[v] > 0) {
			if (count[dist[v]] == 1)  Gap(dist[v]); 
			else Relabel(v);
		}
	}

	long long GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		for (int i = 0; i < G[s].size(); i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		long long totflow = 0;
		for (int i = 0; i < G[s].size(); i++) totflow += G[s][i].flow;
		return totflow;
	}
};
int main(){
	ios_base::sync_with_stdio(0);
	long long n,a[105],sum=0;
	cin>>n;
	PushRelabel d(105);
	for(int i=1;i<=n;++i){
		cin>>a[i];
		if(a[i]>=0) {
			sum+=a[i];
			d.AddEdge(0,i,a[i]);
		}
		else{
			d.AddEdge(i,102,-a[i]);
		}
	}
	for(int i=1;i<=n;++i)
		for(int j=2*i;j<=n;j+=i)
			d.AddEdge(j,i,1e18);
	cout<<sum-d.GetMaxFlow(0,102);
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>

using namespace std;

int cnt;
void merge(int A[], int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1],R[n2+1];

    for(int i = 0; i < n1 ; i++){
       L[i] = A[left+i]; 
    }
    for(int i = 0; i < n2 ; i++){
        R[i]=A[mid+i];
    }
    L[n1] = INT32_MAX;
    R[n2] = INT32_MAX;
    int i=0;
    int j=0; 
    for(int k = left; k<right  ; k++){
        if(L[i]<=R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        } 
        cnt++;
    }
}
void mergesort(int A[],int left,int right){
    if(left+1<right){
        int mid = (left + right)/2;
        mergesort(A,left,mid);
        mergesort(A,mid,right);
        merge(A,left,mid,right);
    }else{
        return ;
    } 
}
int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n ; i++){
        scanf("%d",&A[i]); 
    }
    mergesort(A,0,n);
    for(int i=0; i<n; i++){
        if(i>=1)
            printf(" ");
        printf("%d",A[i]);
    }
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 7116
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextFloat() float64 {
	sc.Scan()
	i, _ := strconv.ParseFloat(sc.Text(), 64)
	return i
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for {
		n := nextInt()
		if n == 0 {
			break
		}
		s := make([]float64, n)
		m := 0.0
		for i := 0; i < n; i++ {
			s[i] = nextFloat()
			m += s[i] / float64(n)
		}
		a := 0.0
		for i := 0; i < n; i++ {
			a += math.Pow(s[i]-m, 2) / float64(n)
		}
		fmt.Println(math.Sqrt(a))
	}
}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    //y /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ss s;
    cin >> s;

    for(ll i=1;i<SIZE(s)-1;i++){

        ll count = 0;

        rep(j,(SIZE(s)-i)/2){
            if(s[j] == s[(SIZE(s)-i)/2+j]){
                count++;
                //cout << count << " ";
            }
            else break;
        }

        //cout << "000" << endl;

        if(count*2 == (SIZE(s)-i)){
            cout << SIZE(s)-i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

long long n;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	if(n % 2){
		cout << 0 << endl;
		return 0;
	}
	
	long long ret = 0;
	for(long long i = 5; i <= n / 2; i *= 5) ret += n / 2 / i;
	
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(R1, C1, R2, C2):
    C = Combination(2*10**6+1, 10**9+7)
    M = Mod(10**9+7)
    ans = 0
    for r in range(R1, R2+1):
        a = C(C2+r+1, r+1)
        b = C(C1-1+r+1, r+1)
        ans = M.add(ans, M.sub(a, b))
    return ans



def main():
    R1, C1, R2, C2 = read_int_n()
    print(slv(R1, C1, R2, C2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 133356
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  ll cnt = 0;
  
  if (K == 0) {
    cnt = N * N;
  } else {
    for (ll b = K + 1; b <= N; b++) {
      cnt += (b - K) * (N / b);
      if (N % b >= K) {
        cnt += N % b - K + 1;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var r = Number(lines[0]);

 var output = 2 * Math.PI * r;
 console.log(output);
});

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

int main(){
	int n;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; ++i) cin >> a[i];
	//dp[i][j] = diff between X,Y with queue start at i end at j
	ll dp[n+5][n+5];
	//optimal - both player take as large as possible
	//from small (1 element) to large (whole queue) interval
	//i - left, j - right
	for (int i = n - 1; i >= 0; --i){
		for (int j = i; j < n; ++j){
			if (i == j){	//one element
				dp[i][j] = a[i];	//Taro (start first) take one, X = a[i]
			}
			else{
				//take left, take right
				//dp[i+1][j] = diff bf taking left, dp[i][j-1] = diff bf taking right
				dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
			}
		}
	}
	cout << dp[0][n-1] << '\n';
	return 0;
}
/*
IF X chooses (maximize)
x + a - y = a + x - y

IF Y chooses (minimize)
x - (y + a) = -a + x - y

note that x - y is fixed (previous dp state),
X chooses = maximize (a + C)
Y chooses = minimize (-a + C) = maximize (a + C)

a + C = a + x - y = a + dp[previous state]
*/

Measured memory_bytes: 46744
def main():
    a,b = map(int,input().split())
    if a-b+1>=2019:
        print(0)
    else:
        mini = 2020
        for i in range(a,b+1):
            for j in range(a,i):
                joke = i*j%2019
                if joke<mini:
                    mini = joke
                    if mini == 0:
                        print(0)
                        return 0
        print(mini)
main()

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

int main() {
    // a. b#
    int a, b;
    cin >> a >> b;
    char grid[105][105];
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            grid[i][j] = i < 50 ? '.' : '#';
        }
    }
    for (int i = 1; i < b; i++) {
        grid[i/50*2][i%50*2] = '#';
    }
    for (int i = 1; i < a; i++) {
        grid[51+i/50*2][i%50*2] = '.';
    }
    cout << 100 << " " << 100 << endl;
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            cout << grid[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
res = ['-1' for _ in range(n)]
for _ in range(m):
    s, c = map(int, input().split())
    if (n > 1 and s == 1 and c == 0) or (res[s-1] != '-1' and res[s-1] != str(c)):
        print(-1)
        exit()
    else:
        res[s-1] = str(c)
for i in range(n):
    if res[i] == '-1':
        res[i] = '1' if i == 0 and n > 1 else '0'
print(''.join(res))

Measured memory_bytes: 38384
N = int(input())
N_List = [0] +list(map(int,input().split())) + [0]
N_Diff_List = []

for i in range(N+1):
    N_Diff_List.append(abs(N_List[i+1]-N_List[i]))

sumans = sum(N_Diff_List)
for i in range(N):
    ans = sumans -(N_Diff_List[i] + N_Diff_List[i+1])
    ans += abs(N_List[i+2]-N_List[i])
    print(ans)


Measured memory_bytes: 20624
import math
n,h = map(int,input().split())
ab =[list(map(int,input().split())) for _ in range(n)]
lisA = []
lisB = []
#使いまわせるaを記録し、その最大値を見つける
for a,_ in ab:
  lisA.append(a)
m = max(lisA)

#ｍより大きければ収納
for _,b in ab:
  if b > m:
  	lisB.append(b)

s = sum(lisB)
lisB.sort(reverse=True)
#print(lisA,lisB)

cnt = 0
#もし、m以上のbの合計だけでhを超えられるなら、点数の低い順に抜いていく
if s>=h:
  while s>=h:
    #小さいやつを抜いていく
    s -= lisB.pop()
  cnt = len(lisB) + 1 
else:
  cnt = len(lisB) + math.ceil((h-s)/m)
  
print(cnt)

  

Measured memory_bytes: 29336
#include <iostream>
#include <algorithm>

#define SIZE 100

int N;
int L[SIZE*2];

int main() {
    int ans = 0;
    std::cin >> N;
    for (int i=0; i<2*N; ++i) std::cin >> L[i];
    std::sort(L, L+(2*N));
    for (int i=0; i<2*N-1; i+=2) {
        ans += L[i];
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long i, k, n, max;
	scanf("%ld", &k);
	scanf("%ld", &n);
	long a[n];
	for (i = 0; i < n; i++)
		scanf("%ld", &a[i]);
	max = a[0];
	for (i = 0; i < (n-1); i++)
	{
		if (max < (a[i + 1] - a[i]))
			max = a[i + 1] - a[i];
	}

	if(max < (k-a[n-1]+a[0])) {
		max = k - a[n-1] + a[0];
	}
	printf("%ld\n", k - max);
	return 0;
}

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

int main(){
  string s;
  long long k;
  cin>>s >>k;
  for(int i=0;i<min((long long)s.size(),k);i++){
    if(s[i]>='2'){
      cout<<s[i]<<endl;
      return 0;
    }
  }
  cout<<1<<endl;
}

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

using namespace std;

int main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    int nr = n / r;
    int ng = n / g; 
    for(int i = 0; i < nr + 1; i++){
        for(int j = 0; j < ng + 1; j++){
            int tmp = n - i * r - j * g;
            if(tmp >= 0 && tmp % b == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

bool num[10];
// true →　useable

int main(){
int N,K; 
 cin >> N >> K;
  
  for(int i = 0; i < 10; i++){ num[i] = true;}
  
  for(int i = 0; i < K; i++){
    int d; cin >> d;
    num[d] = false;}
  
 
  int pay = N;
  
  while(1){
     int k = pay; bool flag = true;
    while( k > 0){
     if( !num[k % 10]){ flag = false;}
      k /= 10;}
    
    if( flag){ break; }
    pay++;
  }
  
  cout << pay << endl; return 0;}
    

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  string ans = "TBD";
  if (S[5] == '0')
  {
    if (S[6] - '0' <= 4)
      ans = "Heisei";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256