akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := NewScanner()
	a := sc.NextInt()
	fmt.Println(a + a*a + a*a*a)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

using namespace std;

const int N = 505;

const unsigned long long inf = (1ULL << 63) - 1;

vector<int> g[N];
int p[N], lv[N];

void dfs(int v, int par) {
  p[v] = par;
  for (int u : g[v]) if (u != par) {
    lv[u] = lv[v] + 1;
    dfs(u, v);
  }
}
int deg[N];

unsigned long long mul(unsigned long long a, unsigned long long b) {
  if (a == 0 || b == 0)
    return 0;
  if (inf / a < b) return inf;
  return min(a * b, inf);
}

int n;
unsigned long long calc2() {
  for (int i = 0; i < n; ++i) deg[i] = 0;
  unsigned long long cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += lv[i] == 0;
    int cur = 0;
    for (int u : g[i]) if (lv[u] == lv[i]+1) ++cur;
    deg[lv[i]] = max(deg[lv[i]], cur);
  }
  for (int i = 0; i <= n; ++i)
    if (deg[i] > 0)
      cnt = mul(cnt, deg[i]);
  return cnt;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  lv[0] = 0;
  dfs(0, 0);
  int x = 0;
  for (int i = 0; i < n; ++i) {
    if (lv[i] > lv[x]) x = i;
  }
  lv[x] = 0;
  dfs(x, -1);
  int y = x;
  for (int i = 0; i < n; ++i)
    if (lv[i] > lv[y]) y = i;
  unsigned long long depth = lv[y]/2 + 1, cnt = 1;
  // cerr << lv[y] << endl;
  if (lv[y] & 1) {
    for (int i = 1; i < depth; ++i) {
      y = p[y];
    }
    int u = p[y], v = y;
    lv[u] = lv[v] = 0;
    dfs(u, v);
    dfs(v, u);
    cnt = calc2();
  }
  else {
    for (int i = 1; i < depth; ++i) {
      y = p[y];
    }
    lv[y] = 0;
    dfs(y, y);
    cnt = calc2();
    for (int u : g[y]) {
      lv[y] = lv[u] = 0;
      dfs(u, y);
      dfs(y, u);
      cnt = min(calc2(), cnt);
    }
  }
  cout << depth << " " << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys, bisect, math, itertools
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

x = inp()
a = 0
b = -100
@lru_cache(maxsize=None)
def dp(a,b):
    return a**5-b**5
while True:
    while True:
        if dp(a,b) >= x:
            break
        a += 1
    while True:
        if dp(a,b) <= x:
            break
        b += 1
    if dp(a, b) == x:
        break
print(a,b)
    

Measured memory_bytes: 68492
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<map>
#include<functional>
using namespace std;
typedef pair<int,int> P; // ê,ÁÄé
typedef pair<float,P> PP;  // Ô,P
#define rep(i,n) for(i=0;i<n;i++)
#define MAX 30
#define INFTY 1<<21
struct edge{int t;float c;};
float T[8];
vector<edge> v[MAX];
float dijkstra(int n,int m,int s,int g)
{
  priority_queue<PP,vector<PP>,greater<PP> > q;
  float cost[1<<n][m],c;
  int d,t,l,i,j;
  edge e;
  rep(i,1<<n)rep(j,m)cost[i][j]=j==s?0:INFTY;
  q.push(PP(0,P(s,0)));
  while(!q.empty()){
    PP p = q.top(); q.pop();
    c=p.first;
    d=p.second.first;
    t=p.second.second;
    if(d==g)return c;
    if(cost[t][d]<c)continue;
    cost[t][d]=c;
    rep(i,v[d].size()){
      e=v[d][i];
      rep(j,n){
        if((t&(1<<j))==0){
          l=t|(1<<j);
          if(c+e.c/T[j]<cost[l][e.t]){
            cost[l][e.t]=c+e.c/T[j];
            q.push(PP(c+e.c/T[j],P(e.t,l)));
          }
        }
      }
    }
  }
  return INFTY;
}
int main(void)
{
  int n,m,p,a,b,i,f,t,c;
  float res;
  edge e;
  for(;;){
    scanf("%d%d%d%d%d",&n,&m,&p,&a,&b); if(!n)break;
    a--; b--;
    rep(i,n)scanf("%f",T+i);
    rep(i,p){
      scanf("%d%d%f",&f,&t,&e.c); f--;t--;
      e.t=t; v[f].push_back(e);
      e.t=f; v[t].push_back(e);
    }
    res=dijkstra(n,m,a,b);
    if(res>=INFTY-1)puts("Impossible");
    else printf("%.3f\n",res);
    rep(i,m)v[i].clear();
  }
  return 0;
}

