akhauriyash/Code-Regression huggingface dataset:
import sys
import heapq
import math
def input(): return sys.stdin.readline().rstrip()
def main():
    n, k = map(int,input().split())
    A = list(map(int,input().split()))
    def is_good(mid, key):
        kk = 0
        for a in A:
            kk += -(-a//mid)-1
        if kk <= key:
            return True
        else:
            return False
    def bi_search(bad, good, key):
        while good - bad > 1:
            mid = (bad + good)//2
            if is_good(mid, key):
                good = mid
            else:
                bad = mid
        return good
    
    print(bi_search(0, max(A), k))
    
    
    


if __name__=='__main__':
    main()

Measured memory_bytes: 31104
#include <stdio.h>          // printf(), scanf(), getchar()
#include <ctype.h>          // isdigit()
#include <stdbool.h>

#define MAX_N 100000
#define min(a, b) ((a) < (b) ? (a) : (b))

int a[MAX_N];
int S;
int n;

int
solve()
{
	int s, t;

	int res = n + 1;
	int sum = 0;
	s = 0, t = 0;
	while (true)
	{
		while (t < n && sum < S)
			sum += a[t++];

		if (sum < S)
			break;

		res = min(res, t - s);
		sum -= a[s++];
	}

	if (res > n)
		return 0;

	return res;
}

int
main(int argc, char** argv)
{
	int d;
	int c;
	int i;

	scanf("%d %d", &n, &S);
	c = getchar();
	for (i = 0; i < n; ++i)
	{
		while (c == ' ' || c == '\n')
			c = getchar();

		d = 0;
		while (isdigit(c))
		{
			d = d * 10 + c - '0';
			c = getchar();
		}

		a[i] = d;
	}

	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 984
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n, m;
	cin >> n >> m;
	vector<pair<long, long>> ps;
	for (int i = 0; i < n; i++)
	{
		long a;
		cin >> a;
		ps.push_back({a, 1});
	}
	while(m--)
	{
		long b, c;
		cin >> b >> c;
		ps.push_back({c, b});
	}
	sort(ps.rbegin(), ps.rend());
	long ans = 0, cnt = n;
	auto it = ps.begin();
	while (cnt && it != ps.end())
	{
		long res = min(cnt, it->second);
		ans += res*it->first;
		cnt -= res;
		it++;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
string S;
int sums,sumt;
int main()
{
    cin>>S;
    for(int i=0;i<S.size();i++)
    {
        if(S[i] == 'S') sums++;
        if((sums)&&(S[i]=='T'))
        {
            sums--;
            sumt+=2;
        }
    }
    cout<<S.size()-sumt<<"\n";
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;
use std::collections::*;
use std::cmp::*;


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let n:usize = read();
    let mut C: Vec<i64> = vec![0;n - 1];
    let mut S: Vec<i64> = vec![0;n - 1];
    let mut F: Vec<i64> = vec![0;n - 1];
    for i in 0..n - 1{
        let a:Vec<i64> = (0..3).map(|_| read()).collect();
        C[i] = a[0];
        S[i] = a[1];
        F[i] = a[2];
    }
    for i in 0..n{
        let mut time:i64 = 0;
        for j in i..n - 1{
            if j == i {
                time = S[j] + C[j];
            }else{
                if time <= S[j] {
                    time = S[j] + C[j];
                }else{
                    let mut cnt = S[j];
                   while cnt < time {
                       cnt += F[j];
                   }
                    time += cnt - time;
                    time += C[j];
                }
            }
        }
        println!("{}",time);
    }
}

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

#define DeltaCube23 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define minimum(a) *min_element(a.begin(), a.end())
#define maximum(a) *max_element(a.begin(), a.end())
#define MOD 1000000007
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i >= (b); i--)

typedef long long int lli;

using namespace std;

const int mx=1e5+5;

int main()
{
    DeltaCube23
    int t=1;
    //cin>>t;
    while(t--)
    {
        lli n;
        cin>>n;
        string s;
        while(n)
        {
            lli r=n%26;
            char c;
            if(r==0)
            {
                c='z';
                n=n-1;
            }
            else
            c='a'+(r-1);
            s+=c;
            n=n/26;
        }
        
        reverse(s.begin(),s.end());
        cout<<s<<"\n";    
    }
    return 0;
}

Measured memory_bytes: 3616
n = int(input())
w1 = input()
words = set([w1])
for _ in range(n-1):
    w2 = input()
    if w2 in words:
        print("No")
        break
    elif w2[0]!=w1[-1]:
        print("No")
        break
    else:
        words.add(w2)
        w1 = w2
else:
    print("Yes")

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int angka;
	scanf ("%d", &angka);
	
	bool cekAngka = false;
	for (int i = 1 ; i<=9; i++){
		for (int j = 1; j <=9; j++){
			if (angka == (i*j)){
				cekAngka = true;
				break;
			}
		}
	}
	
	if (cekAngka){
		puts("Yes");
	}
	else {
		puts ("No");
	}
	return 0;
}

Measured memory_bytes: 1648
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	ids := [1010][1010]int{}
	id := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			ids[i][j] = id
			ids[j][i] = id
			id++
		}
	}

	used := make(map[[2]int]bool)
	g := make([][]int, n*(n-1)/2)
	for i := 0; i < n; i++ {
		pre := -1
		for j := 0; j < n-1; j++ {
			a := nextInt() - 1
			cur := ids[i][a]
			key := [2]int{pre, cur}
			if !used[key] && pre != -1 {
				g[pre] = append(g[pre], cur)
			}
			used[key] = true
			pre = cur
		}
	}

	ans := tsort(g)
	fmt.Println(ans)
}

