akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	int n;

	string s;

	cin >> n >> s;

	int ans = 0;

	for (int i = 0; i < n-2; i++){
		if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
			ans++;
	}

	cout << ans << endl;
	
	return 0;
}

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

#define inf (int)(1e9 + 7)

typedef enum{
	false,
	true
}Boolean;

typedef struct node_sub{
	int data;
	struct node_sub *next;
}node;

typedef struct {
	node *fst;
	node *last;
	int num;
}queue;

queue *make_queue(){
	queue *q = (queue *)malloc(sizeof(queue));
	q->fst = NULL;
	q->last = NULL;
	q->num = 0;
	return q;
}

Boolean is_empty(queue *q){
	if(q->num == 0){
		return true;
	}
	else{
		return false;
	}
}

void add_data(int val, queue *q){
	node *last = (node *)malloc(sizeof(node));
	last->data = val;
	last->next = NULL;
	if(is_empty(q) == true){
		q->fst = last;
	}
	else{
		q->last->next = last;
	}
	q->last = last;
	q->num++;
}

int take_data(queue *q){
	if(q->num == 0){
		printf("no data in the queue\n");
	}
	int ans = q->fst->data;
	node *fst = q->fst;
	if(q->num == 1){
		q->fst = NULL;
		q->last = NULL;
	}
	else{
		q->fst = fst->next;
	}
	free(fst);
	q->num--;
	return ans;
}

void to_empty(queue *q){
	int a;
	while(is_empty(q) == false){
		a = take_data(q);
	}
}

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

//n:頂点数, s:始点の番号, t:終点の番号, e:(u, v)->f uからvへの容量
int Edmonds_Karp(int n, int s, int t, int **e){
	int v, i;
	int flow_sum = 0;
	int *flow = (int *)malloc(sizeof(int) * n);
	int *p = (int *)malloc(sizeof(int) * n);
	queue *q = make_queue();

	for(;;){
		for(i = 0; i < n; i++){
			flow[i] = 0;
			p[i] = -1;
		}
		flow[s] = inf;
		p[s] = -2;

		add_data(s, q);
		while(is_empty(q) == false){
			v = take_data(q);
			if(v == t){
				break;
			}
			for(i = 0; i < n; i++){
				if(e[v][i] > 0 && p[i] == -1){
					p[i] = v;
					flow[i] = min(flow[v], e[v][i]);
					add_data(i, q);
				}
			}
		}
		if(flow[t] == 0){
			break;
		}
		for(v = t; v != s; v = p[v]){
			e[p[v]][v] -= flow[t];
			e[v][p[v]] += flow[t];
		}
		flow_sum += flow[t];
		to_empty(q);
	}
	return flow_sum;
}

