akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 200000;
vector<int> ed[N];
int used[N];
void dfs(int v, int p) {
    used[v] = 1;
    for (auto to: ed[v]) {
        if (used[to] == 3) {
            continue;
        }
        if (to == p) {
            continue;
        }
        if (used[to] == 1) {
            cout << "Yes\n";
            exit(0);
        }
        dfs(to, v);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        ed[u].push_back(v);
        ed[v].push_back(u);
    }
    bool even = true;
    for (int i = 1; i <= n; i++) {
        if (ed[i].size() % 2 == 1) {
            even = false;
        }
    }
    if (!even) {
        cout << "No\n";
        return 0;
    }
    int cnt = 0;
    int nm = 0;
    int qq = 0;
    for (int i = 1; i <= n; i++) {
        if (ed[i].size() >= 6) {
            cout << "Yes\n";
            return 0;
        }
        if (ed[i].size() >= 4) {
            nm = i;
        }
    }
    if (nm == 0) {
        cout << "No\n";
        return 0;
    }
    used[nm] = 3;
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            dfs(i, 0);
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 9984
h,w = map(int,input().split())
board = [input() for i in range(h)]

move = [[0,1],[0,-1],[1,0],[-1,0],[1,1],[-1,1],[1,-1],[-1,-1]]
for i in range(h):
    ans = []
    for j in range(w):
        cnt = "#"
        if board[i][j] == "#":
            ans.append("#")
            continue
        cnt = 0
        for mx,my in move:
            x,y = i+mx,j+my
            if 0 > x or x >= h or 0 > y or y >= w:continue
            if board[x][y] == "#":
                cnt += 1
        ans.append(str(cnt))
    print("".join(ans))




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

constexpr int64_t MOD = 1000000007;

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

    vector<int64_t> fac(2001), finv(2001);

    fac[0] = 1;
    finv[0] = 1;

    auto modpow = [&](int64_t x, int64_t m) {
        int64_t ans = 1;
        while(m != 0){
            if(m&1) ans = ans*x % MOD;
            x = x*x % MOD;
            m = m >> 1;
        }
        return ans;
    };

    for (int i=1; i<=2000; i++) {
        fac[i] = fac[i-1] * i % MOD;
        finv[i] = finv[i-1] * modpow(i, MOD-2) % MOD;
    }

    auto combi = [&](int64_t a, int64_t b) -> int64_t {
        if (a < b) return 0;
        if (a < 0 || b < 0) return 0;
        return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
    };

    for (int i = 1; i <= k; i++) {
        int64_t ans = combi(n-k+1, i) * combi(k-1, i-1) % MOD;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for (int i = 0; i < N; i++)
    cin >> card.at(i);
  
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  int v;
  int diff = 0;
  for (int i = 0; i < N; i++) {
    if ( (i % 2) == 0 ) {
      diff = diff + card.at(i);
    } else {
      diff = diff - card.at(i);
    }
  }  
  cout << diff << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[200100];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
  }
  int it = max_element(Input, Input+N) - Input;
  // cout << it << endl;
  int max = Input[it];
  Input[it] = -1;
  int next_it = max_element(Input, Input+N) - Input;
  // cout << next_it << endl;

  
  int next = Input[next_it];
  
  for (int i = 0; i < N; i++) {
    if (i == it) {
      cout << next << endl;
    } else {
      cout << max << endl;
    }
  }
}


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

