akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N,M;
    map<string,int> m;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++){
        cin >> s[i];
        m[s[i]] = 0;
    }
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++){
        cin >> t[i];
        m[t[i]] = 0;
    }

    for (int i = 0;  i < N; i++){
        m[s[i]]++;
    }
    for (int i = 0; i < M; i++){
        m[t[i]]--;
    }
    int maxv = 0;
    for (int i = 0; i < N; i++){
        maxv = max(maxv,m[s[i]]);
    }
    cout << maxv << endl;
    /*
    if (maxv < 0){
        cout << 0 << endl;
    } else {
        cout << maxv << endl;
    }
    */
    



    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] sList = S.toCharArray();
		int sum = 0;

		for (char s : sList) {
			if (s == '+') {
				sum += 1;
			} else {
				sum -= 1;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  ull n, m;
  cin >> n >> m;

  if (n == m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll H1,H2, M1, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  ll time = (H2 - H1)*60 + M2 - M1;
  cout << time - K << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int ans=0,mx=INT_MAX,flag=0;
    for(int i=0;i<s.size();i++){
        ans=0;
        for(int j=0;j<t.size();j++){
            if(i+j>=s.size()){
                flag=1;
                break;
            }
            if(s[i+j]!=t[j]){
                ans++;
            }
        }
        if(flag==1)break;
        mx=min(mx,ans);
    }
    cout<<mx;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
int n,a,b,ct = 0,count = 0;
int flag[8] = {0,0,0,0,0,0,0,0};

scanf("%d",&n);
for(;n > 0;n--){
scanf("%d",&a);
if(a < 3200){flag[a /400] = 1;}
else{ct++;}
}
for(n = 0;n < 8;n++){
count += flag[n];
}
if(count != 0){a = count;}
else{a = 1;}
b = count + ct;
printf("%d %d\n",a,b);
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
using namespace  std;

int main() {
	int N;
	string S, T;
	string ST="";
	cin >> N;
	cin >> S>>T;
	for (int i = 0; i < N; i++) {
		ST = ST + S[i] + T[i];
	}
	cout << ST << endl;
	return 0;
}

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

int a[106];

int main ()
{
    int n,m;
    cin >> n >> m;
    for (int i=0;i<n;++i)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    int cnt=0;
    for (int i=0;i<n;++i)
    {
        if (a[i] <= m)
        {
            ++cnt;
            m -= a[i];
        }
    }
    if (m == 0)
    {
        cout << cnt << endl;
        return 0;
    }
    else if (cnt == n)
    {
        cout << n-1 << endl;
    }
    else cout << cnt << endl;
}



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

using namespace std;

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

    unsigned long long int nm[100000];
    long double ans = 1;
    for (int i = 0; i < n; i++)
    {
        scanf("%llu", &nm[i]);
        if (nm[i] == 0)
        {
            printf("0");
            return 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        ans *= nm[i];

        if (ans > 1000000000000000000)
        {
            printf("-1");
            return 0;
        }
    }

    printf("%lld", (long long int)ans);

    return 0;
}

Measured memory_bytes: 4580
using System;
using System.Text;

namespace atCodeTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string strings = Console.ReadLine();

            long str1 = Convert.ToInt64(strings.Split(' ')[0]);
            long str2 = Convert.ToInt64(strings.Split(' ')[1]);

            long res = lcm(str1, str2);
            Console.WriteLine(res);
            Console.ReadLine();
        }
        static long lcm(long a, long b)
        {
            return (a * b) / gcd(a, b);
        }
        static long gcd(long a, long b)
        {
            if (a == 0)
                return b;

            return gcd(b % a, a);
        }
    }
}

Measured memory_bytes: 11220
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo


@mt
def slv(N, K, A):

    def f(l):
        k = 0
        for a in A:
            k += -(-a//l) - 1
        return 1 if k <= K else 0

    ans = Bisect(f).bisect_left(1, 1, 10**9+1)

    return ans


def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 101328
#include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){
     
    vector<vector<vector<ll>>> ans(21, vector<vector<ll>>(11, vector<ll>(256)));
      
    REP(i, 1, 21){
        ans[i][1][i] = 1;
        REP(j, 1, 11){
            for(int k = 0; k <= 255; k++){
                ans[i][j][k] += ans[i - 1][j][k];
                if(k - i >= 0) ans[i][j][k] += ans[i - 1][j - 1][k - i];
            }
        }
    }
     
    int n, k, s;
    while(cin >> n >> k >> s, n, k, s){
        cout << ans[n][k][s] << endl;
    }
     
  
    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll either = 0;
  ll sum = 0;
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
    if (i > 1) {
      either ^= A.at(i);
    }
    else {
      sum += A.at(i);
    }
  }
  ll both = sum - either;
  if (both % 2 == 1 || both >= A.at(0) * 2 + 1) {
    cout << -1 << "\n";
    return 0;
  }
  both /= 2;
  if (either & both) {
    cout << -1 << "\n";
    return 0;
  }
  // bitset<40> bs1(either);
  ll ans_small = 0;
  for (ll i = 39; i >= 0; --i) {
    ll temp = pow(2, i);
    if (either & temp) {
      if (ans_small + temp + both <= A.at(0)) {
        ans_small += temp;
      }
    }
  }
  if (both + ans_small == 0) {
    cout << -1 << "\n";
    return 0;
  }
  ll ans = A.at(0) - (both + ans_small);
  cout << ans << "\n";
}


Measured memory_bytes: 4068
#include<cstdio>
using namespace std;
bool d[10];
bool Check(int n){
  while(n>0){
    if(d[n%10]){
      return false;
	}	
  n /= 10;
  }
  return true;
}
int main(){
  int n, k;
  scanf("%d%d", &n, &k);
 
  for(int i=0; i<k; i++){
    int tmp;
    scanf("%d", &tmp);
    d[tmp] = true;
  }
  
  while(!Check(n)){
    n++;
  }
  printf("%d", n);  
}  

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

int main(){
  vector<pair<long long int, long long int>> P(1e5);
  long long int n, m, a, b;
  
  cin >> n >> m;
  
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    P[i] = make_pair(a, b);
  }
  
  sort(P.begin(), P.end());
  
  long long int ans = 0;
  for(int i = 1e5 - n; i<1e5; i++){
    if(P[i].second < m){
      ans += P[i].first * P[i].second;
      m -= P[i].second;
    }else{
      ans += P[i].first * m;
      break;
    }
  }
  cout << ans<< endl;
}

Measured memory_bytes: 1792
l_6 = []
_ = 1
while 6**_ < 100000:
    l_6.append(6**_)
    _ += 1
l_6.sort(reverse = 1)

l_9= []
_ = 1
while 9**_ < 100000:
    l_9.append(9**_)
    _ += 1
l_9.sort(reverse = 1)

n = int(input())

w = 0
z = []
for i in range(n+1):
    x = i
    for j in range(len(l_6)):
        while l_6[j] <= x:
            x -= l_6[j]
            w += 1
    else:
        w += x
    
    y = n-i
    for k in range(len(l_9)):
        while l_9[k] <= y:
            y -= l_9[k]
            w += 1
    else:
        w += y

    z.append(w)
    w = 0

print(min(z))


