akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
using namespace std;

class Dice{
    private:
    int face[7];
    
    public:
    
    void SetFace(){
        for(int i=1;i<sizeof(face)/sizeof(int);++i){
            cin>>face[i];
        }
    }
    void Up(){
        int buf=face[1];
        face[1]=face[2];
        face[2]=face[6];
        face[6]=face[5];
        face[5]=buf;
    }
    void Down(){
        int buf=face[1];
        face[1]=face[5];
        face[5]=face[6];
        face[6]=face[2];
        face[2]=buf;
    }
    void Right(){
        int buf=face[1];
        face[1]=face[4];
        face[4]=face[6];
        face[6]=face[3];
        face[3]=buf;
    }
    void Left(){
        int buf=face[1];
        face[1]=face[3];
        face[3]=face[6];
        face[6]=face[4];
        face[4]=buf;
    }
    void RightRolling(){
        int buf=face[2];
        face[2]=face[3];
        face[3]=face[5];
        face[5]=face[4];
        face[4]=buf;
    }
    void Rolling(char d){
        if(d=='N'){
            Up();
        }
        else if(d=='S'){
            Down();
        }
        else if(d=='E'){
            Right();
        }
        else if(d=='W'){
            Left();
        }
        else if(d=='R'){
            RightRolling();
        }
    }
    int GetFaceNum(int i){
        return face[i];
    }
};

Dice dice[3];
int q;
int main(){
    dice[0].SetFace();
    dice[1].SetFace();
    bool ismatch;
    for(int i=1;i<=6;++i){
        dice[2]=dice[1];
        if(i==1);
        else if(i==2)dice[2].Up();
        else if(i==3)dice[2].Left();
        else if(i==4)dice[2].Right();
        else if(i==5)dice[2].Down();
        else if(i==6){
            dice[2].Up();
            dice[2].Up();
        }
        for(int j=0;j<4;++j){
            dice[2].RightRolling();
            ismatch=true;
            for(int i=1;i<=6;++i){
                if(dice[0].GetFaceNum(i) != dice[2].GetFaceNum(i)){
                ismatch=false;
                break;
                }
            }
            if(ismatch)break;
        }
        if(ismatch)break;
    }
    if(ismatch){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}



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



public class Main{
    static int INFTY=Integer.MAX_VALUE;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            int n=sc.nextInt();
            int[] lake = new int[n+1];
            int[] mountain = new int[n+1];

            for(int i=1;i<=n;i++){
                lake[i]=sc.nextInt();
                if(i%2==0){
                    mountain[1]-=lake[i];
                }else{
                    mountain[1]+=lake[i];
                }

            }
            
            for(int i=2;i<=n;i++){
                mountain[i]=2*lake[i-1]-mountain[i-1];
            }

            for(int i=1;i<=n;i++){
                System.out.print(mountain[i]+" ");
            }
    }
}

Measured memory_bytes: 63800
#include <iostream>
#include<bits/stdc++.h>
#define MOD 998244353
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P>v,vv;
vector<ll>li;
ll n,x,y,N=1,X[200000][4],EX[200000];
/*
ll f(ll n){
    ll A=1;
    while(n--){
        A*=2;
        A%=MOD;
    }
    return A;
}*/
void update(ll b){
    b+=N-1;
    li[b]+=1;
    while(b>0){
        b=(b-1)/2;
        li[b]+=1;
    }
    return ;
}
ll find(ll b,ll c,ll k,ll l,ll r){
    if(r<=b||c<=l)return 0;
    if(b<=l&&r<=c)return li[k];
    else {
        ll c1=find(b,c,2*k+1,l,(l+r)/2);
        ll c2=find(b,c,2*k+2,(l+r)/2,r);
        return c1+c2;
    }
}
int main(void){
    cin>>n;
    EX[0]=1;
    for(int i=0;i<n-1;i++){
        EX[i+1]=EX[i]*2%MOD;
    }
    while(N<n)N*=2;
    li=vector<ll>(2*N-1,0);
    for(int i=0;i<n;i++){
        cin>>x>>y;
        v.push_back(P(y,x));
    }
    sort(v.begin(),v.end());
    for(ll i=0LL;i<n;i++){
        vv.push_back(P(v[i].second,i));
    }
    sort(vv.begin(),vv.end());
    for(int i=0;i<n;i++){
        X[i][1]=find(0,vv[i].second,0,0,N);
        X[i][0]=i-X[i][1];
        update(vv[i].second);
    }//cout<<vv[i].first<<vv[i].second<<endl;
    li=vector<ll>(2*N-1,0);
    
    for(int i=n-1;i>=0;i--){
        X[i][3]=find(0,vv[i].second,0,0,N);
        X[i][2]=n-1-i-X[i][3];
        update(vv[i].second);
    }
    for(int i=0;i<n;i++){
        //cout<<X[i][0]<<X[i][1]<<X[i][2]<<X[i][3]<<endl;
    }
    
    
    ll ans=0,tl[]={0,0,0,0};
    for(int i=0;i<n;i++){
        for(int j=1;j<16;j++){
            ll tmp=1;
            for(int k=0;k<4;k++){
                tl[k]=(j>>k)&1;
                if((j>>k)&1){
                    tmp*=EX[X[i][k]]-1;
                    tmp%=MOD;
                }
            }
            if(tl[0]*tl[3]+tl[1]*tl[2])tmp*=2;
            ans+=tmp;
            //ans%=MOD;
        }
        //cout<<ans<<endl;
    }
    cout<<(ans+n)%MOD<<endl;
    
    
    
}


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

