akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

vvi v;

pair<int,int> find(int n){
	rep(i,v.size())rep(j,v[i].size()){
		if(v[i][j]==n)return make_pair(i,j);
	}
	return make_pair(-1,-1);
}

int main(){
	int m;
	while(scanf("%d",&m) , m){
		int a,b;
		v.assign(m,{0});
		rep(i,m)v[i]={i+1};
		while(scanf("%d%d",&a,&b), a|b){
			auto ia=find(a), ib=find(b);
			vi &A=v[ia.first], &B=v[ib.first];
			if(b==0){
				if(ia.second==0) continue;
				while(1){
					int top=A.back();
					v.push_back({top});
					A.pop_back();
					if(top==a)break;
				}
			}else if(ia.first==ib.first){
				if(ia.second < ib.second){
					v.push_back({b,a});
					while(1){
						int top=A.back();
						if(top!=a && top!=b){
							v.push_back({top});
						}
						A.pop_back();
						if(top==a) break;
					}
				}
			}else{
				while(1){
					int top=A.back();
					A.pop_back();
					if(top==a){
						B.push_back(a);
						break;
					}else{
						v.push_back({top});
					}
				} 
			}
			v.erase(remove_if(v.begin(),v.end(),[](const vi& v){return v.size()==0; }),v.end());
		}
		vi ans;
		rep(i,v.size())if(v[i].size())ans.push_back(v[i].size());
		sort(ans.begin(),ans.end());
		rep(i,ans.size())printf("%d\n",ans[i]);
		puts("end");
	}
}

Measured memory_bytes: 1060
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer search=nil->next;
  while(search!=nil){
    if(search->key==key) return search;
    search=search->next;
  }
  return nil;
}

void init(){
  nil = (node *)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void nodedelete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = (node *)malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
  /*

   your code


  */

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	nodedelete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33936
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N;cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    char X;cin>>X;
    vec[i] = (int)(X - '0');
  }
  int ANS = 0;
  // reverse(ALL(vec));
  for (int i = 0; i < 1000; i++)
  {
    vector<int> ref (3,0);
    ref[0] = i%10;
    ref[1] = i%100/10;
    ref[2] = i/100;
    int cnt = 0;
    // DEBUG(ref);
    for (int j = 0; j < N; j++)
    {
      if(ref[cnt] == vec[j])cnt++;
      if(cnt == 3)
      {
                ANS++;
        break;

      }
      // DEBUG(cnt);
    }
    
  }
  cout<<ANS<<endl;
  
  

  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; ++i) {
            long current = scanner.nextLong();
            a[i] = current;
        }

        List<Long> numbers = new ArrayList<>();
        for (long num : a) {
            int value = Collections.binarySearch(
                    numbers, num
            );
            if (value >= 0 && value < numbers.size()) {
                int lessValue = Collections.binarySearch(
                        numbers, num - 1
                );
                if (lessValue >= 0 && lessValue < numbers.size()) {
                    numbers.set(lessValue, num);
                } else {
                    int lessPos = -1 * (lessValue + 1);
                    if (lessPos - 1 >= 0 && numbers.get(lessPos - 1) < num) {
                        numbers.set(lessPos - 1, num);
                    } else {
                        numbers.add(value, num);
                    }
                }
                continue;
            }

            int pos = -1 * (value + 1);
            if (pos - 1 >= 0 && numbers.get(pos - 1) < num) {
                numbers.set(pos - 1, num);
            } else {
                numbers.add(pos, num);
            }


        }
        System.out.println(numbers.size());

    }
}


Measured memory_bytes: 60836
#include <stdio.h>

int main(void)
{
    long long t, a, b, c, i = 0, k;
    scanf("%lld", &t);

    for(a = 1; a <= t; a++) {
        for(b = a; b <= t; b++) {
            for(c = b; c <= t; c++) {
                for(k = a; k >= 1; k--)
                    if(a % k == 0 && b % k == 0 && c % k == 0) {
                        if(a == b && b == c){
                        i += k; break;}
                        if(a == b || b == c){
                        i += k*3; break;}
                        i += k*6; break;
                    }
            }
        }
    }

    printf("%lld", i);
	return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<string>

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

    bool ansf = true;

    for (int i = 0; i < s.length(); i++) {
        if(i%2 == 0) {
            if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
                ansf = false;
            }
        } else {
            if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
                ansf = false;
            }
        }
    }

    std::string ans = ansf ? "Yes" : "No";

    std::cout << ans << std::endl;
}