signed main(){

  int n,m; cin >> n >> m;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<P> cb(m);
  for(int i = 0; i < m; i++){
    cin >> cb[i].second >> cb[i].first;
  }
  sort(a.begin(),a.end());
  sort(cb.rbegin(),cb.rend());

  int k = 0;
  for(int i = 0; i < m; i++){
    int cnt = 0;
    while(k < n && cnt < cb[i].second){
      if(a[k] <= cb[i].first){
        a[k] = cb[i].first;
        k++;
        cnt++;
      }
      else break;
    }
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += a[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <queue>
#include <map>
using namespace std;
struct info{
        int count;
        bool operator<(const info &other)const{
                return count<other.count;
        }
};
int main(){
        int n,k;
        cin >> n >> k;
        map<int,info> a;
        for(int i=0 ; i<n ; i++ ){
                int x;
                cin >> x;
                a[x].count++;
        }
        priority_queue<int> decrease;
        int now=0;
        for(int i=0 ; i<=200000 ; i++ ){
                if(a[i].count!=0){
                        decrease.push(a[i].count*-1);
                        now++;
                }
        }
        int counter=0;
        while(now>k){
                counter-=decrease.top();
                now--;
                decrease.pop();
        }
        cout << counter << endl;
        return 0;
}

Measured memory_bytes: 10748
# サイコロ        初期状態
#    [1]           N
# [4][2][3][5]   W[1]E
#    [6]           S
#
# 上記の順番でラベルに対する整数が与えられる
# l1 l2 l3 l4 l5 l6
# 2つのサイコロが一致するか

class Dice:
    def __init__(self, l1, l2, l3, l4, l5, l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.tmp = 0
    def move_n(self):
        self.tmp = self.l5
        self.l5 = self.l1
        self.l1 = self.l2
        self.l2 = self.l6
        self.l6 = self.tmp
    def move_s(self):
        self.tmp = self.l2
        self.l2 = self.l1
        self.l1 = self.l5
        self.l5 = self.l6
        self.l6 = self.tmp
    def move_e(self):
        self.tmp = self.l3
        self.l3 = self.l1
        self.l1 = self.l4
        self.l4 = self.l6
        self.l6 = self.tmp
    def move_w(self):
        self.tmp = self.l4
        self.l4 = self.l1
        self.l1 = self.l3
        self.l3 = self.l6
        self.l6 = self.tmp
    def show(self):
        return self.l1, self.l2, self.l3, self.l4, self.l5, self.l6

yn_f = False
d1 = Dice(*map(int, input().split()))
d2 = Dice(*map(int, input().split()))

if set(d1.show()) == set(d2.show()):
    ne_switch = 0
    while d1.l2 != d2.l2:
        if ne_switch < 3:
            d1.move_n()
            ne_switch+=1
        elif 3 <= ne_switch :
            d1.move_e()
            ne_switch+=1
        if ne_switch == 6: ne_switch = 0
    e_cnt = 0
    while d1.l1 != d2.l1 and e_cnt <= 3:
        d1.move_e()
        e_cnt+=1

if d1.l3 == d2.l3 and d1.l4 == d2.l4 and d1.l5 == d2.l5 and d1.l6 == d2.l6:
    yn_f = True

print('Yes' if yn_f else 'No')


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



int main(){
	
	long long x, y;
	cin >> x >> y;
	long ans = 0;
	
	for(long long i = x; i <= y; i*=2)
	{
		ans++;
	}
	
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int a, b, c, n;
	cin >> n;
	for (int i = 3500; i >= 0; i--) {
		for (int j = 1; j <= 3500; j++) {
			a = n*i*j;
			b = 4*i*j - n*i - n*j;
			if (a%b == 0 && b > 0) {
				cout << i << " " << j << " " << a / b << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 384
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    int res = 0;
    FOR(i,1,n)
        FOR(j,1,i-1)
            FOR(k,1,j-1)
                if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i]) {
                    if (a[i] < a[j] + a[k]) res++;
                }
    cout << res;
    return 0;
}


Measured memory_bytes: 3652
class SegTree:
    def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num =2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele]*2*self.num
        self.segfunc = segfunc
        
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
    
### 使い方 ##
N = int(input())


GOTO = [i for i in range(1,N+1)]
INF = 10**15
ide_ele = -1
SEG = SegTree(GOTO,ide_ele,max)


LIST = []
XX = []
mod = 998244353

for i in range(N):
    X,D = map(int,input().split())
    LIST.append([X,D])

LIST.sort(key=lambda x: x[0])
for i in range(N):
    XX.append(LIST[i][0])

#print(LIST)
import bisect
for i in range(N-1):
    j = N-2-i
    Xj = LIST[j][0]
    Dj = LIST[j][1]
    Nj = bisect.bisect_right(XX, Xj+Dj-1)
    #print(Xj,Dj,j+1,Nj)
    NEXT = SEG.query(j+1,Nj)
    if NEXT != -1:
        GOTO[j] = NEXT
        SEG.update(j,NEXT)
    
S = [-1]*(N+1)
S[N] = 1

#print(LIST)
#print(GOTO)
for i in range(N):
    j = N-1-i
    S[j] = S[j+1] + S[GOTO[j]]
    S[j] %= mod

print(S[0])

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

int main(){
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> p;
    rep(i,n){
        ll a;
        cin >> a;
        p.push(a);
    }
    rep(i,m){
        ll b = p.top();
        p.pop();
        p.push(b/2);
    }
    ll ans = 0;
    while(!p.empty()){
        ll c = p.top();
        p.pop();
        ans += c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
/* ex 5_4
   nnasy */

#include <stdio.h>
//最大入力量より大きいサイズをとる
#define SIZE 30

int main(void){
    //str: 与えられた文字列を格納する配列
    //ptr: strの各要素へのポインタ
    char str[SIZE], *ptr;
    //count: str内のAGCT文字列のそれぞれの長さを調べるための整数
    //max: countの最大値を入れておく整数
    int count=0, max=0;

    //与えられた文字列を入力
    scanf("%s", str);

    //ptrにstrのアドレスを代入
    ptr = str;

    //ptrの位置が'\0'になるまでwhile文を動かす
    while(*ptr){
        //ptrの位置がAGCTのいずれかならcountを1増やし、アドレスをずらす
        if (*ptr=='A' || *ptr=='G' || *ptr=='C' || *ptr=='T'){
            count++;
            ptr++;
        //ptrの位置がAGCTのいずれでもないときmax値を調べる
        }else{
            if (count>max){
                max=count;
            }
            //countしなおすので0に戻し、アドレスをずらす
            count=0;
            ptr++;
        }
    }

    //文字列の末尾がAGCTのいずれかのとき最大長が変わる可能性がある
    if (count>max){
        max=count;
    }

    //入力した文字列の部分文字列のうち最も長いACGT文字列の長さを出力
    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 1708
import math
N=int(input())
rt = int(math.sqrt(N))
# print(rt)

res = 0
for a in range(1, rt+1):
    if N % a == 0:
        b1 = N // a
        b = b1-1 
        if b > a and b > 0:
            res += b

print(res)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int N;
int A[200005]={0};
int main(){
	cin>>N;
	int MAX=-1,MAXn;
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
		if(MAX<A[i]){
			MAX=A[i];
			MAXn=i;
		}
	}
	sort(A,A+N,greater<int>());
	if(A[0]==A[1]){
		for(int i=0;i<N;i++){
			cout<<A[0]<<endl;
		}
		return 0;
	}
	for(int i=0;i<N;i++){
		if(i==MAXn) cout<<A[1]<<endl;
		else cout<<A[0]<<endl;
	}
	return 0;
}

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

int main() {
    int a,b,c; cin >> a >> b >> c;
    if(a == b)cout << c << endl;
    else if(a == c)cout << b << endl;
    else cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int[] ints=new int[n];
        for(int i=0;i<n;i++){
            ints[i]=scanner.nextInt();
        }
        int result=selectionSort(ints);
        for(int i=0;i<ints.length;i++){
            System.out.print(ints[i]);
            if(i!=ints.length-1){
                System.out.print(" ");
            }
        }
        System.out.println();
        System.out.println(result);
    }
    public static int selectionSort(int[] ints){
        int result=0;
        for(int i=0;i<ints.length;i++){
            int minj=i;
            for(int j=i;j<ints.length;j++){
                if(ints[j]<ints[minj]){
                    minj=j;
                }
            }
            if(i!=minj){
                result++;
                int tmp=ints[i];
                ints[i]=ints[minj];
                ints[minj]=tmp;
            }
        }
        return result;
    }

}



Measured memory_bytes: 26316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, q, l, r;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<ll> a(n+1), b(n+1);
    for (ll i=1; i<n; i++){
        if (s[i-1] == 'A' && s[i] == 'C'){
            a[i] += a[i-1] + 1;
            b[i+1] += b[i] + 1;
        }
        else {
            a[i] = a[i-1];
            b[i+1] = b[i];
        }
    }
    rep1(i, q){
        cin >> l >> r;
        cout << b[r] - a[l-1] << endl;
    }
}

Measured memory_bytes: 5084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		scn.nextLine();
		char[] str = scn.nextLine().toCharArray();
		N%=26;

		for(int i = 0;i < str.length;i++) {
			str[i] = (char)( (((int)str[i] + N) - 'A')%26 + 'A' );
		}
		for(int i = 0;i < str.length;i++) {
			System.out.print(str[i]);
		}
	}

}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

int n, a, b;
vii v;

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		v.pb(mp(b, a));
	}
	sort(v.begin(), v.end());
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += v[i].sc;
		if (sum > v[i].fs) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

long long gcd(long long a, long long b) {
    if (b==0) return a;
    return gcd(b, a%b);
}

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

    int N, X; cin >> N >> X;
    int x[100000 +1]; REP(i,1,N+1) cin >> x[i];

    REP(i,1,N+1) x[i] = abs(x[i] -X);
    int ans = x[1];
    REP(i,2,N+1) ans = gcd(ans, x[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		double w;
		
		while(scan.hasNextDouble()){
			w = scan.nextDouble();
			
			if(w <= 48.00)System.out.println("light fly");
			if(w > 48.00 && w <= 51.00)System.out.println("fly");
			if(w > 51.00 && w <= 54.00)System.out.println("bantam");
			if(w > 54.00 && w <= 57.00)System.out.println("feather");
			if(w > 57.00 && w <= 60.00)System.out.println("light");
			if(w > 60.00 && w <= 64.00)System.out.println("light welter");
			if(w > 64.00 && w <= 69.00)System.out.println("welter");
			if(w > 69.00 && w <= 75.00)System.out.println("light middle");
			if(w > 75.00 && w <= 81.00)System.out.println("middle");
			if(w > 81.00 && w <= 91.00)System.out.println("light heavy");
			if(w > 91.00)System.out.println("heavy");
		}
	}
}

Measured memory_bytes: 27988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+6;
const ll inf=1e14;
int n,a[N];
ll b[N];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<=n;i++) scanf("%d",&a[i]);
    b[0]=1-a[0];
    if(b[0]<0)
    {
        printf("-1\n");return 0;
    }
    for(int i=1;i<=n;i++)
    {
        b[i]=b[i-1]*2-a[i];
        b[i]=min(b[i],inf);
        if(b[i]<0)
        {
            printf("-1\n");return 0;
        }
    }
    ll ans=a[n],sum=a[n];
    for(int i=n-1;i>=0;i--)
    {
        sum=min(sum,b[i])+a[i];
        ans+=sum;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 5000
def bisection(B_sum, x):
    M = len(B_sum)
    if B_sum[0] > x:
        return 0
    elif B_sum[-1] <= x:
        return M
    else:
        low = 0
        high = M-1
        while True:
            new = (low+high)//2
            if B_sum[new]>x:
                high = new
            else:
                low = new
            if (high-low)==1:
                break
        return high


N, M, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

A_sum = []
B_sum = []

total = 0
for i in range(N):
    total += A[i]
    A_sum.append(total)
total = 0
for i in range(M):
    total += B[i]
    B_sum.append(total)

#print(A_sum)
#print(B_sum)

max_book = 0
##no A
max_book = bisection(B_sum, K)
#print(max_book)
##at least one A
for i in range(N):
    if A_sum[i] > K:
        break
    book = bisection(B_sum, K-A_sum[i])
    #print(book)
    if (i+book+1) > max_book:
        max_book = i+book+1
    
print(max_book)

Measured memory_bytes: 47240
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int price=700;
  if(s[0]=='o') price+=100;
  if(s[1]=='o') price+=100;
  if(s[2]=='o') price+=100;
       cout << price << endl;
       return 0;
       }
       


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	long[][long] AB;
	foreach (i; 0..N)
	{
		auto A = RD;
		auto B = RD;
		AB[A] ~= B;
	}
	foreach (key; AB.keys)
	{
		AB[key].sort();
	}

	auto data = new long[](N);
	auto heap = heapify(data, 0);
	auto keys = AB.keys;
	keys.sort();
	long ans;
	foreach (i; 1..M+1)
	{
		if (!keys.empty)
		{
			while (keys.front <= i)
			{
				auto key = keys.front; keys.popFront;
				foreach (e; AB[key])
				{
					heap.insert(e);
				}
				if (keys.empty) break;
			}
		}
		if (heap.empty) continue;
		ans += heap.front; heap.removeFront;
		debug writeln(i, ":", ans);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 17788
#include<stdio.h>
int main(){
  long long n,i,j,ans=0;
  scanf("%lld",&n);
  if(n!=2)ans=n-1;
  for(i=2;i*i<n;i++){
    if(n%i)continue;
    j=n/i;
    if(n/(i-1)==n%(i-1))ans+=i-1;
    if(n/(j-1)==n%(j-1))ans+=j-1;//printf("%d\n",ans);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
m = input().split()
N = int(m[0])
Y = int(m[1])
ans = [0] * 3

for a in range(N+1):
  for b in range(N - a + 1):
    c = N - (a + b)
    money = (a * 10000) + (b * 5000) + (c * 1000)

    if money == Y:
      ans[0] = a
      ans[1] = b
      ans[2] = c
      break
  else:
    continue

  break

if ans == [0, 0, 0]:
  ans = [-1, -1, -1]

x = ans[0]
y = ans[1]
z = ans[2]

print(str(x) + ' ' + str(y) + ' ' + str(z))


Measured memory_bytes: 3064
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b] <- map readInt . BS.words <$> BS.getLine
  putStrLn $ if solve a b then "Yes" else "No"

solve :: Int -> Int -> Bool
solve a b = elem (read (show a ++ show b)) squareNumbers

squareNumbers :: [Int]
squareNumbers = takeWhile (< 100100) $ map (^ (2 :: Int)) [1 .. ]

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt


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

int main(void)
{
    long long n;
    cin >> n;
    int a, b, res;
    int half = (int)std::sqrt(n);
    for(int i=half; i>=1; i--){
        if(n%i == 0){
            a = i;
            b = n/i;
            if (a<b){
                res = (int)std::log10(b);
            }
            else{
                res = (int)std::log10(a);
            }
            break;
        }
    }
    printf("%d\n", res+1);
}

Measured memory_bytes: 3952
#include<iostream>
using namespace std;
int main()
{
 int n,m;
 cin>>n>>m;
 if(n>=m)
 {
 for(int i=0;i<n;i++)
 {
    cout<<m;
 }
}
else
{
    for(int i=0;i<m;i++)
    {
        cout<<n;
    }
}
    return 0;


}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
char g[105][105];
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int cnt=0;
int n,m;
int dfs(int x,int y)
{
	int flag=0;
	rep(i,0,4)
	{
		int xx=x+dir[i][0];
		int yy=y+dir[i][1];
		if(xx>=n||yy>=n||xx<0||yy<0) continue;
		if(g[xx][yy]=='#') flag++;
	}
	if(flag==0) return 1;
	return 0;
}

int main(){
	cin>>n>>m;
	int flag2=0;
	rep(i,0,n) scanf("%s",g[i]);
	rep(i,0,n)	rep(j,0,n)	if(g[i][j]=='#') {
	if(dfs(i,j)==1 )
	{
		flag2=1;
		break;
	}
	}
	
	if(flag2==0) printf("Yes\n");
	else printf("No\n");
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int n,k,center;
    int x[100010];
    cin >> n >> k;
    rep(i,n){
        cin >> x[i];
        if(x[i]==0)center=i;
    }
    int ans = 1e9;
    int left,right;
    for(left=0,right=k-1;right<n;left++,right++){
        int l = abs(x[left])+abs(x[right]-x[left]);
        int r = abs(x[right])+abs(x[right]-x[left]);
        ans = min(ans,min(l,r));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

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

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
h,w = readInts()
dist = [['0'] * w for _ in range(h)]
maze = [input() for _ in range(h)]
dx = [-1,-1,-1,0,0,1,1,1]
dy = [-1,0,1,-1,1,-1,0,1]

def bfs(y,x):
    dist[y][x] = '#'
    for i in range(8):
        nx = x + dx[i]
        ny = y + dy[i]
        if not(0 <= nx < w and 0 <= ny < h):
            continue
        if maze[ny][nx] == '#':
            continue
        dist[ny][nx] = str(int(dist[ny][nx]) + 1)


for y in range(h):
    for x in range(w):
        if maze[y][x] == '#':
            bfs(y,x)
for i in range(h):
    print("".join(dist[i]),sep = '')


Measured memory_bytes: 5084
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int m,n;
	cin>>m>>n;
	vector<int> a(n);
	int ans=0;
	rep(i,n){
		cin>>a[i];
	}
	if(m==2){
		int x=0,y=0;
		rep(i,n){
			if((a[i]+i)%2)++x;
			else ++y;
		}
		cout<<min(x,y)<<endl;
		return 0;
	}
	rep(i,n-1){
		if(a[i]==a[i+1]){
			++ans;
			a[i+1]=-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3116
function main()
    N = pread(Int)
    a = readvec(Int, N)
    mon = 1000
    for i in 1:N-1
        kb = 0
        if a[i] < a[i+1]
            kb += mon ÷ a[i]
        end
        mon += (a[i+1]-a[i]) * kb
    end
    println(mon)
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 186472
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

typedef pair<int, int> P;
#define rep(i,a) for(int i=0;i<(a);++i)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int w,h,sx,sy,gx,gy,n;
int board[102][102];

int main()
{
    while(cin >> w >> h && w) {
        memset(board, 0, sizeof(board));
        cin >> sx >> sy >> gx >> gy >> n;
        
        int c, d, x, y;
        rep(k, n) {
            cin >> c >> d >> x >> y;
            if(d == 0)
                rep(i, 2) rep(j, 4) 
                    board[i + y][j + x] = c;
             else 
                rep(i, 4) rep(j, 2) 
                    board[i + y][j + x] = c;
        }

        int e = board[sy][sx];
        queue<P> que;
        que.push(P(sx, sy));
        bool ok = false;
        while(!que.empty()) {
            P p = que.front(); que.pop();
            x = p.first; y = p.second;
            if(x == gx && y == gy) {
                ok = true;
                break;
            }
            if(board[y][x] != e) 
                continue;

            board[y][x] = -1;
            for(int k = 0; k < 4; k++) {
                int nx = x + dx[k];
                int ny = y + dy[k];
                if(nx >= 1 && nx <= w && ny >= 0 && ny <= h && board[ny][nx] == e) 
                    que.push(P(nx, ny));
            }
        }

        cout << ((ok) ? "OK" : "NG") << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
    while(true) {
        int a[4], b[4];
        for(int i = 0; i < 4; ++i) cin >> a[i];
        for(int i = 0; i < 4; ++i) cin >> b[i];
        if(cin.eof()) break;

        int hit = 0, blow = 0;
        for(int i = 0; i < 4; ++i) {
            if(a[i] == b[i]) {
                ++hit;
                a[i] = b[i] = -1;
            }
        }
        for(int i = 0; i < 4; ++i) {
            if(b[i] == -1) continue;
            for(int j = 0; j < 4; ++j) {
                if(a[j] == b[i]) {
                    ++blow;
                    a[j] = b[i] = -1;
                    break;
                }
            }
        }

        cout << hit << ' ' << blow << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <map>
#include <climits>

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

int main()
{
  int n;
  cin >> n;
  map<string, int> ms;
  rep(i, n)
  {
    string s;
    cin >> s;
    ms[s]++;
  }
  int maxv = 0;
  for(auto kv : ms)
  {
    maxv = max(maxv, kv.second);
  }
  for(auto kv : ms)
  {
    if(kv.second == maxv)
      cout << kv.first << endl;
  }
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int m,n,r=100001,l=0,a,b;
    cin >> n >> m;
    rep(i,m){
        cin >> a >> b;
        l=max(l,a);
        r=min(r,b);
        if(l>r){
            cout << 0 << "\n";
            return 0;
        }
    }
    cout << r-l+1 << "\n";
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double result = 0;
    for(int i = 0; i < n; i++){
      result += 1/sc.nextDouble();
  	}
    
    System.out.println(1/result);
  }
}

Measured memory_bytes: 25172
import java.util.*;

class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int A = sc.nextInt();
	int B = sc.nextInt();
	int res = 0;

	for(int i = 1; i <= N; i++) {
	    int sum = 0;
	    for(int m = i; m > 0; m /= 10) {
		sum += m % 10;
	    }
	    if(sum >= A && sum <= B) {
		res += i;
	    }
	}
	
	System.out.println(res);
    }
}


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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;


typedef pair<int,int> pa;
pa a[N];
int W[N];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m,d;
    cin>>n>>m>>d;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++){
           int x;
           cin>>x;
           a[x]={i,j};
        }
    }

    for(int i=1;i<=d;i++){
         for(int j=i+d;j<=n*m;j+=d){
            W[j]=abs(a[j].first-a[j-d].first)+abs(a[j].second-a[j-d].second)+W[j-d];
           // cout<<abs(a[j].first-a[j-d].first)+abs(a[j].second-a[j-d].second)+W[j-d]<<endl;
         }
    }
   int q;cin>>q;
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<W[r]-W[l]<<endl;
    }

    return 0;
}


Measured memory_bytes: 4624
//出力をprintfにしたりその場で出力するようにしたりした
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;

int res[101010];
string s;

int main(){
  cin >> s;
  int n = s.size();
  s.push_back('R');
  
  int left = 0, mid = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == s[i + 1]) continue;
    
    if(s[i] == 'R' && s[i + 1] == 'L'){
      mid = i;
      continue;
    }
    res[mid] = (i - mid) / 2 + ((mid - left) / 2) + 1;
    res[mid + 1] = (mid - left + 1) / 2 + (i - mid - 1) / 2 + 1;
    
    for(int j = left; j <= i; j++){
      printf("%d ", res[j]);
    }
    
    left = i + 1;
  }
  
  printf("\n");
    
  return 0;
}

