akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
 
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;

    cin >> n;

    vector<int> alpha(26, 0);

    cin >> s;
    for (int i=0; i<s.size(); i++){
        alpha[s[i] - 'a']++;
    }

    for (int k = 0; k < n-1; k++){
        vector<int> cnt(26, 0);
        cin >> s;
        for (int i=0; i<s.size(); i++){
            cnt[s[i] - 'a']++;
        }

        for (int i=0; i<26; i++){
            alpha[i] = min(alpha[i], cnt[i]);
        }
    }

    string ans;

    for (int i=0; i<26; i++){
        ans.append(alpha[i], char('a' + i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int W,H,x,y,r,a=0;
	cin >> W >> H >> x >> y >> r;
	if(x-r<0){
		a=1;
	}
	if(x+r>W){
		a=1;
	}
	if(y-r<0){
		a=1;
	}
	if(y+r>H){
		a=1;
	}
	if(a==1){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  int ans = 0;

  cin >> n;
  vi v(n);
  REP(i, n) {
    cin >> v[i];
  }

  cout << (max_of(v) - min_of(v)) << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String line = "";

		try {
			scanner = new Scanner(System.in);
			line = scanner.nextLine();

			char[] wkArray = line.toCharArray();
			StringBuffer buf = new StringBuffer();
			for (int i = 0; i < wkArray.length; i++) {
				switch (wkArray[i]) {
				case '1':
					buf.append(9);
					break;
				case '9':
					buf.append(1);
					break;
				default:
					buf.append(wkArray[i]);
					break;
				}

			}

			System.out.println(buf.toString());

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22868
n, a, b = [int(x) for x in input().split()]
s = input()

winners = []
foreign_winners = [0 for _ in range(len(s))]
winner_count = 0

foreign_score = 1
for i, c in enumerate(s):
  if c == 'b':
    foreign_winners[i] = foreign_score
    foreign_score += 1

for i, c in enumerate(s):
  if c == 'a':
    if winner_count < a+b:
      winners.append("Yes")
      winner_count += 1
    else:
      winners.append("No")
  elif c == 'b':
    if winner_count < a+b and foreign_winners[i] <= b:
      winners.append("Yes")
      winner_count += 1
    else:
      winners.append("No")
  else:
    winners.append("No")

for l in winners:
  print(l)

Measured memory_bytes: 13712
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll dp[s.size()+1][13];
    rep(i,s.size()+1)rep(j,13)dp[i][j]=0;
    dp[0][0] = 1;
    int i,j,k;
    for(i=0;i<s.size();i++)
    {
        for(j=0;j<13;j++)
        {
            if (s[i] == '?')
            {
                for(k=0;k<10;k++)
                {
                    ll g=(j*10 + k)%13;
                    dp[i + 1][g] += dp[i][j];
                    if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
                }
            }
            else
            {
                ll g=(j * 10 + (s[i] - '0'))%13;
                dp[i + 1][g] += dp[i][j];
                if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
}


Measured memory_bytes: 10704
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
H = getList()
imos = deepcopy(H)
for i in range(1, N):
    imos[i] = max(imos[i - 1], H[i])

ans = 1 # 最初の一つは必ず景色を見れる
# ２番目以降について
for i in range(1, N):
    if H[i] >= imos[i - 1]:
        ans += 1
print(ans)

Measured memory_bytes: 83440
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C;
    cin >> A;

    if(A==1)
	puts("Hello World");
    else{
	cin >> B;
	cin >> C;
	cout << B+C <<endl;
    }
    // if(A==12)
    // 	cout << 1<<endl;
    // else
    // 	cout << A+1<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    // if(A%2==1 && B%2==1)
    // 	puts("Yes");
    // else
    // 	puts("No");
	
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize
    }

    if a <= 5 {
        println!("0");
    } else if a <= 12 {
        println!("{}", b / 2);
    } else {
        println!("{}", b);
    }
}

Measured memory_bytes: 2200
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
using graph = vector<vector<int>>;
typedef long long ll;


int main() {
	ll n,id,kosu,mem,memb;
	cin >> n;
	vector<ll> parent(n, -1);
	vector<ll> left(n, -1);
	vector<ll> right(n, -1);

	for (int i = 0; i < n; i++) {
		cin >> id >> kosu;
		for (int j = 0; j < kosu; j++) {
			cin >> mem;
			if (j == 0) {
				left[id] = mem;
			}
			else{
				right[memb] = mem;
			}
			parent[mem] = id;
			memb = mem;
		}
	}


	int c,d,e;
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << parent[i] << ", depth = ";
		d = 0;
		e = i;
		while (e != -1) {
			e = parent[e];
			d++;
		}
		cout << d-1 << ", ";
		if (parent[i] == -1) {
			cout << "root, [";
		}
		else if (left[i] == -1) {
			cout << "leaf, [";
		}
		else {
			cout << "internal node, [";
		}

		c = left[i];
		while (c != -1) {
			cout << c;
			if (right[c] != -1) {
				cout << ", ";
			}
			c = right[c];
		}
		cout << "]" << endl;
	}
	return 0;
}


Measured memory_bytes: 5224
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int solve(int i, int m);

int n, A[50];

int main() {

  int i;
  int q,m;

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

  scanf("%d",&q);
  
  for(i=0; i<q; i++){
    scanf("%d",&m);
    if(solve(0,m)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i, int m){

  if(m == 0) return 1;
  if(i >= n) return 0;

  return solve(i+1, m) || solve(i+1, m-A[i]);

}



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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,m,a,next,cnt=0;
    cin>>n>>m;

    max_heap<int> que;

    rep(i,0,n){
        cin>>a;
        que.push(a);
    }

    rep(i,0,m){
        next = que.top();
        que.pop();
        next /= 2;
        que.push(next);
    }

    while(!que.empty()){
        cnt += que.top();
        que.pop();
    }

    cout<<cnt<<'\n';
    return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
#include<string.h>
#define MAX 1000
 
int main(){
  

  int i,j;
  int n;
  int k = 0;
  int total = 0;
  int t, p;
  int v[MAX];
  char T[MAX],P[MAX];


  
  scanf("%s%s",T,P);
  
  t=strlen(T);
  p=strlen(P);

  for(i = 0;i < t;i++){
    if(T[i] == P[0]){
      
      j = i+1;
      n = 1;

      while(n < p){
        if(T[j] != P[n])
          break;
        j++;
	n++;
      }
       if(n == p){
        v[k] = i;
        total++;
	k++;
      }
    }
  }
  for(k = 0;k < total;k++){
    printf("%d\n",v[k]);
  }
  
  return 0;
}

Measured memory_bytes: 544
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main() 
{
	
	int number = 0;
	int i = 0;
	while(scanf("%d",&number) != EOF)
	{
		set<string> s;
		for(i=0;i<number;i++)
		{
			string str;
			cin >> str;
			s.insert(str);
		}
		cout << s.size()  << endl;
	}
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

/*
time: less than O(NlogN+Q) amortized
based on weighted union heuristic
*/
struct UnionFindTree{
    vector<int>par,sz;
	vector<map<int,int>>diff;
   UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
		diff.resize(n);
	
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
			diff[i][i]=0;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int a,int b,int w){
        int x=find(a),y=find(b);
        if(x==y)return;
		if(sz[x]<sz[y]){
			swap(x,y);
			swap(a,b);
			w*=-1;
		}

		w+=diff[x][a]-diff[y][b];

		for(auto &p:diff[y]){
			diff[x][p.fi]=p.se+w;
		}
		sz[x]+=sz[y];
		par[y]=x;
    }
};

int N,M;



signed main(){
	while(scanf("%lld%lld",&N,&M),N){
		UnionFindTree uf(N);
		rep(i,M){
			char c;
			scanf(" %c",&c);
			if(c=='!'){
				int a,b,w;
				scanf("%lld%lld%lld",&a,&b,&w);
				a--;b--;
				uf.unite(a,b,w);
			}
			else{
				int a,b;
				scanf("%lld%lld",&a,&b);
				a--;b--;
				if(uf.find(a)!=uf.find(b)){
					puts("UNKNOWN");
				}
				else{
					printf("%lld\n",uf.diff[uf.find(b)][b]-uf.diff[uf.find(a)][a]);
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 19444
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    A, B = ILI()
    return (A, B)


def solve(A, B):
    if A + B >= 10:
        ans = "error"
    else:
        ans = A + B
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 6304
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		char[] op = sc.next().toCharArray();
		int b = sc.nextInt();

		if (op[0] == '+') {
			pr.println(a + b);
		} else if (op[0] == '-') {
			pr.println(a - b);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9804
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
int Arr[100005];
void seive(){
		Arr[0]=Arr[1]=1;
		for(int i=2;i<100005;++i){
			if(Arr[i]==0)
			for(int j=2*i;j<100005;j+=i)
			Arr[j]=1;
		}
}
// -----------------------------------------------------------------------


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



void q1(){
	int a;
	cin>>a;
	cout<<48-a;
	
}
// -----------------------------------------------------------------------


void q2(){
	int a,b;
	cin>>a>>b;
	string s;cin>>s;
	if(s[a]!='-'){
		cout<<"No\n";
		return ;
	}
	for(int i=0;i<=a+b;++i){
		if(i==a)
		continue;
		if(!(s[i]>='0' && s[i]<='9')){
			cout<<"No\n";
			return ;
		}
	}
	cout<<"Yes\n";
}

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

void q3(){
	int n;
	cin>>n;
	int c[n-1],s[n-1],f[n-1];
	for(int i=0;i<n-1;++i)
	cin>>c[i]>>s[i]>>f[i];
	int res[n];
	res[n-1]=0;
	for(int i=n-2;i>=0;--i){
		int t=s[i]+c[i];
		for(int j=i+1;j<n-1;++j){
			if(t<=s[j]){
				t=s[j];
				t+=c[j];
			}else{
				int next = (t+f[j]-1)/f[j];
				next*=f[j];
				t=next+c[j];
			}
		}
		res[i]=t;
	}
	for(int i=0;i<n;++i)
	cout<<res[i]<<endl;
}


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

void q4(){
	seive();
	int ans[100005];
	ans[0]=ans[1]=ans[2]=0;
	for(int i=3;i<100005;++i){
		if(Arr[i]==0){
			int n=(i+1)/2;
			if(Arr[n]==0)
			ans[i]=1;
		}
	}
	for(int i=1;i<100005;++i)
	ans[i]+=ans[i-1];
	int q;cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<ans[r]-ans[l-1]<<endl;
	}
}

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


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q3();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, x) for (int i = x; i < n; i++)
#define IN(a, x, b) (a <= x && x < b)
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    int ans = 0;
    string a, b;
    cin >> a >> b;
    rep(i, a.size())
    {
        if (a[i] != b[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3912
S = input()
length = len(S)
L = length//2
if length%2==0:
    A = S[:L]
    B = S[L:]
else:
    A = S[:L]
    B = S[L+1:]
hug = 0
for i in range(L):
    if A[i] != B[::-1][i]:
        hug += 1
print(hug)

Measured memory_bytes: 3064
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

struct edge {
    int to, cost;
    bool flag = false;
};
ll N, M;
string S;
vector<edge> X[100010];
bool B[100010];
int D[100010];

int main() {
    cin >> N;
    ll ans = 1e10;
    FOR(i, 1, ceil(sqrt(N)))if (N % i == 0)if (N / i < ans)ans = N / i;
    PRI(floor(log10(ans) + 1))
    return 0;

}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  
  string s;
  cin >> s;
  if(s=="Sunny")cout<<"Cloudy" << endl;
  if(s=="Cloudy")cout<<"Rainy" << endl;
  if(s=="Rainy")cout<<"Sunny" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int list[100000];
    int c;
    c=1;
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int n;
        cin>>n;
        list[n]=c;
        c++;
    }
    for(int i=0;i<N;i++){
        cout<<list[i+1]<<" ";
    }
    return 0;
}


Measured memory_bytes: 1152
from sys import stdin
inf = 10**10
h,w = map(int,stdin.readline().rstrip().split())
li = [stdin.readline().rstrip() for _ in range(h)]
visited = [[0 for i in range(w)]for j in range(h)]
q = []
for i in range(h):
    for j in range(w):
        if li[i][j] == ".":
            continue
        q.append((i,j))
        visited[i][j] = 1
dx = [1,0,-1,0]
dy = [0,1,0,-1]
ans = -1
while q:
    qq = []
    ans += 1
    for y,x in q:
        for i,j in zip(dy,dx):
            ny,nx = i+y,j+x
            if ny < 0 or ny >= h or nx < 0 or nx >= w:
                continue
            elif li[ny][nx] == "#":
                continue
            elif visited[ny][nx] == 0:
                visited[ny][nx] = 1
                qq.append((ny,nx))
    q = qq
print(ans)

Measured memory_bytes: 123136
#define _USE_MATH_DEFINES 
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <set>
#include <locale>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;
//cout << fixed << setprecision(6);
//cout << setfill('0') << right << setw(2);

int main() {
	ll n, a, b;
	cin >> n >> a;
	rep(i, 4) {
		cin >> b;
		a = min(a, b);
	}
	cout << (n + a - 1) / a + 4 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	string a;
	cin >> a;
	if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) {
		cout << "Bad" << endl;
	}
	else cout << "Good" << endl;
}

Measured memory_bytes: 3620
// ALDS1_7_C: Tree Wslk

use std::str::FromStr;

fn scan<T: FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn scan_vec<T: FromStr>() -> Vec<T> {
    let s: String = scan();
    s.split_whitespace().map(|a| T::from_str(a).ok().unwrap()).collect()
}

struct Node {
    p: Option<usize>,
    l: Option<usize>,
    r: Option<usize>,
}

impl Node {
    fn new() -> Node {
        Node { p: None, l: None, r: None }
    }
}

fn pre_parse(t: &Vec<Node>, u: Option<usize>) {
    if let Some(u) = u {
        print!(" {}", u);
        pre_parse(t, t[u].l);
        pre_parse(t, t[u].r);
    }
}

fn in_parse(t: &Vec<Node>, u: Option<usize>) {
    if let Some(u) = u {
        in_parse(t, t[u].l);
        print!(" {}", u);
        in_parse(t, t[u].r);
    }
}

fn post_parse(t: &Vec<Node>, u: Option<usize>) {
    if let Some(u) = u {
        post_parse(t, t[u].l);
        post_parse(t, t[u].r);
        print!(" {}", u);
    }
}

fn main() {
    let n: usize = scan();
    let mut t: Vec<Node> = Vec::new();

    for _ in 0..n {
        t.push(Node::new());
    }

    for _ in 0..n {
        let a: Vec<i64> = scan_vec();
        let v = if a[0] < 0 { None } else { Some(a[0] as usize) };
        let l = if a[1] < 0 { None } else { Some(a[1] as usize) };
        let r = if a[2] < 0 { None } else { Some(a[2] as usize) };
        if let Some(v) = v {
            t[v].l = l;
            t[v].r = r;
        }
        if let Some(l) = l {
            t[l].p = v;
        }
        if let Some(r) = r {
            t[r].p = v;
        }
    }

    let root = t.iter().position(|x| x.p == None);

    println!("Preorder");
    pre_parse(&t, root);
    println!();
    println!("Inorder");
    in_parse(&t, root);
    println!();
    println!("Postorder");
    post_parse(&t, root);
    println!();
}


Measured memory_bytes: 5036
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> ans(n,k-q);
	rep(i,q){
		int a;
		cin >> a;
		ans[a - 1]++;
	}
	rep(i,n){
		cout << (ans[i] <= 0 ? "No" : "Yes") << endl;
	}
}


Measured memory_bytes: 1024
from functools import lru_cache



S=input()
count=[0 for i in range(2019)]
length=len(S)
#S=int(S)
S=S+'0'
S=S[::-1]
_S=0

base=1
for i,s in enumerate(S):
    _S=base*int(s)+_S
    count[_S%2019]+=1
    base*=10
    base=base%2019
    _S=_S%2019



retval=0
for key in range(2019):
    retval+=count[key]*(count[key]-1)//2


print(retval)


Measured memory_bytes: 9748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
//typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/

#define LEN 100005

typedef struct pp
{
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x)
{
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue()
{
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}


int main()
{
	int elaps = 0, c;
	int i, q;
	P u;
	cin >> n >> q;
	
	for (i=1; i<=n; i++)
	{
		cin >> Q[i].name;
		cin >> Q[i].t;
	}
	head = 1;
	tail = n + 1;
	
	while (head != tail)
	{
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t > 0) enqueue(u);
		else cout << u.name << " " << elaps << endl;
	}
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 11324
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cctype>

using namespace std;

int main(){
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  for(int i=0; i< N; i++){
    if(i==K-1) cout << char(tolower(S[i]));
    else cout << S[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
A, B, C, X = map(int, [input() for i in range(4)])
ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i * 500 + j * 100 + k * 50 == X:
                ans += 1

print(ans)


    

Measured memory_bytes: 2940
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int long long
using namespace std;
const int maxn=100005,mod=1e9+7;
int n,k,a[maxn],jiecheng[maxn],inv[maxn],ans;
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<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		char a='-',b='1';
		putchar(a);
		putchar(b);
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}
int quickmi(int dishu,int zhishu)
{
	int kotae=1;
	while(zhishu)
	{
		if(zhishu&1)
			kotae=kotae*dishu%mod;
		dishu=dishu*dishu%mod;
		zhishu>>=1;
	}
	return kotae;
}	  
signed main()
{
    n=read(),k=read();
	for(int i=1;i<=n;++i)
		a[i]=read();
	sort(a+1,a+n+1);
	jiecheng[0]=1;
	for(int i=1;i<=100000;++i)
		jiecheng[i]=jiecheng[i-1]*i%mod;
	inv[100000]=quickmi(jiecheng[100000],mod-2);
	for(int i=99999;i>=0;--i)
		inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=k;i<=n;++i)
		ans=(ans+jiecheng[i-1]*inv[k-1]%mod*inv[i-k]%mod*a[i]%mod)%mod;
	for(int i=1;i<=n-k+1;++i)
	{
		int j=n-i;
		ans=(ans-jiecheng[j]*inv[k-1]%mod*inv[j-k+1]%mod*a[i]%mod)%mod;
	}
	write((ans%mod+mod)%mod);
    return 0;
}


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

int main(){
  string s;
  int k;
  cin >> s >> k;
  int n;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) != '1'){
      n = i;
      //cout << n << endl;
      break;
    }
  }
  if(k <= n){
    cout << 1 << endl;
  }
  else{
    cout << s.at(n) << endl;
  }
}


Measured memory_bytes: 256
/*
３つの整数 a、b、c を読み込み、a から b までの整数の中に、c の約数がいくつあるかを求めるプログラムを作成してください
 */

#include <stdio.h>

int main(void)
{
    int a, b, c;
    int i, counter = 0;

    scanf("%d %d %d", &a, &b, &c);

    for(i = a; i <= b; i++)
    {
        if (c % i == 0)
        {
            counter++;
        }
    }
    printf("%d\n", counter);
    return (0);
}


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2);
    return 0;
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if(B<=C || D<=A){
    cout << 0 << endl;
  }else{
    if(C>=A){
      if(B>=D) cout << D-C << endl;
      else cout << B-C << endl;
    }else{
      if(B>=D) cout << D-A << endl;
      else cout << B-A << endl;
    }
  }
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  string S;
  cin >> S;
  if (S.size() == 1) {
    cout << 1 << endl;
    return 0;
  }

  int ans = 0;
  char curChar = 'A';
  int num = 1;

  int idx = 0;

  while (idx < S.size()) {
    char c = S[idx];
    if (curChar != c) {
      ans++;
      curChar = c;
      idx++;
    } else {
      if (idx == S.size() - 1) {
        break;
      }
      ans++;
      idx += 2;
      curChar = 'A';
    }
  }

  cout << ans << endl;
};


Measured memory_bytes: 640
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on July 27, 2018, 11:57 AM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right; }Node;

Node Tree[MAX];
int size, Depth[MAX], Height[MAX];

int getDepth(int u);
int getSibling(int u);
void print(int u);

int main(int argc, char** argv) {
    int i, index, left, right;
    scanf("%d", &size);

    for ( i = 0; i < size; i++ ) {
      Tree[i].parent = NIL;
    }

    for ( i = 0; i < size; i++ ){
      scanf("%d %d %d", &index, &left, &right);
      Tree[index].left = left;
      Tree[index].right = right;
      if ( left != NIL ) Tree[left].parent = index;
      if ( right != NIL ) Tree[right].parent = index;
    }

    for ( i = 0; i < size; i++ ){
        Depth[i] = getDepth(i);
        Height[i] = 0;
    }

    for ( i = 0; i < size; i++ )
    {
        if ( Tree[i].left == NIL && Tree[i].right == NIL )
        {
            Height[i] = 0;
            int p = Tree[i].parent;
            int c = 1;
            while(1)
            {
                if ( p == NIL ) break;
                if ( Height[p] < c ) Height[p] = c;
                c++;
                p = Tree[p].parent;
            }
        }
    }

    for ( i = 0; i < size; i++ ) print(i);
    return (EXIT_SUCCESS);
}

int getDepth(int u)
{
    int depth = 0;
    while(1)
    {
        u = Tree[u].parent;
        if ( u == NIL ) break;
        depth++;
    }
    return depth;
}

int getSibling(int u)
{
    if ( Tree[u].parent == NIL ) return NIL;
    if ( Tree[Tree[u].parent].left != u && Tree[Tree[u].parent].left != NIL ) return Tree[Tree[u].parent].left;
    if ( Tree[Tree[u].parent].right != u && Tree[Tree[u].parent].right != NIL ) return Tree[Tree[u].parent].right;
    return NIL;
}

void print(int u){
    printf("node %d: ", u);

    printf("parent = %d, ", Tree[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int degree = 0;
    if ( Tree[u].left != NIL ) degree++;
    if ( Tree[u].right != NIL ) degree++;
    printf("degree = %d, ", degree);
    printf("depth = %d, ", Depth[u]);
    printf("height = %d, ", Height[u]);

    if ( Tree[u].parent == NIL ) printf("root\n");
    else if ( Tree[u].left == NIL && Tree[u].right == NIL ) printf("leaf\n");
    else printf("internal node\n");
}




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

int main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<int> nums;
    if (S[0] == '0') nums.push_back(0);
    for (int i = 0; i < N;) {
        int j = i;
        while(j < N && S[j] == S[i]) j++;
        nums.push_back(j - i);
        i = j;
    }

    if (S.back() == '0') nums.push_back(0);

    vector<int> sums((int)nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); i++) sums[i+1] = sums[i] + nums[i];

    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K * 2 + 1;
        if (right >= sums.size()) right = (int)sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int p, q, r;
    cin >> p >> q >> r;
    cout << min(min(p + q, q + r), r + p) << endl;
}


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

inline double add(double a, double b){
    return abs(a+b)<(1e-10)*(abs(a)+abs(b)) ? 0.0 : a+b;
}

struct vec{
    double x,y;
    vec operator-(vec b){
        return (vec){add(x,-b.x),add(y,-b.y)};
    }
    vec operator+(vec b){
        return (vec){add(x,b.x),add(y,b.y)};
    }
    vec operator*(double d){
        return (vec){x*d,y*d};
    }
    double dot(vec v){
        return add(x*v.x,y*v.y);
    }
    double cross(vec v){
        return add(x*v.y,-y*v.x);
    }
    double norm(){
        return sqrt(x*x+y*y);
    }
};
typedef vector<vec> polygon;

int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = ab.cross(ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(ab.dot(ac)<0){
        return 2; //C-A-B
    }else{
        if(ab.dot(ab)<ac.dot(ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

bool isConvex(polygon& g){
    int n=g.size()-2;
    for(int i=0;i<n;i++){
        if(!~ccw(g[i],g[i+1],g[i+2]))return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    polygon g;
    vec v;
    while(n--){
        cin >> v.x >> v.y;
        g.push_back(v);
    }
    g.push_back(g[0]);
    g.push_back(g[1]);
    cout.precision(1);
    cout << fixed;
    cout << (isConvex(g)?1:0) << endl;
    return 0;
}

Measured memory_bytes: 3220
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) { for (auto& e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B; cin >> N >> A >> B;
	cout << (N / (A + B)) * A + min(A, (N % (A + B))) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll N,K,ret=0; cin>>N>>K;
	for (int b=1; b<=N; b++)
		ret+=(N/b) * max(0LL,b-K) + max(0LL,(N%b)-K+1) - !K;
	cout<<ret<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n,k;string s;
    cin>>n>>s>>k;
    char x=s[k-1];
    for(char &a:s){
        if(a!=x)a='*';
    }
    cout<<s;
}

Measured memory_bytes: 256
def main():
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    ds = [tuple(map(int, input().split())) for _ in range(N)]
    ds.sort(key=itemgetter(0))

    ans = 0
    for a, b in ds:
        buy = min(M, b)
        M -= buy
        ans += a * buy
        if not M:
            break
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 18180
card = []
3.times do
  card << gets.split.map(&:to_i)
end
n = gets.to_i
numbers = []
n.times do
  numbers << gets.to_i
end

card.flatten!
finished = card.map { |num| numbers.include?(num) ? 0 : num }

def bingo?(c)
  return false if c.select {|n| n == 0 }.size < 3

  c[0] == 0 && c[1] == 0 && c[2] == 0 \
    || c[3] == 0 && c[4] == 0 && c[5] == 0 \
    || c[6] == 0 && c[7] == 0 && c[8] == 0 \
    || c[0] == 0 && c[3] == 0 && c[6] == 0 \
    || c[1] == 0 && c[4] == 0 && c[7] == 0 \
    || c[2] == 0 && c[5] == 0 && c[8] == 0 \
    || c[0] == 0 && c[4] == 0 && c[8] == 0 \
    || c[2] == 0 && c[4] == 0 && c[6] == 0 \
end

puts bingo?(finished) ? 'Yes' : 'No'


Measured memory_bytes: 1788
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	int n,t,h,l,te[100],ha[100],r;
	cin >> n >> t >> h >> l;
	for(int i=0;i<n;i++){
		cin >> te[i] >> ha[i] ;
	}
	r=0;
	for(int i=0;;i++){
		if(te[i%n]>0){
			te[i%n]-=1;
			r+=1;
			t+=1;
		}
		else if(ha[i%n]>0){
			ha[i%n]-=1;
			r+=10;
			h+=1;
		}
		else{
			cout << i%n+1 <<"\n";
			return 0;
		}
		if(r>=9){
			r-=9;
			te[i%n]+=r;
			t-=r;
			r=0;
		}
		if((t<0)||(t>l)){
			cout << i%n+1 <<"\n";
			return 0;
		}
	}
		
			
return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int n,k;
    cin >> n >> k;

    if(n % k == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
    return 0;
}

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

struct Edge{ int to,cost; };

typedef pair<int,int> P;
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void dijkstra(Graph &G,vector<int> &d,int n,int s){
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d.begin(),d.end(),INT_MAX);
	d[s]=0;
	que.push(P(0,s));
	
	while(!que.empty()){
		P p=que.top();
		que.pop();
		
		int a=p.second;
		if (d[a]<p.first){
			continue;
		}
		for (int i=0;i<G[a].size();i++){
			Edge e = G[a][i];
			if (d[e.to]>d[a]+e.cost){
				d[e.to]=d[a]+e.cost;
				P p2=P(d[e.to],e.to);
				que.push(p2);
			}
		}
	}
}

int main(){
	int n,i,j,k;
	vector<int> d(n);
	Edge e;
	
	cin >> n;
	
	Graph G(n);
	
	for (i=0;i<n;i++){
		cin >> k >> k;
		for (j=0;j<k;j++){
			cin >> e.to >> e.cost;
			G[i].push_back(e);
		}
	}
	
	dijkstra(G,d,n,0);
	
	for (i=0;i<n;i++){
		cout << i << " " << d[i] << endl;
	}
	
	return 0;
}

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

int main() {
	
	int N, D;
	cin >>N >>D;
	
	
	if(N%(D*2+1)!=0){
		cout <<N/(D*2+1)+1 <<endl;
	}
	else{
		cout <<N/(D*2+1) <<endl;
	}
}

Measured memory_bytes: 256