using namespace std;

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<vector<int>> C(H, vector<int>(W));
  auto fill = [&](int i, int color) {
    int h = i / W;
    int w;
    if (h % 2 == 0) {
      w = i % W;
    } else {
      w = W - 1 - i % W;
    }
    C[h][w] = color;
  };
  int idx = 0;
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      fill(idx, i);
      idx++;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j > 0) cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
xs = list(map(int, input().split()))
G = [set() for _ in range(N)]
for i in range(M):
    u, v = sorted(map(int, input().split()),key=lambda x:[xs[x-1],-x])
    G[v-1].add((u-1,i))
xs,d,cc = sorted([(x,i) for i, x in enumerate(xs)]),[0]*M,[-1]*N
for x, u in xs:
    if cc[u]+1:continue
    if not G[u]:break
    cc[u] = 1
    for c, _ in G[u]:
        if cc[c]+1:
            cc[u] = 1-cc[c]
    S = [u]
    while S:
        q = S.pop()
        for c, i in G[q]:
            d[i] = str(x)
            if cc[c]+1:continue
            S.append(c)
            cc[c] = 1-cc[q]
print("".join("BW"[i] for i in cc)+"\n"+"\n".join(d) if cc[u]+1 else -1)

Measured memory_bytes: 147708
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

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

	int n, x, y;
	int cnt[2005];
	
	cin >> n >> x >> y;
	x--, y--;
	rep(i, n) cnt[i] = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int mi = min({ abs(i - j),abs(i - x) + abs(j - y) + 1,abs(i - y) + abs(j - x) + 1 });
			cnt[mi]++;
		}
	}
	for (int i = 1; i < n; i++) {
		cout << cnt[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ll x,k,d;
	cin>>x>>k>>d;
	ll l,r,ans;
	x=abs(x);
	if(x/d>k){
		ans=x-k*d;
	}
	else{
		r=x%d;
		if(r==0){
			ans=(k-x/d)%2*d;
		}
		else{
			l=r-d;
			if((k-x/d)%2==0){
				ans=r;
			}
			else{
				ans=l;
			}
		} 
	}
	cout<<abs(ans);
	re 0;
}

Measured memory_bytes: 3592
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        q: usize,
        t: [(chars, usize); n],
    }
    let mut i = 0;
    let mut time = 0;
    let mut task = t.clone();
    loop {
        //println!("{:?}, {}, {}", task, i, task.len());
        if task[i].1 <= q {
            time += task[i].1;
            task[i].1 = 0;
            println!("{} {}", (task[i].0).iter().collect::<String>(), time);
            if task.len() == 1 {
                break;
            }
            task.remove(i);
        } else {
            time += q;
            task[i].1 -= q;
            i += 1;
        }
        i %= task.len();
    }
}



Measured memory_bytes: 11180
T = input()
S = input()

min_c = len(S)

for i in range(len(T)-len(S)+1):
    Ti = T[i : i + len(S)]
    #print(Ti)
    c = 0
    for j in range(len(S)):
        if Ti[j] != S[j]:
            c += 1
    if c < min_c:
        min_c = c

print(min_c)

Measured memory_bytes: 9112
#include <stdio.h>

int main(void)
{
  int n,m;

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

  int a[100][100]={0},b[100]={0},c[100]={0},i,j;

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

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

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      c[i] = c[i] + (a[i][j] * b[j]);
    }
    printf("%d\n",c[i]);
  }

  return 0;
}

Measured memory_bytes: 648
def examA():
    H = I()
    W = I()
    N = I()
    ans = (N-1)//max(H,W) + 1
    print(ans)
    return

def examB():
    N = I()
    XL = [LI()for _ in range(N)]
    for i in range(N):
        XL[i][0] += XL[i][1]
    XL.sort()
#    print(XL)
    ans = 0
    now = -inf
    for i in range(N):
        if XL[i][0]-XL[i][1]*2>=now:
            ans +=1
            now = XL[i][0]
    print(ans)
    return