Measured memory_bytes: 7276
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n;
    cin>>n;
    set<string> S;
    f(i, n) {
        string s;
        cin>>s;
        S.insert(s);
    }
    cout<<S.size();
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll N;
const ll INF = 1e18;

int main()
{
	scanf("%lld",&N);
	vector<ll> A(N * 3);
	FOR(i,0,N * 3){
		scanf("%lld",&A [i]);
	}

	vector<ll> P(N * 3),Q(N * 3);
	{
		priority_queue< ll,vector<ll>,greater<ll> > pq;
		ll sum = 0;
		FOR(i,0,N * 3){
			pq.push(A [i]);
			sum += A [i];
			while(pq.size() > N){
				sum -= pq.top();
				pq.pop();
			}
			if(pq.size() == N){
				P [i] = sum;
			}
			else{
				P [i] = -INF;
			}
		}
	}
	{
		priority_queue<ll> pq;
		ll sum = 0;
		for(ll i = N * 3 - 1;i >= 0;i--){
			pq.push(A [i]);
			sum += A [i];
			while(pq.size() > N){
				sum -= pq.top();
				pq.pop();
			}
			if(pq.size() == N){
				Q [i] = sum;
			}
			else{
				Q [i] = INF;
			}
		}
	}

	ll ans = -INF;
	FOR(i,0,N * 3 - 1){
		chmax(ans,P [i] - Q [i + 1]);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 9068
#include<stdio.h>

int main()
{
    int x,y;

    while(1) {
      scanf("%d %d", &x, &y);
      if(x==0 && y==0)  break;
      if(x>y) printf("%d %d\n", y, x);
      else    printf("%d %d\n", x, y);
    }

    return 0;
}



Measured memory_bytes: 2036
#include<cstdio>
#define N 100005
#define P pair<int,int>
#define int long long
inline int read(){
    int x=0;char ch=getchar();
    for(;ch<48||ch>57;ch=getchar());
    for(;ch>47&&ch<58;ch=getchar())
    x=(x<<1)+(x<<3)+(ch^48);return x;
}
using namespace std;
signed main()
{
    int n=read(),m=read();
    printf("%lld\n",(n-1)*(m-1));
    return 0;
}

Measured memory_bytes: 128
# 2020/05/10
# AtCoder Beginner Contest 129 - C

# Input
n, m = map(int,input().split())
sav_a = -1
ans = 0
a = [0] * (n+1)
imp_flg = False
for i in range(m):
    ia = int(input())
    a[ia] = 1
    if sav_a + 1 == ia:
        imp_flg = True
    sav_a = ia

dp = [0] * (n+1)

if imp_flg != True and n > 1:
    dp[1] = 1
    dp[2] = 2
    if a[1] == 1:
        dp[1] = 0
        dp[2] = 1
    if a[2] == 1:
        dp[2] = 0

    for i in range(3, n+1):
        if a[i] == 0:
            dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
elif n == 1:
    dp[1] = 1

# Output
print(dp[n])


Measured memory_bytes: 7668
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if((a*b)%2 == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 21844
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
                
#define int long long
#define ll long long 
bool FLAG = 0;
#define debug(x) if (FLAG) { 	cerr << #x << " = " << x << endl;}
#define debug_vec(x) if (FLAG) {cerr << #x << " = {"; for (auto to x) cout << to << ", "; cout << "}" << endl}
#define F first
#define S second                               
#define sqr(x) ((x) * (x))
#define make make_pair
#define pb push_back
#define sz(x) (int)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = 998244353, N = (int)1e6+ 222;
const int INF = (int)1e18;
const ld eps = (ld)1e-6;

int dx[] = {0, -1, 0, 1, 0};
int dy[] = {0, 0, 1, 0, -1};         


int used[N];

inline void solve () {
	int n, sum = 0;
	cin >> n;	
	for (int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		sum += x;
		used[x] ++;
	}
	int q;
	cin >> q;
	for (int i = 1; i <= q; ++i) {
		int l, r;
		cin >> l >> r;
		sum -= used[l] * l;
		sum += used[l] * r;
		used[r] += used[l];
		used[l] = 0;
		cout << sum << endl;
	}
}	
	    

signed main () {
	#ifdef Maga
		freopen("input", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3944
N = int(input())
MOD = 10 ** 9 + 7
memo = [{} for _ in range(N + 1)]


def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]

        if "".join(t).count("AGC") > 0:
            return False

    return True


def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]

    if cur == N:
        return 1

    ret = 0
    for c in "ACGT":
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret


print(dfs(0, "TTT"))


Measured memory_bytes: 75908
#include<stdio.h>
int main(void){
	
	int c[4][13];
	int n,m,i,j;
	char e;
	
	for(i=0;i<4;i++){
		for(j=1;j<=13;j++){
			c[i][j]=0;
		}
	}
	
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%c",&e);
		scanf("%c %d",&e,&n);
		if(e=='S'){
			c[0][n]=1;
		}else if(e=='H'){
			c[1][n]=1;
		}else if(e=='C'){
			c[2][n]=1;
		}else if(e=='D'){
			c[3][n]=1;
		}
	}
	for(i=0;i<4;i++){
		for(j=1;j<=13;j++){
			if(i==0 && c[i][j]!=1)printf("S %d\n",j);
			else if(i==1 && c[i][j]!=1)printf("H %d\n",j);
			else if(i==2 && c[i][j]!=1)printf("C %d\n",j);
			else if(i==3 && c[i][j]!=1)printf("D %d\n",j);
		}
	}
	
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    intl len = s.length();
    intl max = 0;
    rep(i,len){
        if(!((s[i] == 'A')||(s[i] == 'C')||(s[i] == 'G')||(s[i] == 'T')))continue;
        intl cnt = 1;
        repi(j,i + 1,len){
            if((s[j] == 'A')||(s[j] == 'C')||(s[j] == 'G')||(s[j] == 'T'))cnt++;
            else break;
        }
        max = max(max,cnt);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
klist = []
swlist = []
ans = 0
for s in range(m):
	k,*sw = list(map(int,input().split()))#kとswを別々に入力
	klist.append(k) #<- kのリスト
	swlist.append(sw) #<- swのリスト
pwlist = list(map(int,input().split())) #pwのリスト

for i in range(2**n):#0~2**nまでの整数をカウントする(整数→ビットでの全探索)
	check = True
	for lump in range(m):#m個の電球についてカウントする
		cnt = 0
		for j in range(klist[lump]):#各スイッチ内の右シフト数をカウント	
			if (i>>swlist[lump][j]-1)&1==1:#右にjシフトする
				cnt += 1#整数iのビットに対し、klistのスイッチがいくつonかをカウントする
		if cnt%2 != pwlist[lump]:#一つのスイッチ列でのカウント終了につき、判定する
			check = False#pwと互換性が1つでもなければFalseとする
	if check == True:#最後までFalseにならなければ組み合わせがあるということになる
		ans += 1
print(ans)

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

using namespace std;

template <class T> T abs(T x) { return x < 0 ? -x : x; }

int a[2010];
int f[2010][2];

int main() {
  int n, x, y;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  a[0] = y;
  for (int i = n; i >= 1; --i) {
    {
      f[i][0] = abs(a[i - 1] - a[n]);
      for (int j = i; j < n; ++j) {
        f[i][0] = max(f[i][0], f[j + 1][1]);
      }
    }
    {
      f[i][1] = abs(a[i - 1] - a[n]);
      for (int j = i; j < n; ++j) {
        f[i][1] = min(f[i][1], f[j + 1][0]);
      }
    }
  }
  printf("%d\n", f[1][0]);
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;



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

  ll n;
  std::cin>>n;

  std::string s;
  std::cin>>s;

  if(n%2==1){
    std::cout<<"No\n";
    return 0;
  }

  rep(i,0,n/2){
    if(s[i]!=s[i+n/2]){
      std::cout<<"No\n";
      return 0;
    }
  }

  std::cout<<"Yes\n";

  return 0;
}

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

#define Pi acos(-1)
#define INPUT_OUTPUT { \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout); \
}

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main()
{
	//INPUT_OUTPUT; // I use this to test code easily in my code editor!
	
	ull n1, n2, hcf, temp, lcm;
    cin >> n1 >> n2;
    hcf = n1;
    temp = n2;
    
    while(hcf != temp)
    {
        if(hcf > temp)
            hcf -= temp;
        else
            temp -= hcf;
    }
    lcm = (n1 * n2) / hcf;
    cout << lcm << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string str1,str2;
        cin>>str1>>str2;
        int lenth1,lenth2;
        lenth1=(int)str1.length();
        lenth2=(int)str2.length();
        int dp[lenth1+1][lenth2+1];
        for(int j=0;j<=lenth1;j++)dp[j][0]=0;
        for(int j=0;j<=lenth2;j++)dp[0][j]=0;
        for(int j=1;j<=lenth1;j++)
        {
            for(int k=1;k<=lenth2;k++)
            {
                if(str1[j-1]==str2[k-1])
                {
                    dp[j][k]=dp[j-1][k-1]+1;
                }
                else dp[j][k]=max(dp[j-1][k],dp[j][k-1]);
            }
        }
        cout<<dp[lenth1][lenth2]<<endl;
    }
    return 0;
}



Measured memory_bytes: 7012
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())  
s=input()
if s.count("R")>s.count("B"):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;


typedef pair<ll,ll> P;
const ll MO = 1000000007;

struct Item{
    ll w,v;
    // Item(ll x,ll y){
    //     w = x; v = y;
    // }
};

int main(){
    int n,W;
    cin >> n >> W;
    vector<vector<ll>> dp(n+5, vector<ll>(100000+5,INF));
    vector<Item> c(n);
    rep(i,n){
        ll w,v;
        cin >> w >> v;
        c[i].w = w; c[i].v = v;
    }
    // rep(i,n+5)rep(j,100005)dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n+5)dp[i][0] = 0;
    rrep(i,n){
        rrep(j,100001){
            if(j-c[i-1].v<0)dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j-c[i-1].v]+c[i-1].w, dp[i-1][j]);
        }
    }
    // rrep(i,10001){
    //     if(dp[n][i]<=W && maxi<=i)maxi = i;
    // }
    ll ans = 100000;
    while(dp[n][ans]>W)--ans;
    // rep(i,n){
    //     rep(j,100001)cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define sz(a) ((int)a.size())
