akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	b := make([]bool, n)
	idx := 0
	ans := -1
	for i := 1; i <= n; i++ {
		next := a[idx] - 1
		if b[next] {
			break
		} else {
			idx = next
			b[next] = true
			if next == 1 {
				ans = i
				break
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <utility>
#include <string>

using namespace std;

long long brute(int i, vector<int>& v) {
	if (i == (int)v.size()) {
		for (int j = 0; j < (int)v.size(); ++j) {
			if (v[j] % 2 == 0) {
				return 1;
			}
		}
		return 0;
	}
	long long res = 0;
	res += brute(i + 1, v);
	--v[i];
	res += brute(i + 1, v);
	v[i] += 2;
	res += brute(i + 1, v);
	--v[i];
	return res;
}

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

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

	cout << brute(0, A) << "\n";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }

int N, M;
int visitted[10];
int connected[10][10];
int ans=0;

void dfs(int, int);

int main() {
		scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		connected[a][b] = 1;
		connected[b][a] = 1;
	}

	dfs(1, 1);
	printf("%d\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

void dfs(int now, int depth) {
	if (depth >= N) {
		ans++;
		return;
	}

	visitted[now] = 1;

	for (int i = 1; i <= N; i++) {
		if (connected[now][i] == 1 && visitted[i] == 0) {
			visitted[i] = 1;
			dfs(i, depth + 1);
			visitted[i] = 0;
		}
	}
}



Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
inline int in(){ int x; scanf("%d",&x); return x;}

bool isprime[50000];

void sieve(int n){
  memset(isprime,1,sizeof(isprime));
  isprime[0] = isprime[1] = false;
  for(int i = 2; i*i <= n; i++) if(isprime[i]){
    for(int j = 2*i; j <= n; j += i) isprime[j] = false;
  }
}

int main(){
  int i,j,k;
  int n;
  int res;

  sieve(50000);
  while(scanf("%d",&n)){
    if(n == 0) break;

    res = 0;
    for(i = 2; 2*i <= n; i++) if(isprime[i] && isprime[n-i]) res++;
    printf("%d\n",res);
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
int W, H, x, y, r;
scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
printf("Yes\n");
}
else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 584
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7


ULONG D;
vector<ULONG> cost(26);
//vector<vector<ULONG>> sati(D + 1, vector<ULONG>(27));
vector<vector<ULONG>> sati;
vector<ULONG> answer;



int main(void) {

	cin >> D;

	vector<ULONG> tmpans(D);
	answer = tmpans;

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

	vector<ULONG> tmpsati(27);
	sati.push_back(tmpsati);

	for (int d = 0; d < D; d++) {
		for (int i = 0; i < 26; i++) {
			cin >> tmpsati[i];
		}
		sati.push_back(tmpsati);
	}

	for (int i = 0; i < D; i++) {
		answer[i] = i % 26 + 1;
		
	}


	for (int i = 0; i < D; i++) {
		cout << answer[i] << endl;

	}

	return 0;
}

Measured memory_bytes: 3740
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-9;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

ll in[200050];
int main() {
	int N, i;
	scanf("%d", &N);
	N *= 2;
	for (i = 1; i <= N; i++) scanf("%lld", &in[i]);
	sort(in + 1, in + N + 1);

	db ans = 0;
	for (i = 1; i <= N; i++) ans += (i - 1) * in[i];
	return !printf("%.20lf\n", ans / (N - 1));
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef set<int> si;
typedef map<pll,int> mpli;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll x[60],y[60];
mpli m;
bool f[60];
int main(){
  cin>>N;
  rep(i,N) cin>>x[i]>>y[i];
  int mmax=0;
  rep(i,N){
    rep(j,N){
      if(i==j) continue;
      m[mp(x[i]-x[j],y[i]-y[j])]++;
      mmax=max(mmax,m[mp(x[i]-x[j],y[i]-y[j])]);
    }
  }
  prin(N-mmax);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  ll h;
  cin >> h;
  ll k=0,b=0;
  while(h>0){
    h/=2;
    k+=pow(2,b);
    b++;
  }
  cout << k << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//typedef long long  MOD=1000000009;
ll MOD=998244353;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void iofoj(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}


void solution()
{
    ll k,i,j,h,n,m,w;
   cin>>i>>j>>k;
   ll ans=i/j;
   if(i%j)ans++;
   ans*=k;
   cout<<ans;
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}





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

#define N	1000
#define M	200000

int max(int a, int b) { return a > b ? a : b; }

int oo[1 + M * 3], oh[1 + M * 3];

int link(int o, int h) {
	static int _ = 1;

	oo[_] = o, oh[_] = h;
	return _++;
}

int ii[M], jj[M];
int ae[N], af[N], ae_[N], cc[N], qu[N], cnt;

void dfs1(int i) {
	int o;

	if (cc[i])
		return;
	cc[i] = -1;
	for (o = ae[i]; o; o = oo[o]) {
		int h = oh[o], j = jj[h];

		dfs1(j);
	}
	qu[--cnt] = i;
}

void dfs2(int j, int c) {
	int o;

	if (cc[j] != -1)
		return;
	cc[j] = c;
	for (o = af[j]; o; o = oo[o]) {
		int h = oh[o], i = ii[h];

		dfs2(i, c);
	}
}

char visited[N]; int c;
int hh[N * 2], cnt_;

void dfs3(int i) {
	int o;

	visited[i] = 1;
	for (o = ae[i]; o; o = oo[o]) {
		int h = oh[o], j = jj[h];

		if (!visited[j] && cc[j] == c)
			hh[cnt_++] = h, dfs3(j);
	}
}

void dfs4(int j) {
	int o;

	visited[j] = 2;
	for (o = af[j]; o; o = oo[o]) {
		int h = oh[o], i = ii[h];

		if (visited[i] == 1 && cc[i] == c)
			hh[cnt_++] = h, dfs4(i);
	}
}

int h_;

int dfs5(int i, int t) {
	int o;

	if (i == t)
		return 1;
	if (visited[i])
		return 0;
	visited[i] = 1;
	for (o = ae[i]; o; o = oo[o]) {
		int h = oh[o], j = jj[h];

		if (h != h_ && cc[j] == c && dfs5(j, t))
			return 1;
	}
	return 0;
}

int main() {
	static int dd[N];
	static char diff[M];
	int n, n_, m, g, g_, h, i, j, s;

	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		ii[h] = i, jj[h] = j;
		ae[i] = link(ae[i], h);
		af[j] = link(af[j], h);
	}
	cnt = n;
	for (i = 0; i < n; i++)
		if (!cc[i])
			dfs1(i);
	n_ = 0;
	for (g = 0; g < n; g++) {
		i = qu[g];
		if (cc[i] == -1)
			dfs2(i, n_++);
	}
	for (h = 0; h < m; h++) {
		i = cc[ii[h]], j = cc[jj[h]];
		if (i != j)
			ae_[i] = link(ae_[i], h);
	}
	for (s = 0; s < n_; s++) {
		int o;

		memset(dd, 0, n_ * sizeof *dd);
		for (o = ae_[s]; o; o = oo[o]) {
			h = oh[o], j = cc[jj[h]];
			dd[j]++;
		}
		for (o = ae_[s]; o; o = oo[o]) {
			h = oh[o], j = cc[jj[h]];
			if (dd[j] > 1)
				diff[h] = 1;
		}
		memset(dd, -1, n_ * sizeof *dd), dd[s] = 0;
		for (i = s; i < n_; i++)
			if (dd[i] != -1)
				for (o = ae_[i]; o; o = oo[o]) {
					h = oh[o], j = cc[jj[h]];
					dd[j] = max(dd[j], dd[i] + 1);
				}
		for (o = ae_[s]; o; o = oo[o]) {
			h = oh[o], j = cc[jj[h]];
			if (dd[j] > 1)
				diff[h] = 1;
		}
	}
	for (c = 0; c < n_; c++) {
		cnt = 0;
		for (i = 0; i < n; i++)
			if (cc[i] == c)
				qu[cnt++] = i;
		cnt_ = 0;
		dfs3(qu[0]);
		dfs4(qu[0]);
		for (g_ = 0; g_ < cnt_; g_++) {
			h = hh[g_];
			for (g = 0; g < cnt; g++)
				visited[qu[g]] = 0;
			h_ = h;
			diff[h] = !dfs5(ii[h], jj[h]);
		}
	}
	for (h = 0; h < m; h++)
		printf(diff[h] ? "diff\n" : "same\n");
	return 0;
}


Measured memory_bytes: 8148
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

long long int N, K;
long long int a, b;


int main(){
    cin >> N >> K;
    vector<pair<long long int, long long int> > pairs(N);

    for(int i = 0; i < N; i++){
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    sort(pairs.begin(), pairs.end());

    for(int i = 0; i < N; i++){
        K -= pairs[i].second;
        if(K <= 0){
            cout << (pairs[i].first);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    
    int [] s = new int[n];
    int t = 0;
    
    for (int i = 0; i < n; i++){
      s[i] = sc.nextInt();
      t += s[i];
    }
        
		if(h <= t){
          System.out.println("Yes");
        } else {
          System.out.println("No");
        }
  }
}
    
    

Measured memory_bytes: 49924
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

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 Fst first
#define Snd second
#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)

int N,A;

int main(){
	scanf("%d%d" , &N , &A);
	int ans = 1;
	int z = 0;
	repp(i,1,N){
		int x;
		scanf("%d" , &x);
		if(A < x){
			if(z > 0){
				++ans;
				z = 0;
			} else {
				z = -1;
			}
		} else if(A > x){
			if(z < 0){
				++ans;
				z = 0;
			} else {
				z = 1;
			}
		}
		A = x;
	}
	printf("%d\n" , ans);
	return 0;
}


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

int main() {
    int N;
    bool a = false;
    cin >> N;
    for(int i=1;i<=9;i++) {
        for(int j=1;j<=9;j++) {
            if(N==(i*j)) {
                a = true;
            }
        }
    }
    if(a) {
        cout << "Yes" << "\n";
    }
    else {
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
from itertools import product

x1 = int(input())
x2 = input()

R_i = [i for i, x in enumerate(x2) if x == "R"]
G_i = [i for i, x in enumerate(x2) if x == "G"]
B_i = {i for i, x in enumerate(x2) if x == "B"}

R = len(R_i)
G = len(G_i)
B = len(B_i)

xs = map(sorted, product(R_i, G_i))

s = 0
for a in xs:
    k = a[1]*2 - a[0]  # 2j-i
    if k in B_i:
        s +=1
    i = a[0]*2 - a[1]  # 2j-k
    if i in B_i:
        s +=1
    j = (a[0] + a[1]) / 2  # (i+k)/2
    if j in B_i:
        s +=1
print(R*G*B - s)

Measured memory_bytes: 9196
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    use std::iter::FromIterator;
    let mut iter = input.split_whitespace();
    let n : usize = iter.next().unwrap().parse().unwrap();
    let k : usize = iter.next().unwrap().parse().unwrap();
    let v : Vec<usize> = Vec::from_iter(iter.map(|s| s.parse().unwrap()));
    let mut sum = v[0..k].iter().sum::<usize>();
    let mut maxsum = sum;
    for i in k..n {
        sum = sum + v[i] - v[i-k];
        maxsum = std::cmp::max(maxsum, sum);
    }
    println!("{}", (maxsum + k) as f64 * 0.5000000000001);
}


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

const int N = 1e4+5;
const int inf = 1e9+7;
int dp[N];
vector<pair<int,int>> points;



int ans(int val){
	if( val <= 0 ){
		return 0;
	}
	if( dp[val] != -1 ){ return dp[val]; }
	int extra = inf;
	for(auto i : points){
		extra = min(extra, ans(val- i.first) + i.second);
	}
	dp[val] = extra;
	return dp[val];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h,n;
	cin>>h>>n;
	for(int i=0; i<n; ++i){
		int a,b;
		cin>>a>>b;
		points.push_back({a,b});
	}
	for(int i=0; i<N; ++i){
		dp[i] = -1;
	}
	cout<<ans(h)<<endl;

	return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (ll& z : a) {
        cin >> z;
    }

    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] + a[i-1] <= x) continue;

        ll mustEat = a[i-1] + a[i] - x; // 食べなければいけない飴の個数
        // 右から引く
        if (a[i] >= mustEat) {
            ans += mustEat;
            a[i] -= mustEat;
            mustEat = 0;
        } else {
            ans += a[i];
            mustEat -= a[i];
            a[i] = 0;
        }
        // 左から引く
        ans += mustEat;
        a[i-1] -= mustEat;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define MAXN 
using namespace std;
char str[20];
int len,ans,ch;

int main()
{
	cin>>str;
	len=strlen(str);
	ans=str[0]-'0';
	for(int i=1; i<len; i++)
		if(str[i]!='9') ch=1;
	if(ch && len!=1) ans-=1;
	printf("%d\n",(len-1)*9+ans);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
mod=10**9+7
dp=[0]*(1<<n)
dp[0]=1
for i in range(1,1<<n):
  # 既にペアになった女性の集合がS⇔S人目までチェック済み
  k=bin(i).count("1")
  for j in range(n):
    if i&(1<<j) and a[k-1][j]:
      dp[i]+=dp[i^(1<<j)]
  dp[i]%=mod
print(dp[(1<<n)-1])


Measured memory_bytes: 59100
#include <stdio.h>

int main(void){
  int n,k,tmp,sum = 0;
  int a[1000];
  scanf("%d %d", &n, &k);
  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
    for(int j=0;j<i;j++){
      if(a[j]>a[i]){
        tmp = a[i];
        for(int l=i;l>j;l--){
          a[l] = a[l-1];
        }
        a[j] = tmp;
        break;
      }
    }
  }
  for(int i=0;i<k;i++){
    sum += a[i];
  }
  printf("%d", sum);
  return 0;
}

Measured memory_bytes: 1740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str = br.readLine();
            for (int i = 0; i < str.length(); i++) {
                if (i % 2 == 0) {
                    System.out.print(str.charAt(i));
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

int main() {
  int N,K;cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  vector<int> B(N,0);

  int count=0;
 // int all;
  while(count<K){
    //all=0;
    for(int i=0;i<N;i++){
      int l=max(0,i-A[i]);
      int r=min(N-1,i+A[i]);
      B.at(l)++;
      if(r+1<N) B.at(r+1)--;
    }
    for(int i=1;i<N;i++) B.at(i)+=B.at(i-1);
    
    for(int i=0;i<N;i++){
      A.at(i)=B.at(i);
      B.at(i)=0;
    }
	bool can=false;
    for(int j=0;j<N;j++){
      if(A.at(j)!=N) can=true;
      //goto Fin;
    }
    if(!can) break;
    count++;
  }
//Fin:
  for(int i=0;i<N;i++) cout<<A.at(i)<<" ";
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    cout << (A - 2 * B > 0 ? (A - 2 * B) : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__);
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__);


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
    cout<<"ABC";
    SCIN(n);
    COUT(n);
    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n,k,a = 0,b = 0,c,d;
    P o[100005] = {},e[100005] = {};
    rep(i,100005){
        o[i].second = i;
        e[i].second = i;
    }
    cin >> n;
    rep(i,n){
        cin >> k;
        if (i%2){
            o[k].first--;
        }
        else{
            e[k].first--;
        }
    }
    sort(o,o+100001);
    sort(e,e+100001);
    if (o[0].second == e[0].second) PRINT(n+min(o[0].first+e[1].first,o[1].first+e[0].first));
    else PRINT(n+o[0].first+e[0].first);
}

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

int T, D, N;
bool is_composite[1145142];

int main() {
  is_composite[1] = true;
  for (int i=2; i<=1145141; i++) {
    if (!is_composite[i]) {
      for (int j=i+i; j<=1145141; j+=i) {
        is_composite[j] = true;
      }
    }
  }
  
  while (1) {
    scanf("%d%d%d", &T, &D, &N);
    if ((T|D|N) == 0) return 0;

    int cnt = 0;
    int t = T;
    while (1) {
      if (!is_composite[t]) cnt++;
      if (cnt == N) break;
      t += D;
    }
    printf("%d\n", t);
  }
}
  

Measured memory_bytes: 4316
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <map>
#include <iterator>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 
 
 
int main() {
    string s,p;
    cin>>s>>p;
    int a,b;
    cin>>a>>b;
    string c;
    cin>>c;
    if(c==s) a--;
    else b--;
    cout<<a<<" "<<b;
}

Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

one = 0
two = 0
for p in P:
    if p <= A:
        one += 1
    elif A < p <= B:
        two += 1

print(min(one, two, N - (one + two)))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=2100;
int A[N],w[N],n,K,Q;
int check(int l,int r){
	int pre=1; int ans=0;
//	cout<<"chek "<<l<<" "<<r<<endl;
	for (int i=1;i<=n+1;i++){
		if (i==n+1||A[i]<l){
			if (i-pre>=K){
				int num=0;
			//	cout<<pre<<" "<<i-1<<endl;
				for (int j=pre;j<i;j++)
					if (A[j]<=r) num++;
				ans+=min(num,i-pre-K+1);
			}
			pre=i+1;
		}
	}
	return ans>=Q;
}
int main(){
	scanf("%d%d%d",&n,&K,&Q);
	for (int i=1;i<=n;i++) scanf("%d",&A[i]),w[i]=A[i];
	sort(w+1,w+n+1);
	int r=1; int ans=2e9;
	for (int i=1;i<=n;i++){
		while (r<=n&&check(w[i],w[r])==0) r++;
		//cout<<w[i]<<" "<<w[r]<<endl;
		if (r>n) continue;
		ans=min(ans,w[r]-w[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    sc.close();
	    
	    String answer;
	    
	    if(N > 999) {
	    	answer = "ABD";
	    }else {
	    	answer = "ABC";
	    }
	    
	    System.out.println(answer);
	    System.exit(0);
	}
}

Measured memory_bytes: 23124
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	int n, m;
	cin >> n >> m;
	vector<int>x(m);
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	if (n >= m) {
		cout << 0 << endl;
	}
	else {
		sort(x.begin(), x.end());
		vector<pair<int, int>>dif(m - 1);
		for (int i = 0; i < m - 1; i++) {
			dif[i].first = x[i + 1] - x[i];
			dif[i].second = i + 1;
		}
		sort(dif.begin(), dif.end());
		vector<int>pos(n + 1);
		pos[0] = 0;
		pos[n] = m - 1;
		for (int i = 0; i < n - 1; i++) {
			pos[i + 1] = dif[m - 2 - i].second;
		}
		sort(pos.begin(), pos.end());
		int ans = 0;
		for (int i = 1; i < n + 1; i++) {
			if (i != n) {
				ans += x[pos[i] - 1] - x[pos[i - 1]];
			}
			else {
				ans += x[pos[i]] - x[pos[i - 1]];
			}
			
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1792
import numpy as np
from itertools import product

inf = int(1e20)
n, m, x = map(int, input().split())
_ = [[int(x) for x in input().split()] for _ in range(n)]
CA = np.array(_, dtype=int)
ans = inf
for indices in product([0, 1], repeat=n):
    tmp = np.zeros(m + 1, dtype=int)
    for idx, be_used in enumerate(indices):
        tmp += be_used * CA[idx]
    if min(tmp[1:]) >= x:
        ans = min(ans, tmp[0])
print(ans if ans != inf else '-1')


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

const long long MOD = 1e9 + 7;
long long D[1000009], P[1000009];

int main() {
	long long N; scanf("%lld",&N);
	D[1] = N; D[2] = N*N;
	P[1] = N; P[2] = N*N+N;
	for(int i=3; i<=N; i++) {
		D[i] = D[i-1] + (N-1)*(N-1) + (i-3 >= 0 ? P[i-3] : 0) + N-i+2;
		D[i] %= MOD;
		P[i] = (P[i-1] + D[i]) % MOD;
	}
	printf("%lld", D[N]);
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<string>
using namespace std;
int temp[5];
bool compare(int a,int b)
{
    return a>b;
}
int main()
{
  //  freopen("test.txt", "r", stdin);
  //  freopen("testout.txt", "w", stdout);
    while(~scanf("%d",&temp[0]))
    {
        for(int i=1;i<5;i++)
            cin>>temp[i];
        sort(temp,temp+5,compare);
        for(int i=0;i<4;i++)
        {
            cout<<temp[i]<<' ';
        }
        cout<<temp[4]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
int main(int argc, char const *argv[]) 
{
  char s[1000],l ;
  int i,n=0;
  scanf("%s", &s);
  printf("%s", s);
   for(i=0; s[i]!='\0'; ++i);
       n=i;;

l = s[n-1];
 if (l == 's')
 {
    printf("%c%c\n", 'e','s');
 }
 else
 {
     printf("%c\n",'s');
 }
 /*          MD OMOR FARUK
             Daffodil International University(CSE)
             Contact:farukprimate@gmail.com
 */
return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(11); 
	cout.setf(ios::fixed);

	int n;
	cin >> n;
	
	vi cnt(3);
	rep(i , n)
	{
		int x;
		cin >> x;
		++cnt[x - 1];
	}
	
	vector<vector<vector<double>>> dp{ n + 1 , { n + 1 , vector<double>(n + 1) } };
	
	rep(k , n + 1)
	{
		rep(j , n + 1)
		{
			rep(i , n + 1)
			{
				if((i + j + k == 0) || (i + j + k > n))
					continue;
				
				dp[i][j][k] = 1. * n / (i + j + k);

				if(i > 0)
					dp[i][j][k] += 1. * i / (i + j + k) * dp[i - 1][j][k];
				if(j > 0)
					dp[i][j][k] += 1. * j / (i + j + k) * dp[i + 1][j - 1][k];
				if(k > 0)
					dp[i][j][k] += 1. * k / (i + j + k) * dp[i][j + 1][k - 1];
			}
		}
	}
	
	cout << dp[cnt[0]][cnt[1]][cnt[2]] << endl;
	

	return 0;
}

Measured memory_bytes: 216832
#include<bits/stdc++.h>
using namespace std;
#define N 100005
long long dp[N],w[N],val[N];
int main(){
	int n,W;
	scanf("%d %d",&n,&W);
	for(int i=0;i<n;i++) scanf("%lld %lld",&w[i],&val[i]);
	for(int i=1;i<=100000;i++) dp[i]=2e9;
	for(int i=0;i<n;i++){
		for(int j=100000;j>=val[i];j--){
			dp[j]=min(dp[j],dp[j-val[i]]+w[i]);
		}
	}
	for(int i=100000;i>=0;i--){
		if(dp[i]<=W){
			cout<<i;
			return 0;
		}
	}
}

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

int main() {
  string s;
  cin >> s;
  int n = 0;
  rep (i,3) 
    if(s[i]=='1') n++;
  cout<< n <<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
class Cube {
public:
	int f[6];
	Cube(){}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
};
int getRight(Cube c1, int f1, int f2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (c1.f[0] == f1&&c1.f[1] == f2)return c1.f[2];
			c1.roll_z();
		}
		if (i % 2 == 0)c1.roll_y();
		else c1.roll_x();
	}
	return -1;
}
int main() {
	Cube c;
	int f1, f2;
	for (int i = 0; i < 6; i++) {
		cin >> c.f[i];
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> f1 >> f2;
		cout << getRight(c, f1, f2) << endl;
	}
	return 0;
}

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

int A[2000001], n;

void maxheapify(int i) {
    int left, right, largest;
    
    left = 2 * i;
    right = 2 * i + 1;
    
    if (left <= n && A[left] > A[i]) largest = left;
    else largest = i;
    
    if (right <= n && A[right] > A[largest]) largest = right;
    
    if (largest != i) {
        swap(A[i], A[largest]);
        maxheapify(largest);
    }
}

int main() {
    cin >> n;
    for (int j = 1; j <= n; j++) cin >> A[j];
    
    for (int i = n / 2; i >= 1; i--) maxheapify(i);
    
    for (int i = 1; i <= n; i++) {cout << " " << A[i];}
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 4956
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b = mi()
    print((a - 1) * (b - 1))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
#include <iomanip>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if(a <= 5) {
		cout << 0 << endl;
	} else if(6 <= a && a<= 12) {
		cout << b /2 << endl;
	} else {
		cout << b << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
 int a, b, c;
 cin >> a >> b >> c;
 if(a != b && a != c && b != c){
  cout << 3 << endl;
}
else if (a == b && a == c && b == c){
    cout << 1 << endl;
}
else if (a == b != c || a != b == c  ){
    cout << 2 << endl;
}





    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) cin >> s[i];
    queue<pii> q;
    vector<vi> dist(h, vi(w, INF));
    q.emplace(0, 0);
    dist[0][0] = 0;
    while (!q.empty()) {
        auto p = q.front(); q.pop();
        int y = p.first, x = p.second, d = dist[y][x];
        const vi dy = { -1, 0, 1, 0 }, dx = { 0, 1, 0, -1 };
        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny<0||ny>=h||nx<0||nx>=w) continue;
            if (s[ny][nx] == '#') continue;
            if (dist[ny][nx] <= d+1) continue;
            q.emplace(ny, nx);
            dist[ny][nx] = d+1;
        }
    }
    int cnt = 0;
    rep(i, h) rep(j, w) if (s[i][j] == '.') ++cnt;
    if (dist[h-1][w-1] == INF) cout << -1 << endl;
    else cout << (cnt-dist[h-1][w-1]-1) << endl;
    return 0;
}


Measured memory_bytes: 3620
N = int(input())
A, B = map(int,input().split(" "))
P = [int(p) for p in input().split(" ")]
prob1 = [p for p in P if p <=A]
prob2 = [p for p in P if A<p<=B]
prob3 = [p for p in P if B<p]
print(min(len(prob1),len(prob2),len(prob3)))

Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
	int N,T;
	int c[1010], t[1010];
	int hoge;
	int min_cost = 1001;
	
	scanf("%d %d", &N, &T);
	for(hoge = 0;hoge < N;++hoge)
		scanf("%d %d",&c[hoge],&t[hoge]);
	
	for(hoge = 0;hoge < N;++hoge){
		if((t[hoge]<=T)&&(min_cost>c[hoge])){
			min_cost = c[hoge];
		}
	}
	
	if(min_cost == 1001){
		printf("TLE\n");
		return 0;
	}
	printf("%d", min_cost);
	
	return 0;
}


Measured memory_bytes: 128
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
#define debegin printf("debug\nbegin\n")
#define deend printf("debug\nend\n")
#define isfind printf("find\n")
template<class T>inline void rread(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************	
const int maxn=3e2+5,mod=1e9+7;
int n,m;
int f[2][3][maxn][maxn];
int s[3];
vector<int>lim[maxn][4];
inline void upd(int &x,int y){
	x=(x+y)%mod;
}
inline bool check(int r,int a,int b,int c){
	s[0]=a;s[1]=b;s[2]=c;
	rep(i,1,3)rep2(j,0,SZ(lim[r][i])){
		int cnt=0;
		rep(k,0,2)if(s[k]>=lim[r][i][j]&&s[k]<=r)cnt++;
		if(cnt!=i)return 0;
	}
	return 1;
}
int main(){
	rread(n);rread(m);
	rep(i,1,m){
		int x,l,r;rread(l);rread(r);rread(x);
		lim[r][x].pb(l);
		if(x>r-l+1)return puts("0"),0;
	}
	f[1][0][n+1][n+1]=1;
	f[1][1][n+1][n+1]=1;
	f[1][2][n+1][n+1]=1;
	rep(i,1,n-1){
		ms(f[(i+1)&1],0);
		rep(j,0,2)rep(k,1,n+1)rep(l,1,n+1)if(f[i&1][j][k][l]){
			rep(now,0,2){
				int nxtk,nxtl;
				if(now==j)nxtk=k,nxtl=l;
				else if(j==0){
					if(now==1)nxtk=i,nxtl=l;
					else nxtk=i,nxtl=k;
				}else if(j==1){
					if(now==0)nxtk=i,nxtl=l;
					else nxtk=k,nxtl=i;
				}else if(j==2){
					if(now==0)nxtk=l,nxtl=i;
					else nxtk=k,nxtl=i;
				}else assert(0);
				if(check(i+1,i+1,nxtk,nxtl))upd(f[(i+1)&1][now][nxtk][nxtl],f[i&1][j][k][l]);
			}
		}
	}
	int ans=0;
	rep(now,0,2)rep(k,1,n+1)rep(l,1,n+1)upd(ans,f[n&1][now][k][l]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int a, b, c, d, e, k;
int main(){
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
	if(abs(a - b) > k || abs(a- c) > k || abs(a- d) > k || abs(a - e) > k || abs(b - c) > k || abs(b - d) > k || abs(b - e) > k || abs(c - d) > k || abs(c - e) > k) puts(":(");
	else puts("Yay!");
}

Measured memory_bytes: 128
N = int(input())
S = list(input())
S_new_list = []
i = 0

while i != len(S)-1:
    if S[i] != S[i+1]:
        S_new_list.append(S[i])
        del S[0:i+1]
        i =0
    else:
        i += 1
    if len(S) == 1:
        break

print(len(S_new_list)+1)

Measured memory_bytes: 4260
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int sum = a+b+c;
	int tar = 3*max({a,b,c});
	if((tar-sum)%2==1)tar += 3;
	cout<<(tar-sum)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>

using namespace std;

int n, a, b;


int main()
{
	scanf("%d%d%d", &n, &a, &b);
	
	int minN, maxN;
	minN = a + b - n;
	if (minN < 0)
		minN = 0;
		
	if (a < b)
		maxN = a;
	else
		maxN = b;
	if (maxN > n)
		maxN = n;
		
	printf("%d %d\n", maxN, minN);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define M 1000000000
int h,w,cnt;
char c[52][52];
vector<vector<int>> a(52,vector<int>(52,M));
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
queue<pair<int,int>> q;
void bfs(int i,int j){
  for(int k=0;k<4;k++){
    if(c[i+dx[k]][j+dy[k]]=='.'){
      if(a[i][j]+1<a[i+dx[k]][j+dy[k]]){
        a[i+dx[k]][j+dy[k]]=a[i][j]+1;
        q.push(make_pair(i+dx[k],j+dy[k]));
      }
    }
  }
}
int main(){
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>c[i][j];
      if(c[i][j]=='#'){
        cnt++;
      }
    }
  }
  a[1][1]=1;
  bfs(1,1);
  while(!q.empty()){
    bfs(q.front().first,q.front().second);
    q.pop();
  }
  if(a[h][w]==M)cout<<-1;
  else cout<<h*w-a[h][w]-cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(2);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 1e6+10;
const ll bits = 30;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;


struct node{
    ll st,en;
};

 
 
int main(){
    FASTIO;

    ll n,l,x;
    cin>>n;

    vector<node>arr(n);

    for(int i=0;i<n;i++){
        cin>>x>>l;
        arr[i].st = x-l;
        arr[i].en = x+l;
    }

    sort(arr.begin(),arr.end(),[](node a, node b){
        if(a.en==b.en){
            return a.st < b.st;
        }

        return a.en < b.en;
    });

    ll ans = 0,ti=-inf;

    for(int i=0;i<n;i++){
        if(arr[i].st>=ti){
            ans++;
            ti= arr[i].en;
        }
    }

    cout<<ans<<"\n";



    
 
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int mod = 1000000007;
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
string s;
int dp[100005][2];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    dp[0][1] = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '0')
        {
            dp[i + 1][0] = dp[i][0]; //(0,0)
        }
        else
        {
            dp[i + 1][0] = dp[i][0] * 2 % mod; //(1,0)(0,1)
        }
        if (s[i] == '0')
        {
            dp[i + 1][1] += dp[i][1] * 2 % mod; //(0,0)(1,0)(0,1)
            dp[i + 1][1] %= mod;
            dp[i + 1][1] += dp[i][1];
            dp[i + 1][1] %= mod;
        }
        else
        {
            dp[i + 1][1] += dp[i][0]; //(0,0)
            dp[i + 1][1] %= mod;
            dp[i + 1][1] += dp[i][1] * 2 % mod; //(0,0)(1,0)(0,1)
            dp[i + 1][1] %= mod;
            dp[i + 1][1] += dp[i][1];
            dp[i + 1][1] %= mod;
        }
    }
    cout << (dp[n][0] + dp[n][1]) % mod << "\n";
}


Measured memory_bytes: 1232
#include <cstdio>
#include <cstring>
using namespace std;

int main(void)
{
	int n;
	char str[10000],c;
	char *t;

	scanf("%d\n", &n);

	for(int i = 0; i < n; i++){
		gets(str);

		while(t=strstr(str, "Hoshino"),t){
			t[6]  = 'a';
		}
		printf("%s\n", str);
	}
	return 0;
}

Measured memory_bytes: 1024