def examC():
    N, K, S = LI()
    A = [0]*N
    if S>=10**6:
        a = 1
    else:
        a = S+1
    for i in range(N):
        if i<K:
            A[i] = S
        else:
            A[i] = a
    print(" ".join(map(str,A)))
    return

def examD():
    return

def examE():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()


Measured memory_bytes: 66156
class Integer
    def isqrt
        return 0 if self<=0
        return 1 if self<4 # 1
        x,y=0,self
        while x!=y&&x+1!=y
            x,y=y,(self/y+y)/2
        end
        x
    end
end
p gets.to_i.isqrt**2

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct pkt
{
    int x, y;
};

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<string> G(n);
    int bi = 0;
    for (int i = 0; i < n; ++i)
        cin >> G[i];
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (G[i][j] == '.')
                ++bi;
    queue<pkt> Q;
    vector< vector<bool> > odw(n, vector<bool>(m, false));
    vector< vector<int> > odl(n, vector<int>(m, -1));
    Q.push({0, 0});
    odw[0][0] = true;
    odl[0][0] = 1;
    while (!Q.empty())
    {
        pkt akt = Q.front();
        Q.pop();
        for (int i = 0; i < 4; ++i)
        {
            pkt nowy = {akt.x + dx[i], akt.y + dy[i]};
            if (nowy.x >= 0 && nowy.x < n && nowy.y >= 0 && nowy.y < m && !odw[nowy.x][nowy.y] && G[nowy.x][nowy.y] == '.')
            {
                odw[nowy.x][nowy.y] = true;
                Q.push(nowy);
                odl[nowy.x][nowy.y] = odl[akt.x][akt.y] + 1;
            }
        }
    }
    if (odl[n - 1][m - 1] == -1)
        cout << "-1";
    else
        cout << bi - odl[n - 1][m - 1];
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

void solve()
{
    LL h, w, n;
    cin >> h >> w >> n;
    VLL a(n);
    REP(i, 0, n)
    cin >> a[i];
    VI ru(n + 1);
    REP(i, 0, n)
    ru[i + 1] = ru[i] + a[i];
    REP(i, 0, h)
    {
        REP(j, 0, w)
        {
            if (j)
                cout << " ";
            int pos;
            if (i % 2)
            {
                pos = i * w + (w - j) - 1;
            }
            else
            {
                pos = i * w + j;
            }
            cout << distance(ru.begin(), upper_bound(all(ru), pos));
        }
        cout << endl;
    }
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var k, n, tmp int
	resMax := 0
	sumAll := 0
	arr := make([]int, 0)
	fmt.Scanf("%d %d\n", &k, &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		arr = append(arr, tmp)
		if i > 0 {
			resMax = max(resMax, arr[i]-arr[i-1])
			sumAll += arr[i] - arr[i-1]
		}
	}
	resMax = max(resMax, k-arr[n-1]+arr[0])
	// fmt.Println(sumAll)
	// fmt.Printf("Res max: %d\n", resMax)
	sumAll = sumAll + k - arr[n-1] + arr[0] - resMax
	fmt.Println(sumAll)
}


