akhauriyash/Code-Regression huggingface dataset:
con = 10 ** 9 + 7
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

class Combination(object):
	def __init__(self, N, con):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1

		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % con
			self.inv[i] = self.inv[con % i] * (con - (con // i)) % con
			self.finv[i] = self.finv[i - 1] * self.inv[i] % con

	def com(self, k, N):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % con

#処理内容
def main():
	X, Y = getlist()
	N = (X + Y) // 3
	if (X + Y) % 3 != 0:
		print(0)
	elif X < N or Y < N:
		print(0)
	else:
		C = Combination(N, con)
		ans = C.com(X - N, N)
		print(ans)

	

if __name__ == '__main__':
	main()

Measured memory_bytes: 82412
#include <iostream>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
#include <climits>
#include <iomanip>

#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rforr(i, t, n) (int i = n-1; i>=t; --i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 101;
const int MAXW = 1e5+1;

//STRUCTS


//OPERATORS


//GLOBALS
int n, cap;
ll dp[MAXN+1][MAXW+1];
int w[MAXN], v[MAXN];

//FUNCTIONS
/*
ll dyn()
{
	forn(i, n+1)
	{
		forn(j, cap+1)
		{
			if (i == 0 or j == 0) dp[i][j] = 0;
			else if (j<w[i-1]) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + ll(v[i-1]));
		}
	}
	return dp[n][cap];
}*/

ll td(int curn, int curw, ll curs)
{
	if (curn == 0 or curw == 0) return curs;
	if (dp[curn][curw] != -1) return dp[curn][curw];
	if (curw - w[curn-1] >= 0) 
	{
		dp[curn][curw] = max(td(curn-1, curw, curs), ll(v[curn-1]) + td(curn-1, curw-w[curn-1], curs));
	}
	else dp[curn][curw] = td(curn-1, curw, curs);
	return dp[curn][curw];
}
//PROBLEM: 
//LINK: 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

		memset(dp, -1, sizeof(dp));
		cin >> n >> cap;
		forn(i, n) cin >> w[i] >> v[i];
		cout << td(n, cap, 0);



	return 0;
}

Measured memory_bytes: 80000
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
vector<int> bi[100005];
long long n,m,i,j,col[100005],x,y,cnt[3],bo;
void dfs(int x,int y)
{
	if (col[x]!=0) {if (col[x]!=y) bo=1;return;}
	col[x]=y,cnt[y]++;
	int i;
	for (i=0;i<bi[x].size();i++)
	{
		 dfs(bi[x][i],3-y);
	}
}
int main()
{
	cin>>n>>m;
	for (i=1;i<=m;i++)
	{
		cin>>x>>y;
		bi[x].push_back(y);
		bi[y].push_back(x);
	}
	dfs(1,1);
	if (bo) cout<<n*(n-1)/2-m; else cout<<cnt[1]*cnt[2]-m;
	return 0;
}

Measured memory_bytes: 7296
print=console.log;
line=require("fs").readFileSync("/dev/stdin","utf-8").split("\n")[0]
Array.prototype.rotate = function(n) {
  return this.slice(n, this.length).concat(this.slice(0, n));
}

y = "y"; g = "g"; r = "r";
b = "b"; o = "o"; w = "w";
A = [y, g ,r]; B = [y, r, b];
C = [y, b, o]; D = [y, o, g];
E = [w, b, r]; F = [w, r, g];
G = [w, g, o]; H = [w, o, b];
cube = [A,B,C,D,E,F,G,H];

for (var i=0; i<line.length; ++i)
  operate(line[i])

print(".."+cube[5][1]+cube[4][2]+"....");
print(".."+cube[0][2]+cube[1][1]+"....");
print(cube[5][2]
  +cube[0][1]+cube[0][0]
  +cube[1][0]+cube[1][2]
  +cube[4][1]+cube[4][0]
  +cube[5][0]);
print(cube[6][1]
  +cube[3][2]+cube[3][0]
  +cube[2][0]+cube[2][1]
  +cube[7][2]+cube[7][0]
  +cube[6][0]);
print(".."+cube[3][1]+cube[2][2]+"....");
print(".."+cube[6][2]+cube[7][1]+"....");

function operate(ch) {
  if (ch == "R") {
    var tmp = cube[1];
    cube[1] = cube[2].rotate(2);
    cube[2] = cube[7].rotate(1);
    cube[7] = cube[4].rotate(2);
    cube[4] = tmp.rotate(1);
    return;
  }
  else if (ch == "L") {
    var tmp = cube[3];
    cube[3] = cube[0].rotate(2);
    cube[0] = cube[5].rotate(1);
    cube[5] = cube[6].rotate(2);
    cube[6] = tmp.rotate(1);
    return;
  }
  else if (ch == "F") {
    var tmp = cube[0];
    cube[0] = cube[3];
    cube[3] = cube[2];
    cube[2] = cube[1];
    cube[1] = tmp;
    return;
  }
  else if (ch == "B") {
    var tmp = cube[4];
    cube[4] = cube[7];
    cube[7] = cube[6];
    cube[6] = cube[5];
    cube[5] = tmp;
    return;
  }
  else if (ch == "U") {
    var tmp = cube[0];
    cube[0] = cube[1].rotate(2);
    cube[1] = cube[4].rotate(1);
    cube[4] = cube[5].rotate(2);
    cube[5] = tmp.rotate(1);
    return;
  }
  else {
    var tmp = cube[6];
    cube[6] = cube[7].rotate(2);
    cube[7] = cube[2].rotate(1);
    cube[2] = cube[3].rotate(2);
    cube[3] = tmp.rotate(1);
    return;
  } 
}

Measured memory_bytes: 8524
<?php
    fscanf(STDIN,"%d %d %d", $a, $b, $c);
    $array = [$a, $b, $c];
    sort($array);
    $first = $array[0] - $array[1];
    $second = $array[1] - $array[2];
    echo abs($first) + abs($second);
  ?>

Measured memory_bytes: 4604
import java.util.Scanner;

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

        for (int t = 0; t < n; ++t) {
            int[] num = new int[9];
            int[][] color = new int[3][9];
            boolean ans = true;

            for (int i = 0; i < 9; ++i) {
                num[i] = scanner.nextInt() - 1;
            }
            for (int i = 0; i < 9; ++i) {
                String c = scanner.next();

                int idx;
                if (c.equals("R")) idx = 0;
                else if (c.equals("G")) idx = 1;
                else idx = 2;
                ++color[idx][num[i]];
            }

            for (int i = 0; i < 3; ++i) {
                for (int j = 0; j < 9; ++j) {
                    if (color[i][j] < 0) {
                        ans = false;
                    } else if (color[i][j] >= 3) {
                        color[i][j] -= 3;
                    }
                    if (color[i][j] > 0) {
                        if (j >= 7) ans = false;
                        else {
                            color[i][j + 1] -= color[i][j];
                            color[i][j + 2] -= color[i][j];
                            color[i][j] = 0;
                        }
                    }
                }
            }
            System.out.println((ans ? 1 : 0));
        }
    }
}