Measured memory_bytes: 384
# Acceptance of input
import sys

file_input = sys.stdin

n = file_input.readline()

EP = []
l = -1000000001
r = 1000000001

for line in file_input:
    x1, y1, x2, y2 = (map(int, line.split()))
    if y1 == y2:
        EP.append((min(x1, x2), l, y1))
        EP.append((max(x1, x2), r, y1))
    else:
        EP.append((x1, min(y1, y2), max(y1, y2)))

# Sweep
import bisect

EP.sort()
BT = []
cnt = 0

for p in EP:
    y1 = p[1]
    if y1 == l:
        bisect.insort(BT, p[2])
    elif y1 == r:
        i = bisect.bisect_left(BT, p[2])
        BT.pop(i)
    else:
        cnt += bisect.bisect(BT, p[2]) - bisect.bisect_left(BT, y1)

# Output
print(cnt)

Measured memory_bytes: 27032
//Littleboy123 Template 1.1

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

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

//End of template

int main(){
	init();

	//debug
	/*
	ifstream in("input.in");
	streambuf *cinbuf = std::cin.rdbuf();
	cin.rdbuf(in.rdbuf());

	ofstream out("out.txt");
	streambuf *coutbuf = std::cout.rdbuf();
	cout.rdbuf(out.rdbuf());
	*/
	//end debug

	string s;
	cin >> s;
	cout << "2018" << s.substr(4, s.length()) << nl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var n, q int
	var s string
	fmt.Scan(&n, &q, &s)

	xs := make([]int, n)
	xs[0] = 0
	for i := 1; i < n; i++ {
		if s[i-1] == 'A' && s[i] == 'C' {
			xs[i] = xs[i-1] + 1
		} else {
			xs[i] = xs[i-1]
		}
	}

	var l, r int
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < q; i++ {
		sc.Scan()
		l, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ = strconv.Atoi(sc.Text())
		fmt.Println(xs[r-1] - xs[l-1])
	}
}


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

int main(){
	int sum = 0;
	string k;
	cin >> k;
	for(int i = 0; i < k.length(); i++){
		if(k[i] == '+')
			sum++;
		else
			sum--;
	}
	cout << sum << endl;

	return 0;
}

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

