akhauriyash/Code-Regression huggingface dataset:
def main():
    N, X = (int(i) for i in input().split())

    A = [1]
    B = [1]
    for i in range(N):
        A.append(2*A[-1]+3)
        B.append(2*B[-1]+1)

    def dfs(n, x):
        a = A[n]
        b = B[n-1]
        if n == 0:
            return 1
        elif n >= x:
            return 0
        elif x == a//2:
            return b
        elif x == a//2 + 1:
            return b + 1
        elif x < a//2:
            return dfs(n-1, x-1)
        elif x > a//2 + 1:
            return dfs(n-1, x-(a//2)-1) + (b + 1)

    print(dfs(N, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

// デバッグ用
#define _DEBUG
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
// ここまで
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    vector<int> l(N);
    vector<int> r(N);
    REP(i, N) { cin >> v[i]; }
    l[0] = v[0], r[N - 1] = v[N - 1];
    FOR(i, 1, N - 1) {
        l[i] = gcd(l[i - 1], v[i]);
        r[N - i - 1] = gcd(r[N - i], v[N - 1 - i]);
    }
    int ma = 0;
    REP(i, N) {
        if(i == 0) {
            chmax(ma, r[1]);
            continue;
        }
        if(i == N - 1) {
            chmax(ma, l[N - 2]);
            continue;
        }
        int a = gcd(l[i - 1], r[i + 1]);
        chmax(ma, a);
    }
    cout << ma;
    return 0;
}

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

int n, a = 2222, b = 2222;

int main()
{
    for (int i = 0; i < 3; i++)
    {
        cin >> n;
        a = min(n, a);
    }
    for (int i = 0; i < 2; i++)
    {
        cin >> n;
        b = min(n, b);
    }
    cout << a + b - 50 << endl;
}


Measured memory_bytes: 3104
while n = gets
  n = n.chomp.to_i
  if n>0
    a=1000-n
    b=a/500
    c=(a%500)/100
    d=(a%500%100)/50
    e=(a%500%100%50)/10
    f=(a%500%100%50%10)/5
    g=(a%500%100%50%10%5)/1
    puts b+c+d+e+f+g
  end
end

Measured memory_bytes: 6092
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int N, M;
	string s[101], t[101];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> s[i];
	}
	cin >> M;
	for (int i = 0; i < M; ++i) {
		cin >> t[i];
	}
	int ans = 0; int Ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (s[i] == s[j]) {
				ans++;
			}
		}
		for (int j = 0; j < M; ++j) {
			if (s[i] == t[j]) {
				ans--;
			}
		}
		Ans = max(Ans, ans);
		ans = 0;
	}
	if (Ans > 0)
		cout << Ans;
	else
		cout << 0;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,m = MI()
ab = LI(m)

g = [ [] for _ in range(n) ]
for i in range(m):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    g[a].append(b)
    g[b].append(a)
# print(g)

ls_ans = [-1]*n

q = deque()
q.append(0)

while q:
    t = q.popleft()
    ls = g[t]
    for i in ls:
        if ls_ans[i]==-1:
            ls_ans[i] = t
            q.append(i)
        else:
            pass
# print(ls_ans)

if -1 in ls_ans:
    print("No")
else:
    for i in range(n):
        if i==0:
            print("Yes")
        else:
            print( ls_ans[i] + 1 )