#define mp make_pair
#define fi first
#define se second

const int maxn = 2e6 + 5;

const int maxv = 1e9;
const int mod = 1e9 + 7;

int T, tc;
int n;
int a[maxn];
long long fact[maxn], inv[maxn];
string s;

long long power_mod(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b % 2) res = res * a % mod;
		a = a * a % mod;
		b /= 2ll;
	}
	return res;
}

long long C(int n, int k) {
	return fact[n] * inv[k] % mod * inv[n - k] % mod;
}

int main() {
//	freopen("inp.txt", "r", stdin);
    
   	cin >> n;
   	
   	fact[0] = inv[0] = 1;
   	for (int i = 1; i < maxn; i++) {
		fact[i] = fact[i - 1] * i % mod;
		inv[i] = power_mod(fact[i], mod - 2);   
	}
   	
   	cin >> s;
   	
   	long long len = (long long)s.size();
   	
   	long long ans = 0;
   	for (int i = 0; i <= n; i++) {
		int rem = n - i;   
//		cout << power_mod(25, rem) << ' ' << C(rem + len - 1, len - 1) << ' ' << power_mod(26, i) << endl;
		(ans += power_mod(25, rem) * C(rem + len - 1, len - 1) % mod * power_mod(26, i) % mod) %= mod;
	}
	
	cout << ans;
    
    return 0;
}