Measured memory_bytes: 28904
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<EntryPoint>]
let main _ =
    let s = readInts()

    s
    |> Array.filter (fun x -> x = 1)
    |> Array.length
    |> printfn "%d"
    0 // return an integer exit code


Measured memory_bytes: 12120
#include <cstdio>
#include <vector>
#include <algorithm>

int n;
bool visit[9];
std::vector<int> v[9];

int dfs(int vert)
{
  visit[vert] = true;
  
  int count = 0;
  for (int i = 0; i < v[vert].size(); ++i)
  {
    if (visit[v[vert][i]]) continue;
    count += dfs(v[vert][i]);
  }

  bool all = true;
  for (int i = 1; i <= n; ++i)
  {
    all &= visit[i];
  }
  if (all) ++count;
  
  visit[vert] = false;
  return count;
}

int main()
{
  int m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }

  printf("%d\n", dfs(1));
  return 0;
}

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

n,k,q = map(int, input().split())
a = [0]*n
for i in range(q):
    i = int(input())-1
    a[i] += 1
for i in range(n):
    s = a[i]-q+k
    if s > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 47704
import java.util.Scanner;

public class Main {

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

        int k = Integer.parseInt(scan.next());
        scan.close();

        int[] array = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

        System.out.println(array[k - 1]);

    }

}

Measured memory_bytes: 24532
#include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

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

  vector<ll> N;
  for (ll i = 0; i < s.size(); i++) {
    N.push_back(s[i] - '0');
  }

  vector<ll> next(2019, 0);
  vector<ll> pre(2019, 0);

  ll sum = 0;
  for (ll i = 0; i < N.size(); i++) {
    for (ll d = 0; d < 2019; d++) {
      next[(d * 10 + N[i]) % 2019] = pre[d];
    }
    sum += next[0];
    next[N[i]] += 1;
    swap(next, pre);
    next.clear();
  }
  cout << sum << endl;
}

Measured memory_bytes: 5504
#include<cstdio>

int main(){
        int w,h,x,y,r;
        scanf("%d %d %d %d %d", &w,&h,&x,&y,&r);
        if(x >= r && y >= r && x + r <= w && y + r <= h){
                printf("Yes\n");
        }else{
                printf("No\n");
        }
}