Measured memory_bytes: 121712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool comp(pair<ll, ll> x, pair<ll, ll> y) {
    if(x.second < y.second) return true;
    return false;
}
int main() {
    int n, flag = 1;
    cin >> n;
    pair<ll, ll> t[n];
    ll a, b, s = 0;
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        t[i].first = a;
        t[i].second = b;
    }
    sort(t, t + n, comp);
    for(int i = 0; i < n; i++) {
        s += t[i].first;
        if(s > t[i].second) {
            flag = 0;
            break;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3456
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define MAX 10000000000
#define rep(i,n) for(int i = 0; i < n;i++)
ll v, n, e, u, k, ans = 0,sum,d[50];
int main(void) {
	int x, k;cin >> k >> x;
	int a, b;a = x - k + 1;b = x + k - 1;
	for (int i = a;i <= b;i++) cout << i << " ";
}

Measured memory_bytes: 256
#include<stdio.h>

void quicksort(int i,int j,int *A);
int partition(int i,int j,int a,int *A);
int pivot(int i,int j,int *A);
void swap(int i,int j,int *A);

int main(void){
  int N,K,i;
  long total = 0;
  int h[200009];
  scanf("%d %d\n",&N,&K );
  for(i=0; i<N; i++){
    scanf("%d",&h[i] );
  }
  quicksort(0,N-1,h);
  for(i=0;i<N-K;i++ ){
    total += h[i];
  }
  printf("%ld\n",total );
  return 0;
}
void quicksort(int i,int j,int *A){
  int a,pv,k;
  pv = pivot(i,j,A);
  if(pv != -1){
    a = A[pv];
    k = partition(i,j,a,A);
    quicksort(i,k-1,A);
    quicksort(k,j,A);
  }
}
int partition(int i,int j,int a,int *A){
  int l,r,k;
  l = i;
  r = j;
  while(1){
    while(A[l] < a) l++;
    while(A[r] >= a) r--;
    if(l <= r){
      swap(l, r, A);
      l++;
      r--;
    }else break;
  }
  k = l;
  return k;
}
int pivot(int i,int j,int *A){
  int pv,k;
  k = i+1;
  while(k<=j && A[i] == A[k]) k++;
  if(k > j) pv = -1;
  else if(A[i] >= A[k]) pv = i;
  else pv = k;
  return pv;
}
void swap(int i,int j,int *A){
  int tmp;
  tmp = A[i];
  A[i] = A[j];
  A[j] = tmp;
}

Measured memory_bytes: 896
from collections import deque

n,m = map(int,input().split())

up = [[] for i in range(n)]
down= [[]for i in range(n)]
for i in range(n+m-1):
    a,b = map(int,input().split())
    a -=1
    b -=1
    up[b].append(a)
    down[a].append(b)

res = [-1]*n
root = -1

for i in range(n):
    if len(up[i])==0:
        res[i] = 0
        root = i
        break

#0なら不使用
used = [0]*n
used[root]=1

#yの親に不使用が一つも存在しなければTrue
def g(y):
    for pe in up[y]:
        if used[pe]==0:
            return False
    return True
    
#zの下のusedとresを埋める
def f(z):
    for e in down[z]:
        if used[e]==0 and g(e):
            res[e]=z+1
            tank2.append(e)
            usedtank.append(e)
c = 1
tank = deque([root])
tank2 = deque([root])
usedtank = []
while c != n:
    tank = tank2
    tank2 = deque([])
    usedtank = []
    while len(tank)!=0:
        f(tank.popleft())
    for usede in usedtank:
        used[usede]=1
    c += len(tank2)
    
for i in range(n):
    print(res[i])


Measured memory_bytes: 38900
def is_prime(num):
  if 2 < num and num % 2 == 0:
    return False

  n = num ** (1 / 2)

  cnt = 2

  while cnt <= n:
    if num % cnt == 0:
      return False
    cnt += 1
  
  return True

prime_num_cnt = 0

for i in range(int(input())):
  if is_prime(int(input())):
    prime_num_cnt += 1

print(prime_num_cnt)



Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    int N;
    cin >> N;
    int B[N-1];
    rep(i,N-1){
        cin >> B[i];
    }

    int A[N];
    A[0] = B[0];
    A[N-1] = B[N-2];
    for(int i = 1;i < N-1;i++){
        if(B[i-1] > B[i])
            A[i] = B[i];
        else
            A[i] = B[i-1];
    }
    int sum = 0;
    rep(i,N){
//        printf("%d ",A[i]);
        sum+=A[i];
    }
//    printf("\n");
    
    cout <<sum << endl;
    return 0;
}


Measured memory_bytes: 256
def bubbleSort(a, n)
  flag = true
  count = 0
  while flag do
    for i in 0..n-1 do
      flag = false
      for j in (i+1..n-1).to_a.reverse do
        if a[j] < a[j-1]
          a[j-1], a[j] = a[j], a[j-1]
          flag = true
          count += 1
        end
      end
    end
  end
  puts a.join(" ")
  puts count
end


n = gets.to_i
a = gets.split.map(&:to_i)
bubbleSort(a, n)



Measured memory_bytes: 6932
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];

      int minIdx = 0; 
      for(int i = 0; i < n; i++) {
        arr[i] = sc.nextInt();
        if(arr[minIdx] > arr[i]){
          minIdx = i;
        } 
      }

      int nextMinIdx = minIdx;
      minIdx = -1;
      while(minIdx != nextMinIdx) {
        minIdx = nextMinIdx;
        for(int i = 0; i < arr.length; i++) {
          if(i == minIdx) continue;
          arr[i] = arr[i] % arr[minIdx];
          if(arr[i] == 1) {
              System.out.println(1);
              return;
          }
          if(arr[nextMinIdx] > arr[i] && arr[i] != 0) {
            nextMinIdx = i;
          }
        }
      }
      System.out.println(arr[minIdx]);
  }
}