Measured memory_bytes: 36524
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define LOOP(i,first,end) for(int i=(first);i<(end);i++)
#define ULL unsigned long long
#define LL long long
#define VULL vector<ULL>
#define VLL vector<LL>
#define VINT vector<int>

int main(void){
	int n;
	VINT d;

	cin >> n;
	d.resize(n);
	LOOP(i, 0, n)cin >> d[i];

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

	int c = n / 2;

	cout << (d[c] - d[c - 1]) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	bool f=false;
	scanf("%d",&n);
	for (int i=1;i*i<=n;++i)
		if (n%i==0) {
			int j=n/i;
			if (i<10&&j<10) {
				f=true;
				break;
			}
		}
	puts(f?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
b = [int(i) for i in input().split()]
a = []
while b:
    p = 0
    for i in range(len(b)-1,-1,-1):
        if b[i]==i+1:
            p = b.pop(i)
            break
    if p: a.append(p)
    else: break
if p:
    for i in a[::-1]: print(i)
else: print(-1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <sstream>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define LOOP_IT(s) for(auto it=(s).begin();it!=(s).end();++it)

ll const mod=1e9+7;

ll mod_pow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x,ll mod){
    return mod_pow(x, mod - 2);
}

ll nCr(ll n, ll r){
    ll ans=1;
    for(ll i=0;i<r;++i){
        ans=(ans*(n-i))%mod;
        ans=(ans*mod_inv(i+1, mod))%mod;
    }
    return ans;
}

int main(int argc, char* argv[])
{
    ZOOM

    ll n,tot=0;
    cin>>n;
    vector<ll> v(n);
    map<ll,ll> m;
    for(int i=0;i<n;++i)
    {
        cin>>v[i];
        ++m[v[i]];
    }
    LOOP_IT(m)
    {
        if(ss>1)
        {
            ll k = ss;
            tot+=((ss*(ss-1)*1ll)/2);
        }
    }
    for(ll i=0;i<n;++i)
    {
        if(m[v[i]]>1)
        cout<<(tot-(m[v[i]]-1))<<" ";
        else
            cout<<tot<<" ";
    }
    return 0;
}



Measured memory_bytes: 11136
#include<stdio.h>
#include<stdlib.h>
typedef struct Node {
  struct Node *parent;
  struct Node *left;
  struct Node *right;
  int key;
} node;
void preOrder(node *);
void inOrder(node *);
void insert(int);
node *find(int, node *);
node *root;
int n;
int main() {
  int i, j, key;
  char command[7];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {    
    scanf("%s", command);
    switch (command[0]) {
    case 'i':
      scanf("%d", &key);
      insert(key);
      break;
    case 'f':
      scanf("%d", &key);
      node *tmp = find(key, root);
      if (tmp != NULL) {
	printf("yes\n");
      } else {
	printf("no\n");
      }
      break;
    default:
      inOrder(root);
      printf("\n");
      preOrder(root);
      printf("\n"); 
      break;
    }
  }
  return 0;
}
void inOrder(node *u) {
  if (u == NULL) {
    return ;
  }
  if (u->left != NULL) inOrder(u->left);
  printf(" %d",u->key);
  if (u->right != NULL) inOrder(u->right);
  return ;
}
void preOrder(node *u) {
  if (u == NULL) {
    return ;
  }
  printf(" %d",u->key);
  if (u->left != NULL) preOrder(u->left);
  if (u->right != NULL) preOrder(u->right);
  return ;
}
void insert(int key) {
  node *y = NULL;
  node *x = root;
  node *z;

  z = (node*) malloc(sizeof(node));
  z->left = NULL;
  z->right = NULL;
  z->key = key;

  while (x != NULL) {
    y = x;
    if (key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
 
  z->parent = y;
  if ( y==NULL ) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
  return ;
}
node *find(int key, node *u) {
  node *x;
  x = u;
  while (x != NULL && x->key != key) {
    if (x->key < key) x = x->right;
    else  x = x->left;
  }
  return x;
}

Measured memory_bytes: 19360
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define INF 1e9

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,bitset<12>>> data(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    data.at(i).first = a;
    bitset<12> key;
    rep(i,b){
      int c;
      cin >> c;
      key.set(c-1,1);
    }
    data.at(i).second = key;
    //cout << "key is " << key << endl;
  }
  //sort(data.begin().data.end());
  int maxkey = pow(2,n);
  //cout << "maxkey " << maxkey << endl;
  vector<vector<int>> dp(m+1,vector<int>(maxkey,INF));
  dp.at(0).at(0) = 0;
  for(int i=1;i<=m;i++){
    int key = data.at(i-1).second.to_ullong();
    rep(j,maxkey){
      int next = (key | j);
      //cout << " after j " << j << " key " << key << endl;
      //cout << "next is " << next << endl;
      dp.at(i).at(j) = min(dp.at(i).at(j),dp.at(i-1).at(j));
      dp.at(i).at(next) = min(min(dp.at(i).at(next),dp.at(i-1).at(j) + data.at(i-1).first),dp.at(i-1).at(next));
    }
  }
  /*rep(i,m+1){
    rep(j,maxkey) cout << dp.at(i).at(j) << " ";
    cout << endl;
  }*/
  
  if(dp.at(m).at(maxkey-1) == INF) cout << -1 << endl;
  else cout << dp.at(m).at(maxkey-1) << endl;
}

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

int d[1000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

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

	set<int> s;
	for(int i = 0; i < N; i++){
		s.insert(d[i]);
		if(i + 1 < N) s.insert(d[i] * 10 + d[i + 1]);
		if(i + 2 < N) s.insert(d[i] * 100 + d[i + 1] * 10 + d[i + 2]);
	}

	int ans = 0;
	while(s.count(ans)) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3236
"""#################################################################
【ABC081】
C - Not so Diverse
#################################################################"""

#インポート
import sys
from collections import Counter

#入力用
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  #リスト(int型)
def MI(): return map(int, sys.stdin.readline().rstrip().split())        #多変数(int型)
def II(): return int(sys.stdin.readline().rstrip())                     # 1変数(int型)
def S(): return sys.stdin.readline().rstrip()                           #文字列(str型)

N, K = MI()
A = LI()
A = sorted(Counter(A).values(), reverse = True)
sum = sum(A[K:])
print(sum)


Measured memory_bytes: 32556
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m;
ll p[100000],y[100000];
vector<ll> yd[100001];
int main(){
  cin>>n>>m;
  rep(i,m){
    cin>>p[i]>>y[i];
    yd[p[i]].push_back(y[i]);
  }
  rep(i,n){
    sort(ALL(yd[i+1]));
  }
  rep(i,m){
    printf("%012lld\n",ll(p[i])*1000000+(ll)(lower_bound(ALL(yd[p[i]]),y[i])-yd[p[i]].begin())+1);
  }
}

Measured memory_bytes: 8576
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int H;
int W;
int K;
char C[6][8];
int main(){
  int h;
  int res = 0;
  int cnt;
  rd(H);
  rd(W);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(H);Lj4PdHRW++){
      rd(C[Lj4PdHRW]);
    }
  }
  for(h=(0);h<(1<<H);h++){
    int w;
    for(w=(0);w<(1<<W);w++){
      int i;
      cnt = 0;
      for(i=(0);i<(H);i++){
        if(((h) &(1<<(i)))){
          int j;
          for(j=(0);j<(W);j++){
            if(((w) &(1<<(j)))){
              if(C[i][j]=='#'){
                cnt++;
              }
            }
          }
        }
      }
      if(cnt==K){
        res++;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int H, W, K;
// char C[6][8];
// {
//   int res = 0, cnt;
//   rd(H,W,K,C(H));
//   rep(h,1<<H) rep(w,1<<W){
//     cnt = 0;
//     rep(i,H) if(BIT_ith(h,i)) rep(j,W) if(BIT_ith(w,j)) if(C[i][j]=='#') cnt++;
//     if(cnt==K) res++;
//   }
//   wt(res);
// }


Measured memory_bytes: 3640
if __name__ == '__main__':
	inp = map(int, input().split(' '))
	a,b,c = inp
	step = 0
	mx = max((a,b,c))

	while True:
		step += 1
		if a<mx-1:
			a+=2
		elif b<mx-1:
			b+=2
		elif c<mx-1:
			c+=2
		else:
			break

	if 3*max((a,b,c)) == a+b+c+1:
		step+=1

	if 3*max((a,b,c)) == a+b+c:
		step-=1

	print(step)


Measured memory_bytes: 3064
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())

def p(a):
  if a == 'r':
    return P
  elif a == 's':
    return R
  else:
    return S

A = [0]*N
for i in range(K):
  A[i] = p(T[i])

for i in range(K):
  for j in range(1,((N-1-i)//K)+1):
    if T[K*j+i] != T[K*(j-1)+i] or A[K*(j-1)+i] == 0:
      A[K*j+i] = p(T[K*j+i])

print(sum(A))

Measured memory_bytes: 50544
#include <stdio.h>
int x, y, temp_x;

int main() {
  while(1) {
    scanf("%d %d", &x, &y);
    if(x == 0 && y == 0) break;
    if(x > y) {
      temp_x = x;
      x = y;
      y = temp_x;
    }
    printf("%d %d\n", x, y);
  }
  return 0;
}


Measured memory_bytes: 2040
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//最頻値とランレングス圧縮
template<class T>
vector<pair<T,int>> runlength(vector<T> arr) {
	int i = 0;
	int n = arr.size();
	vector<pair<T, int>> run;
	while (i < arr.size()) {
		T t = arr[i];
		int k = 0;
		while (i + k < n && arr[i + k] == t) k++;
		run.push_back(pair<T, int>(t, k));
		i += k;
	}
	return run;
}
#define MAXN 60
ll C[MAXN][MAXN];
void comb_table(int MAX_N){
	rep(i,MAX_N)rep(j,MAX_N) C[i][j] = (j==0||j==i ? 1LL : C[i-1][j-1]+C[i-1][j]);
}
int main(void){
   int n,a,b;cin >> n >> a >> b;
   vector<ll> d(n);
   rep(i,n)cin >> d[i];
   sort(all(d)); reverse(all(d));
   
   ll sum = 0LL;
   rep(i,a) sum += d[i];
   cout << fixed << setprecision(22) << (double)sum / (double)a << endl;
   
   auto run = runlength(d);
   comb_table(60);
   //一種類だけなら
   int ub;
   int left;
   ll ans = 0LL;
   if(run[0].second >= a){
      left = run[0].second;
      if(run[0].second <= b) ub = run[0].second;
      else ub = b;
      
      for(int j = a;j <= ub;j++) ans += C[left][j];
   }else{
      int count = 0;
      for(auto i : run){
         if(count + i.second < a) count += i.second;
         else{ ans = C[i.second][a - count]; break;}
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

INF = 10**5
d = [[10**5] * W for _ in range(H)]
d[0][0] = 0

q = deque()
q.append((0, 0))

dy = [-1, 1, 0, 0]
dx = [0, 0, -1, 1]

while len(q):
    y, x = q.popleft()

    if y == H-1 and x == W-1:
        break

    for i in range(4):
        ny = y + dy[i]
        nx = x + dx[i]

        if (0 <= ny < H and 0 <= nx < W and
            maze[ny][nx] != '#' and d[ny][nx] == INF):

            d[ny][nx] = d[y][x] + 1
            q.append((ny, nx))

if d[H-1][W-1] == INF:
    print(-1)
else:
    black = 0
    for a in maze:
        black += a.count('#')
    
    print(H * W - black - d[H-1][W-1] - 1)

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

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

const int mx=101;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> x(n), y(n), h(n);
	for (int i=0; i<n; i++)
		cin>>x[i]>>y[i]>>h[i];
	for (int xc=0; xc<mx; xc++)
		for (int yc=0; yc<mx; yc++) {
			int hc=-1;
			for (int i=0; i<n; i++)
				if(h[i]) {
					hc=h[i]+abs(xc-x[i])+abs(yc-y[i]);
					break;
				}
			bool ok=true;
			for (int i=0; i<n; i++)
				if(max(hc-abs(x[i]-xc)-abs(y[i]-yc), 0)!=h[i])
					ok=false;
			if(ok) {
				cout << xc << " " << yc << " " << hc << endl;
				return 0;
			}
		}	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll ans=0;
  if(a>=k){
    ans+=k;
  }
  else{
    ans+=a;
    k-=a;
    if(b>=k){
      ans+=0;
    }
    else{
      k-=b;
      ans-=k;
    }
  }
  out(ans);
}

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


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, o, z = 0;
    string s[6] = {};
    cin >> n >> m >> o;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < (1 << n); i++) for (int j = 0; j < (1 << m); j++) {
        int a = 0;
        for (int k = 0; k < n; k++) for (int l = 0; l < m; l++) if ((i & (1 << k)) && (j & (1 << l)) && s[k][l] == '#') a++;
        if (a == o) z++;
    }
    cout << z;
}


Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	char a[22];
	while(scanf("%c",&a[0])!=-1)
	{
		for(int i=1;i<=19;i++)
	    	scanf("%c", &a[i]);
		for(int n=0;n<=4;n++)
		   printf("%c",a[n]);
	    printf(" ");
	    for(int m=6;m<=12;m++)
	       printf("%c",a[m]);
	    printf(" ");
	    for(int b=14;b<=18;b++)
	        printf("%c", a[b]);
	    printf("\n");
	    
	}
	return 0;
}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  string a, b, c; cin >> a >> b >> c;
  if(a.at(a.size()-1) != b.at(0)) drop("NO");
  if(b.at(b.size()-1) != c.at(0)) drop("NO");
  cout << "YES" << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3576
package main

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

func main() {
	stdin := bufio.NewReader(os.Stdin)
	var H, A int

	_, err := fmt.Fscan(stdin, &H, &A)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%d\n", calc(H, A))
}

func calc(H int , A int) int {
	if H%A == 0 {
		return H / A
	} else {
		return int(H/A) + 1
	}
}


Measured memory_bytes: 640
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

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

	vector<int> A(N);
	int min_mons = 1e9;
	int min_mons_next = 1e9;
	int min_idx = 0;
	int min_idx_next = 0;

	REP(i, N) {
		cin >> A[i];
		min_mons = min(min_mons, A[i]);
		if (min_mons == A[i])
			min_idx = i;
	}

	while (1) {
		bool end_flag = true;
		//cout << "min_mons" << min_mons << endl;
		REP(i, N) {
			//cout << A[i];
			if ((i != min_idx) && (A[i] != 0)) {
				A[i] %= min_mons;
				if (A[i] != 0) {
					end_flag = false;
					min_mons_next = min(min_mons_next, A[i]);
					min_idx_next = i;
				}
			}
			//cout << "  " << A[i] << endl;
		}
		if (end_flag)
			break;
		else {
			min_mons = min_mons_next;
			min_idx = min_idx_next;
		}
	}

	cout << min_mons << endl;

	return 0;
}


Measured memory_bytes: 640
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
vector<ll> divmod(ll p,ll m){return {p/m, p%m};}

int main(){
	ll n; int x, m; cin>>n>>x>>m;
	vector<int> X(m, -1);
	vector<int> P;
	ll sum_p = 0;
	while(X[x] < 0){ // preset
		X[x] = P.size(); // pre length
		P.push_back(sum_p); // pre sum_p
		sum_p += x; // now sum_p
		x = (ll)x*x % m;
	}
	vector<ll> qr = divmod(n - X[x], P.size() - X[x]);
	ll cyc = (sum_p - P[X[x]]) * qr[0];
	ll remain = P[X[x] + qr[1]];
	cout<< cyc + remain <<endl;
}


Measured memory_bytes: 3948
#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 Would
#define you
#define please

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	string S;
	cin >> N >> S;

	int maximum = 0;
	rep1(i, S.length() - 1) {
		string S1 = S.substr(0, i);
		string S2 = S.substr(i, S.length() - i);

		int count = 0;
		rep(i, 26) {
			if (S1.find('a' + i) != string::npos && S2.find('a' + i) != string::npos) count++;
		}
		maximum = max(maximum, count);
	}

	cout << maximum << "\n";
	Would you please return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl
use Data::Dumper;

# 引数取り込み
my @a;

while ( my $line = <STDIN> ) {
    chomp($line);
    push @a, $line;
}

if ( $a[0] eq substr( $a[1], 0 , length( $a[0] ) ) ) {
    print "Yes";
}
else {
    print "No";
}

1;

Measured memory_bytes: 6356
#include<stdio.h>
int main(){
    int n,m,ans=0;
	float a[256],cnt=0;
    scanf("%d %d",&n,&m);
      for(int i=0;i<n;i++){
          	scanf("%d",&a[i]);
      }
  for(int i=0;i<n;i++){
    cnt+=a[i];
  }
    for(int i=0;i<n;i++){ 
	    if(a[i]*4*m>=cnt){
          ans++;
        }
  }
        if(ans>=m){
          printf("Yes\n");
      }
  else
    printf("No\n");
	
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int count=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i])count++;
    }
    cout<<count<<endl;
    return 0;
}

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

int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<'#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
N = int(input())
dA1 ={}
dA0 ={}
def lenbin(a):
    return len(bin(a)) - 2
def addData(oDict,a):
    if a in oDict:
        oDict[a]+=1
    else:
        oDict[a]=1
for a in input().split():
    a = int(a)
    if a % 2 :
        addData(dA1,a)
    else:
        addData(dA0,a)
def searchPair(oD):
    iC = 0
    for a in sorted(oD.keys(),reverse=True):
        t = ( 1 << lenbin(a)) - a
        if t == a:
            iAT = oD[a] // 2
            iC += iAT
            oD[a] -= iAT *2
        elif t in oD:
            iAT = min(oD[a],oD[t])
            iC += iAT
            oD[a] -= iAT
            oD[t] -= iAT
    return iC
#iC = 0
#iC += searchPair(dA1)
#iC += searchPair(dA0)
print(searchPair(dA1)+searchPair(dA0))



Measured memory_bytes: 42296
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	if (K <= A)
	{
		cout << K << endl;
	}
	else if (K <= A + B)
	{
		cout << A << endl;
	}
	else
	{
		K -= A + B;
		cout << A - K << endl;
	}
}

Measured memory_bytes: 3556
n=int(input())
l=list(map(int,input().split()))

p=0
for i in range(n):
    if l[i]<0:
        l[i]=-l[i]
        p+=1
if p/2==p//2:
    print(sum(l))
else:
    print(sum(l)-2*min(l))



Measured memory_bytes: 14252
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
a = []
res = 0
n.times do |i|
  a[i] = gets.split.map(&:to_i) 
end
a.each_with_index do |e, i|
  ans = 0
  m.times do |j|
    ans += e[j] * b[j]
  end
  res += 1 if ans + c > 0
end
puts res

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    long double a,b;
    long double h,m;
    cin >> a >> b >> h >> m;
    long double pi = 3.14159265359;
    long double Hx,Hy;
    long double Mx,My;
    Mx = b * cos((90-6*m)/180*pi);
    My = b * sin((90-6*m)/180*pi);
    //cout <<"   "<< 90-6*m <<endl;
//cout<< Mx << " " << My <<endl;
    Hx = a * cos((90- 30*h - m/2)/180*pi);
    Hy = a * sin((90- 30*h - m/2)/180*pi);
    //cout <<"  " << (90- 30*h - m/4) << endl;
//cout<< Hx <<" " << Hy <<endl;
    long double ans = sqrt((Hy-My)*(Hy-My) + (Hx-Mx)*(Hx-Mx));
    //cout << ans << endl;
    printf("%.10Lf\n",ans);
    return 0;
}

Measured memory_bytes: 4172