int main(){
	int H, W, n, i, j;
	scanf("%d%d", &H, &W);
	char *a = (char *)malloc(sizeof(char) * (W + 1));
	n = H + W + 2;
	int **e = (int **)malloc(sizeof(int *) * n);
	for(i = 0; i < n; i++){
		e[i] = (int *)malloc(sizeof(int) * n);
		for(j = 0; j < n; j++){
			e[i][j] = 0;
		}
	}
	int sx, sy, tx, ty;
	for(i = 0; i < H; i++){
		scanf("%s", a);
		for(j = 0; j < W; j++){
			if(a[j] == 'S'){
				e[0][1 + i] = inf;
				e[0][1 + H + j] = inf;
				sx = i;
				sy = j;
			}
			else if(a[j] == 'T'){
				e[1 + i][n - 1] = inf;
				e[1 + H + j][n - 1] = inf;
				tx = i;
				ty = j;
			}
			else if(a[j] == 'o'){
				e[1 + i][1 + H + j] = 1;
				e[1 + H + j][1 + i] = 1;
			}
		}
	}
	if(sx == tx || sy == ty){
		printf("-1\n");
	}
	else{
		printf("%d\n", Edmonds_Karp(n, 0, n - 1, e));
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

        // 標準入力から値を取得してinput_lineに入れる
        String line1 = sc.nextLine();
        String num1 = line1.substring(0,line1.indexOf(" "));
        String num1_2 = line1.substring(line1.indexOf(" ")+1);
        String num2 = num1_2.substring(0,num1_2.indexOf(" "));
        String num2_2 = num1_2.substring(num1_2.indexOf(" ")+1);
        String num3 = num2_2.substring(0);
        String line2 = sc.nextLine();
        String num4 = line2.substring(0,line2.indexOf(" "));
        String num4_2 = line2.substring(line2.indexOf(" ")+1);
        String num5 = num4_2.substring(0,num4_2.indexOf(" "));
        String num5_2 = num4_2.substring(num4_2.indexOf(" ")+1);
        String num6 = num5_2.substring(0);
        String line3 = sc.nextLine();
        String num7 = line3.substring(0,line3.indexOf(" "));
        String num7_2 = line3.substring(line3.indexOf(" ")+1);
        String num8 = num7_2.substring(0,num7_2.indexOf(" "));
        String num8_2 = num7_2.substring(num7_2.indexOf(" ")+1);
        String num9 = num8_2.substring(0);

        // ArrayList<String> input = new ArrayList<String>();
        // 入力をすべて受け取る
        while(sc.hasNextLine()){
         String inta = sc.nextLine();
        //   if(inta.equals(null)){
        //       break;
        //   }
         	if(inta.equals(num1)) {
         		num1 = "check";
         	} else if(inta.equals(num2)) {
         		num2 = "check";
         	} else if(inta.equals(num3)) {
         		num3 = "check";
         	} else if(inta.equals(num4)) {
         		num4 = "check";
         	} else if(inta.equals(num5)) {
         		num5 = "check";
         	} else if(inta.equals(num6)) {
         		num6 = "check";
         	} else if(inta.equals(num7)) {
         		num7 = "check";
         	} else if(inta.equals(num8)) {
         		num8 = "check";
         	} else if(inta.equals(num9)) {
         		num9 = "check";
         	}
        }
        if(num1.equals("check") && num2.equals("check") && num3.equals("check")) {
        	System.out.println("Yes");
        } else if(num1.equals("check") && num4.equals("check") && num7.equals("check")) {
        	System.out.println("Yes");
        } else if(num1.equals("check") && num5.equals("check") && num9.equals("check")) {
        	System.out.println("Yes");
        } else if(num2.equals("check") && num5.equals("check") && num8.equals("check")) {
        	System.out.println("Yes");
        } else if(num3.equals("check") && num5.equals("check") && num7.equals("check")) {
        	System.out.println("Yes");
        } else if(num3.equals("check") && num6.equals("check") && num9.equals("check")) {
        	System.out.println("Yes");
        } else if(num4.equals("check") && num5.equals("check") && num6.equals("check")) {
        	System.out.println("Yes");
        } else if(num7.equals("check") && num8.equals("check") && num9.equals("check")) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }

}
}

Measured memory_bytes: 21844
#!/usr/bin/env python

n = int(input())
c = [0 for _ in range(n-1)]
s = [0 for _ in range(n-1)]
f = [0 for _ in range(n-1)]
for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

t = [[-1 for _ in range(n)] for _ in range(n-1)]

for i in range(n-1):
    t[i][i] = s[i]

for i in range(n-1):
    for j in range(i, n): 
        if i != j:
            t[i][j] = t[i][j-1]+c[j-1]
            if j == n-1:
                break
            if t[i][j]-t[j][j] <= 0:
                t[i][j] = t[j][j]
            else:
                if (t[i][j]-t[j][j])%f[j] != 0:
                    t[i][j] = t[j][j] + ((t[i][j]-t[j][j])//f[j]+1) * f[j]


#print('t =', t)

# output 
for i in range(n-1):
    print(t[i][n-1])
print(0)


Measured memory_bytes: 14936
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k,sum ;
    cin >> a >> b >> c;
    cin >> k;
    int num = 1;
    for(int i = 1; i<=k; i++)
    {
        num*=2;
    }
    int sum1 = a*num+b+c;
    int sum2 = a+b*num +c;
    int sum3 = a+b+c*num;
    if(sum1 >= sum2 && sum1 >= sum3)
    {
        cout << sum1 << endl;
    }
    else if(sum2 >= sum1 && sum2>=sum3)
    {
        cout << sum2<< endl;
    }
    else
    {
        cout << sum3 << endl;
    }

    //cout << max2 << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.math.{max,min}

object Main extends App {

  var (n,x) = (0,0)
  while({val Array(n2,x2) = readLine.split(" ").map(_.toInt);n=n2;x=x2;(n,x)} != (0,0) ) {
    println( ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) =>sum + (max(i+1,x-i-n) until min(n,(x-i+1)/2)).length} )
  }
}

Measured memory_bytes: 43936
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

vector<uint64_t> make_count_up_array(const string& str, const char char_a, const char char_b)
{
    size_t count = 0;
    auto count_up_array = vector<uint64_t>(str.size(), 0);

    for(size_t i = 0; i < str.size(); i++)
    {
        if (i == 0) {
            count_up_array[i] = count;
            continue;
        }

        if (str[i-1] == char_a && str[i] == char_b) {
            count++;
        }
        count_up_array[i] = count;
    }

    return move(count_up_array);
}