Measured memory_bytes: 3992
// ABC 143-D
// 2019.10.19 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
int getchar_unlocked(void);
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void Qsort(int *a, int l, int r) {
	int i, j, m, t;
	
	i = l, j = r, m = a[(l+r) >> 1];
	while (1) {
		while (a[i] < m) i++;
		while (m < a[j]) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

int L[2005];

int main()
{
	int i, j, k, N, ans;
	
	N = in();
	for (i = 0; i < N; ++i) L[i] = in();
	Qsort(L, 0, N-1);
	ans = 0;
	for (i = 0; i < N; ++i) {
		for (j = i+1; j < N; ++j) {
			for (k = j+1; k < N; ++k) {
				if (L[i] + L[j] <= L[k]) break;
				++ans;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/
static const int MAX_N = 110;
static const int WHITE=0, GRAY=1, BLACK=2;
static const int INF = pow(10,8);

int color[MAX_N], M[MAX_N][MAX_N], d[MAX_N], p[MAX_N];
int N;

void dijkstra(int s){
    d[s] = 0; p[s] = -1;
    color[s] = GRAY;
    while(true){
        int minv = INF;
        int u = -1;
        rep(i,N){
            if(color[i] != BLACK && d[i] < minv){
                minv = d[i];
                u = i;
            }
        }

        if(u == -1) break;   // 全頂点への最短経路を調べ終えたということ

        color[u] = BLACK;
        rep(v,N){
            if(color[v] != BLACK && M[u][v] != INF){
                if(d[u]+M[u][v] < d[v]){
                    d[v] = d[u] + M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    rep(i,N){
        printf("%d %d\n", i, d[i]);
    }
}

int main()
{
    cin >> N;
    // 初期化
    rep(i,N){
        color[i] = WHITE; d[i] = INF;
        rep(j,N) M[i][j] = INF;
    }
    // 読み込み
    rep(i,N){
        int u, k; cin >> u >> k;
        rep(j,k){
            int v, c; cin >> v >> c;
            M[u][v] = c;
        }
    }
    dijkstra(0);
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int N;
	int A, B, C, D, E, F;

	cin >> A >> B >> C >> D >> E >> F;
	bool dp1[3005]={};
	dp1[0] = true;
	rep(i,3005){
		int nx = i+100*A;
		if( nx <= F ) dp1[nx] |= dp1[i];
	}
	rep(i,3005){
		int nx = i+100*B;
		if( nx <= F ) dp1[nx] |= dp1[i];
	}
	bool dp2[3005]={};
	dp2[0] = true;
	rep(i,3005){
		int nx = i+C;
		if( nx <= F ) dp2[nx] |= dp2[i];
	}
	rep(i,3005){
		int nx = i+D;
		if( nx <= F ) dp2[nx] |= dp2[i];
	}

	double ans = -1.0;
	int ans_s = 0;
	int ans_w = 0;
	rep(w,3005) rep(s,3005) if(dp1[w] && dp2[s]){
		if( s > E*w/100 ) continue;
		if( w + s > F ) continue;
		double a = w;
		double b = s;
		double con = 100.0 * b / (a+b);
		if( chmax(ans, con) ){
			ans_s = s;
			ans_w = w;
		}
	}

	cout << (ans_s+ans_w) << " " << ans_s << endl;

	return 0;
}


Measured memory_bytes: 256
L, R =map(int,input().split())
cnti = 0
cntj = 0
ans = 2020
for i in range(L,R+1):
    if cnti > 2020:
        break
    cntj = 0
    cnti += 1
    for j in range(i+1,R+1):
        if cntj > 2020:
            break
        ans = min(ans,(i*j)%2019)
        cntj += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

ll Pow(ll n,ll r){
	ll dim=1;
	for(ll i=0;i<r;i++)dim*=n;
	return dim;
}

int main(){
	int n,ans;
	cin>>n;
	ans=n;
	for(int i=0;i<=n;i++){
		int count=0;
		int dim=i;
		while(dim>0){
			count+=dim%6;
			dim/=6;
		}
		int dim2=n-i;
		while(dim2>0){
			count+=dim2%9;
			dim2/=9;
		}
		if(ans>count){
			ans=count;
		}
		DEB(i)END
	}
	cout<<ans<<endl;
	return 0;
}
//n=13

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

long long ans;
bool graph[10][10],visited[10];

void dfs(int now, int n){

  bool all_visited=true;
  for(int i=0;i<n;i++){
    if(!visited[i]){
      all_visited=false;
    }
  }
  if(all_visited){
    ans++;
    return ;
  }
  for(int i=0;i<n;i++){
    if(now!=i and graph[now][i] and !visited[i]){
      visited[i]=true;
      dfs(i, n);
      visited[i]=false;
    }
  }
  return ;
}

int main(){
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  visited[0]=true;
  dfs(0, n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
N = str(N)

if len(N) == 2:
    b = int(N[-2])
    c = int(N[-1])
    x = 10*b + c
elif len(N) == 1:
    c = int(N[-1])
    x = c
else:
    a = int(N[-3])
    b = int(N[-2])
    c = int(N[-1])
    x = 100*a + 10*b + c
ans = 1000 - x
if ans == 1000:
    ans = 0
print(ans)

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

const int n = 62;
int l = 128, nc[100];
char c[100];

int query(string s) {
  cout << "? " << s << endl;
  int r;
  cin >> r;
  return r;
}

string ass(vector<int> & v) {
  string s;
  for (int i : v)
    s.push_back(c[i]);
  return s;
}

int query(vector<int> & v) {
  return query(ass(v));
}

void answer(vector<int> & v) {
  cout << "! " << ass(v) << endl;
}

void rep(vector<int> & v, int a, int m) {
  for (int i = 0; i < m; i++)
    v.push_back(a);
}

void pre(vector<int> & v, vector<int> & r, int m) {
  for (int i = 0; i < m; i++)
    r.push_back(v[i]);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  for (int i = 0; i < 10; i++)
    c[i] = '0' + i;
  for (int i = 0; i < 26; i++)
    c[i + 10] = 'a' + i, c[i + 36] = 'A' + i;
  int ll = l, hl = 0;
  for (int i = 0; i < n; i++) {
    string s;
    s.push_back(c[i]);
    int cl = query(s);
    ll = min(ll, cl);
    hl = max(hl, cl);
  }
  if (ll == hl)
    l = ll + 1;
  else
    l = hl;
  for (int i = 0; i < n; i++) {
    vector<int> v;
    rep(v, i, l);
    nc[i] = l - query(v);
  }
  vector<int> res;
  for (int i = 0; i < n; i++) {
    if (!nc[i])
      continue;
    if (sz(res) == 0) {
      rep(res, i, nc[i]);
      continue;
    }
    vector<int> pos;
    int lp = sz(res);
    for (int j = 0; j < nc[i]; j++) {
      int lw = 0, hi = lp + 1;
      while (lw + 1 < hi) {
        int mid = (lw + hi) / 2;
        vector<int> qh;
        pre(res, qh, mid);
        rep(qh, i, j + 1);
        if (l - query(qh) == mid + j + 1)
          lw = mid;
        else
          hi = mid;
      }
      pos.push_back(lw);
      lp = lw;
    }
    for (int j : pos)
      res.insert(res.begin() + j, i);
  }
  answer(res);
}


Measured memory_bytes: 3796
def build_tree(N, edge_list):

    G = dict()
    for i in range(1, N+1):
        G[i] = dict()

    for i in range(N-1):
        a, b = edge_list[i]
        G[a][b] = 1
        G[b][a] = 1

    leaves = []
    for i in range(1, N+1):
        if len(G[i].keys()) == 1:
            leaves.append(i)

    return G, leaves


def pop_leaf_loop(G, leaves, c_list):

    res_list = [""]*N

    for i in range(N):
        leaf = leaves[i]
        res_list[leaf-1] = str(c_list[i])
        for j in G[leaf]:
            del G[j][leaf]
            if len(G[j].keys()) == 1:
                leaves.append(j)

    return res_list


if __name__ == "__main__":
    N = int(input())
    edge_list = [[] for _ in range(N-1)]
    for i in range(N-1):
        edge_list[i] = list(map(int, input().split()))
    c_list = list(sorted(list(map(int, input().split()))))
    G, leaves = build_tree(N, edge_list)
    res_list = pop_leaf_loop(G, leaves, c_list)
    print(sum(c_list) - max(c_list))
    print(" ".join(res_list))


Measured memory_bytes: 52696
S = input()

S_p1 = S[:2]
S_p2 = S[2:]

def is_MM(s):
    return int(s) >= 1 and int(s) <= 12

if is_MM(S_p1) and is_MM(S_p2):
    print("AMBIGUOUS")
elif not is_MM(S_p1) and not is_MM(S_p2):
    print("NA")
elif is_MM(S_p1):
    print("MMYY")
elif is_MM(S_p2):
    print("YYMM")



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

int n, w;
int value[100], weight[100], dp[101][10001];

int main(){
        scanf("%d %d", &n, &w);
        for(int i=0; i<n; i++) scanf("%d %d", &value[i], &weight[i]);

        memset(dp, 0, n*w);
        for(int i=0; i<n; i++){
                for(int j=0; j<=w; j++){
                        if(j<weight[i]){
                                dp[i+1][j] = dp[i][j];
                        }else{
                                dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i]);
                        }
                }
        }
        printf("%d\n", dp[n][w]);
        return 0;
}


Measured memory_bytes: 7128
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

class Heap{
public:
	Heap(){
		array = new long long[2000000];
		n = 0;
	}
	void insert(long long data){
		array[n] = data;
		int tmp = n;
		while(tmp != 0 && array[tmp] > array[(tmp-1)/2]){
			std::swap(array[tmp], array[(tmp-1)/2]);
			tmp = (tmp-1)/2;
		}
		n++;
	}
	long long extract(){
		int ret = array[0];
		n--;
		std::swap(array[0],array[n]);
		int tmp = 0;
		while(2*tmp+1 <= n-1){
			if(2*tmp+2 <= n-1){
				if(array[2*tmp+2] > array[tmp] && array[2*tmp+2] >= array[2*tmp+1]){
					std::swap(array[2*tmp+2],array[tmp]);
					tmp = 2*tmp+2;
				}else if(array[2*tmp+1] > array[tmp] && array[2*tmp+1] >= array[2*tmp+2]){
					std::swap(array[2*tmp+1],array[tmp]);
					tmp = 2*tmp+1;
				}else{
					break;
				}
			}else{
				if(array[tmp] < array[2*tmp+1]){
					std::swap(array[tmp],array[2*tmp+1]);
					tmp = 2*tmp+1;
				}else{
					break;
				}
			}
		}
		return ret;
	}

private:
	long long* array;
	int n;
};

int main(){

	long long insert_data;
	char buf[22];
	Heap heap;

	while(true){
		fgets(buf,22,stdin);
		if(buf[2] == 'd') break;
		if(buf[0] == 'i'){
			insert_data = 0;
			for(int i = 0; buf[i] != '\0';i++){
				if(buf[i] >= '0' && buf[i] <= '9'){
					insert_data = 10*insert_data + (buf[i] - '0');
				}
			}
			heap.insert(insert_data);
		}else{
			printf("%lld\n",heap.extract());
		}
	}
}

Measured memory_bytes: 10128
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a >= 0 && c >= 0)
    {
        c -= b;
        if (c <= 0)
        {
            break;
        }
        a -= d;
        if (a <= 0)
        {
            break;
        }
    }
    if (a <= 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

string S; cin >> S ;

if(S=="ABC") cout << "ARC" << endl;

else cout << "ABC" << endl;

return 0;
}

Measured memory_bytes: 3628
n = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
diff_p = []
diff_m = []

for i in range(n):
    diff = A[i] - B[i]
    if diff >= 0:
        diff_p.append(diff)
    else:
        diff_m.append(diff)

diff_p.sort(reverse=True)
diff_m.sort()

ans = 0
if sum(A) < sum(B):
    ans = -1
else:
    ans += len(diff_m)
    target = sum(diff_m)
    if len(diff_m) > 0:
        for p in diff_p:
            target += p
            ans += 1
            if target >= 0:
                break
            
print(ans)        

Measured memory_bytes: 18708
fun main(args: Array<String>) {
    val nNum = readLine()!!.toInt()
    val numLine = readLine()!!
    val numbers = numLine.split(" ").map { s -> s.toInt() }.toIntArray()

    var swapCount = 0
    for (i in 0..nNum-1) {
        var minJ = i
        for (j in i..nNum-1) {
            if (numbers[j] < numbers[minJ]) {
                minJ = j
            }
        }
        if (minJ != i) {
            val temp = numbers[minJ]
            numbers[minJ] = numbers[i]
            numbers[i] = temp

            swapCount++
        }
    }

    printNumbers(numbers)
    println(swapCount)
}

private fun printNumbers(numbers: IntArray) {
    for (i in 0..numbers.size-1) {
        print(numbers[i])
        if (i != numbers.size-1) {
            print(" ")
        }
    }
    println()
}



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

int main() {
vector<char>S(6);
  for(int i=0;i<6;i++){
    cin >>S[i];
  }
    if(S[2]==S[3]&&S[4]==S[5]){
        cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}


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

const long long int mod = 1e9+7;

long long int dfs(int k, vector<vector<int> >& graph, int from, int now)
{
  long long int case_num = 1;
  int can_color_num;
  if(from == -1){
    can_color_num = k-1;
  }else{
    can_color_num = k-2;
  }

  if(k < graph[now].size()) return 0;

  // for(int e : graph[now)){
  //   if(e == from) continue;
  //   case_num *= can_color_num;
  //   can_color_num--;
  //   can_color_num %= mod;
  // }
  //
  // for(int e : graph[now)){
  //   if(e == from) continue;
  //   case_num *= dfs(k, graph, now, e);
  //   case_num %= mod;
  // }

  for(int i = 0; i < graph[now].size(); i++){
    if(graph[now][i] == from) continue;
    case_num *= can_color_num;
    can_color_num--;
    case_num %= mod;
  }
  for(int i = 0; i < graph[now].size(); i++){
    if(graph[now][i] == from) continue;
    case_num *= dfs(k, graph, now, graph[now][i]);
    case_num %= mod;
  }

  return case_num;
}

int main() {
  int n, k; cin >> n >> k;
  vector<vector<int> > graph(n);
  for(int i = 0; i < n-1; i++){
    int a, b; cin >> a >> b; a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  long long int ans = k * dfs(k, graph, -1, 0);
  ans %= mod;
  cout << ans << endl;
}


Measured memory_bytes: 11520
#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 n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    int ans = 0;
    int cnt = 0;
    rep(i,n-1){
        if(a[i]>=a[i+1])ans=max(ans,++cnt);
        else cnt = 0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
s = input()
res_list = []
# 2^nはbit全探索が効果絶大！！
for i in range(2 ** (len(s) - 1)):
    res = s[0]
    for j in range((len(s) - 1)):
        if (i >> j) & 1:
            res += '+'
        res += s[j + 1]
    res_list.append(eval(res))

print(sum(res_list))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
  
  int n;
  int a,b,c,d;

  int i,j,k,l;
  int count;

  
  while(scanf("%d",&n)!=EOF) {

    count=0;

    for(i=0;i<10;i++) {

      for(j=0;j<10;j++) {

	for(k=0;k<10;k++) {

	  for(l=0;l<10;l++) {

	    if(i+j+k+l==n) count++;

	  }

	}

      }

    }

    printf("%d\n",count);
  
  }

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (s); i < (int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i = (int)(s - 1); i >= (int)(e); i--)
#define pb push_back
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template <typename T> T chmax(T &a, const T &b) { return a = (a > b ? a : b); }
template <typename T> T chmin(T &a, const T &b) { return a = (a < b ? a : b); }

struct UF { // O(loga(n))
    int n;
    int m;
    vi d, r;
    UF(int n) : n(n), m(n), d(n, -1), r(n, 0){};
    int root(int i) {
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y])
            swap(x, y);
        else if(r[x] == r[y])
            r[x]++;
        d[x] += d[y];
        d[y] = x;
        --m;
        return true;
    }
    int size(int i) { return -d[root(i)]; }
    int size() { return m; }
};

int main() {
    int w, h;
    while(cin >> w >> h) {
        if(w == 0 && h == 0) break;
        vector<vi> d(h, vi(w));
        rep(i, h) rep(j, w) cin >> d[i][j];
        UF uf(h * w);
        rep(i, h) rep(j, w) {
            if(d[i][j]) REP(dy, -1, 2) REP(dx, -1, 2) {
                int x = j + dx, y = i + dy;
                if(min(x, y) < 0 || x >= w || y >= h || d[y][x] == 0)
                    continue;
                uf.unite(i * w + j, y * w + x);
            }
        }
        int ans = 0;
        rep(i, h) rep(j, w) if(d[i][j] && uf.root(i * w + j) == i * w + j) {
            ++ans;
            // cout << " " << i << " " << j << endl;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int n, l;
string a[101];
int main()
{
	cin >> n >> l;
	rep(i, n)
	{
		cin >> a[i];
	}
	sort(a, a+n);
	rep(i, n)
	{
		cout << a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll a[110], b[110], c[110], d[110];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < M; i++) cin >> c[i] >> d[i];
	for (int i = 0; i < N; i++) {
		int length =  mod;
		int point = 0;
		for (int j = 0; j < M; j++) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < length) {
				length = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				point = j;
			}
		}
		cout << point + 1 << endl;
	}
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
C=[]
A=[]
for _ in range(N):
    ci,*ai = map(int,input().split())
    C.append(ci)
    A.append(ai)
# もし全部買っても理解度が足りなければ不可能
sum_x = [0 for i in range(M)]
for i in range(N):
    ai = A[i]
    for j,aij in enumerate(ai):
        sum_x[j] += aij
min_x = min(sum_x)
if min_x<X:
    print('-1')
    exit()

# 普通にビット探索
import math
max_bit = 2**(N)
min_expense = math.inf
for i in range(2**(N)):
    binary = bin(max_bit+i)[1+2:]
    sum_x = [0 for _ in range(M)]
    expense = 0
    for j,b in enumerate(binary):
        if b=='1':
            expense += C[j]
            for k,ajk in enumerate(A[j]):
                sum_x[k] += ajk
    min_x = min(sum_x)
    if min_x<X:
        continue
    min_expense = min(expense,min_expense)

print(min_expense)








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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int n = read();
  string s = readString();
  int x = 0, ans = 0;
  for (auto &c : s) {
    if (c == 'I')
      x++;
    else if (c == 'D')
      x--;
    chmax(ans, x);
  }
  print(ans);
}


Measured memory_bytes: 2304
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  VI a(5);
  int ans=0;
  rep(i,5){
    cin>>a[i];
    if(a[i]==0) ans=i+1;
  }
  cout<<ans<<endl;


}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    int n,k;
    cin >> n >> k;
    int l=k/2;
    if(k&1) print((ll)(n/k)*(ll)(n/k)*(ll)(n/k));
    else print((ll)(n/k)*(ll)(n/k)*(ll)(n/k)+(ll)(n/l-n/k)*(ll)(n/l-n/k)*(ll)(n/l-n/k));
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < s.size(); i++){
    if (i % 2 == 0){
      if (s[i] == '0'){
        cnt2++;
      }
      else{
        cnt1++;
      }
    } else {
      if (s[i] == '0'){
        cnt1++;
      }
      else
        cnt2++;
    }
  }
  cout << min(cnt1, cnt2) << endl;
  return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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


int main(){

    lli N;
    cin>>N;

    for(lli n=1;n<=3500;n++){
        for(lli w=1;w<=3500;w++){
            lli a = n*w*N;
            lli b = 4*n*w - n*N - w*N;
            if(b<=0)continue;
            if(a%b!=0)continue;
            lli h = a/b;
            cout<<h<<" "<<n<<" "<<w<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
vl BIT(500500);
ll n , q;
void add(ll ind , ll x){
  for(ll i = ind; i <= n; i += (i & -i)){
    BIT[i] += x;
  }
}
      
ll sum(ll ind){
  ll ret = 0;
  for(ll i = ind; i > 0; i -= (i & -i)){
    ret += BIT[i];
  }
  return ret;
}

signed main(){
	//cout << fixed << setprecision(10);
    cin >> n >> q;
    rep(i,1,n+1){
      ll a; cin >> a;
      add(i , a);
    }
    while(q--){
      ll t; cin >> t;
      ll a , b; cin >> a >> b;
      if(t == 0){
        add(a+1 , b);
      }
      else{
        cout << sum(b) - sum(a) << endl;
      }
    }
  

	return 0;
}


Measured memory_bytes: 8216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; ++i) {
		for (int j = 0; j <= x; ++j) {
			if (i + j == x && 2 * i + 4 * j == y) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

const int M = 13;

string s;
ll t = 1, ans;
ll dp[2][13];
int ind[13][13];
int ho = 0, ge = 1;

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

    rep(i,M) {
        rep(j,M) ind[i][j] = i*j%M;
    }

    cin >> s;
    dp[ho][0] = 1;
    for (int i = (int)s.size()-1; i >= 0; i--) {
        rep(j,M) dp[ge][j] = 0;
        if (s[i] != '?') {
            int x = t*(s[i]-'0')%M;
            rep(j,M) {
                if (x == M) x -= M;
                dp[ge][x++] = dp[ho][j];
            }
        } else {
            ll sum = 0;
            rep(j,9) sum += dp[ho][ind[t][j]];
            for (int j = 9; j < M; j++) {
                sum += dp[ho][ind[t][j]];
                //sum = (sum+MOD*MOD)%MOD;
                dp[ge][ind[t][j]] = sum;
                sum = sum+MOD-dp[ho][ind[t][j-9]];
            }
            for (int j = 0; j < 9; j++) {
                sum += dp[ho][ind[t][j]];
                //sum = (sum+MOD*MOD)%MOD;
                dp[ge][ind[t][j]] = sum;
                sum = sum+MOD-dp[ho][ind[t][j+4]];
            }
        }
        rep(j,M) dp[ge][j] %= MOD;
        t = t * 10 % M;
        swap(ho,ge);
    }
    cout << dp[ho][5]%MOD << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
 
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
#define L 2
#define U 3
#define R 0
#define D 1
 
int cost[30][30];
bool wall[4][30][30];
bool visited[30][30];
int w, h;
 
int bfs(int sx, int sy, int gx, int gy) {
  fill(cost[0], cost[32], 0);
  fill(visited[0], visited[32], false);
  cost[0][0] = 1;
   
  queue<pair<int, int> > Q;
  Q.push(make_pair(0, 0));
  visited[0][0] = true;
  while(!Q.empty()) {
    pair<int, int> st = Q.front(); Q.pop();
     
    if(st.first == gx && st.second == gy) {
      return cost[gy][gx];
    }
     
    for(int i=0; i<4; i++) {
      int nx = st.first + dx[i], ny = st.second + dy[i];
      if(0<= nx && nx < w && 0<= ny && ny < h) {
    if(!visited[ny][nx] && !wall[i][st.second][st.first]) {
      visited[ny][nx] = true;
      cost[ny][nx] = cost[st.second][st.first] + 1;
      Q.push(make_pair(nx, ny));
    }
      }
    }
  }
  return 0;
}
 
int main() {
  while(cin >> w >> h && w+h) {
    for(int i=0; i<4; i++) for(int j=0; j<32; j++) for(int k=0; k<32; k++) wall[i][j][k] = 0;
     
    for(int i=0; i<h; i++) {
      wall[R][i][0] = wall[L][i][w-1] = 1;
    }
    for(int i=0; i<w; i++) {
      wall[D][0][i] = wall[U][h-1][i] = 1;
    }
     
    for(int i=0; i<h; i++) {
       
      for(int j=0; j<w-1; j++) {
    cin >> wall[L][i][j];
    wall[R][i][j+1] = wall[L][i][j];
      }
       
      if(i < h-1) {
    for(int j=0; j<w; j++) {
      cin >> wall[U][i][j];
      wall[D][i+1][j] = wall[U][i][j];
    }
      }
    }
 
    /*
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
    cout << "R: " << wall[R][i][j] << " L: " << wall[L][i][j] << " U: " << wall[U][i][j] << " D: " << wall[D][i][j] << endl;
      }
    }
    */
     
    cout << bfs(0, 0, w-1, h-1) << endl;
    /*
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) 
    cout << cost[i][j] << " "; 
      cout << endl; 
    }
    */
  }
   
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>     
#define ll long long      
using namespace std;  
inline ll read()  
{  
    long long f=1,sum=0;  
    char c=getchar();  
    while (c<'0' || c>'9')  
    {  
        if (c=='-') f=-1;  
        c=getchar();  
    }     
    while (c>='0' && c<='9')  
    {  
        sum=sum*10+c-'0';  
        c=getchar();  
    }  
    return sum*f;  
}  
int main()  
{  
    ll l=read(),r=read();  
    int ans=0;  
    while (r>=l) l*=2,ans++;   
    cout<<ans;  
    return 0;  
}  

Measured memory_bytes: 256
import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline

MOD = 1000000007

# input functions
I = lambda : int(input())
M = lambda : map(int, input().split())
Ms = lambda : map(str, input().split()) 
ARR = lambda: list(map(int, input().split()))

def main():
    n, k = M()
    arr = ARR()
    for i in range(n - k):
        # print(arr[i], arr[k+i])
        if arr[k + i] > arr[i]:
            print("Yes")
        else:
            print("No")
        


# testcases
tc = 1
for _ in range(tc):
    main()

Measured memory_bytes: 101056