Measured memory_bytes: 10240
n=int(input())
ans=[]
if n%2==1:
  for i in range((n-1)//2):
    for j in range(i+1,n-i):
      if i==0:
        ans.append(((n-i),j))
      else:
        ans.append((i,j))
        ans.append(((n-i),j))
elif n%2==0:
  for i in range(1,n//2):
    for j in range(i+1,n-i+1):
      ans.append((i,j))
      ans.append(((n-i+1),j))
print(len(ans))
for u,v in ans:
  print(u,v)

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

int main(){
    using namespace std;
    int N; cin >> N;
    vector<long long> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    long long r = 0, ans = 0;
    long long sum = 0;
    for (long long i = 0; i < N; i++)
    {
        while(r<N && (sum^v[r]) == sum+v[r]){
            sum += v[r];
            r++;
        }
        ans += r - i;
        //cout << i << " " << r << " " << ans << endl;
        if(r==i) r++;
        else sum -= v[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <cctype>
#include <algorithm>
#include <set>
#include <cmath>
#include <cassert>
#include <array>
using namespace std;

int pow_int(int x, int n) {
	int res = 1;
	for(int i = 0; i < n; ++i) {
		res *= x;
	}
	return res;
}

array<int, 10> count_num(const string &s) {
	array<int, 10> cnt;
	cnt.fill(0);
	for(const auto &c : s) {
		++cnt[c - '0'];
	}
	return cnt;
}

int match(const string &a, const string &b) {
	const int n = a.size();
	int res = 0;
	for(int i = 0; i < n; ++i) {
		if(a[i] == b[i]) ++res;
	}
	return res;
}

int count_blow(const string &a, const string &b) {
	const array<int, 10> cnt_a = count_num(a);
	const array<int, 10> cnt_b = count_num(b);

	int res = 0;
	for(int i = 0; i < 10; ++i) {
		res += min(cnt_a[i], cnt_b[i]);
	}
	return res - match(a, b);
}

string to_leading_zero_string(int x, int n) {
	char buf[256];
	sprintf(buf, "%0*d", n, x);
	return string(buf);
}

bool valid(const string &s) {
	const array<int, 10> cnt = count_num(s);
	return *max_element(cnt.begin(), cnt.end()) <= 1;
}

vector<string> solve(const vector<string> &number, const vector<int> &hit, const vector<int> & blow) {
	const int n = number.size();
	const int l = number[0].size();
	const int half = l / 2;

	const int first_size = half;
	const int second_size = l - half;

	const int max_first = pow_int(10, first_size);
	const int max_second = pow_int(10, second_size);

	vector<string> first, second;
	first.reserve(n);
	second.reserve(n);

	for(int i = 0; i < n; ++i) {
		first.emplace_back(number[i].substr(0, half));
		second.emplace_back(number[i].substr(half));
	}

	map<vector<int>, vector<string>> candidates;

	for(int x = 0; x < max_first; ++x) {
		const string str = to_leading_zero_string(x, first_size);
		if(!valid(str)) continue;

		vector<int> key(n);

		for(int i = 0; i < n; ++i) {
			const int rest_hit = hit[i] - match(str, first[i]);
			if(rest_hit < 0) goto ng_first;
			key[i] = rest_hit;
		}

		candidates[key].emplace_back(str);

	ng_first:;
	}


	vector<string> res;
	for(int x = 0; x < max_second; ++x) {
		const string str = to_leading_zero_string(x, second_size);
		if(!valid(str)) continue;
		vector<int> key(n);

		for(int i = 0; i < n; ++i) {
			key[i] = match(str, second[i]);
			if(key[i] > hit[i]) goto ng_second;
		}

		if(!candidates.count(key)) goto ng_second;
		for(const auto &e : candidates.at(key)) {
			string s = e + str;
			if(!valid(s)) continue;

			bool ok = true;

			for(int i = 0; i < n; ++i) {
				if(count_blow(s, number[i]) != blow[i]) {
					ok = false;
					break;
				}
			}

			if(ok) {
				res.emplace_back(s);
				if(res.size() > 1) return res;
			}
		}

	ng_second:;
	}

	return res;
}

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

	for(int l, h; cin >> l >> h && l;) {
		vector<string> number(h);
		vector<int> hit(h), blow(h);

		for(int i = 0; i < h; ++i) {
			cin >> number[i] >> hit[i] >> blow[i];
		}

		const auto answers = solve(number, hit, blow);
		cout << (answers.size() == 1 ? answers.front() : "NO") << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;

    int v[50];
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    if (n == 1) {
        cout << max(v[0], 0) << endl;
        exit(0);
    }

    int s = 0;
    int p[50];
    for (int i0 = 0; i0 < n; i0++) {
        for (int i1 = 0; i1 < n; i1++) {
            int i2 = i0 + i1;
            if (i2 > n || i2 > k) continue;
            int l = k - i2;
            int t = 0;
            int h = 0;
            for (int i = 0; i < i0; i++) {
                p[h++] = v[i];
            }
            for (int i = 0; i < i1; i++) {
                p[h++] = v[n - 1 - i];
            }
            sort(p, p + h);
            for (int i = 0; i < h; i++) {
                if (i < l && p[i] < 0) continue;
                t += p[i];
            }
            s = max(s, t);
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, k = ns()
    p = na()

    p.sort()
    ans = sum(p[:k])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10684
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define cout_db cout << fiXed
#define PI 3.1415926

typedef long long ll;
const int MOD = 1e9+7;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, m, x[100000];
	vector< pair<int, int> > diff;
	priority_queue<int, vector<int>, greater<int>> que;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	sort(x, x+m);
	for (int i = 1; i < m; i++) {
		diff.pb(make_pair(x[i]-x[i-1], i));
	}
	sort(ALL(diff), greater<pair<int, int>>());
	for (int i = 0; i < n-1; i++) {
		if(i >= diff.size()) break;
		que.push(diff[i].second);
	}
	int split = 0, ans = 0;
	for (int i = 0; i < m; i++) {
		if(!que.empty() and i == que.top()){
			ans += x[i-1] - x[split];
			split = i;
			que.pop();
		}
	}
	ans += x[m-1] - x[split];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2292
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
int main()
{
   char a,b;
   string s;
   cin>>a>>b;
   ll aa=int(a)-48,bb=int(b)-48;
   if(a==b)
   {
       for(ll i=0;i<aa;i++)
       s+=a;
   }
   else
   {
       if(a<b)
       {
            for(ll i=0;i<bb;i++)
            s+=a;
       }
       else
       {
            for(ll i=0;i<aa;i++)
            s+=b;
       }
   }
   cout<<s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ans,cnt=0;
    FOR(i,1,n+1){
      int c=0;
      int now=i;
      while(now%2==0){
        c++;
        now/=2;
        //cout<<i<<' '<<now<<endl;
      }
      if(c>=cnt){
        cnt=c;
        ans=i;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, ans, P;
int fac[MAXN], inv[MAXN], dp[MAXN][MAXN];
int c(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
void update(int &x, int y) {
	x = (x + y) % P;
}
int power(int x, int y, int P) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2, P);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int getdp(int x) {
	int mul = power(2, power(2, n - x, P - 1), P);
	int chs = power(2, n - x, P), now = 1, ans = 0;
	for (int i = 0; i <= x; i++) {
		update(ans, 1ll * dp[x][i] * now % P);
		now = 1ll * now * chs % P;
	}
	return 1ll * mul * ans % P;
}
int main() {
	read(n), read(P);
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2, P);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	for (int j = 0; j <= i; j++) {
		if (j) dp[i][j] += dp[i - 1][j - 1];
		update(dp[i][j], dp[i - 1][j] * (j + 1ll) % P);
	}
	for (int i = 0; i <= n; i++)
		if (i & 1) update(ans, 1ll * (P - c(n, i)) * getdp(i) % P);
		else update(ans, 1ll * c(n, i) * getdp(i) % P);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 34176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int X;
	scanf("%d",&X);
	int ret=0,now=0;
	do
	{
		ret++;
		now+=X;
	}while(now%360!=0);
	printf("%d\n",ret);
}

Measured memory_bytes: 3824
#include <cstdio>
#include <algorithm>

using namespace std;

int dp[1000][1001],t[1000],w[1000];

int main(){
  for(int c=1;;c++){
    int n,q,i,j;
    scanf("%d",&q); if(q==0) break;
    scanf("%d",&n);

    for(i=0; i<n; i++)
      scanf("%d,%d",&t[i],&w[i]);

    for(i=0; i<=q; i++)
      dp[0][i] = (i>=w[0])?t[0]:0;

    for(i=1; i<n; i++)
      for(j=0; j<=q; j++){
	/*if(j+w[i]<=q)
	  dp[i][j+w[i]] = dp[i-1][j]+t[i];
	  dp[i][j] = max(dp[i][j],dp[i-1][j]);*/
	if(j>=w[i])
	  dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+t[i]);
	else
	  dp[i][j] = dp[i-1][j];
      }

    int mw=0,mt=0;
    for(j=0; j<=q; j++)
      if(dp[n-1][j]>mt){
	mt = dp[n-1][j];
	mw = j;
      }

    /*    for(i=0; i<=q; i++)
      printf("%3d ",i);
      putchar('\n');
    for(i=0; i<n; i++){
      for(j=0; j<=q; j++)
	printf("%3d ",dp[i][j]);
      putchar('\n');
      }*/


    printf("Case %d:\n%d\n%d\n",c,mt,mw);
  }
}

Measured memory_bytes: 0
n=int(input())
l=[int(i) for i in input().split()]
min=l[0]
max=l[0]
sum=0
for i in range(n):
    if l[i]>max:
        max=l[i]
    elif l[i]<min:
        min=l[i]
    sum+=l[i]
print(min,max,sum)


Measured memory_bytes: 6604
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int a,b;
	scdd(a,b);
	while(a!=0 || b!=0)
	{
		forin(i,0,a)
		{
			forin(j,0,b)
			{
				printf("#");
			}
			newline;
		}
		newline;
		scdd(a,b);
	}
	
	return 0;
}

Measured memory_bytes: 3064
fun main(args: Array<String>) = abc155c()

fun abc155c() {
    val n = readLine()!!.toInt()
    val list = (1..n).map { readLine()!! }

    val map = list.groupBy { it }.map { it.key to it.value.size }
    val max = map.maxBy { it.second }!!.second

    val answer = StringBuilder()

    map.filter { it.second == max }.map { it.first }.sorted().forEach { answer.appendln(it) }

    print(answer)
}


Measured memory_bytes: 114204
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N; cin >> N;
  vector < pair<ll, ll> > BA(N);
  for (int i = 0; i < N; i++){
    ll A, B; cin >> A >> B;
    BA[i] = make_pair(B, A);
  }
  sort(BA.begin(), BA.end());

  ll now = 0;
  for (int i = 0; i < N; i++){
    now += BA[i].second;
    if (now > BA[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ll N; cin>>N;
  vector<ll> L(N); rep(i,N) cin>>L[i];
  sort(L.begin(),L.end());
  
  ll ans=0;
  rep(i,N){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(L[i]==L[j]) continue;
        if(L[j]==L[k]) continue;
        if(L[k]==L[i]) continue;
        if(L[i]+L[j]>L[k]) ans++;
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3680
N = int(input())
S = input().strip()

cnt = [0 for _ in range(N + 1)]
black = 0
white = 0

for idx in range(N):
    if S[idx] == '#':
        black += 1
    else:
        white += 1
    cnt[idx] = black - white

print(min(cnt) + white)

Measured memory_bytes: 11368
s=input()
t=input()
ans1=0
ans2=0
m=len(s)
n=len(t)
s=s+s
for i in range(n):
  a=s.find(t[i],ans2)
  if a==-1:
    print(-1)
    exit()
  if a>=m:
    ans1+=1
  ans2=a%m+1
print((ans1*m)+ans2)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

#define P pair<int, int>

const int INF = 1e9;

int main() {
    int m, n;
    while (cin >> m && m) {
        P star[m], t;
        vector<P> vec;
        for (int i = 0, x, y; i < m; i++) {
            cin >> x >> y;
            star[i] = P(x, y);
            if (i > 0) vec.push_back(P(star[i].first - t.first, star[i].second - t.second));
            else vec.push_back(P(0, 0));
            t = star[i];
        }
        cin >> n;
        P photo[n];
        for (int i = 0, x, y; i < n; i++) {
            cin >> x >> y;
            photo[i] = P(x, y);
        }
        sort(photo, photo+n);
        for (int i = 0; i < n; i++) {
            int cx = photo[i].first, cy = photo[i].second;
            bool flag = true;
            for (auto v : vec) {
                cx += v.first, cy += v.second;
                if (P(cx, cy) != *lower_bound(photo, photo+n, P(cx, cy))) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << photo[i].first - star[0].first << ' ' << photo[i].second - star[0].second << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3016
#include<cstdio>
#include<queue>
using namespace std;

typedef pair<int, int> PII;

int x, N;

int d[15], c[15];
int INF = 1001001001;
int ans[200001];

int main() {
	
	for(int i = 0; i <= 200000; i++) {
			ans[i] = INF;
	}
	
	scanf("%d%d", &N, &x);
	for(int i = 0; i < N; i++) {
		scanf("%d%d", &d[i], &c[i]);
	}
	priority_queue<PII, vector<PII>, greater<PII> > que;
	que.push( PII(0, 0) );
	while(!que.empty()) {
		PII p = que.top(); que.pop();
		if(ans[p.second] > p.first) {
			if(p.second == x) {
				printf("%d\n", p.first);
				return 0;
			}
			ans[p.second] = p.first;
			for(int i = 0; i < N; i++) {
				if(p.second+d[i] <= 200000) {
					que.push( PII(p.first+c[i], p.second+d[i]) );
				}
				if(p.second-d[i] >= 0) {
					que.push( PII(p.first+c[i], p.second-d[i]) );
				}
			}
		}
	}
	
	printf(ans[x]==INF?"-1\n":"%d\n", ans[x]);
	
	return 0;
	
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> xs(m);
	for (auto &x : xs)
	{
		cin >> x;
	}
	if (m <= n)
	{
		cout << 0 << endl;
		return 0;
	}
	sort(xs.begin(), xs.end());
	vector<int> ys(m - 1);
	for (int i = 0; i < m - 1; i++)
	{
		ys[i] = xs[i + 1] - xs[i];
	}
	sort(ys.begin(), ys.end());
	reverse(ys.begin(), ys.end());
	cout << accumulate(ys.begin(), ys.end(), 0) - accumulate(ys.begin(), ys.begin() + n - 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
 long long dp[85];
 long long ryuka(int64_t x){
  if (dp[x] != 0) return dp[x];
   if(x == 0){
     return 2;
   }
   if(x == 1){
     return 1;
   }
   else{
   long long a = ryuka(x-1);
   long long b = ryuka(x-2);
   long long s = a + b;
   return dp[x] = s;
   }
 }

int main() {
  int64_t N;
  cin >> N;
  for (int i = 0; i < 86; ++i) dp[i] = 0;
  cout << ryuka(N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> mp(n*n,0);
    vector<vector<int>> G(n*n);
    rep(i,n){
        int a,b,aa,bb;
        cin >> a; a--; b = i; // 0-indexed
        if(a > b) swap(a,b); // a < b
        rep(j,n-2){
            cin >> aa; aa--; bb = i; // 0-indexed
            if(aa > bb) swap(aa,bb); // aa < bb
            G[a*n+b].pb(aa*n+bb);
            mp[aa*n+bb]++;
            a = aa; b = bb;
        }
    }

    int ans = 0;
    queue<int> que1;
    rep(i,n*n) if(mp[i] == 0) que1.push(i);
    while(true){
        ans++;
        queue<int> que2;
        while(!que1.empty()){
            int v = que1.front(); que1.pop();
            for(auto nv : G[v]){
                mp[nv]--;
                if(mp[nv] == 0) que2.push(nv);
            }
        }
        que1 = que2;
        if(que1.empty()) break;
    }

    bool check = true;
    rep(i,n*n) if(mp[i] != 0) check = false;
    if(check) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 48372
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

H,W = inpl()
ss = [inpls() for i in range(H)]

for y in range(H):
	for x in range(W):
		if ss[y][x] == 'snuke':
			ans = chr(65+x) + str(y+1)
			print(ans)
			sys.exit()


Measured memory_bytes: 4336
n=int(input())
b =list(map(int, input().split()))
a = [0 for _ in range(n)]

for i in range(n-1):
  if i==0:
    a[i]=b[i]
    a[i+1]=b[i]
  elif b[i]>b[i-1]:
    a[i+1]=b[i]
  else:
    a[i]=b[i]
    a[i+1]=b[i]
print(sum(a))

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

using namespace std;
using ll = long long;
const int MAXN = 100000 + 100;
const int INF = 0x3f3f3f3f;

ll n, a, b;
ll h[MAXN];

bool f(ll mi) {
	ll need = 0;
	for (int i = 0; i < n; i++) {
		ll cur = h[i] - mi * b;
		if (cur <= 0)
			continue;
			
		// ceil(need / (a - b))
		need += (cur + a - b - 1) / (a - b);
		if (need > mi)
			return false;
	}
	
	return true;
}

int main(void) {
	cin >> n >> a >> b;
	
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	
	ll le = 1, ri = INF;
	ll ans = -1;
	while (le <= ri) {
		ll mi = le + (ri - le) / 2;
		if (f(mi)) {
			ans = mi;
			ri = mi - 1;
		} else {
			le = mi + 1;
		}
	}
	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4404
//
//  main.cpp
//  backToProblemSolving
//
//  Created by Khaled Abdelfattah on 6/27/17.
//  Copyright © 2017 Khaled Abdelfattah. All rights reserved.
//

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

typedef long long ll;
#define MAX 1000000000
#define BASE1 23
#define BASE2 31
#define MOD1 1000000007
#define MOD2 217645177
#define eps 1e-6

int colors[100005];
vector<int> adjList[100005];
bool visited[100005][15];
void DFS (int node, int d, int c) {
    if (d < 0 || visited[node][d])
        return;
    visited[node][d] = true;
    if (colors[node] == 0)
        colors[node] = c;
    for (int i : adjList[node])
        DFS(i, d - 1, c);
}
int main() {
    int n, m;
    cin >> n >> m;
    memset(colors, 0, n);
    memset(visited, 0, sizeof visited);
    for (int i = 0; i < m; i ++) {
        int u, v;
        scanf("%d %d", &u, &v);
        v--, u--;
        adjList[u].push_back(v);
        adjList[v].push_back(u);
    }
    int q;
    cin >> q;
    pair<pair<int, int>, int> *quers = new pair<pair<int, int>, int> [q];
    for (int i = 0; i < q; i ++) {
        int s, d, c;
        scanf("%d %d %d", &s, &d, &c);
        quers[i] = {{s - 1, d}, c};
    }
    for (int i = q - 1; i >= 0; i --)
        DFS(quers[i].first.first, quers[i].first.second, quers[i].second);
    for (int i = 0; i < n; i ++)
        cout << colors[i] << endl;
    return 0;
}


Measured memory_bytes: 9464
import java.util.*;
import java.math.*;
 class Main
{
	public static void main(String[] args) {
		Scanner in= new Scanner(System.in);
String st=in.nextLine();
int ans=7;
if(st.compareTo("SAT")==0)
 ans=1;
else if(st.compareTo("FRI")==0)
ans=2;
else if(st.compareTo("THU")==0)
ans=3;
else if(st.compareTo("WED")==0)
ans=4;
else if(st.compareTo("TUE")==0)
ans=5; 
else if(st.compareTo("MON")==0)
ans=6;
	System.out.print(ans);
}
}


Measured memory_bytes: 22604
import java.util.Scanner;

public class Main{
	int[][] pat = {
		{4, 1, 4, 1, 2, 1, 2, 1},
		{1, 4, 1, 2, 1, 2, 1, 4},
		{4, 1, 2, 1, 2, 1, 4, 1},
		{1, 2, 1, 2, 1, 4, 1, 4},
		{2, 1, 2, 1, 4, 1, 4, 1},
		{1, 2, 1, 4, 1, 4, 1, 2},
		{2, 1, 4, 1, 4, 1, 2, 1},
		{1, 4, 1, 4, 1, 2, 1, 2},
	};
	
	Main(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] str = (sc.nextLine()).split(" ");
			int[] c = new int[8];
			for(int i = 0; i < 8; i++){
				c[i] = Integer.parseInt(str[i]);
			}
			
			int s = 99999, t = 0, p=0, q;
			for(int i = 0; i < 8; i++){
				int u = 0, v;
				String st = "";
				for(int j = 0; j < 8; j++){
					v = c[j] - pat[i][j];
					if(v < 0){
						v = 0;
					}
					u += v;
					st += Integer.toString(pat[i][j]);
				}
				q = Integer.parseInt(st);
				if(s > u || (s == u && p > q)){
					s = u;
					t = i;
					p = q;
				}
			}
			
			System.out.print(Integer.toString(pat[t][0]));
			for(int i = 1; i < 8; i++){
				System.out.print(" "+Integer.toString(pat[t][i]));
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
//**************************
//*** author  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
  
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,ans=0;
vector <pii> v;
map <LL,LL> mp;

LL fastpow(LL x,LL a)
{
	LL res=x,ret=1;
	while(a>0)
	{
		if((a&1)==1) ret=ret*res;
		a/=2;
		res=res*res;
	}
	return ret;
}

void dfs(int pos,vector <int> x)
{
	if(pos==v.size())
	{
		bool ok=false;
		rep(i,pos) if(x[i]>0) ok=true;
		if(!ok) return;
		LL lft,K;
		repn(i,40)
		{
			ok=true;
			rep(j,pos)
			{
				if(x[j]%i>0)
				{
					ok=false;
					break;
				}
			}
			if(!ok) continue;
			lft=K=1;
			rep(j,pos)
			{
				lft*=fastpow(v[j].fi,v[j].se-x[j]);
				K*=fastpow(v[j].fi,x[j]/i);
			}
			if((lft-1)%K==0&&K>1) mp[K]=1;
		}
		return;
	}
	x.pb(0);
	rep(i,v[pos].se+1)
	{
		x[pos]=i;
		dfs(pos+1,x);
	}
}

int main()
{
	cin>>n;
	LL sv=n-1;
	for(LL i=2;i<=1e6;i++)
	{
		LL tmp=0;
		while(n%i==0)
		{
			tmp++;
			n/=i;
		}
		if(tmp>0) v.pb(mpr(i,tmp));
	}
	if(n>1) v.pb(mpr(n,1));
	dfs(0,{});
	if(sv>1)
	for(LL i=1;i*i<=sv;i++)
	{
		if(sv%i==0)
		{
			if(i*i==sv||i==1||sv/i==1) ans++;
			else ans+=2;
		}
	}
	cout<<ans+mp.size()<<endl;
	return 0;
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	bool is = false;
	if(s.size() >=4 && s.at(0) == 'Y' && s.at(1) == 'A' && s.at(2) == 'K' && s.at(3) == 'I') {
		is = true;
	}
	cout << (is ? "Yes" : "No");
	return 0;
}



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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int H, A;
  cin >> H >> A;
  int ans = 0;
  while (true) {
    H -= A;
    ans++;
    if (H <= 0) break;
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,X,Y;
int cnt[3001];
int d[5001];
vector<int>G[3001];
typedef pair<int,int>P;
void dijkstra(int x){
	REP(i,N){
		d[i]=1e9;
	}
	d[x]=0;
	priority_queue<P,vector<P>,greater<P> >que;
	que.push(P(0,x));
	while(que.empty()==false){
		P p=que.top();
		//cout<<p.first<<" "<<p.second<<endl;
		que.pop();
		if(p.first>d[p.second])continue;
		int now=p.second;
		int value=p.first;
		d[now]=value;
		REP(i,G[now].size()){
			que.push(P(value+1,G[now][i]));
		}
	}
	REP(i,N){
		cnt[d[i]]++;
	}
}

int main(){
	cin>>N>>X>>Y;
	X--;
	Y--;
	REP(i,N-1){
		G[i].push_back(i+1);
		G[i+1].push_back(i);
	}
	G[X].push_back(Y);
	G[Y].push_back(X);
	REP(i,N){
		dijkstra(i);
	}
	REP(i,N){
		if(i==0)continue;
		cout<<cnt[i]/2<<endl;
	}
}

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

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    --k;
    if(s[k] == 'A') s[k] = 'a';  
    if(s[k] == 'B') s[k] = 'b';  
    if(s[k] == 'C') s[k] = 'c';  
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string X;cin >> X;
  int cntS = 0;
  int N = X.size();
  int ans = N;
  for(int i = 0; i < N; ++i){
    if(X[i] == 'S')cntS++;
    else if(cntS > 0){
      cntS--;
      ans-=2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640