uint64_t get_count_between(const vector<uint64_t>& count_up_array, size_t l, size_t r)
{
    assert(0 <= l && l <= count_up_array.size());
    assert(0 <= r && r <= count_up_array.size());
    assert(l < r);

    uint64_t count = count_up_array[r] - count_up_array[l];
    return count;
}

void test_large_case()
{
    string largeStr = "";
    for(size_t i = 0; i < pow(10, 5); i++)
    {
        if (i % 2 == 0) {
            largeStr.push_back('A');
        } else {
            largeStr.push_back('C');
        }
    }

    vector<uint64_t> count_up_array = make_count_up_array(largeStr, 'A', 'C');
    for(size_t i = 0; i < pow(10, 5); i++)
    {
        uint64_t count = get_count_between(count_up_array, 0, pow(10, 5) - 1);
        cout << count << endl;
    }
}

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

    uint64_t n, q = 0;
    cin >> n;
    cin >> q;
    assert(2 <= n && n <= pow(10, 5));
    assert(1 <= q && q <= pow(10, 5));

    string str;
    cin >> str;
    assert(str.size() == n);

    vector<pair<uint64_t, uint64_t> > ranges;
    for(size_t i = 0; i < q; i++)
    {
        uint64_t l, r = 0;
        cin >> l;
        cin >> r;
        assert(1 <= l && l <= n);
        assert(1 <= r && r <= n);
        ranges.push_back(make_pair(l, r));
    }
    assert(ranges.size() == q);

    vector<uint64_t> count_up_array = make_count_up_array(str, 'A', 'C');

    for(size_t i = 0; i < q; i++)
    {
        uint64_t l = ranges[i].first - 1;
        uint64_t r = ranges[i].second - 1;
        uint64_t count = get_count_between(count_up_array, l, r);
        cout << count << endl;
    }

    // test_large_case();

    return 0;
}

Measured memory_bytes: 3264
#include <iostream>