func tsort(g [][]int) int {
	nn := len(g)
	ins := make([]int, nn)

	for i := 0; i < nn; i++ {
		for _, u := range g[i] {
			ins[u]++
		}
	}

	ds := make([]int, nn)
	q := make([]int, 0)
	for i := 0; i < len(ins); i++ {
		if ins[i] == 0 {
			ds[i] = 1
			q = append(q, i)
		}
	}

	ans := 0
	sorted := make([]int, 0)
	for len(q) > 0 {
		u := q[0]
		q = q[1:]
		sorted = append(sorted, u)
		for _, v := range g[u] {
			ins[v]--
			if ins[v] == 0 {
				ds[v] = max(ds[v], ds[u]+1)
				ans = max(ans, ds[v])
				q = append(q, v)
			}
		}
	}
	if len(sorted) != nn {
		ans = -1
	}

	return ans
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

int main(int argc, const char * argv[]) {
    
    int a[3][6];
    int t[3][3];
    
    
    for(int i=0;i<3;i++){
        for(int j=0;j<6;j++){
            cin >> a[i][j];
        }
    }
    
    for(int i=0;i<3;i++){
        
        t[i][2]=a[i][5]-a[i][2];
        if(t[i][2]<0){
            t[i][2]=t[i][2]+60;
            a[i][4]--;
        }
        t[i][1]=a[i][4]-a[i][1];
        if(t[i][1]<0){
            t[i][1]=t[i][1]+60;
            a[i][3]--;
        }
        t[i][0]=a[i][3]-a[i][0];
        
    }
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cout << t[i][j];
            if(j<2){
                cout << " ";
            }
        }
        cout << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

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

  Graph G(n, vi(n, 0));
  int ans = 0;

  rep(i,n-1) {
    if (s[i] == s[n-1]) {
      G[n-1][i] = 1;
      ans = 1;
    }
  }

  for (int i=n-2; i>0; --i) {
    rep(j,i) {
      if (s[i] == s[j]) {
        G[i][j] = min(i-j, G[i+1][j+1] + 1);
        ans = max(ans, G[i][j]);
      }
    }
  }

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


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

using ll = long long;

ll arr[60];

ll memo[60][60] = {};

// a C b
ll combi(ll a,ll b){
    
    if(!memo[0][0]){
        for(int i = 0; i < 60; i++){
            for(int j = 0; j < 60; j++){
                if(i == 0 || j == 0){
                    memo[i][j] = 1;
                }else{
                    memo[i][j] = memo[i-1][j] + memo[i][j-1];
                }
            }
        }
    }
    
    return memo[a-b][b];
    
    
}




int main(void){
    // Here your code !
    
    int n,a,b;
    
    map<ll,ll> number;
    
    cin >> n >> a >> b;
    
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        number[arr[i]]++;
    } 
    
    sort(arr,arr+n);
    
    long double Max = 0;
    
    for(int i = a; i <= b; i++){
        ll total = 0;
        for(int j = n - 1; j >= n-i; j--){
            total += arr[j];
        }
        Max = max((long double)total/i,Max);
    }
    
    printf("%.7Lf\n",Max);
    
    ll res = 0;
    
    for(int i = a; i <= b; i++){
        ll tmp = 0,total = 0;
        for(int k = n-i; k < n; k++){
            if(arr[n-i] == arr[k]){
                tmp++;
            }
            total += arr[k];
        }
        
        //0.000001
        if(fabsl((long double)total/i - Max ) <= 0)
            res += combi(max(number[arr[n-i]] ,tmp), min(number[arr[n-i]] ,tmp));
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 384
//ABC 045-B
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	string SA, SB, SC;
	int iA = 0, iB = 0, iC = 0;
	cin >> SA >> SB >> SC;
	int NumberA = SA.size();
	int NumberB = SB.size();
	int NumberC = SC.size();
	char card = 'a', winner;
	while ((NumberA >= 0) && (NumberB>=0) && (NumberC >=0)) {
		if (card == 'a') {
			winner = 'A';
			card = SA[iA];
				iA++;
			NumberA--;
		}
		if (card == 'b') {
			winner = 'B';
			card = SB[iB];
				iB++;
			NumberB--;
		}
		if (card == 'c') {
			winner = 'C';
			card = SC[iC];
				iC++;
			NumberC--;
		}
	}
	cout << winner << endl;
}


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

const int MAX = 1000005 ;

struct Query
{
	int l, r, idx ;
} ;

bool cmp(Query x, Query y)
{
	return x.r < y.r;
}

int arr[500005] ;
int n, q ;
Query queries[500005] ;

void update(int idx, int val, int bit[])
{
	for (; idx <= n; idx += idx&-idx)
		bit[idx] += val;
}

int query(int idx, int bit[])
{
	int sum = 0;
	for (; idx>0; idx-=idx&-idx)
		sum += bit[idx];
	return sum;
}

void answeringQueries()
{
	int bit[n + 1] ;
	memset(bit, 0, sizeof(bit)) ;

	int last_visit[n + 5] ;
	memset(last_visit, -1, sizeof(last_visit)) ;

	int ans[q] ;
	int query_counter = 0 ;

	for (int i = 0; i < n; i++) {
		if (last_visit[arr[i]] !=-1)    update(last_visit[arr[i]] + 1, -1, bit) ;

		last_visit[arr[i]] = i;
		update(i + 1, 1, bit) ;

		while (query_counter < q && queries[query_counter].r == i) {
			ans[queries[query_counter].idx] = query(queries[query_counter].r + 1, bit) - query(queries[query_counter].l, bit) ;
			query_counter++;
		}
	}

	// print answer for each query
	for (int i = 0; i < q; i++) {
        cout << ans[i] << endl ;
	}
	return ;
}

int main()
{
	int left, right ;
	cin >> n >> q ;
	for (int i = 0; i < n; i++) {
        cin >> arr[i] ;
	}
    for (int i = 0; i < q; i++) {
        scanf("%d %d", &left, &right) ;
        queries[i].l = left - 1, queries[i].r = right - 1, queries[i].idx = i ;
    }
	sort(queries, queries + q, cmp) ;
	answeringQueries() ;

	return 0 ;
}


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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

X, N, *P = map(int, read().split())

for i in range(0, 10000):
    acc = (X - i, X + i)
    for x_ in acc:
        if x_ not in P:
            print(x_)
            sys.exit()


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d)
    {
        cout << "Left" << endl;
    }
    if (a + b == c + d)
    {
        cout << "Balanced" << endl;
    }
    if (a + b < c + d)
    {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = Convert.ToInt32(input[0]);
            int i = Convert.ToInt32(input[1]);
            Console.WriteLine(N - i + 1);
            Console.Read();
        }
    }
}


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