Measured memory_bytes: 50924
import sys
from collections import defaultdict as dd
import heapq
input = sys.stdin.readline
N, u, v = map(int, input().split())
e = dd(list)
for _ in range(N - 1):
  a, b = map(int, input().split())
  e[a].append((b, 1))
  e[b].append((a, 1))
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 6)
      v0 = v // (10 ** 6)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 6) + p[0])
    return d
d = dijkstra(N, e)
p = d.path(v, 0)
pp = d.path(u, 0)
#print(p)
#print(pp)
res = 0
for i in range(1, N + 1):
  if p[i] > pp[i]: res = max(p[i], res)
print(res - 1)

Measured memory_bytes: 103772
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

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

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

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

int N, H[100001];

int main() {
    cin >> N;
    REP (i, N) {
        cin >> H[i];
    }
    int acc = 0, max = 0;
    FOR (i, 1, N) {
        if (H[i] <= H[i - 1]) {
            acc++;
        }
        else {
            if (acc > max) {
                max = acc;
            }
            acc = 0;
        }
    }
    if (acc > max) {
        max = acc;
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

string s;

bool ok(int L, int R) {
    //cout<<L<<" "<<R<<endl;
    while(L <= R) {
        if(s[L] != s[R]) return false;
        L++, R--;
    }
    return true;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>s;
    int n = s.size();
    if(ok(0, n - 1) && ok(0, n / 2 - 1) && ok((n + 1)/2, n - 1)) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=0;i<=n;i++) cin >> a[i];

    if(n == 0){
        if(a[0] == 1){
            cout << 1 << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    vector<long long> mx(n+1, 0);
    mx[n] = a[n];
    for(int i=n-1;i>=0;i--) mx[i] = mx[i+1] + a[i];
    long long v = 1;
    long long ans = 1;
    for(int i=1;i<=n;i++){
        v = min(v*2, mx[i]);
        ans += v;
        v -= a[i];
        if((i == n && v < 0) || (i < n && v <= 0)){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
long long n,a,maj;
int main(){
	cin>>n;
	a=n;
	while(a>0){
		maj+=a%10;
		a/=10;
	}
	if(n%maj==0)
		cout<<"Yes";
	else
		cout<<"No";
}


Measured memory_bytes: 256
import sys
from itertools import product
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, Ma, Mb = map(int, input().split())
    ABC = [list(map(int, input().split())) for _ in range(n)]
    s = (n + 1) // 2
    t = n - s

    S = defaultdict(int)
    for pattern in product([0, 1], repeat=s):
        a = b = c = 0
        for idx, p in enumerate(pattern):
            if p == 1:
                a += ABC[idx][0]
                b += ABC[idx][1]
                c += ABC[idx][2]
        S[(a, b)] = min(S.get((a, b), f_inf), c)

    T = defaultdict(int)
    for pattern in product([0, 1], repeat=t):
        a = b = c = 0
        for idx, p in enumerate(pattern):
            if p == 1:
                a += ABC[s + idx][0]
                b += ABC[s + idx][1]
                c += ABC[s + idx][2]
        T[(a, b)] = min(T.get((a, b), f_inf), c)

    MAX_A = sum([a for a, _, _ in ABC])
    MAX_B = sum([b for _, b, _ in ABC])

    res = f_inf
    for k, v in S.items():
        a, b = k
        x, y = Ma, Mb
        while x <= MAX_A and y <= MAX_B:
            if T.get((x - a, y - b), -1) != -1:
                if not (a == b == 0 and x - a == x - b == 0):
                    cost = v + T[(x - a, y - b)]
                    res = min(res, cost)
            x += Ma
            y += Mb
    print(res if res != f_inf else -1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 71732
N, K = map(int, input().split())
mod = 10 ** 9 + 7

ans = 0
min_x, max_x = 0, 0
for i in range(N+1):
    min_x += i
    max_x += N-i
    if i+1 < K: continue
    ans += max_x - min_x + 1
    ans %= mod

print(ans)


Measured memory_bytes: 64200
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
flag = [[False]*3 for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                flag[i][j] = True
ans = False
for i in range(3):
    if all(flag[i][j] for j in range(3)):
        ans = True
    if all(flag[j][i] for j in range(3)):
        ans = True
if all(flag[i][i] for i in range(3)):
    ans = True
if all(flag[2-i][i] for i in range(3)):
    ans = True
if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n+1);
    REP(i, n) {
        scanf("%d", &a[i]);
        b[a[i]] = i;
    }
    set<int> st;
    st.insert(-1);
    st.insert(n);
    ll ans = 0;
    FOR(i,1,n+1) {
        auto lw = st.lower_bound(b[i]);
        ans += (ll)(*(lw)-b[i]) * (b[i] - *(--lw)) * i;
        st.insert(b[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int YesFlag = 0;
  if (S.at(2) == S.at(3)) {
    YesFlag++;
  }
  if (S.at(4) == S.at(5)) {
    YesFlag++;
  }
  if(YesFlag == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
	int N=0;
	cin >> N;
	if(N==0) return -1;
	
	vector <int> a(N);
	for(int i=0; i<N; i++){
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int alice, bob;
	
	for(int i=0; i<N; i++){
		if(i%2==0){
			alice += a.at(i);
		}else{
			bob += a.at(i);
		}
	}
	//cout << "Alice:" << alice << ", Bob:" << bob << endl;
	cout << alice-bob << endl;
	return 0;
}

Measured memory_bytes: 256
w = input()
t_list = list()
while True:
    t = input()
    if t == "END_OF_TEXT":
        break
    t_list.append(t)

cnt = 0
for t in t_list:
    for word in t.split(" "):
        if w.lower() == word.lower():
            cnt += 1

print(cnt)



Measured memory_bytes: 5556
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll a, b, c; cin >> a >> b >> c;
	if(a%2==1 && b%2==1 && c%2==1)
	{
		vector<ll> vec; vec.pb(a); vec.pb(b); vec.pb(c);
		sort(vec.begin(), vec.end());
		cout << vec[0]*vec[1];
	}
	else
	{
		cout << 0;
	}
}	


Measured memory_bytes: 256
#include <cstdio>

int n = 0, m = 0;
int u[66], v[66], c[66];
int main()
{
	int l; scanf("%d", &l);
	int C = l;
	while(l) l >>= 1, n++;
	l = C;
	for(int i = 1; i < n; i++) 
	{
		++m;
		u[m] = i; v[m] = i + 1; c[m] = 1 << (n - i - 1);
		++m;
		u[m] = i; v[m] = i + 1; c[m] = 0;
	}
	int s = 1 << (n - 1); 
	for(int i = n - 2; i >= 0; i--)
	{
		if((l >> i) & 1)
		{
			m++;
			u[m] = 1; v[m] = n - i; c[m] = s;
			s += 1 << i;
		}
	}
	printf("%d %d\n", n, m);
	for(int i = 1; i <= m; i++) printf("%d %d %d\n", u[i], v[i], c[i]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e5+1;
const ll mod = 1e9+7;


int main(){

    FASTIO;
    PRECISION;

    ll x;
    cin>>x;

    ll st = 100;
    ll cntr = 0;

    while(st<x){
        cntr++;
        ll add = st/100;
        st+=add;
    }

    cout<<cntr<<"\n";    
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int a[1005];
int sum;
int ans;
int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
	}
	double flag = sum*(1.00 /(4.00*m));
	for(int i = 1; i <= n; i++)
		if(a[i] >= flag) ans++;
	if(ans >= m) cout <<"Yes"<<endl;
	else cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9+7;

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

  int n;cin>>n;
  int odd=0;
  for(int i=0;i<n;i++){
      int a;cin>>a;
      if(a%2==1) odd++;
  }
  if(odd%2==1) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int sum,n;
	while(1){
	cin>>sum;
	if(sum==0)break;
	rep(i,9)
	{
		cin>>n;
		sum-=n;
	}
	cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const int maxn=6e5;
int dp[maxn];
int a[10];
int c[10]= {0,2,5,5,4,5,6,3,7,6};
int m;
void dfs(int n)
{
    for(int i=m-1; i>=0; i--)
    {
        if(dp[n]==dp[n-c[a[i]]]+1)
        {

            if(n>=c[a[i]])
            {
                cout<<a[i];
                dfs(n-c[a[i]]);
                return;
            }
        }
    }
}
int main()
{
    int n;
    cin>>n>>m;
    for(int i=0; i<m; i++)
        cin>>a[i];
    sort(a,a+m);
    memset(dp,-127,sizeof(dp));
    dp[0]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(i>=c[a[j]])
            {
                dp[i]=max(dp[i-c[a[j]]]+1,dp[i]);
            }
        }
        //cout<<dp[i]<<endl;
    }
    dfs(n);
}


Measured memory_bytes: 2560
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		int count = 0;
		for(int i = 0; i < n; i++){
			arr[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			if(arr[i] >= k)
				count++;
		}
		System.out.println(count);
		
	}

	}

Measured memory_bytes: 50364
#include <iostream>

int main() {
  int n;
  std::cin >> n;

  long h[n];
  for (int i = 0; i < n; i++) { std::cin >> h[i]; }

  int max = 0, cnt = 0;
  for (int i = 1; i < n; i++) {
    if (h[i - 1] >= h[i]) {
      cnt++;
    } else {
      if (max < cnt) max = cnt;
      cnt = 0;
    }
  }
  if (max < cnt) max = cnt;

  std::cout << max << std::endl;
}


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

int main() {
    int a, b, c;
    int tmp;
    cin >> a >> b >> c;

    if(a > b){
        tmp = b;
        b = a;
        a = tmp;
    }
    if(b > c){
        tmp = c;
        c = b;
        b = tmp;

        if(a > b){
            tmp = b;
            b = a;
            a = tmp;
        }
    }
    cout << a << ' ' << b << ' ' << c << endl;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long

int main()
{
    ll n,i;
    cin>>n;
    ld arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    
    ld d[n+1]={0};
    int j;
    d[0]=1;
    for(i=0;i<n;i++)
    {
    	ld p=arr[i],q=1-arr[i];
    	for(j=i+1;j>=0;j--)
    	{
    		d[j]=d[j]*q;
    		
    		if(j>0)
    		d[j]+=d[j-1]*p;
	    }
	}
	ld sum=0;
	for(i=n/2+1;i<=n;i++)
	sum+=d[i];
	cout<<fixed<<setprecision(20)<<sum;
	cout<<"\n";
	
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int g=a[0];
    for(int i = 0; i < n; i++) {
        g=__gcd(g,a[i]);
    }
    if(g!=1){
        cout << "not coprime" << "\n";
        return 0;
    }

    map<int,int> mp;
    for(int i = 0; i < n; i++) {
        int m=a[i];
        int d=2;
        while(d*d<=m) {
            if(m%d) d++;
            else{
                mp[d]++;
                while(m%d==0) m/=d;
            }
        }
        mp[m]++;
    }

    for(auto itr=mp.begin() ; itr!=mp.end() ; itr++) {
        if(itr->first!=1 && itr->second>1){
            cout << "setwise coprime" << "\n";
            return 0;
        }
    }

    cout << "pairwise coprime" << "\n";

    return 0;
}

Measured memory_bytes: 10668
#include<iostream>
 
using namespace std;
 
int main()
{
  int a;
  cin >> a;
  
  if (a == 7 || a == 5 || a == 3)
  {
    cout << "YES";
  }
  else
  {
    cout << "NO";
  }
 
  cout << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
const int inf = 10e9 + 7;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<n;i++)
#define endre getchar(); getchar();return 0;
int a[40][40];
int b[40];
int k[40];
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, n) {
		cin >> k[i];
		rep(j, k[i]) {
			cin >> a[i][j]; b[a[i][j]]++;
		}
	}
	int ans = 0;
	for(int i=1;i<=m;i++){
		if (b[i]==n)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import Data.Ratio

main = do
  n <- readLn :: IO Int
  dat <- getContents >>= return . map ((\(t:a:_) -> (t,a)) . map read . words) . lines :: IO [(Integer, Integer)]

  print $ (\(a,b) -> a+b) $ foldl solve (1,1) dat

    where
      solve (t,a) (tr,ar) = (n*tr, n*ar)
        where
          t' = ceiling $ t % tr
          a' = ceiling $ a % ar
          n = max t' a'


Measured memory_bytes: 1660
@A=split //,<>;
@B=split //,<>;
chomp(@A);
chomp(@B);
if($#A!=$#B){
    print+$#A>$#B?"GREATER":"LESS";
}else{
    while($#A){  
        $a=shift(@A);
        $b=shift(@B);
        if($a!=$b){
            print+$a>$b?"GREATER":"LESS";
            exit;
        }
    }
    print "EQUAL"
}

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

int main()
{
   int a , b ;
   cin>> a>> b;
   string res="";
   if (a>b){
    while (a>0){
        cout<<b;
        a--;
    }}
   else if (b>a){
    while (b>0){
       cout<<a;
        b--;
    }
   }
   else {
    while (a>0){
            cout<<b;
    a--;

    }
   }

    return 0;
}

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

const int64_t MOD = 1e9+7;;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int main(){
    int N, K;
    cin >> N >> K;
    int64_t ans = N*K*(K+1)/2 * power_mod(K+1, N-1) % MOD;

    static int64_t dp[101][101*101];
    dp[N][0] = 1;
    int mx = 0;
    for(int i=N; i>0; i--){
        int mx2 = mx;
        for(int j=0; j<=mx; j++) for(int k=0; k<=K; k++){
            int op = 0;
            if(k <= i) op = (j+k) / i;
            int64_t sub = op * dp[i][j] % MOD * power_mod(K+1, i-1) % MOD;
            add(ans, MOD - sub);
            add(dp[i-1][j+op], dp[i][j]);
            mx2 = max(mx2, j+op);
        }
        mx = mx2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}
bool mp[5001][5001];

int func(pair<int, int> a, pair<int, int> b){
  pair<int, int> c = {0, 0};
  c.first = a.first + abs(b.second-a.second);
  c.second = a.second + abs(b.first-a.first);

  pair<int, int> d = {0, 0};
  d.first = b.first + abs(b.second-a.second);
  d.second = b.second + abs(b.first-a.first);
  if(c.first < 0 || c.first > 5000 || c.second < 0 || c.second > 5000) return 0;
  if(d.first < 0 || d.first > 5000 || d.second < 0 || d.second > 5000) return 0;
  if(mp[c.first][c.second] && mp[d.first][d.second]){
    // cerr << (a.first-b.first) << " " << (a.second-b.second) << endl;
    return (a.first-b.first)*(a.first-b.first) + (a.second-b.second) * (a.second-b.second);
  }
  return 0;
}

int main() {
  int n;
  while(cin >> n){
    if(n == 0) break;
    for(int i=0; i<=5000; i++) for(int j=0; j<=5000; j++) mp[i][j] = false;
    vector< pair<int, int> > p(n);
    for(int i=0; i<n; i++){
      cin >> p[i].first >> p[i].second;
      mp[p[i].first][p[i].second] = true;
    }

    int ans = 0;
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        if(i==j) continue;
        ans = max(ans, func(p[i], p[j]));
      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 27452
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int a[214514];
int b[214514];
signed main(){
	int c;
	string d;
	cin>>c>>d;
	if(c>=3200)c(d)
	else c("red")
}	
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k,aya=0;
  cin >> a >> b >> c >> k;
    while(a>=b){b=b*2; aya++;}
    while(b>=c){c=c*2; aya++;}
  if(aya>k){
    cout << "No" << endl;
  }else{
      cout << "Yes" << endl;
    }
}


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

int main() {
	int n = 1000001;
	vector<int> a(n, n);
	a[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 1; i + j < n; j *= 6)
			if (a[i] + 1 < a[i + j])
				a[i + j] = a[i] + 1;
		for (int j = 9; i + j < n; j *= 9)
			if (a[i] + 1 < a[i + j])
				a[i + j] = a[i] + 1;
	}
	cin >> n;
	cout << a[n] << endl;
}


Measured memory_bytes: 4096
/**
 *    author:  skmonir
 *    created: 21-Jan-2018 18:05:23
**/
#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}
template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = (int) 1e5 + 5;
const int INF = (int) 1e9 + 7;
const long long MOD = (long long) 1e9 + 7;


int main() {
    int n; Int(n);
    int x = 0, y = 0, t = 0;
    while (n--) {
        int nt, nx, ny; Int(nt, nx, ny);
        int dt = nt - t;
        int dd = abs(nx - x) + abs(ny - y);
        if (dd > dt) return !printf("No\n");
        if (((dt & 1) and (dd & 1)) or (!(dt & 1) and !(dd & 1))) {
        } else return !printf("No\n");
        x = nx, y = ny, t = nt;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
if 2 * x < y or 2 * y < x:
    print(0)
    exit()
elif (x + y) % 3 != 0:
    print(0)
    exit()

fix_x, fix_y = 0, 0

tmp_x, tmp_y = x, y
while True:
    if tmp_x == 2 * tmp_y:
        break
    tmp_x -= 1
    tmp_y -= 2
    fix_y += 1

tmp_x, tmp_y = x, y
while True:
    if tmp_x * 2 == tmp_y:
        break
    tmp_x -= 2
    tmp_y -= 1
    fix_x += 1


#-------------------------------------
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(fix_x + fix_y, fix_x,mod)
print(a)


Measured memory_bytes: 122120
// by DEADFISH
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define p 1e6+7
#define N 200
#define mc(a,b) memset(a,b,sizeof(a))
#define close std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ln;
int n,x;
int a[N];
int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int k=x,tot=0;
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
		if(x>=a[i]) x-=a[i],tot++;
	if(x==a[n]) tot++;
	printf("%d",tot);
	return 0;
}

Measured memory_bytes: 256
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine().Trim());
    static int[] ReadInts => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine().Trim());
    static long[] ReadLongs => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    const int mod = 1000000007;
    public static int Mod(int a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion




    public class UnionFind
    {
        public UnionFind(int number)
        {
            Data = new List<int>();
            for (int i = 0; i < number; i++) Data.Add(-1);
        }

        /// <summary>
        /// 負なら親(絶対値はサイズ)　正なら子(絶対値は親のID)
        /// </summary>
        public List<int> Data { get; }

        public int Find(int node)
        {
            //自身が親なら、そのまま返す
            if (Data[node] < 0) return node;

            //子なら、その親を呼び、さらにその親を探す。再帰的に呼び出しrootを見つけ、全ての子の親をrootにする
            return Data[node] = Find(Data[node]);
        }

        public bool Unite(int node1, int node2)
        {
            //二つの点の親をさがす
            node1 = Find(node1);
            node2 = Find(node2);

            //二つの親が一致しているなら、することはない
            if (node1 == node2) return false;

            int parent = 0;
            int newSon = 0;

            //サイズが小さいほうが、大きい方の子になる(親のDataの値は負であることに注意)
            if (Data[node1] > Data[node2])
            {
                parent = node2;
                newSon = node1;
            }
            else
            {
                parent = node1;
                newSon = node2;
            }

            Data[parent] += Data[newSon];
            Data[newSon] = parent;

            return true;
        }
    }


    static void Main()
    {
        int[] NM = ReadInts;
        int N = NM[0];
        int M = NM[1];

        UnionFind tree = new UnionFind(N);

        int[][] pairs = new int[M][];
        for (int i = 0; i < M; i++)
        {
            pairs[i] = ReadInts;
            pairs[i][0]--;
            pairs[i][1]--;

            tree.Unite(pairs[i][0], pairs[i][1]);
        }

        Dictionary<int, int> group = new Dictionary<int, int>();

        for (int i = 0; i < N; i++)
        {
            int p = tree.Find(i);
            if (!group.ContainsKey(p)) group.Add(p,-tree.Data[p]);
        }


        WriteLine(group.Values.Max());
    }
}



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

int main(){
    int n, k;
    cin >> n >> k;
    vector<vector<int> > boat(k);
    for(int i=0;i<k;i++){
        int m;
        cin >> m;
        for(int j=0;j<m;j++){
            int b;
            cin >> b;
            boat[i].push_back(b-1);
        }
    }
    int r;
    vector<vector<bool> > g(n, vector<bool>(n,false));
    cin >> r;
    for(int i=0;i<r;i++){
        int p, q;
        cin >> p >> q;
        p--; q--;
        g[p][q] = true;
        g[q][p] = true;
    }
    vector<bool> bad(n);
    for(int i=0;i<k;i++){
        int m = boat[i].size();
        for(int p=0;p<m;p++){
            for(int q=p+1;q<m;q++){
                int x = boat[i][p], y = boat[i][q];
                if(g[x][y]){
                    bad[x] = true;
                    bad[y] = true;
                }
            }
        }
    }
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(bad[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3176
#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#if 1
int main()
{
	std::vector<int> a;
	a.resize(3);
	// 整数の入力
	cin >> a[0];
	cin >> a[1];
	cin >> a[2];

	std::sort(a.begin(), a.end());

	int cost = (a[1] - a[0]) + (a[2] - a[1]);

	cout << cost << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

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




int main(void){
    const ll M = 1000000000;
    int n;
    int x=0;
    string ans;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++)cin >> p[i];
    for(int i=0;i<n;i++)if(p[i]!=i+1)x++;
    if(x==0||x==2)ans = "YES"; else ans = "NO";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    ll ans=0;
    while(n>0){
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		String a=get(),b=get();
		b=reverse(b);
		System.out.println(a.compareTo(b)<0?"Yes":"No");
	}
	private static String reverse(String b){
		StringBuilder sb=new StringBuilder();
		for(int i=b.length()-1;i>=0;--i)
			sb.append(b.charAt(i));
		return sb.toString();
	}

	static String get(){
		StringBuilder sb=new StringBuilder();
		s.next().chars().sorted().forEach(i->sb.append((char)i));
		return sb.toString();
	}
}

Measured memory_bytes: 28496
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		ArrayList<Integer> A = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}
		Collections.sort(A, Collections.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i = 0; i < A.size(); i++) {
			if((i % 2) == 0) {
				alice += A.get(i);
			} else {
				bob += A.get(i);
			}
		}
		System.out.println(alice - bob);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21204
import sys
#from me.io import dup_file_stdin

def prec(op):
    if op in "+-":return 1
    if op in "*/":return 2
    raise NotImplementedError()
    
def postFix(expr):
    stack = []
    operators = []
    num = 0
    isdigit = False
    for ch in expr:
        if ch.isdigit():
            isdigit = True
            num*=10
            num+=int(ch)
            continue
        else :
            if isdigit:
                stack.append(num)
                num = 0
            isdigit = False
            
            if ch == ')':
                while len(operators) > 0:
                    op = operators.pop()
                    if op == '(':
                        break
                    else:
                        stack.append(op)
                else:
                    raise ValueError
            elif ch == '(':
                operators.append(ch)
            else:
                while len(operators) > 0 and operators[-1]!='(' and prec(operators[-1]) >= prec(ch):
                    stack.append(operators.pop())
                operators.append(ch)
    if isdigit:
        stack.append(num)
    for op in operators[::-1]:
        if op not in "()":
            stack.append(op)
    return stack
        
def evaluate(stack):
    op = stack.pop()
    if type(op) is int:
        return op;
    else:
        b = evaluate(stack);
        a = evaluate(stack);
        return int(eval(str(a)+op+str(b)))

#@dup_file_stdin
def solve():
    for _ in range(int(sys.stdin.readline())):
        expr = sys.stdin.readline()[:-1].strip("=")
        print(evaluate(postFix(expr)))
        
solve()

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

int main() {
  int N, K;
  int x = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (x < K) {
      x *= 2;
    }
    else {
      x += K;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256