int main(){

        int A[3];
        int i,j;
        int tmp;

        cin >> A[0] >> A[1] >> A[2];

        for(i=0;i<3;i++){
                for(j=i+1;j<3;j++){
                        if(A[i]<A[j]){
                        tmp=A[i];
                        A[i]=A[j];
                        A[j]=tmp;
                        }
                }
        }

        cout << (A[0]-A[1])+(A[1]-A[2]);


        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int p = 0, m = 0, a, b;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i < 0) {
			m++;
		}
		else if (i == 0) {
			cout << "Zero" << endl;
			return 0;
		}
	}
	if (m % 2 == 0) {
		cout << "Positive" << endl;
		return 0;
	}
	else {
		cout << "Negative" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
p = 10 ** 8
ans = 0
for i in range(n):
    x = t - h[i] * 0.006
    x = abs(a - x)
    if p > x:
        p = x
        ans = i + 1
print(ans)

Measured memory_bytes: 9252
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

const int MAX = 2e5 + 10;
int N, M;
int A[MAX], B[MAX];
VI G[MAX];

int ans[MAX];
void calc_dist() {
    fill(ans, ans + MAX, -1);
    queue<int> que;
    que.emplace(0);
    while (!que.empty()) {
        const auto el = que.front();
        que.pop();
        FORE(e, G[el]) if (ans[e] == -1) {
            ans[e] = el;
            que.emplace(e);
        }
    }
}

int main(void) {
    cin >> N >> M;
    REP(i, M) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        G[A[i]].EB(B[i]);
        G[B[i]].EB(A[i]);
    }
    calc_dist();

    REP(i, N - 1) if (ans[i + 1] == -1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    REP(i, N - 1) {
        cout << ans[i + 1] + 1 << endl;
    }
}


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

int main()
{
	int Q;
	cin >> Q;
	for (int ite = 0; ite < Q; ite++) {
		long long int N,res = 0;
		cin >> N;
		while (N >= 10) {
			long long int max = 0;
			for (long long int i = 1; i <= N; i *= 10) {
				if (max < (N % i) * (N / i)) {
					max = (N % i) * (N / i);
				}
			}
			N = max;
			res++;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int a,b,c,d;
    bool flag=false;
    cin>>a>>b>>c>>d;
    if(abs(c-a)<=d) flag=true;
    if(abs(b-a)<=d&&abs(c-b)<=d) flag=true;
    if(flag) cout <<"Yes" <<endl;
    else cout <<"No" <<endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ll;

const int MOD = 1000000007;

int f[100005];

int main() {
	int N;

	cin >> N;

	for (int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		f[t]++;
		f[t + 1]++;
		f[t + 2]++;
	}

	int maxl = 0;
	for (int i = 0; i < 100005; ++i) {
		maxl = max(maxl, f[i]);
	}
	cout << maxl << endl;
}

Measured memory_bytes: 640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <chrono> 
using namespace std::chrono;
#define fl(i,z,n) for(int i=z;i<=(n);i++)
#define flr(i,z,n) for(int i=z;i>=(n);i--)
using namespace std;
#define ll long long 
#define pa(a,s) fl(i,0,s-1) cout<<*(a+i)<<" "; cout<<nl;
#define pv(v) fl(i,0,v.size()-1) cout<<v[i]<<" "; cout<<nl;
#define read(v) fl(i,0,v.size()-1) cin>>v[i];
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define vll vector<ll>
#define sll set<ll>
#define spll set<pll>
#define debnl(x) cout<<#x<<"="<<x<<nl;
#define deb(x) cout<<#x<<"="<<x<<" ";
#define mkp(x,y) make_pair(x,y)
#define ump unordered_map
#define ff first
#define ss second
#define in insert
#define sz size
#define len length
#define nl '\n'
#define pb push_back
#define in insert
#define ub upper_bound
#define lb lower_bound
#define ld long double
const int MXN=1e5;
ll mod=1e9+7;
void solve(){
    ll n;
    cin>>n;
    vll v(n);
    read(v);
    vll p(n);
    ll sum=0;
    p[n-1]=v[n-1];
    sum=v[n-1];
    flr(i,n-2,1){
        p[i]=(v[i]+p[i+1])%mod;
    }
    ll ans=0;
    fl(i,0,n-2){
        ans+=(v[i]*p[i+1])%mod;
        ans%=mod;
    }
    cout<<ans<<nl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); ll t=1;
    //cin>>t; //comment for single test
    while(t--) solve();
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    cout << fixed;
    cout << setprecision(10);
    if(N%2==0) cout << double(1.0/2.0) << endl;
    else cout << (double(N/2)+1.0)/double(N) << endl;

    return 0;
}

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

#define LL long long
const int N = 1e6 + 5, mod = 1e9 + 7;
bool A[N], B[N];
int n, m, x;
LL ans = 1, r, c, tc, tr;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        cin >> x;
        if(A[x]) {return cout << 0, 0;}
        A[x] = 1;
    }

    for(int i = 0; i < m; i++) {
        cin >> x;
        if(B[x]) {return cout << 0, 0;}
        B[x] = 1;
    }

    for(int i = n * m; i > 0; i--) {
        tc = c, tr = r;
        if(A[i]) {tr = 1, r++;}
        if(B[i]) {tc = 1, c++;}
        if(A[i] || B[i]) {ans *= (tc * tr) % mod;}
        else ans *= (tc * tr - (n * m - i)) % mod;
        ans %= mod;
    }
    cout << ans;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
  int n;
  cin >> n;
  ll sum = 0;
  int a[n],b[n],c[n-1];
  rep(i, n) cin >> a[i];
  rep(i, n) {
    cin >> b[i];
    sum += b[i];
  }
  rep(i, n-1) cin >> c[i];

//  ll sum = 0;
  rep(i, n){
    if(i != n-1){
      if(a[i+1] == a[i] + 1){
        sum += c[a[i]-1];
      }
    }
  }
  cout << sum << endl;
  return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    bool first_bit = s[0] - '0';
    vi nums(n);
    int m = 0;
    s += 'p'; // padding bit
    repeat(i, 1, n + 1) {
        int num = 1;
        while (s[i] == s[i - 1]) {
            num++;
            i++;
        }
        nums[m] = num;

        // debug(m);
        // debug(nums[m]);
        m++;
    }

    vl accum(m + 1, 0);
    accum[0] = nums[0];
    repeat(i, 1, m) {
        accum[i] = accum[i - 1] + nums[i];

        // debug(i);
        // debug(accum[i]);
    }

    ll ans = 0;
    rep(i, m) {
        bool bit;
        if (i % 2 == 0) {
            bit = first_bit;
        } else {
            bit = !first_bit;
        }
        if (bit) {
            ans = max(ans, accum[min(m - 1, 2 * k + i)] - (i - 1 < 0 ? 0 : accum[i - 1]));
        } else {
            ans = max(ans, accum[min(m - 1, 2 * k - 1 + i)] - (i - 1 < 0 ? 0 : accum[i - 1]));
        }
        // debug(bit);
        // debug(ans);
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 1664
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)


Measured memory_bytes: 47540
N,K=map(int,input().split())
if K==0:
  print(N**2)
  exit(0)
ans=0
for i in range(K+1,N+1):
  base=i-(K-1)-1
  ans+=(N//i)*base
  rest=N%i
  ans+=max(rest-(K-1),0)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }


signed main(){
  string s;
  cin >> s;
  int n = s.size();
  int x,y;
  cin >> x >> y;
  vint xary;
  vint yary;
  int cnt = 0;
  bool flag = true;
  rep(i,0,n){
    if(s[i] == 'T'){
      if(flag){
        xary.push_back(cnt);
        flag = false;
      }
      else{
        yary.push_back(cnt);
        flag = true;
      }
      cnt = 0; 
    }
    else if(s[i] == 'F'){
      cnt++;
    }
  }
  if(cnt > 0){
    if(flag){
        xary.push_back(cnt);
        flag = false;
      }
      else{
        yary.push_back(cnt);
        flag = true;
      }
  }
  /* rep(i,0,xary.size()){
    cout << xary[i] << endl;
  }
  cout << endl; */
  vector<set<int>> xans(11010);
  vector<set<int>> yans(11010);
  xans[0].insert(0);
  yans[0].insert(0);
  rep(i,0,xary.size()){
    if(i != 0){
      for(auto p:xans[i]){
        xans[i+1].insert(p+xary[i]);
        xans[i+1].insert(p-xary[i]);
      }
    }
    else if(i == 0){
      for(auto p:xans[i]){
        xans[i+1].insert(p + xary[i]);
      }
    }
  }
  rep(i,0,yary.size()){
    for(auto p:yans[i]){
      yans[i+1].insert(p+yary[i]);
      yans[i+1].insert(p-yary[i]);
    }
  }
  bool xflag = false;
  bool yflag = false;
  /* rep(i,0,xary.size()){
    for(auto p:xans[i]){
      cout << p << endl;
    }
    cout << endl;
  } */
  for(auto p:xans[xary.size()]){
    if(p == x) xflag = true;
  }
  for(auto p:yans[yary.size()]){
    if(p == y) yflag = true;
  }
  if(xflag && yflag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 233088
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	Vi a(n);
	rep(i,n){
		cin>>a[i];
		a[i]--;
	}
	rep(i,n){
		if(a[a[i]]==i){
			ans++;
		}
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

void bubble_sort(int *data, int n);
void swap(int *a, int *b);

int main(void)
{
	int n;
	int num_line[5000];
	int sum_max;
	int i, j, k, temp;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0)	break;
		
		memset(num_line, 0, sizeof(num_line));
		
		for (i = 0; i < n; i++){
			scanf("%d", &num_line[i]);
		}
		
		sum_max = -1;
		for (i = 0; i < n; i++){
			temp = 0;
			for (k = 0; k < n; k++){
				if (i > k) continue;
				temp += num_line[k];
				if (temp > sum_max) sum_max = temp;
			}
		}
		
		bubble_sort(num_line, n);
		if (num_line[0] <= 0) sum_max = num_line[0];
		
		printf("%d\n", sum_max);
	}
	return (0);
}

void bubble_sort(int *data, int n){
	int i, j;
	for (i = 0; i < n - 1; i++) for (j = 0; j < n - i - 1; j++) if (data[j] < data[j + 1]) swap(&data[j], &data[j + 1]);
}

void swap(int *a, int *b)
{
	*a ^= *b;
	*b ^= *a;
	*a ^= *b;
}

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

int main() {
    int n,m;
    cin >> n >> m;
    int A[100][100], b[100];
    for(int i=0; i<n; i++){
        for(int j=0;j<m;j++){
            cin >> A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<m;j++){
            sum += A[i][j] * b[j];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3108
<?php

function createPermutation($n, $r)
{
    if (!$r || $n < $r) {
        return array();
    }

    $return = array();
    $n2 = $n - 1;

    if ($r == 1) {
        for ($i=0; $i < $n ; $i++) {
            $return[] = array($i);
        }
        return $return;
    }
    //(n-1)Prは、ほしい順列の一部
    foreach (createPermutation($n2, $r) as $row) {
        $return[] = $row;
    }
    //(n-1)P(r-1)各行の左端から右端まで、n-1を挿入したものを追加。
    foreach (createPermutation($n2, $r-1) as $row) {
        for ($i=0; $i < $r; $i++) {
            $return[] = array_merge(array_slice($row, 0, $i), array($n2), array_slice($row, $i));
        }
    }
    return $return;
}

fscanf(STDIN, "%d", $in_n);
for($i = 0; $i < $in_n; $i++){
    fscanf(STDIN, "%d %d", $in_x[$i], $in_y[$i]);
}
//var_dump($in_x);
//var_dump($in_y);
$kyori_goukei = 0;
$arr_junban = createPermutation($in_n,$in_n);

//var_dump($arr_junban);

foreach($arr_junban as $junban){
//    var_dump("junban");
//    var_dump($junban);
    for($i = 0; $i < ($in_n - 1); $i++){
//        var_dump("test");
//        var_dump($i);
//        var_dump($in_x[$junban[$i]]);
//        var_dump($in_x[$junban[$i+1]]);
//        var_dump($in_y[$junban[$i]]);
//        var_dump($in_y[$junban[$i+1]]);
//        var_dump(pow(abs($in_x[$junban[$i]] - $in_x[$junban[$i+1]]),2) + pow(abs($in_y[$junban[$i]] - $in_y[$junban[$i+1]]),2));
        $kyori_goukei = $kyori_goukei + (sqrt(pow(abs($in_x[$junban[$i]] - $in_x[$junban[$i+1]]),2) + pow(abs($in_y[$junban[$i]] - $in_y[$junban[$i+1]]),2)));
    }
}

$ans = $kyori_goukei / (count($arr_junban));

echo "$ans\n";

?>

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

int main() {
  long long a,b;
  cin >> a >> b;
  if(a>1 && b>1){
    cout << a*b-((a-1)*2+(b-1)*2) << endl;
  }
  else if(a>1 || b>1) cout << a*b-2 << endl;
  else cout << 1 << endl;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    string s;
    cin >> s;
    deque<char> st;
    rep(i, s.size())
    {
        if (s[i] == '0')
        {
            st.push_back('0');
        }
        else if (s[i] == '1')
        {
            st.push_back('1');
        }
        else
        {
            if (!st.empty())
                st.pop_back();
        }
    }
    rep(i, st.size())
    {
        cout << st.at(i);
    }
    cout << endl;
}


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

#define int long long
#define ld long double

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>b;i--)

#define pb push_back
#define mp make_pair
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define precise(i) fixed << setprecision(i)
#define fi first
#define se second

#define err() cout<<"\n==================================\n";
#define errA(A) for(auto i:A) cout<<i<<" "; cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n";
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n";
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<"\n";

const int logN = 20;
const int M = 1000000007;
const int INF = 1e12;
#define PI 3.14159265;
const int N = 200005;

#define Pii pair<int,int>
#define Vi vector<int>
#define Vpii vector<Pii>

int a[6][6]={};
int row[6]={};
int col[6]={};

void solve()
{
       int h,w,k,num=0,black=0;
       cin>>h>>w>>k;
       rep(c,0,h)
       {
              rep(d,0,w)
              {
                   char x;
                   cin>>x;
                   if(x=='#')
                   {
                          black++;
                          a[c][d]=1;
                          row[c]++;
                          col[d]++;
                   }
              }
       }
       k=(black-k);
       rep(c,0,pow(2,h))
       {
              Vi ro;
              rep(i,0,h)
              {
                     if(c&(1<<i))
                     {
                            ro.pb(i);
                     }
              }
              rep(d,0,pow(2,w))
              {
                     Vi co;
                     rep(j,0,w)
                     {
                            if(d&(1<<j))
                            {
                                   co.pb(j);
                            }
                     }
                     int tot=0;
                     for(int x:ro)
                     {
                            tot+=row[x];
                     }
                     for(int x:co)
                     {
                            tot+=col[x];
                     }
                     for(auto x:ro)
                     {
                            for(auto y:co)
                            {
                                   if(a[x][y])
                                   {
                                          tot--;
                                   }
                            }
                     }
                     if(tot==k)
                     {
                            num++;
                     }
              }
       }
       cout<<num;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)
    {
           solve();
    }
    return 0;
}

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

int main() {
  
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  
  if (L > R) cout << "Left" << endl;
  else if (L==R) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  
}

Measured memory_bytes: 256
from itertools import*
n=int(input())
a=[[s for s in input().split()]for _ in range(n)]
for b in a:
 b[3],b[4]=b[4],b[3]
def f():
 for d,e in combinations(a,2):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[i]for i in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(f())


Measured memory_bytes: 5652
from bisect import bisect_left
n = int(input())
l = [int(_) for _ in input().split()]
l.sort()
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        cnt += max(0, bisect_left(l, l[i] + l[j]) - (j+1))
print(cnt)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define fi first
#define se second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
const int MAXN = 2e5+10;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    map<int,vector<int>> m;
    map<int,int> ans;
    int n;
    pii a[MAXN];
    int b[MAXN]={0};
    cin>>n;
    rep(n) 
    {
        cin>>a[i].fi;
        a[i].se = i;
        // m[a[i]].pu(i);
    }
    sort(a,a+n);
    rep(n)
    {
        if((i+1)<=n/2)
            ans[a[i].se] = a[n/2].fi;
        else
            ans[a[i].se] = a[n/2-1].fi;     
    }
    rep(n)
    {
        cout<<ans[i]<<endl; 
    }
    return 0;

}
    

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

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

typedef long long ll;


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

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

  string ans = "AC";
  if (s[0] != 'A') 
  {
    ans = "WA";
  }
  
  int count_C = 0;
  rep(i, s.size()) {
    if (s[i] == 'C' && i >= 2 && i < s.size() - 1)
    {
      /* code */
      count_C++;
    }
    else
    {
      /* code */
      if (i != 0 && !islower(s[i]))
      {
        /* code */
        ans = "WA";
      }
    }
  }
  ans = (count_C != 1) ? "WA" : ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 30;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

bool collision_detection( double x1, double y1, double x2, double y2, double x3, double y3, double xp, double yp ) {
	x2 -= x1;
	x3 -= x1;
	xp -= x1;
	y2 -= y1;
	y3 -= y1;
	yp -= y1;
	double t_size = fabs( ( x2 * y3 - y2 * x3 ) / 2 );
	t_size -= fabs( ( x2 * yp -  y2 * xp ) / 2 );
	t_size -= fabs( ( x3 * yp -  y3 * xp ) / 2 );
	x2 -= xp;
	x3 -= xp;
	y2 -= yp;
	y3 -= yp;
	yp = xp = 0;
	t_size -= fabs( ( x2 * y3 - y2 * x3 ) / 2 );
	return fabs( t_size ) < 1e-10;
}

int main() {
	double x[ 4 ], y[ 4 ];
	while ( ~scanf( "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x[ 0 ], &y[ 0 ], &x[ 1 ], &y[ 1 ], &x[ 2 ], &y[ 2 ], &x[ 3 ], &y[ 3 ] ) ) {
		bool print_yes = true;
		for ( int i = 0; i < 4; i++ ) {
			if ( collision_detection( x[ ( i + 1 ) % 4 ], y[ ( i + 1 ) % 4 ], x[ ( i + 2 ) % 4 ], y[ ( i + 2 ) % 4 ], x[ ( i + 3 ) % 4 ], y[ ( i + 3 ) % 4 ], x[ i ], y[ i ] ) ) {
				print_yes = false;
				break;
			}
		}
		printf( "%s\n", print_yes ? "YES" : "NO" );
	}
	return 0;
}

Measured memory_bytes: 1192
N = int(input())
A = list(map(int, input().split()))


cnt_1 = 0
cnt_2 = 0
for i in A:
	if i%2 ==0:
		cnt_1 += 1
		if i%3 == 0 or i%5==0:
			cnt_2 += 1
if cnt_1 == cnt_2:
	print('APPROVED')
else:
	print('DENIED')

Measured memory_bytes: 3060
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

vll x[1000];

int main() {
	ll n;
	cin >> n;
	ll k = -1;
	REP(i, 1, n+2) {
		if (i*(i - 1) / 2 == n) {
			k = i;
			break;
		}
	}
	if (k == -1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	ll u = 1;
	ll v = 2;
	REP(i, 1, n) {
		x[u].push_back(i);
		x[v].push_back(i);
		if (v == k) {
			u++;
			v = u + 1;
		}
		else {
			v++;
		}
	}
	cout << k << endl;
	REP(i, 1, k) {
		cout << k - 1 << " ";
		REP(j, 0, SIZE(x[i]) - 1) {
			cout << x[i][j];
			if (j < SIZE(x[i]) - 1) { cout << " "; }
		}
		cout << endl;
	}
}



Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main(){
  int n,i,a,b,c,d;
  a=0;
  b=0;
  c=0;
  d=0;
  cin >> n;
  string s[n]; 
  
  for(i=0;i<n;i++){
    cin >> s[i];
  }
  
  for(i=0;i<n;i++){
    if(s[i]=="AC"){
      a++;
    }else if(s[i]=="WA"){
      b++;
    }else if(s[i]=="TLE"){
      c++;
    }else if(s[i]=="RE"){
      d++;
    }
  }
  
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}


Measured memory_bytes: 6748
INF = 10 ** 9

class NilClass
  def +(i)
    return nil
  end
end

def dfs(a, b, c, k)
  
  if k == N
    return nil if [a, b, c].min == 0
    return (A-a).abs + (B-b).abs + (C-c).abs - 10 * 3
  end
  
  x = dfs(a+L[k], b, c, k+1) + 10
  y = dfs(a, b+L[k], c, k+1) + 10
  z = dfs(a, b, c+L[k], k+1) + 10
  w = dfs(a, b, c, k+1)
  
  [x, y, z, w].compact.min
end

N, A, B, C = gets.split.map(&:to_i)

L = Array.new(N)
N.times{ |i| L[i] = gets.to_i }

p dfs(0, 0, 0, 0)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)



int32_t main()
{
    boost;
 
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n>0){
        ans++;
        n/=k;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(String::toInt)
    val b = readLine()!!.split(" ").map(String::toInt)

    val ans = (0..N-1).map { a.subList(0, it+1).sum() + b.subList(it, b.size).sum() }.max()
    println(ans)
}

Measured memory_bytes: 37572
n = int(input())
A = [list(map(int,input().split())) for i in range(n)]

# def gcd(x, y):
#     #print(x, y)
#     while x != 0 and y != 0:
#         x, y = max(x, y), min(x, y)
#         x %= y
#     return y

# def lcm(x, y):
#     return x * y // gcd(x, y)

# for i in range(1, n):
#     lcms = [0] * 2
#     for j in range(2):
#         lcms[j] = lcm(A[i][j], A[i-1][j])
#     print("lcms", lcms)
#     st = 0
#     op = 1
#     if lcms[0] > lcms[1]:
#         st = 1
#         op = 0
#     new_1 = (lcms[st] // A[i][st]) * A[i][op]
#     print(new_1)
#     if new_1 >= A[i-1][op]:
#         A[i][op] = new_1
#         A[i][st] = lcms[0]
#     else:
#         new_0 = lcms[op] // A[i][op] * A[i][st]
#         A[i][st] = new_0
#         A[i][op] = lcms[op]
#     print(A[i])

# print(sum(A[-1]))

for i in range(1, n):
    s = -(-A[i-1][0] // A[i][0])
    t = -(-A[i-1][1] // A[i][1])
    # print(i,s,t)
    for j in range(2):
        A[i][j] *= max(s, t)
    # print(A)
    
print(sum(A[-1]))

Measured memory_bytes: 40560
//written by NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    register char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int N = 103;

int main() {
    int n = read(), k = read();
    printf("%d\n", n - k + 1);
    return 0;
}


Measured memory_bytes: 128
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public void run() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		long[] A = new long[K];
		for (int i = 0; i < K; ++i) {
			A[i] = sc.nextLong();
		}
		long max = 2;
		long min = 2;
		for (int i = K - 1; i >= 0; --i) {
			if (max < A[i]) {
				System.out.println(-1);
				return;
			}
			max = max / A[i] * A[i];
			min = (min + A[i] - 1) / A[i] * A[i];
			max += A[i] - 1;
			if (max < min) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(min + " " + max);
	}


	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}
}


Measured memory_bytes: 55916
import java.util.Scanner;

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

	int N = scan.nextInt();
	int X = scan.nextInt();

	int min = Integer.MAX_VALUE;
	int sum = 0;
	int[] m_ = new int[N];
	for(int i = 0; i < N; i++){
	    m_[i] = scan.nextInt();
	    if(m_[i] < min){
		min = m_[i];
	    }
	    sum += m_[i];
	}

	X -= sum;

	int count = N + (X/min);

	System.out.println(count);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,ans;
vll a,b;

bool is_even(int l, string s){return s.substr(0,l/2) == s.substr(l/2);}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);

    cin >> n;
    bool res = false;
    if(n%10==7) res = true;
    n/=10;
    if(n%10==7) res = true;
    n/=10;
    if(n%10==7) res = true;

    cout << (res?"Yes":"No") << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

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;}
//-----------------------------------------------------------------------

string table[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

int n; cin>>n;
while(n--)
{
    string s; cin>>s;
    int cnt=0,idx;
    REP(i,s.size()){
        if(s[i]!='0'){
            cnt++;
            idx=s[i]-'0';
        } else{
            if(cnt>0) cout<<table[idx][(cnt-1)%table[idx].size()];
            cnt=0;
        }
    }
    cout<<endl;
}
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
# define ALL(x) (x).begin(), (x).end()
using namespace std;
int main()
{string post;
 int a,i;
 char pp='?';
 cin>>post;
 a=post.size();
 if(a==1&&post.at(0)==pp){post.at(0)='D';}
 for(i=1;i<a;i++)
 { if(i==1&&post.at(0)==pp)
 {
  post.at(0)='D'; 
 }
   if(post.at(i)==pp&&post.at(i-1)=='P')
   {
     post.at(i)='D';
   }
   if(post.at(i)==pp&&post.at(i-1)=='D'){post.at(i)='D';}
 }
 cout<<post<<endl;
return 0;
}

Measured memory_bytes: 3756
import math
prime = [True]*(55555)
prime[0],prime[1] = False,False
for i in range(2, int(math.sqrt(55555))+1):
	if not prime[i]: continue
	for j in range(i*2,55555,i): prime[j] = False
n = int(input())
x,num = [2,7,17,37,47],57
while len(x)!=n:
	 num+=10
	 if prime[num]: x.append(num)
for i in x[:n-1]: print(i,end=" ")
print(x[-1])

Measured memory_bytes: 3444
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

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

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

static const int N = 100;

signed main() {
	ios::sync_with_stdio(false);
	int n, p[N + 1], m[N + 1][N + 1];
	cin >> n;
	int i;
	FOR(i, 1, n + 1) {
		cin >> p[i - 1] >> p[i];
	}
	FOR(i, 1, n + 1) m[i][i] = 0;
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l +1 ; i++) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k <= j - 1; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	cout << m[1][n] << '\n';
	return 0;
}


Measured memory_bytes: 3232