Measured memory_bytes: 1012
#include <stdio.h> 
 #include <math.h> 
 #define MAX 1000 
 
 
 int main(){ 
     int n; 
     int i, j=0, sum; 
     int score[MAX]; 
     double ave, tmp; 
     double dev[MAX]; 
 
 
     while(1){ 
         scanf("%d", &n); 
         if(n==0)break; 
         sum=0; 
         for(i=0;i<n;i++){ 
             scanf("%d", &score[i]); 
             sum+=score[i]; 
         } 
         ave=(double)sum/(double)n; 
         tmp=0.0; 
         for(i=0;i<n;i++){ 
             tmp+=pow(score[i]-ave, 2); 
         } 
         dev[j++]=sqrt(tmp/(double)n); 
     } 
     for(i=0;i<j;i++){ 
         printf("%f\n", dev[i]); 
     } 
     return 0; 
 } 



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

int main()
{
  int Q, H, S, D, N; // 0.25, 0.5, 1, 2
  cin >> Q >> H >> S >> D;
  cin >> N;
  vector<pair<int, double>> unit = {
    make_pair(Q, 0.25),
    make_pair(H, 0.5),
    make_pair(S, 1.0),
    make_pair(D, 2.0)
  };
  sort(unit.begin(), unit.end(), [](const pair<int, double>& a, const pair<int, double>& b) -> bool {
    return a.first / a.second < b.first / b.second;
  });

  long long cost = 0;
  for (int i = 0; N && i < unit.size(); ++ i) {
    long long slots = N * 1LL / unit[i].second;
    cost += slots * unit[i].first;
    N -= slots * unit[i].second;
  }
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
h, n = map(int, input().split())
A = [0] * n
B = [0] * n
for i in range(n):
    A[i], B[i] = map(int, input().split())
min_hp = h
max_hp = h + max(A)
 
dp = [sys.maxsize] * (max_hp + 1)
dp[0] = 0
 
for i in range(1, max_hp + 1):
    dp[i] = min(dp[i - A[j]] + B[j] for j in range(n))
print(min(dp[h:]))

Measured memory_bytes: 44508
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

int main(){
    string s;
    cin >> s;
    vector<int>alpa(26);
    int n = s.size();
    rep(i,n){
        int x = s[i] - 'a' ;
        alpa[x]++;
    }
    bool beauty = true;
    rep(i,26){
        //cout << alpa[i] << endl;
        if(alpa[i]%2==1)beauty = false;
    }
    if(beauty)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
B = 0
if x == -y:
    print(1)
elif x <= y:
    if x < 0 and y > 0:
        print(1 + abs(abs(y)-abs(x)))
    else:
        print(abs(abs(y)-abs(x)))
elif y < x:
    if x >= 0 and y <= 0:
        print(1 + abs(x+y))
    else:
        print(2 + abs(y-x))
"""
y = -x : print(1)

x <= y : print(y-x)
(ex: x=3, y=10)
(ex: x=-3, y=-1)
(ex: x=-3, y=1)

(ex: x=-3, y=50) : 

y < x : 2 + |y-x|
(ex: x=20, y=10)
(ex: x=20, y=-100)
(ex: x=-20, y=-100)

"""

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

vector<pair<int, int>> e[100000];
bool used[100000];
int color[100000];

void coloring(int v, int c) {
    used[v] = true;
    color[v] = c;
    for (auto p: e[v]) if (!used[p.first]) {
        coloring(p.first, (c + p.second) % 2);
    }
}

int main(void) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n-1; i++) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        u--; v--;
        e[u].emplace_back(v, w);
        e[v].emplace_back(u, w);
    }

    coloring(0, 0);
    for (int i = 0; i < n; i++) {
        printf("%d\n", color[i]);
    }
    return 0;
}

Measured memory_bytes: 7680
from itertools import product
h, w, m = map(int, input().split())


row = [set()for _ in range(h)]
col = [set()for _ in range(w)]
for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    row[x].add(y)
    col[y].add(x)

crow = 0
ic = []
for i, x in enumerate(row):
    if crow < len(x):
        crow = len(x)
        ic = [i]
    elif crow == len(x):
        ic.append(i)

ccol = 0
jc = []
for j, x in enumerate(col):
    if ccol < len(x):
        ccol = len(x)
        jc = [j]
    elif ccol == len(x):
        jc.append(j)


ans = crow+ccol
for i, j in product(ic, jc):
    if j not in row[i]:
        print(ans)
        break
else:
    print(ans-1)