int main()
{
	string s;
	cin>>s;
	
	int n,len=s.size();
	string left,right;
	
	if(len%2==0)
	{
		left=s.substr(0,len/2);
		right=s.substr(len/2,len);
	}
	else
	{
		left=s.substr(0,(len-1)/2);
		right=s.substr((len+1)/2,len);
	}
	
	int total=0;
	
	for(int i=0; i<left.size(); i++)
	{
		if(left[i]!=right[right.size()-1-i])
		total++;
	}
	
	cout<<total<< endl;
	return 0;
}

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

int main(){
  int n;
  cin>> n;
  
  int64_t ans=0;
  for(int a=1; a<=n; a++){
    if(a%10==0) continue;
    string s=to_string(a);
    int head=s[s.size()-1]-48,tail=s[0]-48;
    if (head==tail) ans++;
    
    for(int i=1; head*pow(10,i)+tail<=n; i++){
      if(n/(int)pow(10,i)>head){ ans+=pow(10,i-1); continue;}
      ans+=(n-head*(int)pow(10,i)-tail)/10+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4116
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll x; cin >> x;
    vl kind(6);
    rep(i,6) kind[i] = 100+i;
    vl dp(101000,0);
    dp[0] = 1;
    rep(i,100100){
        rep(j,6) dp[i+kind[j]] = max(dp[i],dp[i+kind[j]]);
    }
    if(dp[x]>0) puts("1");
    else puts("0");
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, L, bA, A, P;
	bool check = false;
	cin >> N >> L >> bA;
	for (int i = 1; i < N; i++) {
		cin >> A;
		if (bA + A >= L) P = i, check = true;
		bA = A;
	}
	if (check) {
		cout << "Possible" << endl;
		for (int i = 1; i < P; i++) cout << i << endl;
		for (int i = N - 1; i >= P; i--) cout << i << endl;
	}
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 768
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.nextLine());
		int b = Integer.parseInt(sc.nextLine());
		int h = Integer.parseInt(sc.nextLine());
		System.out.println((a+b)*h/2);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//cout<<""<<endl;
int main(){
  int N;cin>>N;
  vl x(N),y(N);
  ll l=0,r=1000000000,u=1000000000,d=0;
  rep(i,N){
    cin>>x[i]>>y[i];
    l=min(l,x[i]);
    d=min(d,y[i]);
    r=max(r,x[i]);
    u=max(u,y[i]);
  }
  vl lf,rg;
  rep(i,N){
    lf.pb(abs(l-x[i])+abs(d-y[i]));
    rg.pb(abs(r-x[i])+abs(d-y[i]) );
  }
  sort(all(lf));
  sort(all(rg));
  cout<<max(abs(lf[0]-lf[N-1]),abs(rg[0]-rg[N-1]) );
  
}






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

int main(){
  int N;
  cin >> N;
  int C0=0,C1=0,C2=0,C3=0;
  vector<string>S(N);
  for(int i=0; i<N;i++)cin >> S.at(i);
  
  for(int i=0;i<N;i++){
  	if(S.at(i) == "AC")C0++;
    if(S.at(i) == "WA")C1++;
    if(S.at(i) == "TLE")C2++;
    if(S.at(i) == "RE")C3++;
  }
  cout << "AC x " << C0 << endl;
  cout << "WA x " << C1 << endl;
  cout <<"TLE x " << C2 << endl;
  cout << "RE x " << C3 << endl;
}

Measured memory_bytes: 6432
#include<iostream>
using namespace std;
int main(){
  int a,b,i;
  cin >> a >> b;
  int c=1;
  for(i=0;;i++){
    if(c>=b){
      cout << i << endl;
      return 0;
    }
    c+=a-1;
  }
  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int t, x;
  cin >> t >> x;
  cout << ((long double)t / x);
}
#endif


Measured memory_bytes: 3748
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

typedef short s;

int main()
{
    ll H, W;
    cin >> H >> W;
    s m[2000][2000];
    rep(i, H) {
        string tmp;
        cin >> tmp;
        rep(j, W) {
            if (tmp[j] == '#') m[i][j] = -1;
            else m[i][j] = 0;
        }
    }
    rep(i, H) {
        ll cnt = 0;
        s start = 0;
        rep(j, W) {
            if (m[i][j] != -1) {
                if (cnt == 0) {
                    start = j;
                }
                cnt++;
            } else {
                for(s k = 0; k < cnt; k++) {
                    m[i][start+k] = cnt;
                }
                cnt = 0;
            }
            if (j == W-1) {
                for(s k = 0; k < cnt; k++) {
                    m[i][start+k] = cnt;
                }
                cnt = 0;
            }
        }
    }
    rep(i, W) {
        ll cnt = 0;
        s start = 0;
        rep(j, H) {
            if (m[j][i] != -1) {
                if (cnt == 0) {
                    start = j;
                }
                cnt++;
            } else {
                for(s k = 0; k < cnt; k++) {
                    m[start+k][i] += cnt;
                }
                cnt = 0;
            }
            if (j == H-1) {
                for(s k = 0; k < cnt; k++) {
                    m[start + k][i] += cnt;
                }
                cnt = 0;
            }
        }
    }
    s ma = 0;
    rep(i, H) {
        rep(j, W) {
            ma = max(ma, m[i][j]);
        }
    }
    print(ma-1);
    return 0;
}

Measured memory_bytes: 8064
loop do
  n = gets.to_i
  break if n==0
  y = gets.to_i
  max =0
  bs = Hash.new
  bank = Array.new
  n.times do
    b,r,t=gets.split.map(&:to_i)
    bank << b
    bene = 10000 * (t==1 ? (1+y*r/100.0) : (1+r/100.0)**y)
    bs[b]=bene
  end
  puts bank.sort_by{|x|-bs[x]}[0]
end

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

int ds(int x){
  int count = 0;
  while(x>0){
    count += x%10;
    x /= 10;
  }
  return count;
}

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int ans = 0;
  for(int i=1;i<=N;i++){
    if(A<=ds(i) && ds(i)<=B){
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import copy


def make_empty_nums():
    under_empty_nums = [[0 for _ in range(W)] for _ in range(H)]

    for h in range(H - 1, -1, -1):
        for w in range(W):
            if grids[h][w] == '#':
                under_empty_nums[h][w] = 0
            else:
                if h == H - 1:
                    under_empty_nums[h][w] = 1
                else:
                    under_empty_nums[h][w] = under_empty_nums[h + 1][w] + 1

    empty_nums = copy.copy(under_empty_nums)
    for h in range(1, H):
        for w in range(W):
            if empty_nums[h][w] != 0:
                empty_nums[h][w] = max(empty_nums[h][w], empty_nums[h-1][w])

    return empty_nums


H, W = map(int, input().split())
grids = [input() for _ in range(H)]
empty_nums = make_empty_nums()
ans = 0
for h in range(H):
    max_lighted_grids = 0
    tmp_max_lighted_grids = [0, 0]
    for w in range(W):
        if empty_nums[h][w] == 0:
            max_lighted_grids = max(max_lighted_grids, sum(tmp_max_lighted_grids) - 1)
            tmp_max_lighted_grids = [0, 0]
        else:
            tmp_max_lighted_grids[0] = max(tmp_max_lighted_grids[0], empty_nums[h][w])
            tmp_max_lighted_grids[1] += 1
            if w == W-1:
                max_lighted_grids = max(max_lighted_grids, sum(tmp_max_lighted_grids) - 1)
    ans = max(ans, max_lighted_grids)
print(ans)

Measured memory_bytes: 99800
n,m = map(int, input().split())
ink = list(map(int, input().split()))
ink.sort()
array = [0 for i in range(n+1)]

array[1] = 1
for i in range(2, n+1):
	if i in ink:
		array[i] = 1
	else:
		mini = i
		for j in ink[::-1]:
			if j < i:
				if mini > 1 + array[i-j]:
					mini = 1 + array[i-j]
		array[i] = mini
print(array[n])


Measured memory_bytes: 7376
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
point=B[A[0]-1]
for n in range(N-1):
    left=A[n]
    right=A[n+1]
    point+=B[right-1]
    if right==left+1:
        point+=C[left-1]
print(point)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define Maxn 307
using namespace std;
char s[Maxn];
int n,k;
int f[Maxn][Maxn][Maxn];
int calc(int x,int y)
{
	if (s[x]==s[y]) return 0;
	return 1;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	scanf("%d",&k);
	for (int i=1;i<=n;i++)
		for (int j=0;j<=k;j++)
			f[i][i][j]=1;
	for (int del=1;del<n;del++)
		for (int i=1;i+del<=n;i++)
		{
			int j=i+del;
			for (int r=0;r<=k;r++)
			{
				f[i][j][r]=max(f[i+1][j][r],f[i][j-1][r]);
				int t=calc(i,j);
				if (r>=t) 
				{
					if (i+1>j-1) f[i][j][r]=max(2,f[i][j][r]);
					else f[i][j][r]=max(f[i][j][r],f[i+1][j-1][r-t]+2);
				}
			}
		}
	printf("%d\n",f[1][n][k]);
	return 0;
}


Measured memory_bytes: 112512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int n, m, q;
vector<int> a;
vector<int> b,c,d;
int ans;
 
void dfs(vector<int> A) {
  if(A.size() == n+1){
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }
  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }
}
  
int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
}

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


int main()
{
	int num, a,k;
	int sum = 0;
	cin >> num;
	 a = num * 2;

	int data[400];


	for (int i = 0; i < a; i++) {
		scanf("%d", &k);
		data[i] = k;
	}

	sort(data,data+a);

	for (int t = 0; t < a; t = t + 2) {
		sum = sum + data[t];
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x3 = (x2 - x1) - (y2 - y1) + x1;
  int y3 = (y2 - y1) + (x2 - x1) + y1;
  int x4 = -(y2 - y1) + x1;
  int y4 = (x2 - x1) + y1;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <atcoder/convolution>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;


signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,M;cin>>N>>M;
	vector<int>A(N),B(M);
	for(int &i:A)cin>>i;
	for(int &i:B)cin>>i;
	vector<int>c=atcoder::convolution(A,B);
	for(int i:c)cout<<i<<" ";
	cout<<"\n";
}

Measured memory_bytes: 27252
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	REP(i,n)
	{
		ll a;
		cin >> a;
		if (a % 2 == 1)
		{
			sum++;
		}
	}
	if(sum%2==0)
	{
		cout << "YES" << endl;
	}else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii pair <int, int>
#define PI 3.1415926535897932384626433832795

using namespace std;

int a, b, c, d;

int main()
{
	cin >> a >> b >> c >> d;
	
	if(abs(c - a) <= d || (abs(c - b) <= d && abs(b - a) <= d))
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#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 FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);

	int dp[100001] = { 0 };
	RREPS(i, Max(n,k)) {
		if (i >= k) {
			dp[i] = 1;
			continue;
		}
		if (i * 2 >= k) {
			dp[i] = 2;
			continue;
		}
		dp[i] = dp[i * 2] * 2;
	}
	int max = 0;
	REPS(i, n) {
		max = Max(max, dp[i]);
	}
	
	ll num1 = 0;
	ll num2 = (ll)max * n;
	REPS(i, n) {
		num1 += max / dp[i];
	}
	double ans = num1 / (double)num2;
		printf("%.11lf\n", ans);
	
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
    int x,n,p[101],q[102]={0},i,a,b,s;
    scanf("%d%d",&x,&n);
    for(i=0;i<n;i++)
        scanf("%d",&p[i]);
    for(i=0;i<n;i++)
        q[p[i]]=1;
    a=x; b=x;
    while(1){
        if(q[a]==0){
            s=a;
            break;
        }
        else if(q[b]==0){
            s=b;
            break;
        }
        a--; b++;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;

int main()
{
    int K, S, ans = 0;
    cin >> K >> S;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            int n = S - i - j;
            if ((0 <= n) && (n <= K))
            {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll

bool check(string s) {
    int n = s.size();
    for(int i=0;i<n;i++) {
        if(s[i]!=s[n-1-i]) return false;
    }
    return true;
}

signed main() {
    fast;

    int h,w,k1;
    cin>>h>>w>>k1;

    int ff = inf;

    string s[h];
    for(int i=0;i<h;i++) cin>>s[i];

    for(int i=0;i<(1LL<<(h-1));i++) {

        int ans = 0;

        vector<int> cut;
        for(int j=0;j<h-1;j++) {
            if((i&(1LL<<j))) cut.pb(j);
        }

        vector<int> val(cut.size()+1,0);

        for(int j=0;j<w;j++) {
            int index = 0;
            vector<int> temp(cut.size()+1,0);
            for(int k=0;k<h;k++) {
                if(s[k][j]=='1') temp[index]++;
                if(index!=cut.size() && k==cut[index]) index++;
            }

            int f = 1;
            for(int k=0;k<val.size();k++) {
                if(val[k]+temp[k]>k1) f = 0;
            }

            if(!f) {
                val = temp;
                for(auto x: temp) if(x>k1) ans = inf;
                ans++;
            }
            else {
                for(int k=0;k<val.size();k++) val[k] += temp[k];
            }
        }

        // cout<<ans<<"+"<<(int)cut.size()<<endl;
        ff = min(ans+(int)cut.size(), ff);

    }

    cout<<ff<<endl;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> P(m), Y(m);
    for (int i = 0; i < m; ++i) cin >> P[i] >> Y[i], --P[i];
    
    vector<vector<int> > vals(n);
    for (int i = 0; i < m; ++i) vals[P[i]].push_back(Y[i]);
    
    for (int v = 0; v < n; ++v) {
        sort(vals[v].begin(), vals[v].end());
        
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    for (int i = 0; i < m; ++i) {
        int v = P[i];
        printf("%06d", v + 1);
        
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
}


Measured memory_bytes: 8880
n,a,b = input().split()
C = 0

for j in range(1,int(n)+1): #1<=j<=nを出力
  j = str(j)
  S = 0
  for i in range(len(j)): #整数の各位の和を求める
    S += int(j[i])
  if int(a) <= S <= int(b): #a<=S<=bに収まるかどうかでCに加算するか判別
    C += int(j)
  else:
    C += 0

print(C)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

bool inside(const int& i, const int& j, const long & H, const long & W, const vector<vector<char>>& mat){
    return (i >= 0 && i < H && j >= 0 && j < W && mat[i][j] == '.');
};


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long H, W;
    cin >> H >> W;
    long Cx, Cy;
    cin >> Cy >> Cx;
    Cy--;Cx--;
    long Dx, Dy;
    cin >> Dy >> Dx;
    Dy--;Dx--;
    std::vector<std::vector<char>> mat(H, vector<char>(W));
    string S;
    for(size_t i=0;i<H; i++)
    {
        cin >> S;
        for(size_t j=0;j<S.size(); j++)
        {
            mat[i][j] = S[j];
        }
    }

    vector<vector<ll> > dist(H, vector<ll> (W, INF));
	dist[Cy][Cx] = 0;
	deque<pair<int, int>> que;
	que.push_front(pair<int, int>(Cy, Cx));
    while(que.size()){
	    pair<int, int> p = que.front(); que.pop_front();
		int y = p.first, x = p.second;
		for(int i = y - 2; i <= y + 2; i++){
			for(int j = x - 2; j <= x + 2; j++){
				if(!inside(i, j, H, W, mat)) continue;
				int adj = (abs(y - i) + abs(x - j) != 1);
				int d = dist[y][x] + adj;
				if(d < dist[i][j]){
					dist[i][j] = d;
                    if(adj) que.push_back(pair<long, long>(i, j));
					else que.push_front(pair<long, long>(i, j));
				}
			}
		}
	}

	ll ans = dist[Dy][Dx];
    if(ans == INF) ans = -1;
    cout << ans << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 12416
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d;
  	cin>>a>>b>>c>>d;
  	bool chose = true;
  	while(true){
      if(chose){
      	//taka turn 
        c-=b;
        if(c<=0)
          break;
        chose = false;
      }else{
      	//aoki turn 
        a-=d;
        if(a<=0)
          break;
        chose = true;
      }
    }
  if(chose)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> t(n);
  int sum = 0;
  for (int i=0; i<n; i++){
    cin >> t.at(i);
    sum += t.at(i);
  }
  int m; cin >> m;
  vector<pair<int, int>> drink(m);
  for (int i=0; i<m; i++){
    cin >> drink.at(i).first >>drink.at(i).second;
  }
  
  for (int i=0; i<m; i++){
    cout <<sum - t.at(drink.at(i).first-1) + drink.at(i).second <<endl;
  }
}


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

using namespace std;

struct card {
	string mark;
	int number;
};

int partition(card A[], int p, int r) {

	int x = A[r].number;
	int i = p - 1;
	for (int j = p; j < r; ++j) {
		if (A[j].number <= x) {
			++i;
			card tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	card tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;
	return i + 1;
}

void quicksort(card A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
}

int main() {
	int n;
	scanf("%d", &n);

	card A[n];
	vector<card> B;

	for (int i = 0; i < n; ++i) {
		cin >> A[i].mark >> A[i].number;
	}
	for (int i = 0; i < n; ++i) {
		B.push_back(A[i]);
	}

	quicksort(A, 0, n - 1);

	for (int i = 0; i < n; ++i) {
		vector<card>::iterator it = B.begin();
		while (it != B.end()) {
			card c = *it;
			if (A[i].number == c.number) {
				if (A[i].mark != c.mark) {
					cout << "Not stable" << endl;
					goto OUTPUT;
				} else {
					B.erase(it);
				}
				break;
			}
			++it;
		}

	}
	cout << "Stable" << endl;

	OUTPUT:

	for (int i = 0; i < n; ++i) {
		cout << A[i].mark << " " << A[i].number << endl;
	}

	return 0;
}

Measured memory_bytes: 11084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vdebug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n, a, b;
    cin >> n >> a >> b;

    if((b-a)%2 == 1) cout << "Borys" << endl;
    else if((b-a)%2 == 0) cout << "Alice" << endl;

    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())

a= [list(input()) for _ in range(h)]

x=[]

#最初の行追加
first =[]
for i in range(w+2):
  first.append("#")
  
#for文で回す

for i in range(h):
  a[i].append("#")
  
  for j in range(w):
    a[i].append(a[i][j])
    
  a[i].append("#")
  del a[i][:w]

#最後の行追加
last=[]
for i in range(w+2):
  last.append("#")

print("".join(first))
for k in range(h):
  print("".join(a[k][:]))

print("".join(last))



Measured memory_bytes: 3188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		
		Pair[] P = new Pair[N];
		for(int i=0;i<N;i++) P[i] = new Pair(i, R[i] - L[i] + 1);
		Array.Sort(P, (p,q) => p.Len.CompareTo(q.Len));
		
		var ST = new SegTree(M+1);
		int bigger = N;
		int ptr = 0;
		var ans = new List<long>();
		for(int i=1;i<=M;i++){
			long cnt = 0;
			while(ptr < N && P[ptr].Len <= i){
				ST.AddRange(L[P[ptr].Idx] , R[P[ptr].Idx] + 1, 1);
				bigger--;
				ptr++;
			}
			cnt += bigger;
			for(int j=0;j<=M;j+=i){
				cnt += ST.At(j);
			}
			ans.Add(cnt);
		}
		
		Console.WriteLine(String.Join("\n",ans));
		
	}
	
	class Pair{
		public int Idx, Len;
		public Pair(int idx, int len){
			Idx = idx; Len = len;
		}
	}
	
	
	int N,M;
	int[] L,R;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		L = new int[N];
		R = new int[N];
		for(int i=0;i<N;i++){
			d = ria();
			L[i] = d[0]; R[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class SegTree{
	//segment Tree 
	// range add / point value query
	// 0-origin
	protected long[] Data;	
	protected long Inf;	
	protected int N;		
	protected int n;		
	
	public SegTree(int n_){
		N = n_; Inf = (long)1e18;
		n = 1;
		while(n < n_) n *= 2;
		Data = new long[2 * n - 1];
		for(int i=0; i < 2 * n - 1; i++) Data[i] = 0;
	}
	
	//	   0
	//	 1   2
	//	3 4 5 6
	
	public long At(int k){
		long ret = 0;
		k += n - 1;
		ret = Data[k];
		while(k > 0){
			k = (k - 1) / 2;
			ret += Data[k];
		}
		return ret;
	}
	
	public void AddRange(int a, int b, long v){
		Query(a, b, v, 0, 0, n);
	}
	
	//Range Sum; [a,b)
	public void Query(int a, int b, long v, int k, int l, int r){
		if(r <= a || b <= l) return;
		if(a <= l && r <= b) {
			Data[k] += v;
			return;
		}
		Query(a, b, v, k * 2 + 1, l, (l + r) / 2);
		Query(a ,b, v, k * 2 + 2, (l + r) / 2, r);
		return;
	}
	
	public void Dump(){
		Console.WriteLine();
		int h = 0;
		int cnt = 0;
		for(int i=0;i<Data.Length;i++){
			Console.Write("{0} ", Data[i]);
			cnt++;
			if(cnt == 1 << h){
				cnt = 0;
				h++;
				Console.WriteLine();
			}
		}
	}
	
}


Measured memory_bytes: 37988
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;

int main() {
    int n, m;
    string s;
    cin >> n >> m >> s;

    vector<int> dp(n+1, INF);
    dp[n] = 0;
    
    queue<int> Q;
    Q.push(0);
    for(int i = n-1; i >= 0; i--) {
        while(1) {
            if(Q.size() == 0) {
                cout << -1 << endl;
                return 0;
            }
            if(Q.front() != INF && Q.size() <= m) {
                break;
            } 
            Q.pop();
        }
        if(s[i] == '0') {
            dp[i] = Q.front() + 1;
        } 
        Q.push(dp[i]);
    }
    
    vector<int> ans;
    int x = 0;
    int rest = dp[0];
    while(x < n) {
        rest--;
        int i = 1;
        while(dp[x+i] != rest) {
            i++;
        } 
        ans.push_back(i);
        x += i;
    }

    rep(i, ans.size()) {
        cout << ans[i];
        if(i < ans.size() - 1) {
            cout << " ";
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1528
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int n, m;
  cin >> n >>m;
  int data[101][101] = {0};
  for(int i = 0; i < n ; i ++) {
    for(int j = 0; j < m ; j++) { 
      cin >> data[i][j];
      data[i][m] += data[i][j];
      data[n][j] += data[i][j];
      data[n][m] += data[i][j];
    }
  }


  for(int i = 0; i < n+1 ; i ++) {
    for(int j = 0; j < m+1 ; j++) { 
      cout << data[i][j];
      if (j != m) {
      cout << " ";
      } 
    }
    cout << endl;
  }
}

Measured memory_bytes: 3132
package main

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

func main() {
	switch readLine() {
	case "SUN":
		fmt.Println(7)
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	case "SAT":
		fmt.Println(1)
	}
}

/////////////////////////////////////////
//
//func readLineInt() []int {
//	result := make([]int, 0)
//	for _, v := range strings.Split(readLine(), " ") {
//		i, _ := strconv.Atoi(v)
//		result = append(result, i)
//	}
//	return result
//}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

NK = input().split(' ')
N = int(NK[0])
K = int(NK[1])
S = input()

prev = '1'
count = 0
nums = []
for i in S:
    if i == prev:
        count += 1
    else:
        nums.append(count)
        count = 1
        prev = i
if count > 0:
    nums.append(count)
# print(nums)

C = min(K * 2 + 1, len(nums))
s1 = 0
for i in range(0, C):
    s1 += nums[i]
sums = [s1]
prev = s1
for i in range(0, len(nums)):
    s = prev - nums[i]
    if i + C < len(nums):
        s += nums[i + C]
    if i % 2 == 1:
        sums.append(s)
    prev = s
# print(sums)

print(max(sums))


Measured memory_bytes: 5904