Measured memory_bytes: 1024
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
int dp[55][55*55][55];

void solve()
{
    int n,a;
    cin>>n>>a;
    dp[0][0][0]=1;
    vector<int>v;
    rep1(i,n){
        rep0(j,55*55)rep0(k,55){
            dp[i][j][k]=dp[i-1][j][k];
        }
        int x;
        cin>>x;
        v.pb(x);
        repp(j,x,55*55){
            rep1(k,55){
                dp[i][j][k]+=dp[i-1][j-x][k-1];
            }
        }
    }
    int ans=0;
    rep1(i,54){
        ans+=dp[n][i*a][i];
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


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

int main() {
  int X, A, B;
  scanf("%d%d%d", &X, &A, &B);

  if (B <= (A + X)) {
    if (B <= A) {
      printf("delicious");
    } else {
      printf("safe");
    }
  } else {
    printf("dangerous");
  }
  return 0;
}

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

int main(){
	double num,maximum=0,minimum=DBL_MIN,cnt=0;
	while(cin>>num){
		maximum=max(maximum,num);
		if(cnt==0){
			minimum=num;
		}else{
			minimum=min(minimum,num);
		}
		cnt++;
	}
	cout<<maximum-minimum<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>

int main (int argc, char **argv)
{
  int n = 0;
  char x[16] = {0};
  char u[4] = {0};
  int i = 0;
  long long ji = 0;
  long long jf = 0;
  long long bi = 0;
  long long bf = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
  {
    scanf("%s %s", x, u);
    if(*u == 'J')
    {
      ji += atoi(x);
    }
    else
    {
      bi += atoi(strtok(x, "."));
      bf += atoi(strtok(NULL, "."));
      while(bf >= 100000000)
      {
        bi++;
        bf -= 100000000;
      }
    }
  }

  ji = ji + (bi * 380000) + ((38 * bf) / 10000);
  jf = (38 * bf) % 10000;

  printf("%lld", ji);
  if(jf)
  {
    printf(".%04lld\n", jf);
  }

  return 0;
}


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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m=0,k,i,a,b,j;
	str s,st;
	cin >> s;
	cin >> st;
	for(i=0;i<s.size();i++)
	{
		if(s[i]!=st[i])
			m=1;
	}
	if (m)
	{
		cout << "No\n";
	}
	else
		cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int n, m;
string bt;
vector<string> vec;
map<string, string> mpp;

void conv()
{
  string str;

  for(int i = 0; i < n; ++i){
    str = "";
    for(int j = 0; j < vec[i].size(); ++j){
      if(vec[i][j] <= 'c') str += '2';
      else if(vec[i][j] <= 'f') str += '3';
      else if(vec[i][j] <= 'i') str += '4';
      else if(vec[i][j] <= 'l') str += '5';
      else if(vec[i][j] <= 'o') str += '6';
      else if(vec[i][j] <= 's') str += '7';
      else if(vec[i][j] <= 'v') str += '8';
      else str += '9';
    }
    mpp[vec[i]] = str;
  }
}

void solve(string str, int p)
{
  if(p == m){
    str += ".";
    cout << str << endl;
    return;
  }

  int l;
  for(int i = 0; i < n; ++i){
    l =vec[i].size();
    if(l+p <= m && mpp[vec[i]] == bt.substr(p, l)){
      if(p > 0) solve((str+" "+vec[i]), p+l);
      else solve(vec[i], p+l);
    }
  }
}

int main()
{
  while(cin>>n && n){
    vec = vector<string>(n);
    for(int i = 0; i < n; ++i) cin >> vec[i];
    cin >> bt;

    m = bt.size();
    conv();
    solve("", 0);
    cout << "--" << endl;

    mpp.clear();
    vec.clear();
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

// index が条件を満たすかどうか
int main() {
	int n;
	cin >> n;
	long long int ans = 0;
	map<pair<int, int>, long long int>s;
	for (int i = 1; i <= n; i++) {
		long long int a = i % 10;
		long long int b = i;
		long long  int c = 0;
		long long int temp = 0;
		if (a != 0) {
			while (b > 0) {
				c = b % 10;
				b = b / 10;
			}
			pair<int, int>key;
			key.first = a;
			key.second = c;
			s[key]++;
		}
	}
	for (int i = 1; i <= 9;i++) {
		for (int j = 1; j <= 9; j++) {
			pair<int, int>key,key2;
			key.first = i;
			key.second = j;
			key2.first = j;
			key2.second = i;
			if (i == j) {
				ans = ans + s[key] * s[key];
			}
			else {
				ans = ans + s[key] * s[key2];
			}

		}
	}
	cout << ans;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (a[i] > x) break;
        else {
            x -= a[i];
            cnt++;
        }
        if (i == n-1 && x > 0) cnt--;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,x,y;
    scanf("%d",&a);
    x = a/100;
    y = a%100;
    if( 0<x && x<13 && 0<y && y<13){
        printf("AMBIGUOUS");
    }else if( (x>12&& 0<y && y<13) || (x==0 && 0<y && y<13) ){
        printf("YYMM");
    }else if(0<x && x<13){
        printf("MMYY");
    }else{
        printf("NA");
    }
    return 0;
}


Measured memory_bytes: 128
N = input("")
L = input("").split(" ")
suc = int(N)
min_ = 200001

for i in range(int(N)):
    if (L[i] == 1):
        min_= 1
        continue
    if (int(min_) < int(L[i])):
        suc -= 1
        continue
    if (int(min_) >= int(L[i])):
        min_ = L[i]
print(suc)

Measured memory_bytes: 19336
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
char a[30002];
int dp[30002][4];
int last[10];
void sol() {
  int n;
  cin >> n;
  a[0] = '$';
  for(int i=1; i<=n; i++) {
    cin >> a[i];
  }
  a[n+1] = '\0';
  for(int i=0; i<=n; i++) {
    dp[i][0] = 1;
  }
  for(int i=1; i<=n; i++) {
    for(int j=0; j<=3; j++) {
      if(j) {
        dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
        int v = last[a[i]-48];
        if(v > 0) {
          dp[i][j] -= dp[v-1][j-1];
        }
      }
      //cout << i << "," << j << ":";
      //cout << dp[i][j] << " ";
    }
    last[a[i]-48] = i;
  }
  cout << dp[n][3];
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


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

S = input()

if S == "keyence":
	print("YES")
	exit()

for i, j in combinations(list(range(len(S))), 2):
	if S[:i] + S[j:] == "keyence":
		print("YES")
		break
else:
	print("NO")



Measured memory_bytes: 5200
S = input()
s_list=[]
string= ""
AGCT = ["A", "G", "C", "T"]
for s in S:
    if s in AGCT:
        #string = string + s
        string += s
    else:
        s_list.append(string)
        string=""
s_list.append(string)
print(max(map(len, s_list)))

Measured memory_bytes: 3060