Measured memory_bytes: 202984
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#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 YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
map<long long int,long long int> prime;
void prime_fact(long long int n){
    long long int nc=n;
    long long int i=2;
    while(nc!=1){
        if(i*i>nc) {
            if(prime.count(nc)) {prime.at(nc)+=1; break;}
            else {prime[nc]=1;}
            break;
        }
        if(nc%i==0){
            long long int count=0;
            while(nc%i==0){
                nc/=i;
                count++;
            }
            if(prime.count(i)) prime.at(i)+=count; 
            else{prime[i]=count;}
        }
        i++;
    }
};
lli gcd(long long int x,long long int y){
    if(y==0) return x;
    return gcd(y,x%y);

}

int main(){
    lli ans=1;
    int n;
    cin>>n;
    rep(i,n){
        lli ti;
        cin>>ti;
        lli g=gcd(ti,ans);
        ti/=g;
        ans*=ti;
    }
    out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k;
double x[65], y[65], c[65], r[65];
double eps = 1e-5;

double dist(pair<double, double> p, pair<double, double> q) {
	double xx = (p.first - q.first)*(p.first - q.first);
	double yy = (p.second - q.second)*(p.second - q.second);

	return sqrt(xx + yy);
}

vector<pair<double, double>> circle_circle_intersection(double x1, double y1, double r1, double x2, double y2, double r2) {
	vector<pair<double, double>> ans;
	double d = dist(make_pair(x1, y1), make_pair(x2, y2));
	if (d > r1 + r2) {
		return ans;
	}
	if (x1 == x2 && y1 == y2) {
		ans.push_back(make_pair(x1, y1)); return ans;
	}
	if (d < abs(r1 - r2)) {
		ans.push_back(make_pair(x1, y1)); return ans;
	}

	double a = (r1*r1 - r2*r2 + d*d)/(2*d);
	double h = sqrt(r1*r1 - a*a);


	double x3 = (x2 - x1)*(a/d) + x1;
	double y3 = (y2 - y1)*(a/d) + y1;

	ans.emplace_back(x3 + h*(y2 - y1)/d, y3 - h*(x2 - x1)/d);
	ans.emplace_back(x3 - h*(y2 - y1)/d, y3 + h*(x2 - x1)/d);

	return ans;
}

int check(double t) {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		r[i] = t/c[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			vector<pair<double, double> > pts = circle_circle_intersection(x[i], y[i], r[i], x[j], y[j], r[j]);
			for (auto p: pts) {
				int cnt = 0;
				for (int k = 0; k < n; k++) {
					if (dist(p, make_pair(x[k], y[k])) <= r[k] +eps) cnt++;
				}
				ans = max(ans, cnt);
			}
		}
	}
	

	return ans;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	if (k == 1) {
		cout << "0\n"; exit(0);
	}
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> c[i];
	}

	double l = 0, r = 100000000;
	while(r-l>=1e-7)
	{
		double mid = (l + r)/2;

		if (check(mid) >= k) {
			r = mid;
		} else {
			l = mid;
		}
	}
	cout << fixed << setprecision(9) << r << '\n'; 

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> A(n); rep(i, n) cin >> A[i];
  ll ans = 1;
  ll odd = 1;
  rep(i, n) {
    if(A[i]%2) {
      odd *= 1;
    } else {
      odd *= 2;
    }
    ans *= 3;
  }
  cout << ans-odd << "\n";
  return 0;
}


Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    l = [A, B, C]
    if max(l) == A:
        print(A * 10 + B + C)
    elif max(l) == B:
        print(A + B * 10 + C)
    else:
        print(A + B + C * 10)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
int A[1000];
cin>>N;
double tmp=0;
for(int i=0;i<N;i++){
    cin>>A[i];
    tmp+=(1/float(A[i]));
}

cout<<1/tmp<<endl;
//system("pause");
return 0;
}

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

int main(void){

  std::vector<std::vector<int>> c(3, std::vector<int>(3));
  int c_sum = 0;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      std::cin >> c[i][j];
      c_sum += c[i][j];
    }
  }

  if(c_sum == 3*(c[0][0] + c[1][1] + c[2][2])){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }

  return 0;

}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a[101][101],b[101];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  vector<int> ans(1001,0);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      ans[i]+=a[i][j]*b[j];
    }
  }
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}

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

int main(){
  using namespace std;

	  int K;
	  int A;
	  int B;
	  int i = 0;
	  int flag = 0;
	  cin >> K;
	  cin >> A;
	  cin >> B;


	  while (i < B - A + 1) {
		  if ((A + i) % K == 0) {
			  flag = 1;
			  break;
		  }
		  i++;
	  }

	  if (flag) {
		  cout << "OK" << endl; 
	  }else{
		  cout << "NG" << endl;
	  }
}

Measured memory_bytes: 3596
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	string S;
	cin >> S;

	int N = S.size();

	int OK = 1;
	rep(i, N) if (S[i] != S[N - 1 - i]) OK = 0;
	if (OK) {
		rep(i, N / 2) if (S[i] != S[N / 2 - i - 1]) OK = 0;

		rep(i, N / 2) if (S[N / 2 + 1 + i] != S[N - 1 - i]) OK = 0;
	}

	co(OK ? "Yes" : "No");

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