int main(int argc, char const *argv[]) {
    int time_insec;
    std::cin >> time_insec;

    int hour;
    int min;
    int sec;
    
    hour = time_insec / 3600;
    min = (time_insec - hour * 3600) / 60;
    sec = time_insec % 60;

    std::cout << hour << ":" << min << ":" << sec << std::endl;

    return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#define N 1010
#define ll long long
#define mo ((ll)1e9+7)
//10000000000037ll
//21993833369ll
#define db double
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
bool cmp(int a, int b) {return a > b;}
inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
int row[300010], column[300010];
#define pr pair<int,int>
map<pr, bool> ma;
int Mr[300010], Mc[300010];
int main() {
	int n = read(), m = read(), c = read(), mr = 0, mc = 0;

	rep(i, 1, c) {
		int x = read(), y = read();
		//printf("%d %d\n", x, y);
		ma[make_pair(x, y)] = 1;
		row[x]++, column[y]++;
		cmax(mr, row[x]), cmax(mc, column[y]);
	}
	//if (ma[po(1, 2)])puts("error");
	rep(i, 1, n)if (row[i] == mr)Mr[++Mr[0]] = i;
	rep(i, 1, m)if (column[i] == mc)Mc[++Mc[0]] = i;
	int ans = mr + mc;
	rep(i, 1, Mr[0])rep(j, 1, Mc[0]) {
		if (ma[make_pair(Mr[i], Mc[j])] == 0) {printf("%d\n", ans); return 0;}
	}
	printf("%d\n", --ans);
	return 0;
}


Measured memory_bytes: 21656
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   	int n;
  	cin >> n;
  	ll ans = 0;
  	for (int i = 1; i < n; i++) {
      	double cur = sqrt(i);
		for (int j = 1; j < cur; j++)
      		if (i % j == 0)
      			ans += 2;
      	if (floor(cur) == ceil(cur))
          ans++;
    }
  	cout << ans;
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  ll a[N], b[N];
  rep(i,N) cin >> a[i] >> b[i];

  ll retval = 0;
  for (int i=N-1;i>=0;i--){
    a[i] += retval;
    retval += ((a[i]+b[i]-1)/b[i])*b[i] - a[i];
  }
  cout << retval << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 5192
import sys

sys.setrecursionlimit(500000)


N,M = list(map(int,input().split()))

e_list = [[] for i in range(N)]

for i in range(M):
    x,y = list(map(int,input().split()))
    x,y = x-1,y-1
    e_list[x].append(y)

memo = [-1]*N

def DFS(v):
    if memo[v]!=-1:
        return memo[v]
    if len(e_list[v])==0:
        memo[v] = 0
        return 0
    res = 0
    for v1 in e_list[v]:
        res1 = DFS(v1)
        if res<res1+1:
            res = res1+1
    memo[v] = res
    return res

ans = 0
for i in range(N):
    res = DFS(i)
    if res>ans:
        ans = res
print(ans)

Measured memory_bytes: 158540
#include <bits/stdc++.h>
#define ll long long
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
using namespace std;

int main(){
  ll N,K,ans=0;
  cin>>N>>K;
  map<ll,ll> m;
  set<ll> s;
  vector<ll> v;
  for(ll i=0;i<N;i++){
    ll A;
    cin>>A;
    m[A]++;
    if(!s.count(A)){
      s.insert(A);
      v.push_back(A);
    }
  }
  for(ll i=0;i<s.size();i++) v[i]=m[v[i]];
  sort(v.begin(),v.end());
  if(s.size()>K){
    for(ll i=0;i<s.size()-K;i++) ans+=v[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 23664
x,k,d=map(int,input().split())

#x zahyo   k k kaisu  d hohaba

if abs(x)-k*d>0:
  print(abs(x)-k*d)
else:
  nearZeroHosu=abs(x)//d
  if (k-nearZeroHosu)%2==0:
    print(abs(x)-d*nearZeroHosu)
  else:
    print(abs(abs(x)-d*(nearZeroHosu+1)))

Measured memory_bytes: 9052
n=int(input())
syougen={}
for i in range(n):
    a=int(input())
    syougen[i+1]=[[],[]]

    for j in range(a):
        x,y=map(int,input().split())
        if y==1:
            syougen[i+1][0].append(x)
        else:
            syougen[i+1][1].append(x)

result=0

for i in range(2**n):
    sei=set([])
    ayamari=set([])

    for j in range(n):
        if((i>>j)&1):
            sei=sei|(set(syougen[j+1][0]))|set([j+1])
            ayamari=ayamari|(set(syougen[j+1][1]))

    if sei.isdisjoint(ayamari):
        flag="true"
        cnt=0
        for j in range(n):
            if((i>>j)&1):
                cnt+=1
                if j+1 not in sei:
                    flag="fales"
                    
        if flag=="true" and cnt==len(sei):
            result=max(result,len(sei))
print(result)


#print(syougen)





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

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  string s1;
  string s2;
  if(N % 2 == 1){
    cout << "No" << endl;
  } else {
    int mm = N/2;
    for(int i = 0; i<N; i++){
      if(mm <= i){
        s1 += S[i];
      } else {
        s2 += S[i];
      }
    }
    if(s1 == s2){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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

long long N, M, dpa[1 << 18], dpb[1 << 18], power[200], powerinv[200], power3[200], mod = 1000000007;
bool used[16][16];
int V3[16];

vector<long long> solve(int pos) {
	vector<long long>dp((1 << N), 0);
	for (int i = 0; i < (1 << N); i++) {
		int bit[15]; for (int j = 0; j < N; j++) bit[j] = (i / (1 << j)) % 2;
		if (bit[pos] == 0) continue;

		int cnt = 0;
		for (int j = 0; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (bit[j] == 1 && bit[k] == 1 && used[j][k] == true) cnt++;
			}
		}
		long long res = power[cnt]; int G = 0;
		vector<int>V1; for (int j = 0; j < N; j++) { if (bit[j] == 1) { if (j == pos) G = (1 << V1.size()); V1.push_back(j); } }

		for (int j = 0; j < (1 << V1.size()); j++) {
			if ((j&G) == 0) continue;
			int R = 0, T = 0;
			for (int k = 0; k < V1.size(); k++) {
				if ((j & (1 << k)) != 0) R += (1 << V1[k]);
				else { V3[T] = V1[k]; T++; }
			}
			long long Y = dp[R]; if (Y == 0) continue;
			for (int k = 0; k < T; k++) {
				for (int l = k + 1; l < T; l++) { if (used[V3[k]][V3[l]] == true) { Y *= 2; if (Y >= mod)Y -= mod; } }
			}
			res -= Y; if (res < 0) res += mod;
		}
		dp[i] = res;
	}
	return dp;
}

int main() {
	power[0] = 1; for (int i = 1; i < 200; i++) power[i] = (2LL * power[i - 1]) % mod;
	powerinv[0] = 1; for (int i = 1; i < 200; i++) powerinv[i] = (500000004LL * powerinv[i - 1]) % mod;
	power3[0] = 1; for (int i = 1; i < 200; i++) power3[i] = (3LL * power3[i - 1]) % mod;

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b; a--; b--;
		used[a][b] = true; used[b][a] = true;
	}

	vector<long long> A1 = solve(0); for (int i = 0; i < (1 << N); i++) dpa[i] = A1[i];
	vector<long long> A2 = solve(1); for (int i = 0; i < (1 << N); i++) dpb[i] = A2[i];

	long long ret = 0;
	for (int i = 7; i < power3[N]; i += 9) {
		int col[15]; for (int j = 0; j < N; j++) col[j] = (i / power3[j]) % 3;
		int pa = 0, pb = 0;
		for (int j = 0; j < N; j++) { if (col[j] == 1) pa += (1 << j); if (col[j] == 2) pb += (1 << j); }

		if (dpa[pa] == 0 || dpb[pb] == 0) continue;
		long long E1 = dpa[pa] * dpb[pb] % mod;
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if (col[j] == 1 && col[k] == 2 && used[j][k] == true) E1 *= 0;
				if (col[j] == 0 && col[k] == 0 && j < k && used[j][k] == true) { E1 *= 2; E1 %= mod; }
			}
		}
		ret += E1; ret %= mod;
	}
	cout << (power[M] - ret + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 3200
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n,c;
pair<pii,int> data[100005];
pii lst[100005];

int main()
{
  scanf("%d %d",&n,&c);
  REP(i,n) scanf("%d %d %d",&data[i].fi.fi,&data[i].fi.se,&data[i].se);
  SORTA(data,n);
  REP(i,n) lst[i] = mp(-1,-1);
  int risan = 0;
  REP(i,n)
  {
    REP(j,n) 
    {
      if(lst[j].fi < data[i].fi.fi)
      {
        lst[j] = mp(data[i].fi.se,data[i].se);
        MAX(risan,j);
        break;
      }
      if(lst[j].fi == data[i].fi.fi && lst[j].se == data[i].se)
      {
        lst[j] = mp(data[i].fi.se,data[i].se);
        MAX(risan,j);
        break;
      }
    }
  }
  printf("%d\n",risan + 1);
  return 0;
}










Measured memory_bytes: 2176
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll mod=1e9+7;
 
using pear = pair<int,int>;
 
int main(){
    ll n; cin >>n;
    rep1(i,9){
        rep1(j,9){
            if(i*j == n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    rep(i, n)
    {
        int A;
        cin >> A;
        a[i] = make_pair(A, i + 1);
    }
    sort(ALL(a));
    rep(i, n)
    {
        cout << a[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
     
int main(){
int a[3];
int b;

cin >> a[0] >> a[1] >> a[2];
     
for (int i =2; 0 < i; i--){
for (int j = 0; j < i; j++){
if(a[j] > a [j+1]){
b= a[j];
a[j] = a[j+1];
a[j+1] = b;
}
}
}
   
cout << a[0] << " " << a[1] << " " << a[2] << endl;
}


Measured memory_bytes: 3096
ABCD = list(input())
p_m = []
for i in range(2 ** 3):
    tmp = bin(i)[2::]
    while len(tmp) < 3:
        tmp = "0" + tmp
    p_m.append(tmp)

for i in p_m:
    sum = int(ABCD[0])
    cnt = 1
    plusminus = []
    for j in i:
        # print(j, sum, cnt)
        if j == "1":
            sum += int(ABCD[cnt])
            plusminus.append("+")
        else:
            sum -= int(ABCD[cnt])
            plusminus.append("-")
        cnt += 1
    if sum == 7:
        for i in range(3):
            print(ABCD[i], end = "")
            print(plusminus[i], end = "")
        print(ABCD[3] + "=7")
        break

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int N,K;
  cin>>N>>K;
  int arr[N];
  for(int i=0;i<N;i++)
    cin>>arr[i];
  sort(arr,arr+N);
  int t = 0;
  for(int i=0;i<K;i++)
    t = t + arr[i];
  cout<<t; 
}


Measured memory_bytes: 3628
tailrec fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}

fun lcm(a: Long, b: Long): Long {
    return a * b / gcd(a, b)
}

fun main(args: Array<String>) {
    val (n, m) = readLine()?.split(" ")?.map(String::toLong) ?: return
    val aList = readLine()?.split(" ")?.map(String::toLong) ?: return
    aList.map {
        var r = it
        var count = 0
        while (r % 2 == 0L) {
            count++
            r /= 2
        }
        count
    }.distinct().size.apply {
        if (this != 1) {
            println(0L)
            return
        }
    }

    //最小公倍数を求めて割る
    val ak = aList.fold(1L) { a, b -> lcm(a, b) }
    val ak2 = aList.map { it / 2 }.fold(1L) { a, b -> lcm(a, b) }
    val count = m / ak2 - m / ak
    println(count)
}



Measured memory_bytes: 74140
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var num = input[0];
        var time = input[1];
        var times = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var result = 0;
        for(var i = 1; i < num; i++)
            result += Min(time, times[i] - times[i - 1]);
        WriteLine(result+time);
    }
}


Measured memory_bytes: 30304
import java.util.Scanner;

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

Measured memory_bytes: 46528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n, k;
  cin >> n >> k;
  ld ex[1007];
  for(ll i=1;i<1007;i++){
    ld a = i*(i + 1) / 2;
    ex[i] = a / (ld)i;
  }
  ld sum = 0;
  ld maxi = 0;
  vector<ld> p(n);
  rep(i, n){
    ll b;
    cin >> b;
    p[i] = ex[b];
    sum += p[i];
    if(i>=k){
      sum -= p[i-k];
    }
    chmax(maxi, sum);
  }
  cout << fixed << setprecision(10) << maxi << endl;
}


Measured memory_bytes: 6404
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final String str = sc.nextLine();
			
			if("END OF INPUT".equals(str)){
				break;
			}
			
			for(String s : str.split(" ")){
				System.out.print(s.length());
			}
			
			System.out.println();
			
		}
		
	}

}

Measured memory_bytes: 12000
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int digits(ll n){
    int ret = 0;
    while(n){
        n /= 10;
        ret++;
    }
    return ret;
}

int main(){
    ll n; cin >> n;
    int ans = M;
    for(ll i=1;i*i<=n;i++){
        if(n % i == 0){
            ans = min(ans, max(digits(i), digits(n / i)));
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>

using namespace std;

typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

int A, B, C, D, E, N;

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

        return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	s.erase(unique(s.begin(),s.end()),s.end());
	if(s.size()%2==1)cout<<"No"<<endl;
	else if(s.size()==4)cout<<"Yes"<<endl;
	else if((s[0]=='E'&&s[1]=='W')||(s[0]=='N'&&s[1]=='S'))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b; return true;
    }
    return false;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b; return true;
    }
    return false;
}
ll INF = 1LL << 60;
ll n;
ll w;
ll weight[110], value[110]; 
ll dp[110][100100];

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> w;
    for (ll i = 0; i < n; i++)
        cin >> weight[i] >> value[i];
    
    for (ll i = 0; i < 110; i++)
        for (ll j = 0; j < 100100; j++)
            dp[i][j] = INF;

    dp[0][0] = 0;
    for (ll i = 0; i < n; i++) {
        for (ll sum_v=0; sum_v < 100100; sum_v++) {
            if (sum_v - value[i] >=0)
                chmin(dp[i+1][sum_v], dp[i][sum_v-value[i]] + weight[i]);
            
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    ll ans = 0;
    for (ll i = 0; i < 100100; i++) {
        if (dp[n][i] <= w)
            ans = i;
    
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 86400
#include <stdio.h>
#include <math.h>

int main(void)
{
  int X, ans = 1;
  scanf("%d", &X);
  double limit = sqrt(X);
  for(int i = 2; i <= limit; i++){
    int p = 2,
        temp = i*i;
    while(temp <= X){
      if(ans < temp)
        ans = temp;
      temp *= i;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll k,ans=0;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int x=1;x<=k;x++){
                ans+=gcd(gcd(i,j),x);
            }
        }       
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    
    int a,b,l;
    cin>>a>>b>>l;
    if(a>b)
    cout<<(l+a-1)/a;
    else
    cout<<(l+b-1)/b;
    return 0;
}


Measured memory_bytes: 256
import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)

def main():
    def judge(u=0,b=False):
        bt[u]=b
        res=False
        for ku in range(n):
            if not to[u][ku]:continue
            if bt[ku]==b:
                return True
            if bt[ku]==None:
                res|=judge(ku,not b)
        return res

    def bfs(u):
        hp=[]
        heappush(hp,(0,u))
        while hp:
            d,u=heappop(hp)
            for v in range(n):
                if not to[u][v]:continue
                if dis[v]!=-1:continue
                dis[v]=d+1
                heappush(hp,(d+1,v))

    n = int(input())
    to = [[c == "1" for c in input()] for _ in range(n)]
    bt=[None]*n
    if judge():
        print(-1)
        exit()
    ans=0
    for u in range(n):
        dis=[-1]*n
        dis[u]=0
        bfs(u)
        ans=max(ans,max(dis)+1)
    print(ans)
main()


Measured memory_bytes: 3572
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

const int kMaxN = 1e5+10;
const int kInf = (1<<30);

vector<vector<int>> dp;
vector<vector<int>> T;

void DFS(int x, int f) {
	vector<int> sons;	

	for (auto y : T[x]) {
		if (y != f) {
			DFS(y, x);
			sons.push_back(y);
		}
	}

	if (sons.size() == 0) {
		dp[x][0] = 0;
		dp[x][1] = 0;
	} else if (sons.size() == 1) {
		dp[x][0] = dp[sons[0]][0];
		dp[x][1] = dp[sons[0]][1];
	} else {
		for (auto y : sons) {
			dp[x][0] += max(1, dp[y][1]);
		}

		int alt = 0;
		bool zero = true;
		for (auto y : sons) {
			if (dp[y][1] == 0 && zero) {
				zero = false;
			} else if (dp[y][1]	 == 0 && !zero) {
				alt += 1;
			} else {
				alt += dp[y][1];
			}
		}

		dp[x][1] = alt;
	}

	// cerr << x << " " << dp[x][0] << " " << dp[x][1] << "\n";
}

int ComputeRoot(int x) {
	if (T[x].size() == 2 && (dp[T[x][0]][1] == 0 || dp[T[x][1]][1] == 0)) {
		if (dp[T[x][0]][1] == 0) {
			return max(1, dp[T[x][1]][0]);
		} else	{
			return max(1, dp[T[x][0]][0]);
		}
	}

	int alt = 0;
	bool zero = true;
	for (auto y : T[x]) {
		if (dp[y][1] == 0 && zero) {
			zero = false;
		} else if (dp[y][1]	 == 0 && !zero) {
			alt += 1;
		} else {
			alt += dp[y][1];
		}
	}

	return alt;
}

void Solve() {
	int n;
	cin >> n;


	T = vector<vector<int>>(n + 1);
	dp = vector<vector<int>>(n + 1, vector<int>(2));

	for (int i = 1; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		++x;
		++y;
		T[x].push_back(y);
		T[y].push_back(x);
	}


	if (n == 2) {
		cout << 1 << "\n";
		return;
	}

	int root = 1;

	for (int i = 1; i <= n; ++i) {
		if (T[i].size() > 1) {
			root = i;
			break;
		}
	}

	DFS(root, 0);

	cout << ComputeRoot(root) << "\n";
}


int main() {
	int tests = 1;

	for (;tests; --tests) {
		Solve();
	}
}

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 2e3 + 10;


int n;
int a[N], b[N], c[N];

void Solve(){
    cin >> n;
    for(int i = 1; i < n; i++) cin >> a[i];
    int ans = a[n - 1];
    a[0] = ooi;
    for(int i = n - 1; i >= 1; i--){
        ans += min(a[i - 1], a[i]);
    }
    cout << ans;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main()
{
  ll H, N; cin >> H >> N;
  vector<ll> dp(H + 1, MOD);
  dp[0] = 0;
  for (ll i = 0; i < N; i++) {
  	int A, B; cin >> A >> B;
    for (ll j = 0; j < H; j++) {
    	ll nj = min(j + A, H);
      	dp[nj] = min(dp[nj], dp[j] + B);
    }
  }
  cout << dp[H] << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int x , a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>x;
    cout<<a[x-1]<<endl;
    return(0);
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 100
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int B[MAX_N];
  rep(i, N - 1) { cin >> B[i]; }

  int A[MAX_N];
  A[0] = B[0];
  A[N - 1] = B[N - 2];
  for (int i = 1; i < N - 1; i++) {
    A[i] = min(B[i - 1], B[i]);
  }

  int Ans = 0;
  rep(i, N) { Ans += A[i]; }
  cout << Ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  int n = s.size();
  ll r,d=1;
  vector<vector<int>> dp(n+1,vector<int>(13,0));
  reverse(s.begin(),s.end());
  dp[0][0] = 1;
  for(int i=0; i<n; i++){
    if(s[i]=='?'){
      for(int j=0; j<=9; j++){
        r = (d * j) % 13;
        for(int k=0; k<13; k++){
          dp[i+1][(k+r)%13] += dp[i][k];
          dp[i+1][(k+r)%13] %= MOD;
        }
      }
    }else{
      r = (d * (s[i]-'0')) % 13;
      for(int j=0; j<13; j++){
        dp[i+1][(j+r)%13] = dp[i][j];
        dp[i+1][(j+r)%13] %= MOD;
      }
    }
    d *= 10;
    d %= 13;
  }
  cout << dp[n][5];
  return 0;
}


Measured memory_bytes: 8912
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;
	vector<int>sum;
	if (s[0] == '0') {
		sum.push_back(0);
	}
	for (int i = 0; i < N;) {
		int j = i;
		while (j<s.size()&&s[j] == s[i]) {
			++j;
		}
		sum.push_back(j-i);
		i = j;
	}
	if (s.back() == '0') {
		sum.push_back(0);
	}
	vector<int>fuck(sum.size()+1,0);
	for (int i = 0; i < sum.size(); ++i) {
		fuck[i + 1] = fuck[i] + sum[i];
	}
	int res = 0;
	for (int left = 0; left < fuck.size(); left += 2) {
		int right = left + K * 2 + 1;
		if (right >= fuck.size())right = (int)fuck.size() - 1;
		res = max(res, fuck[right] - fuck[left]);
	}
	cout << res << endl;
	return 0;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int ruijou(int x){
    int val = 1;
    rep(i, x) val*=10;
    return val;
}

int main(void){
    int N; cin >> N;
    int hyou[10][10];
    rep(i, 10) rep(j, 10) hyou[i][j] = 0;
    for(int i = 1; i <= 9; i++){
        if(i <= N) hyou[i][i] = 1;
    }
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            int k = 1;
            int acc = 0;
            bool cont = true;
            while(cont){
                int val = i * ruijou(k);
                if(k == 1){
                    if(val+j > N) cont = false;
                    else acc++;
                }
                else{
                    int ulim = ruijou(k-1)-1;
                    for(int v = 0; v <= ulim; v++){
                        if(val+(v*10)+j > N) cont = false;
                        else acc++;
                    }
                }
                k++;
            }
            hyou[i][j] += acc;
        }
    }

    int ans = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ans += hyou[i][j]*hyou[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;                                                                                  

mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;

int fl = 1, fr = 1;
int pl = 10, pr = 10;
int l = 1, r = 1;
int sum = 1;
int s, ans = 0;
void upr(){
	r++;
	if(pr == r)
		fr++, pr *= 10;
	sum += fr;
}
void upl(){
	sum -= fl;
	l++;
	if(pl == l)
		fl++ , pl *= 10;
}

main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> s;
	
	for(; r < 100000000 ; ){
	          
		while(sum > s)
			upl();
        if(sum == s)
			ans++;
		upr();
	}
	ans %= mod;
	int p = (900000000ll)%mod;

	for(int i = 8 ; i <= s; i++){
		int n = s/i;
		int m = s % i;
		if(m == 0)n--,m += i;
		if(n - m >= 0){
			ans += ((n - m)/(i + 1) + 1)%mod;
			if(ans >= mod)ans -= mod;
			if(s % (i + 1) == 0){
				int x = s/(i + 1);
				ans += (p - x + mod)%mod;
				if(ans >= mod)ans -= mod;
			}			
		}
		p *= 10;
		p %= mod;
	}
	cout << ans%mod;
}
 


Measured memory_bytes: 384
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort(reverse=True, key=lambda a: (a & -a))

xor = 0
for a in A:
    xor ^= a

left = 0
ans = 0

for digit in range(xor.bit_length() + 1)[:: -1]:
    if (xor & (1 << digit)) > 0:
        while left < N and ((A[left] & -A[left]).bit_length() - 1) > digit:
            left += 1

        if left >= N or ((A[left] & -A[left]).bit_length() - 1) != digit:
            print(-1)
            exit()

        ans += 1
        xor ^= ((1 << (digit + 1)) - 1)

print(ans)

Measured memory_bytes: 11036
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
K = INT()


for i in range(len(S)):
	if int(S[i]) != 1:
		print(int(S[i]))
		break
	else:
		K -= 1
		if K <= 0:
			print(S[i])
			break


Measured memory_bytes: 5780
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 100010

int cnt[SIZE] = {0};

int main() {
   int n;
   cin >> n;
   for (int i = 0 ; i < n ; ++i) {
      int j;
      cin >> j;
      ++cnt[j];
   }
   int ans = cnt[0] + cnt[1];
   for (int i = 1 ; i < SIZE - 1 ; ++i) {
      ans = max(ans, cnt[i] + cnt[i - 1] + cnt[i + 1]);
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


int main() {
  ll n, a, b; cin >> n >> a >> b;
  ll ans = n / (a+b) * a;
  ans += min(a, (n % (a+b)));
  cout << ans << endl;
}


Measured memory_bytes: 256