akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    double ans = 0;
    reps(i, 1, n + 1) {
        ll cv = i;
        double p = 1.0 / n;
        while(cv < k) {
            p *= 0.5;
            cv *= 2;
        }
        ans += p;
        // printf("i=%lld, p=%.10f\n", i, p);
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <string>
# include <set>
# include <algorithm>

using namespace std;

int main () {
    string s;
    cin >> s;
    set <char> set;
    for (char i : s) set.insert(i);
    if (set.size() == 2) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

int main(){
  int x,i=3,ans=0; 
   vector<int> p; 
   cin>>x;
  if(x==2) ans=2; 
   p.push_back(2);
  while (ans==0){
    for(int j=0;j<p.size();j++){
      if(i%p[j]==0) break;
      if(j==p.size()-1){
        p.push_back(i);
        if(i>=x) ans=i;
      }
    }
    i++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var s = bufio.NewScanner(os.Stdin)

func main() {
	s.Scan()
	in := strings.Split(s.Text(), " ")
	x, _ := strconv.Atoi(in[0])
	y, _ := strconv.Atoi(in[1])
	z, _ := strconv.Atoi(in[2])
	k, _ := strconv.Atoi(in[3])
	a := make([]int, x)
	s.Scan()
	in = strings.Split(s.Text(), " ")
	for i := 0; i < x; i++ {
		a[i], _ = strconv.Atoi(in[i])
	}
	b := make([]int, y)
	s.Scan()
	in = strings.Split(s.Text(), " ")
	for i := 0; i < y; i++ {
		b[i], _ = strconv.Atoi(in[i])
	}
	c := make([]int, z)
	s.Scan()
	in = strings.Split(s.Text(), " ")
	for i := 0; i < z; i++ {
		c[i], _ = strconv.Atoi(in[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	sort.Sort(sort.Reverse(sort.IntSlice(c)))

	d := make([]int, 0, x*y)
	for i, _ := range a {
		for j := range b {
			d = append(d, a[i]+b[j])
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(d)))
	var e []int
	if x*y < k {
		e = d[:x*y]
	} else {
		e = d[:k]
	}
	f := make([]int, 0, k*z)
	for i, _ := range e {
		for j := range c {
			f = append(f, e[i]+c[j])
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(f)))
	for i := 0; i < k; i++ {
		fmt.Println(f[i])
	}
}


Measured memory_bytes: 33024
package main

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

func main() {
	rs := []rune(getString())
	n := len(rs)

	ans := make([]int, n)
	now := 'R'
	start := 0
	boundary := -1
	for i, r := range rs {
		if now != r {
			if now == 'R' {
				now = 'L'
				boundary = i - 1
				ans[boundary] += ((boundary - start + 1) + 2 - 1) / 2
				ans[boundary+1] += (boundary - start + 1) / 2
			} else {
				now = 'R'
				start = i
				ans[boundary] += (i - boundary - 1) / 2
				ans[boundary+1] += ((i - boundary - 1) + 2 - 1) / 2
			}
		}

		if i == n-1 {
			ans[boundary] += (i - boundary) / 2
			ans[boundary+1] += (i - boundary + 2 - 1) / 2
		}
	}

	for _, a := range ans {
		fmt.Println(a)
	}
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	tmp := 200001
	sc.Buffer(make([]byte, tmp), tmp)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 3072
#coding:utf-8

if __name__ == "__main__":
    date = input()
    year, month, day = date.split("/")

    if int(year) <= 2019:
        if int(month) <= 4:
            if int(day) <= 30:
                print("Heisei")
                exit()
    
    print("TBD")

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define CLEAR(d) memset((d), 0, (sizeof((d))))
#define ALL(c) (c).begin(), (c).end()
#define ABS(x) ((x < 0) ? -(x) : (x))
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define SIZE(a) ((int)((a).size()))
#define MOD 1000000007
#define EPS 1e-7
#define PI  3.14159265358979323846
#define INF 100000000
struct edge { int to; int cost; };
//===================================================

int main()
{
    int n, d, x, a[100];
    cin >> n >> d >> x;
    REP(i, n) cin >> a[i];
    int sum = x;
    REP(i, n) {
        sum += 1 + (d - 1) / a[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}

int main(void){
    int i,j,n,m,k,a[262144],b,c,w,r=0,l,t;
    double d;
    char s[262144];
    scanf("%d%d",&n,&k);
    n%=500;
    //l=strlen(s);
    //for(i=0;i<n;i++){scanf("%d",&a[i]);}
    //qsort(a,n,sizeof(int),sortfncsj);
    if(n>k){printf("No\n");}else{printf("Yes\n");}
    return 0;
}

Measured memory_bytes: 128
N,K=map(int,input().split())
A=list(map(int,input().split()))

DP=[None]*(K+1)
for i in range(A[0]):
    DP[i]=1#Jiro wins.

for i in range(A[0],K+1):
    for a in A:
        if i-a>=0 and DP[i-a]==1:
            DP[i]=0
            break

    else:
        DP[i]=1

#print(DP)
            
if DP[K]==0:
    print("First")
else:
    print("Second")


Measured memory_bytes: 3828
#include <iostream>
using namespace std;
#define ll long long
int main()
{
	ll a,b;
	cin>>a>>b;
	int ans,i;
	ans=0;
	i=2;
	while(a<=b)
	{
		a*=i;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200010
#define ll long long 
#define db double
using namespace std;
int n;
ll a[N], f[N]; 
int main()
{
   cin >> n;
   ll ans = 1e18;  
   for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      f[i] = f[i-1] + a[i]; 
   }
   for (int i = 1; i < n; i++) {
      ans = min(ans, abs(f[n] - f[i] * 2));
   }
   cout << ans << endl; 
   return 0; 
}


Measured memory_bytes: 3328
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    int n = str.size();

    long long dp[n][13];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 13; j++) dp[i][j] = 0;
    }

    if (str[n - 1] != '?') {
        int num = str[n - 1] - '0';
        dp[0][num] = 1;
    } else {
        for (int i = 0; i < 10; i++) dp[0][i] = 1;
    }

    int power = 10;
    for (int i = n - 2; i >= 0; i--) {
        if (str[i] != '?') {
            int num = ((str[i] - '0') * power) % 13;
            for (int j = 0; j < 13; j++) dp[n - i - 1][(j + num) % 13] += dp[n - i - 2][j] % MOD;
        } else {
            for (int j = 0; j < 10; j++) {
                int num = (j * power) % 13;
                for (int k = 0; k < 13; k++) dp[n - i - 1][(k + num) % 13] += dp[n - i - 2][k] % MOD;
            }
        }
        power *= 10;
        power %= 13;
    }

    cout << dp[n - 1][5] % MOD << endl;
}


Measured memory_bytes: 10624
n,p=map(int,input().split())
ans=[]
for i in range(2,int(p**0.5)+1):
	cnt=0
	while p%i==0:
		p//=i
		cnt+=1
	if cnt>0:
		ans.append([i,cnt])
ans.append([p,1])
ret=1
for i in range(len(ans)):
	ret*=pow(ans[i][0],(ans[i][1]//n))
print(ret)




Measured memory_bytes: 3060
#include <cstdio>
#include<cmath>
#include<cstring>

int main() {
	char chars[5];
	scanf("%s", chars);
	int flags[5];
	char a[4];
	int res = 0;
	if (res = chars[0] - '0' + chars[1] - '0' + chars[2] - '0' + chars[3] - '0' == 7) {
		a[0] = '+';
		a[1] = '+';
		a[2] = '+';
	}
	else if (res = chars[0] - '0' + chars[1] - '0' - (chars[2] - '0') + chars[3] - '0' == 7) {
		a[0] = '+';
		a[1] = '-';
		a[2] = '+';
	}
	else if (res = chars[0] - '0' + chars[1] - '0' + chars[2] - '0' - (chars[3] - '0') == 7) {
		a[0] = '+';
		a[1] = '+';
		a[2] = '-';
	}

	else if (res = chars[0] - '0' + chars[1] - '0' - (chars[2] - '0') - (chars[3] - '0') == 7) {
		a[0] = '+';
		a[1] = '-';
		a[2] = '-';
	}

	else if (res = (chars[0] - '0') - (chars[1] - '0') + chars[2] - '0' + (chars[3] - '0') == 7) {
		a[0] = '-';
		a[1] = '+';
		a[2] = '+';
	}
	else if (res = chars[0] - '0' - (chars[1] - '0') - (chars[2] - '0') + chars[3] - '0' == 7) {
		a[0] = '-';
		a[1] = '-';
		a[2] = '+';
	}
	else if (res = chars[0] - '0' - (chars[1] - '0') + chars[2] - '0' - (chars[3] - '0') == 7) {
		a[0] = '-';
		a[1] = '+';
		a[2] = '-';
	}

	else if (res = chars[0] - '0' - (chars[1] - '0') - (chars[2] - '0') - (chars[3] - '0') == 7){
		a[0] = '-';
		a[1] = '-';
		a[2] = '-';
	}
	printf("%c%c%c%c%c%c%c=7\n",chars[0],a[0], chars[1], a[1], chars[2], a[2], chars[3]);

}

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

#define ll long long
#define pb push_back
#define mp make_pair

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

	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r+", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w+", stdout);
	#endif*/

    int k;
    cin >> k;
    ll ans = 0;
    for(int i=1;i<=k;i++) {
    	for(int j=1;j<=k;j++) {
    		for(int l=1;l<=k;l++) {
    			ans = ans + __gcd(i,__gcd(j,l));
    		}
    	}
    }
    cout << ans;
}

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

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

// 埃筛 把1e5之内素数给筛选出来
vector<int> prime;
int p[maxn];

void init() {
    // 先假设所有的数都是素数
    for (int i = 1; i < maxn; i++) p[i] = 1;
    // 0 1都不是素数
    p[0] = p[1] = 0;
    // 将素数的所有倍数都不是素数
    for (int i = 2; i < maxn; i++) {
        if (p[i]) {
            prime.push_back(i);
            for (int j = i * 2; j < maxn; j += i) p[j] = 0;
        }
    }
}

int main() {
    init();
    int x;
    scanf("%d", &x);
    int idx = lower_bound(prime.begin(), prime.end(), x) - prime.begin();
    printf("%d\n", prime[idx]);
    return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

vector< pair<int,int> > sche[370];
int dp[370][370];

int solve(){
	for(int i=0; i<370; i++){
		for(int j=0; j<370; j++){
			dp[i][j] = -1;
		}
	}
	dp[1][1] = 0;
	for(int day=1; day<366; day++){
		for(int res=day; res<370; res++)if(dp[day][res]>=0){
			dp[day+1][max(day+1,res)] = max(dp[day+1][max(day+1,res)], dp[day][res]);

			if(day == res){
				for(int i=0; i<(int)sche[day].size(); i++){
					int end = sche[day][i].first;
					dp[day+1][end+1] = max(dp[day+1][end+1], dp[day][res] + sche[day][i].second);
				}
				for(int i=0; i<(int)sche[day].size(); i++){
					for(int j=i+1; j<(int)sche[day].size(); j++){
						int w = sche[day][i].second + sche[day][j].second;
						int d1 = min(sche[day][i].first, sche[day][j].first) + 1, d2 = max(sche[day][i].first, sche[day][j].first) + 1;
						dp[d1][d2] = max(dp[d1][d2], dp[day][res] + w);
					}
				}
			}
			else{
				for(int i=0; i<(int)sche[day].size(); i++){
					int end = sche[day][i].first, w = sche[day][i].second;
					if(res < end + 1){
						dp[res][end+1] = max(dp[res][end+1], dp[day][res] + w);
					}
					else{
						dp[end+1][res] = max(dp[end+1][res], dp[day][res] + w);
					}
				}
			}
		}
	}

	return *max_element(dp[366], dp[366]+370);
}

int main(){
	int N;
	while(scanf("%d",&N),N){
		for(int i=0; i<370; i++){
			sche[i].clear();
		}
		for(int i=0; i<N; i++){
			int st, en, we;
			scanf("%d%d%d",&st,&en,&we);
			sche[st].push_back(make_pair(en,we));
		}
		printf("%d\n",solve());
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    bool ans = false;
    int k = 0;
    rep(i, N - 1) {
        if (A[i] + A[i + 1] >= L) {
            ans = true;
            k = i;
            break;
        }
    }

    if (!ans) {
        write("Impossible");
        return 0;
    }
    else {
        write("Possible");

        rep(i, k) {
            write(i + 1);
        }
        for (int i = N - 2; i > k; --i) {
            write(i + 1);
        }
        write(k + 1);
    }
}

Measured memory_bytes: 1280
main = do
  s <- getLine
  let toInt x = read x :: Int
  let puts a b = putStrLn $ a ++ " " ++ b
  let [a,b] = map toInt . words $ s
  if a == 0 && b == 0 then return ()
  else do
    if a < b then puts (show a) (show b) else puts (show b) (show a)
    main

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

#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000

vector<bool>prime(MAX, true);
vector<ll>fact(MAX);
vector<ll>factinv(MAX);

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a=(a * a) % MOD;
    }
    return res;
}

void getprime()
{
    for(ll i = 2;i < MAX; i++)
    {
        if(prime[i-1])
        {
            for(ll j = i*i; j < MAX; j += i)
                prime[j-1] = false;
        }
    }
}

void getfact()
{
    fact[0] = 1;
    factinv[0] = 1;
    
    for(ll i = 1; i < MAX; i++)
        fact[i] = (fact[i-1] * i)%MOD;
    
    for(ll i = 1; i < MAX; i++)
        factinv[i] = (factinv[i-1] * fastpower(i, MOD -2) )%MOD;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,n,m,q;
    cin>>n>>q;
    vector<bool>a(n,false);
    while(q--)
    {
        cin>>m;
        while(m--)
        {
            ll x;
            cin>>x;
            a[x-1]=true;

        }
    }
    ll res=0;
    for(ll i=0;i<n;i++)
    {
        if(!a[i])
            res++;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 18904
# C
sd = input()
scnt = len(sd)
t = input()
tcnt = len(t)

point = 0
unrestorable = True
while point <= scnt - tcnt:
    oneroopcorres = True
    for i in range(tcnt):
        anyone = sd[point+i] == '?'
        correspond = sd[point+i] == t[i]
        if not (anyone or correspond):
            oneroopcorres = False

    if oneroopcorres:
        unrestorable = False
        good_point = point

    point += 1

if unrestorable:
    print('UNRESTORABLE')
    exit()
else:
    sd = list(sd)
    for i in range(tcnt):
        sd[good_point + i] = t[i]
    sd = ''.join(sd)

sd = sd.replace('?', 'a')
print(sd)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
vector<int> v[100005],v1[100005],vis(100005),dis(100005);
vector<int> ts;
void dfs(int node){
      vis[node]=1;
      rr(v[node]){
         if(!vis[val])dfs(val);
      }
      rr(v1[node]){
         dis[val]=max(dis[val],dis[node]+1);
      }
}
int32_t main(){
   int n,m; cin>>n>>m;
   rep(i,0,m){
      int a,b; cin>>a>>b;
      v[a].pub(b);
      v1[b].pub(a);
   }
   rep(i,1,n+1)if(!vis[i])dfs(i);
   int ans=0;
   rep(i,1,n+1)ans=max(ans,dis[i]);
   cout<<ans<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 17724
#include <stdio.h>
 int main()
 {
    char a[4],t;
    int i,j;
    for(i=0;i<4;i++)
        scanf("%c",&a[i]);
    for(i=0;i<3;i++)
    {
        for(j=0;j<3-i;j++)
        {
            if(a[j]>a[j+1])
            {
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
    }
    if(a[0]==a[1]&&a[2]==a[3]&&a[1]==a[2]) printf("No\n");
    else if(a[0]==a[1]&&a[2]==a[3])printf("Yes\n");
    else printf("No\n");
    return 0;
 }

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    readFromCli()
}

private fun readFromCli() {
    val scanner = Scanner(System.`in`)
    val prog: MutableList<Int> = scanner
            .nextLine()
            .split(" ")
            .map{ it.toInt() }
            .toMutableList()
    scanner.close()
    prog.sort()
    println(prog[0].toString() + " " + prog[1] + " " + prog[2])
}


Measured memory_bytes: 33416
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int64_t x, y;
    cin >> x >> y;
    int cnt = 1;
    while(x*2 <= y){
        if (x*2 <= y){
            cnt++;
            x *= 2;
        }
        else {
            break;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3684
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h1, m1, h2, m2, k = map(int, input().split())

print((h2 - h1)* 60 + (m2 - m1) - k)

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

int w[300];
int can[310][310];
int dp[310];

int len(int l, int r) {
	return r - l + 1;
}

int f(int l, int r) {
	if(can[l][r] != -1) return can[l][r];
	int L = len(l, r);
	if(L == 0) return 1;
	if(L == 2) return abs(w[l] - w[r]) <= 1;
	if(L % 2) return 0;

	if(abs(w[l] - w[r]) <= 1 && f(l + 1, r - 1)) {
		can[l][r] = 1;
		return 1;
	}
	for(int i = l + 1; i < r; i++) {
		if(f(l, i) && f(i + 1, r)) {
			can[l][r] = 1;
			return 1;
		}
	}
	can[l][r] = 0;
	return 0;
}

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

	int N;
	while(cin >> N, N) {
		for(int i = 0; i < N; i++) {
			cin >> w[i];
		}

		memset(can, -1, sizeof can);
		memset(dp, 0, sizeof dp);
		for(int l = 0; l < N; l++) {
			dp[l + 1] = max(dp[l + 1], dp[l]);
			for(int r = l + 1; r < N; r++) {
				if(f(l, r)) {
					dp[r + 1] = max(dp[r + 1], dp[l] + len(l, r));
				}
			}
		}
		cout << dp[N] << endl;
	}
}

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

int main() {
 long long int a,c[100];
  cin >>a;
  
  c[0] = 2;
  c[1] = 1;
  
  for(int i=2; i<= a;i++){
    
   c[i] = c[i-1] +c[i-2];
  }
  cout << c[a] << endl;
}


Measured memory_bytes: 256
def main():
    s = input()
    n = len(s)
    ans = 0
    g,p = 1,0
    for i in range(1,n):
        if g>p:
            if s[i]=='g':
                ans += 1
            p+=1
        else:
            if s[i]=='p':
                ans -=1
            g += 1
    print(ans)
            

if __name__ == "__main__":
    main()


Measured memory_bytes: 9232
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int num[26],co[26];

int main(){
  int N,T,t[210000];
  cin>>N>>T;
  ll sum=0;
  for(int i=0;i<N;i++){
    cin>>t[i];
  }
  for(int i=0;i<N-1;i++){
    if(t[i]+T<t[i+1]) sum+=T;
    else sum+=t[i+1]-t[i];
  }
  sum+=T;
  cout<<sum<<endl;
}


Measured memory_bytes: 1024
import math
H,N=map(int,input().split())
A=[0 for i in range(N)]
B=[0 for i in range(N)]
dp=[[0 for j in range(H)] for i in range(N)]
for i in range(N):
    A[i],B[i]=map(int,input().split())

for i in range(N):
    for j in range(H):
        if i==0:
            dp[i][j]=B[i]*math.ceil((j+1)/A[i])
        elif j+1<=A[i]:
            dp[i][j]=min(dp[i-1][j],B[i])
        else:
            dp[i][j]=min(dp[i-1][j],dp[i][j-A[i]]+B[i])

print(dp[N-1][H-1])

Measured memory_bytes: 286216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define rep(p,q) for(int i = p; i < q;i++)

int main(void) {
	double a, b, c, d, e, f;
	cout << fixed;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double y = (d*c - a*f) / (b*d - a*e);
		double x = (c - b*y) / a;
		
		cout << setprecision(3) << round(x * 1000) / 1000 << " "<< setprecision(3) << round(y * 1000) / 1000 << endl;
	}
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a;
  cin >> a;
  cout << "ABC" << a << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef struct{
	string name;
	int p,abc,de,f,s,m;
	int sum;
	double KORITU;	//sum(収入) / 時間(abc+de)+付加時間(de*(m-1)
}K;

int main(){
	int n;
	int A,B,C,D,E;
	while(1){
	cin >> n;
	if(n==0)break;
	K data[51];
	K temp;
	for(int i=0;i<n;i++){
		cin >> data[i].name >> data[i].p >> A >> B >> C >> D >> E >> data[i].f >> data[i].s >> data[i].m;
		data[i].abc=A+B+C;
		data[i].de=D+E;

		data[i].sum= data[i].f * data[i].s * data[i].m - data[i].p;
		data[i].KORITU = (double)data[i].sum / (double)(data[i].abc+data[i].de + data[i].de*(data[i].m-1) );
	}
	for(int i=0;i<n-1;i++){
		for(int j=n-1;j>i;j--){
			if(data[j].KORITU > data[j-1].KORITU){
				temp=data[j];
				data[j]=data[j-1];
				data[j-1]=temp;
			}
		}
	}
	for(int i=0;i<n-1;i++){
	for(int j=n-1;j>i;j--){
		if(data[j].KORITU==data[j-1].KORITU&& data[j].name < data[j-1].name){
			temp=data[j];
				data[j]=data[j-1];
				data[j-1]=temp;
		}
	}
	}
	for(int i=0;i<n;i++){
		cout << data[i].name << endl;
	}
	cout << "#" << endl;
	}
}

Measured memory_bytes: 1216
userIn = input().split()
n = int(userIn[0])
a = int(userIn[1])
b = int(userIn[2])
sum = 0
for i in range(1, n+1):
    tempSum = 0

    for j in range(5):
        tempSum += int(i/(10**j)) % 10

    if a <= tempSum and tempSum <= b:
        sum += i

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define endl "\n"
template <typename T>
void printvec(vector<T> &v, int n, int start = 0)
{
    //cout << "\nprinting vector\n";
    for (int i = start; i < n; i++)
    {
        cout << v[i] << " ";
    }
    cout << "done printing";
    cout << endl;
}
const int mod = 1e9 + 7;

void solve()
{
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<3;)
    {
        int ix = i+1;
        int cnt = 0;
        if(s[i] == 'R')
        {
            cnt = 1;
            while(ix<3 && s[i] == s[ix])
            {
                cnt++;
                ix++;
            }
        }
        i = ix;
        ans = max(ans,cnt);
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>

int main(){
  int n,S[10001],q,T[501],i,j,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
      }
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if(T[i]<0 || T[i]>1000000000){
      exit(8);
      }
  }
  
  //Linearsearch
  for(i=0;i<q;i++){
    for(j=0;j<n-1;j++){
      if(T[i]==S[j]){
	count++;
	break;
      }
    }
  }
  
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100010;
vector<int> edge[maxn*2];
int tot,m,n,c[maxn];

void dfs(int u,int col)
{
    c[u]=col;
    for(int i=0;i<edge[u].size();i++){
        int v=edge[u][i];
        if(c[v]==-1) dfs(v,!col);
        if(c[v]!=!col){
            cout<<1ll*n*(n-1)/2-m<<endl;
            exit(0);
        }
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    memset(c,-1,sizeof(c));
    for(int i=0;i<m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1,0);
    int b=0,w=0;
    for(int i=1;i<=n;i++)
        if (c[i]) b++;
    else w++;
    cout<<1ll*b*w-m<<endl;
    return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long N;
    cin >> N;
    vector<long long> A(N+1);
    for (long i = 0; i < N+1 ; i++) {
        cin >> A.at(i);
    }
    vector<long long> B(N);
    for (long k = 0; k < N ; k++) {
        cin >> B.at(k);
    }
    B.emplace_back(0);
    long long next = 0;
    long long count = 0;
    for (long j = 0; j < N+1; j++)
    {
        if (B[j]+next > A[j])
        {
            count = count + A[j];
            if (A[j] < next)
            {
                next = B[j];
            }else{
                next = B[j]-A[j]+next;
            }
        }else{
            count = count + B[j] + next;
            next = 0;
        }
        
    }
    cout << count;

}


Measured memory_bytes: 2560
#include<stdio.h>
int main(){
  int n,m,p,x;
  int t[101];
  int sum = 0;

  scanf("%d",&n);

  for(int i=0; i<n; i++){
    int tmp = 0;
    scanf("%d",&tmp);
    t[i] = tmp;
    sum = sum + t[i];
  }

  scanf("%d",&m);
  
  for(int j=0; j<m; j++){
    scanf("%d %d",&p,&x);
    int def = 0;
    if(t[p-1]>x){
      def = t[p-1]-x;
      printf("%d\n",sum-def);
    }else if(t[p-1]<x){
      def = x - t[p-1];
      printf("%d\n",sum+def);
    }else{
      printf("%d\n",sum);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define EPS (1e-10)
#define rep(i,n) for(int i=0;i<n;i++)
typedef complex<double> P;

double x,y,xx,yy,xxx,yyy,xxxx,yyyy;

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int main(){
	while(cin>>x>>y>>xx>>yy>>xxx>>yyy>>xxxx>>yyyy){
		P a=P(x,y),b=P(xx,yy),c=P(xxx,yyy),p=P(xxxx,yyyy);
		int C=cross(p-a,b-a)>0&&cross(p-b,c-b)>0&&cross(p-c,a-c)>0||cross(p-a,b-a)<0&&cross(p-b,c-b)<0&&cross(p-c,a-c)<0;
		cout<<(C?"YES":"NO")<<endl;
	}
}

Measured memory_bytes: 0
#include <cmath>
#include <string>
#include <iostream>

using namespace std;

int main()
{
	string S;

	cin >> S;

	int ptr1 = 0, ptr2, mem[16]; mem[0] = 0;

	for (int i = 1; i < 16; i++)
	{
		cout << '>';

		mem[i] = i * 8;

		for (int j = 0; j < i * 8; j++)
		{
			cout << '+';
		}
	}

	cout << "<<<<<<<<<<<<<<<";

	for (int i = 0; i < S.size(); i++)
	{
		ptr2 = S[i];

		if (ptr1 < ptr2)
		{
			for (int j = 0; j < abs(ptr1 / 8 - ptr2 / 8); j++)
			{
				cout << '>';
			}
		}

		if (ptr1 > ptr2)
		{
			for (int j = 0; j < abs(ptr1 / 8 - ptr2 / 8); j++)
			{
				cout << '<';
			}
		}

		int x = ptr2 - mem[ptr2 / 8];

		mem[ptr2 / 8] = ptr2;

		if (x > 0)
		{
			for (int j = 0; j < x; j++)
			{
				cout << '+';
			}
		}

		if (x < 0)
		{
			for (int j = 0; j < -x; j++)
			{
				cout << '-';
			}
		}

		ptr1 = ptr2;

		cout << '.';
	}

	return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>
#include <stdlib.h>


    int nn[100001];

int main(void){
    int N,K,Q;
    int A[100000];
    
    scanf("%d%d%d",&N,&K,&Q);
    
    int i,j;
    for(i=1;i<=Q;i++){
        scanf("%d",&A[i]);
       if(K-i+nn[A[i]-1]>-1) nn[A[i]-1]++;
    }
    
    for(i=0;i<N;i++){
        if(K-Q+nn[i]>0)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main() {
  int n,k=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n-2;i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
      k++;
  }
  cout<<k;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int n;
  cin >> n;
  lvec a(n);
  ll sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  ll x = 0;
  ll y = sum - x;
  ll minDiff = INF;
  ll diff = INF;
  REP(i, n - 1) {
    x += a[i];
    y = sum - x;
    diff = abs(x - y);
    minDiff = min(minDiff, diff);
  }
  cout << minDiff << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  int m = dup(a[n-1], 2);
  int m2 = dup(a[n-1], 2);
  if (a[n-1]/2 % 2 == 0) {
    m2 = a[n-1]/2;
  }
  int sa = min(m - a[0], m2 - a[0]);
  int ans = a[0];
  rep(i, n-1) {
    chmin(sa, abs(m - a[i]));
    if (sa == abs(m - a[i])) ans = a[i];
    chmin(sa, abs(m2 - a[i]));
    if (sa == abs(m2 - a[i])) ans = a[i];
  }
  cout << a[n-1] << " " << ans << endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int H,W,N;
    cin>>H>>W>>N;
    set<pii> p;
    REP(i,N) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        p.insert({a,b});
    }
    vector<int> ans(10,0);
    FORE(q,p) {
        int y=q.first,x=q.second;
        REPF(dy,-2,1) {
            REPF(dx,-2,1) {
                int cnt=0;
                REP(i,3) {
                    REP(j,3) {
                        int yy=y+dy+i;
                        int xx=x+dx+j;
                        if(OUTOFRANGE(yy,xx,H,W)) {
                            goto next;
                        }
                        if(CONTAIN(p,pii(yy,xx))) cnt++;
                    }
                }
                ans[cnt]++;
                next:;
            }
        }
    }
    ans[0]=(H-2)*(W-2);
    REPF(i,1,10) {
        ans[i]/=i;
        ans[0]-=ans[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> ti;
typedef vector<ti> vti;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e5 + 2;

vii xs;
vii ys;
priority_queue<ti,vti, greater<ti>>pq;
int n;
int pai[T];
int peso[T];

void init() {
    for(int i = 0; i <= n; i++) {
        pai[i] = i;
        peso[i] = 1;
    }
}

int find(int x) {
    return (x == pai[x]? x : pai[x] = find(pai[x]));
}

void join(int x, int y) {
    x = find(x);
    y = find(y);
    if(peso[x] < peso[y]) swap(x,y);
    pai[y] = x;
    peso[x] += peso[y];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    init();

    for(int i = 0; i < n; i++) {
        int a,b; cin >> a >> b;
        xs.eb(a,i);
        ys.eb(b,i);
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    for(int i = 1; i < n; i++) {
        pq.emplace(xs[i].fi - xs[i-1].fi, xs[i-1].se, xs[i].se);
        pq.emplace(ys[i].fi - ys[i-1].fi, ys[i-1].se, ys[i].se);
    }

    ll ans = 0;

    while(!pq.empty()) {
        ti at = pq.top();
        pq.pop();
        ll d,a,b;
        tie(d,a,b) = at;
        if(find(a) != find(b)) {
            ans += d;
            join(a,b);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7912
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int SumMoney = 0;
  int OneYenCount = 0;
  cin >> SumMoney >> OneYenCount;
  // 500で割ったあまりが1円の枚数より少なければ払える。
  if( OneYenCount >= (SumMoney % 500)  )
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()

if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    print(2**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    print(2**(N//2) % mod)


Measured memory_bytes: 55532
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n, m = inpm()
if(n == m):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 74672
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int k, x;
	cin >> k >> x;
	k *= 500;
	cout << (k >= x ? "Yes" : "No");
}

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

int main() {
  int n, em = 0, om = 0, emn, omn, es = 0, os = 0, esn, osn, s = 0;
  cin >> n;
  vector<int> v(n);
  map<int, int> o, e;
  rep(i, n){
    cin >> v[i];
    if(i % 2 == 0) o[v[i]]++;
    else e[v[i]]++;
  }
  for(auto a: e){
    if(em < a.second){
      emn = a.first;
      em = a.second;
    }
  }
  for(auto a: o){
    if(om < a.second){
      omn = a.first;
      om = a.second;
    }
  }
  for(auto a: e){
    if(a.first != emn && es < a.second){
      esn = a.first;
      es = a.second;
    }
  }
  for(auto a: o){
    if(a.first != omn && os < a.second){
      osn = a.first;
      os = a.second;
    }
  }
  if(emn != omn) s += n - em - om;
  else s += n - max(em + os, om + es);
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int N;
	cin >> N;
	bool aho = true;
	if (N >= 25) {
		cout << "Yes" << endl;
	}
	else {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (i * 7 + j * 4 == N) {
					aho = false;
				}
			}
		}
		if (aho) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
vector<pii> ans;
void add(int x, int y)
{
    ans.push_back({x, y});
}
void out()
{
    cout << ans.back().first - ans.back().second << "\n";
    for (auto it : ans) {
        cout << it.first << " " << it.second << "\n";
    }
    exit(0);
}
main() {
    int n = readInt();
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
    }
    if (n == 2) {
        if (a[1] - a[2] >= a[2] - a[1]) {
            cout << a[1] - a[2] << "\n";
            cout << a[1] << " " << a[2] << "\n";
        } else {
            cout << a[2] - a[1] << "\n";
            cout << a[2] << " " << a[1] << "\n";
        }
        return 0;
    }
    sort(a + 1, a + n + 1);
    if (a[1] >= 0) {
        int x = a[1];
        for (int i = 2; i < n; i++) {
            add(x, a[i]);
            x -= a[i];
        }
        add(a[n], x);
    } else if (a[n] <= 0) {
        int x = a[n];
        for (int i = n - 1; i >= 1; i--) {
            add(x, a[i]);
            x -= a[i];
        }
    } else {
        int x = a[1];
        for (int i = 2; i < n; i++) {
            if (a[i] >= 0) {
                add(x, a[i]);
                x -= a[i];
            }
        }
        add(a[n], x);
        x = a[n] - x;
        for (int i = n; i > 1; i--) {
            if (a[i] < 0) {
                add(x, a[i]);
                x -= a[i];
            }
        }
    }
    out();
}


Measured memory_bytes: 4336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Calc c = new Calc();
		c.abc119A();
	}

}

class Calc{
	void abc119A() {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int m = Integer.valueOf(s.substring(5,7));
		if(m>=5) {
			System.out.println("TBD");
		}else {
			System.out.println("Heisei");
		}
	}
}

Measured memory_bytes: 21716