string str;
int j=0;

int calc_mult(){
	int num = str[j] - '0';
	j++;
	while(1){
		if (j>=str.size()){
			return num;
		}else if (str[j]=='+'){
			j++;
			return (num += calc_mult());
		}else{
			j++;
			num *= str[j] - '0';
			j++;
		}
	}
}

int calc_lr(){
	int ret=str[0] - '0';
	char last_op = '+';
	for (int i=1; i+1<str.size(); i++){
		last_op = str[i];
		i++;
		ret = last_op=='+' ? ret+(str[i]-'0') : ret*(str[i] - '0');	
	}
	return ret;
}

int main(){
	int bob;
	cin >> str >> bob;
	int mult=calc_mult(), lr = calc_lr();
	if (mult==bob){
		if (lr==bob){
			cout << "U" << endl;
		}else{
			cout << "M" << endl;
		}
	}else if (lr==bob){
		cout << "L" << endl;
	}else{
		cout << "I" << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	ll ans = 0;

	cin >> n >> m;

	V a(m);
	ans = n;
	rep(i, m) {
		cin >> a[i];
		ans -= a[i];
	}

	ans = max(ans, -1LL);

	cout << ans << "\n";
}

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

	solve_abc_b();

	return 0;
}

Measured memory_bytes: 3732
#include<iostream>
using namespace std;
int main(){
    string str;
    cin >> str;
    int n;
    n = str.size();
    string tmp1,tmp2;
    int mx=0;
    for(int i=1;i<n/2;i++){
        tmp1 = str.substr(0,i);
        tmp2 = str.substr(i,i);
        //cout << "i, tmp1, tmp2 = " << i << tmp1 << tmp2 << endl;
        if(tmp1 == tmp2){
            mx = tmp1.size()+tmp2.size();
        }
    }
    int ans;
    ans = mx;
    cout << ans << endl;
}



Measured memory_bytes: 3580
#include<cstdio>
using namespace std;
int H,W,h,w;
void structure(int id){
	switch(id){
		case 1:{
			const unsigned int HLJ=(19260817)*(25252)*(0x98e);
			int HLL=HLJ%998244853;
			for(int i=0;i<H;i++){
    				for(int j=0;j<W;j++){
    					printf("%d%c",
    					((i%h)||(j%w))?
    					(
    					(((i+1)%h)||((j+1)%w))
    					?(0)
    					:(-HLL-1)
    					):HLL,(j+1)!=W?' ':'\n');
				}
    			}
		}break;
		case 2:{
			
		}break;
		case 3:{
					
		}break;
	}
}
int main(){
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H%h||W%w)puts("Yes"),structure(1);
	else puts("No");
	return 0;
}

Measured memory_bytes: 2688
n,m  = list(map(int, input().split()))
ab =[]
cs =[]
for i in range(m):
    ab.append(list(map(int, input().split())))
    cs.append(list(map(int, input().split())))

dp = [float("inf") for _ in range(1 << n)]
dp[0] = 0

for i in range(m):
    csbit = 0
    for j in cs[i]:
        csbit += 2**(j-1)
    for j in range(1 << n):
        dp[j | csbit] = min(dp[j | csbit], dp[j] + ab[i][0])

if dp[-1] == float("inf"):
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 46552
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int a, b;

    cin >> a >> b;

    if(a+b==15){
        cout << '+' << endl;
    }
    else if(a*b==15){
        cout << '*' << endl;
    }
    else{
        cout << 'x' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define ll long long
using namespace std;
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   lli n;
   cin>>n;
   if(n>=400 && n<=599)
   cout<<8<<"\n";
   else if(n>=600 && n<=799)
    cout<<7<<"\n";
   else if(n>=800 && n<=999)
    cout<<6<<"\n";
   else if(n>=1000 && n<=1199)
    cout<<5<<"\n";
   else if(n>=1200 && n<=1399)
    cout<<4<<"\n";
   else if(n>=1400 && n<=1599)
    cout<<3<<"\n";
   else if(n>=1600 && n<=1799)
    cout<<2<<"\n";
   else if(n>=1800 && n<=1999)
    cout<<1<<"\n";
 }
    
    

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

namespace _0083
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (string.IsNullOrEmpty(s)) break;
                int[] x = s.Split().Select(int.Parse).ToArray();
                DateTime date = new DateTime(x[0],x[1],x[2]);
                DateTime meiji = new DateTime(1868,9,8);
                DateTime taisho = new DateTime(1912,7,30);
                DateTime showa = new DateTime(1926,12,25);
                DateTime heisei = new DateTime(1989,1,8);
                if (date < meiji) Console.WriteLine("pre-meiji");
                else
                {
                    if (date < taisho) Console.Write("meiji " + (date.Year - 1867));
                    else if (date < showa) Console.Write("taisho " + (date.Year - 1911));
                    else if (date < heisei) Console.Write("showa " + (date.Year - 1925));
                    else Console.Write("heisei " + (date.Year - 1988));
                    Console.WriteLine(" " + date.Month + " " + date.Day);
                }
            }
        }
    }
}


Measured memory_bytes: 9484
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int N, K;
int A[100010];



//---------- 1000000007 ----------
const int MOD = 1000000007;
int m_add(int a, int b)
{
	return (a + b) % MOD;
}
int m_sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int m_mul(int a, int b)
{
	return (a * b) % MOD;
}
int m_pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = m_pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int m_divide(int a, int b)
{
	return m_mul(a, m_pow(b, MOD - 2));
}
int m_comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = m_mul(p, (n - i + 1));
		p = m_divide(p, i);
	}
	return p;
}



signed main()
{
	cin >> N >> K;
	REP(i, N) cin >> A[i];

	if (K == 1)
	{
		cout << 0 << endl;
		return 0;
	}

	ARY_SORT(A, N);
	int cur = 0;

	for (int i = 0; i < N - (K - 1); i++)
	{
		int a = A[i];
		int b = A[i + K - 1];
		if (a < 0) a = (a + MOD) % MOD;
		if (b < 0) b = (b + MOD) % MOD;
		cur = m_add(cur, b);
		cur = m_sub(cur, a);
	}

	int ans = cur;

	int C = 1;

	for (int i = K; i < N; i++)
	{
		int c = A[(N - 1) - (i - 1)];
		int d = A[(i - 1)];
		if (c < 0) c = (c + MOD) % MOD;
		if (d < 0) d = (d + MOD) % MOD;
		cur = m_add(cur, c);
		cur = m_sub(cur, d);
		C = m_mul(C, i - 1);
		C = m_divide(C, (i - 1) - (K - 2));
		int ad = m_mul(cur, C);

		ans = m_add(ans, ad);
	}

	cout << ans << endl;
}




Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
	int h =0;
	int w =0;
	int t =0;
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> listw = new ArrayList<Integer>();
	ArrayList<Integer> listh = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		}
		
		
		
		for(int i=0;i<listh.size();i++){
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					System.out.print("#");
				}
			System.out.println("");
			}
		System.out.println("");
		}
	}
}

Measured memory_bytes: 33224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
// #define int long long
#define mod 1000000007
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define nl endl
#define inf 1e18
#define cases ll t;cin>>t;while(t--)
#define BLOCK 500
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
 
using namespace std;



int32_t main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif

    //fast
    int n;
    scanf("%d",&n);
    vector<double> dp(n+1);
    //dp[i]=p-bility of having i heads so far
    // ms(dp,0);
    dp[0]=1;
    double p;
    f(i,n)
    {
        scanf("%lf",&p);
        // cin>>p;
        for(ll j=i+1;j>=0;j--)
        {
            dp[j]=((j==0)?0:dp[j-1]*p)+dp[j]*(1-p);

        }

    }
    double ans=0;
    f(heads,n+1)
    {
        ll tails=n-heads;
    
        if(heads>tails)
            ans+=dp[heads];

    }

    
    printf("%.10lf",ans);
    // cout<<ans;
    

       
    return 0;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
int main(){
    int n,x;
    cin>>n>>x;
    int m[n],ans=n,mi=1000;
    rep(i,0,n){
        cin>>m[i];
        x-=m[i];
        mi=min(mi,m[i]);
    }
    ans+=x/mi;
    cout<<ans<<endl;
}

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

#define ll long long
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))

const int N =100;

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);

}
ll f(ll n) {
	return n * (n - 1) / 2;
}
bool cmp(const tuple<int, string, string>& a,
               const tuple<int, string, string>& b)
{
    return (get<0>(a) < get<0>(b));
}

void solve()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    int ans=0;
    for(int i=0;i<=n-3;i++)
    {
        if(a[i]==b[i] && b[i+1]==a[i+1] && a[i+2]==b[i+2])
        {
            ans++;
            break;
        }
    }
    if(ans)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3720
n, m = list(map (int, input().split()))
k = [list(map(int, input().split())) for i in range(m)]
p = list(map (int, input().split()))
ans = 0


for i in range(1 << n):
    check = True
    for j in range(m):
        cnt = 0
        for l in range(1, len(k[j])):
            cnt += (i>>(k[j][l]-1))&1
        if cnt%2 != p[j]:
            check = False
    if check == True:
        ans += 1

print (ans)


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (b-a==c-b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a;
	string s;
	cin>>a>>s;
	if(a>=3200){
		cout <<s;
	}
	else{
		cout << "red";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	cin >> s;
	int n = s.size();
	while (n > 0) {
		bool flag = false;
		if (n >= 5 && s.substr(n - 5, 5) == "dream") {
			flag = true;
			n -= 5;
		}
		else if (n >= 7 && s.substr(n - 7, 7) == "dreamer") {
			flag = true;
			n -= 7;
		}
		else if (n >= 5 && s.substr(n - 5, 5) == "erase") {
			flag = true;
			n -= 5;
		}
		else if (n >= 6 && s.substr(n - 6, 6) == "eraser") {
			flag = true;
			n -= 6;
		}
		if (!flag) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>

using namespace std;

int main(){
	string in;
	cin >> in;
	char tar = '0';
	int a = 0;
	for(int i = 0;i < in.size();i++){
		char c = in[i];
		if(c != tar)a++;
		if(tar == '0'){
			tar = '1';
		}else{
			tar = '0';
		}
	}
	tar = '1';
	int b = 0;
	for(int i = 0;i < in.size();i++){
		char c = in[i];
		if(c != tar)b++;
		if(tar == '0'){
			tar = '1';
		}else{
			tar = '0';
		}
	}

	cout << min(a,b) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

void show(vector<int> &s) {
	for (auto x: s) {
		cout << x << " ";
	}
	cout << endl;
}

int main() {
	int n, k, c;
	cin >> n >> k >> c;

	string s;
	cin >> s;

	vector<int> workable1;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'o') {
			workable1.emplace_back(i + 1);
		}
	}
	auto workable2 = workable1;
	reverse(workable2.begin(), workable2.end());
	for (int i = 0; i < workable2.size(); i++) {
		workable2[i] *= -1;
	}



	int day = -1;
	vector<int> work1, work2;

	for (int i = 0; i < k; i++) {
		day = *upper_bound(workable1.begin(), workable1.end(), day);
		work1.push_back(day);
		day += c;
	}

	day = workable2[0] - 100;
	for (int i = 0; i < k; i++) {
		day = *upper_bound(workable2.begin(), workable2.end(), day);
		work2.push_back(abs(day));
		day += c;
	}
	sort(work2.begin(), work2.end());

	// show(work1);
	// show(work2);

	for (int i = 0; i < k; i++) {
		if (work1[i] == work2[i]) {
			cout << work1[i] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4984
k = [i ** 5 for i in range(200)]
x = int(input())
for a, i in enumerate(k):
    for b, j in enumerate(k):
        if i - j == x:
            ans = (a, b)
            break
        elif i + j == x:
            ans = (a, -b)
            break
ans = str(ans[0]) + ' ' + str(ans[1])
print(ans)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
 ll n;
 ll dp[3001][3001];

 ll funn(ll start,ll end,ll a[]){
  if(start>end)return 0;
  if(dp[start][end]!=1e13)return dp[start][end];
 
     ll chance = (n-1-end)+(start);
     if(chance&1)return dp[start][end]=min(-1*a[end]+funn(start,end-1,a),-1*a[start]+funn(start+1,end,a));
     else return dp[start][end]=max(a[end]+funn(start,end-1,a),a[start]+funn(start+1,end,a));

 }
 
int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    
   
    cin>>n;
    ll a[n];
    fori(0,n)cin>>a[i];

    fori(0,3001)
    for (int j = 0; j < 3001; ++j)
    {
      dp[i][j]=1e13;
    }

    
    cout<<funn(0,n-1,a);
 
return 0;
}

Measured memory_bytes: 74212
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[100005]={0};
int main()
{
	 LL n,h,w;
	 cin>>n>>h>>w;
	 LL ans=0;
	 for(int i=0;i<n;i++)
	 {  LL x,y;
	 cin>>x>>y;
	 if(x>=h&&y>=w)
	   ans++;
	 	 
	 }
	 cout<<ans<<endl;
 } 

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL A,B;

int halt(){
	printf("1\n");
	return 0;
}

int main(){
	scanf("%lld%lld" , &A , &B);
	if(A==B) return halt();
	int a = -1 , b = -1;
	do {
		if(a >= 0){
			A -= ((LL)1<<a);
			B -= ((LL)1<<a);
		}
		a = b = -1;
		for(LL i = 1 ; A + 1 > i ; ++a,i<<=1);
		for(LL i = 1 ; B + 1 > i ; ++b,i<<=1);
	} while(a == b);
	LL ans = ((LL)1<<b)-A;
	B -= ((LL)1<<b);
	int c = 0;
	for(LL i = 1 ; B + 1 > i ; ++c,i<<=1);
	B = ((LL)1<<c)-1;
	if(A<=B) B = A-1;
	printf("%lld\n" , ans + B + 1 + ((LL)1<<b) - A);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
typedef tuple<int,int,int,int>T;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;

int main(){
  	int N;
  	cin >>N;
   	vector<vector<P>>A(N);
  	vector<int>memo(N);
	rep(i,N){
      	int g;
    	cin >>g;
      	memo[i]=g;
    	rep(j,g){
          int b,c;
          cin >>b>>c;
          A[i].push_back(P(b-1,c));
        }
    }
  			
  	int ans=0;	
  	for(int tmp=0;tmp<(1<<N);tmp++){
    	bitset<20>s(tmp);
      	int flag=0; //flag=1 でむじゅん
      	int count=0;
      	rep(i,N){
        	if(s.test(i)){
              count++;
            	rep(j,memo[i]){
                	auto qq=A[i][j];
                	if(qq.second==1&&(!s.test(qq.first)))flag=1;
                    if(qq.second==0&&(s.test(qq.first)))flag=1;
                }
            	
            }
        }
      	if(flag==0){
        	ans=max(count,ans);
        }
    }
  	cout<<ans<<endl;
  	
  	
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,A,B,C;
    scanf("%d",&a);
    100<=a<=999;
    A=a/100;
    B=a/10-A*10;
    C=a-A*100-B*10;
    if(A==C)
        printf("Yes");
    else printf("No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<int> A(9);
    for(auto &it: A){
        cin >> it;
    }

    int N; cin >> N;
    vector<bool> chk(9,false);

    for(int i=0; i<N; i++){

        int b; cin >> b;
        for(int j=0; j<9; j++){
            if(b == A.at(j)){
                chk.at(j) = true;
            }
        }

    }

    bool ans = false;
    if(chk.at(0) == true && chk.at(1) == true && chk.at(2) == true){
        ans = true;
    } else if(chk.at(3) == true && chk.at(4) == true && chk.at(5) == true){
        ans = true;
    } else if(chk.at(6) == true && chk.at(7) == true && chk.at(8) == true){
        ans = true;
    } else if(chk.at(0) == true && chk.at(3) == true && chk.at(6) == true){
        ans = true;
    } else if(chk.at(1) == true && chk.at(4) == true && chk.at(7) == true){
        ans = true;
    } else if(chk.at(2) == true && chk.at(5) == true && chk.at(8) == true){
        ans = true;
    } else if(chk.at(0) == true && chk.at(4) == true && chk.at(8) == true){
        ans = true;
    } else if(chk.at(2) == true && chk.at(4) == true && chk.at(6) == true){
        ans = true;
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
set<ll> cnt[26];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,m,y,z;
    string s,t;
    cin>>s>>t;
    n = s.size();
    for(int i=0;i<n;i++){
        cnt[s[i]-'a'].insert(i+1);
    }
    n = t.size();
    for(int j=0;j<n;j++){
        if(!cnt[t[j]-'a'].size()){
            cout<<-1;
            return 0;
        }
    }
    ll curr = 0,foo=0;
    for(int i=0;i<n;i++){
        auto it = cnt[t[i]-'a'].upper_bound(curr);
        if(it==cnt[t[i]-'a'].end()){
            foo++;
            curr = *cnt[t[i]-'a'].begin();
        }
        else{
            curr = *it;
        }
    }
    n = s.size();
    cout<<foo*n+curr;
    

    


    return 0;
}

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[3][3];
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin >> a[i][j];
  bool hit[3][3];
  memset(hit, 0, sizeof(hit));

  int n;
  cin>>n;
  int b;
  for(int i=0;i<n;i++){
    cin>>b;
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++)
        if(a[j][k] == b) hit[j][k] = true;
  }

  bool ok = false;
  for(int i=0;i<3;i++) {
    if(hit[0][i]  && hit[1][i] && hit[2][i])
      ok = true;
    if(hit[i][0] && hit[i][1] && hit [i][2])
      ok = true;
  }
  if(hit[0][0] && hit[1][1] && hit[2][2]) ok = true;
  if(hit[2][0] && hit[1][1] && hit[0][2]) ok = true;

  if(ok)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 888
def main():
    import sys
    readline = sys.stdin.buffer.readline

    x, y = map(int, readline().split())

    if (x+y) % 3 != 0 or y > 2*x or y < x/2:
        print(0)
        exit()
    
    mod = 10**9 + 7
    xy = (x + y) // 3
    z = min(x-xy, y-xy)
    ans = 1
    for i in range(1, z+1):
        ans = (ans * (xy-i+1)) % mod
        ans = (ans * pow(i, mod-2, mod)) % mod
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if (s[5] == '0' && s[6] <= '4') cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256