akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
int p[N];
int h[N];


int main(){
  fastIO;
  int n, k;
  cin >> n >> k;
  for(int i = 1; i <= n; i ++ ){
    cin >> p[i];
  }
  for(int i = 2; i <= n; i ++ ){
    h[i] = (p[i-1] > p[i]) + h[i - 1];
  }
  int srt = 0;
  int res = 0;
  if(h[k] == 0) srt = 1, res = 0;
  else res = 1;
  multiset<int> cur;
  for(int i = 2;i <= k ; i ++ ){
    cur.insert(p[i]);
  }
  int l, r;
  int low, high;
  for(int i = 2 ; i <= n - k + 1; i ++ ){
    l = i - 1;
    r = i + k - 1;
    low = *cur.begin();
    auto it = cur.end();
    --it;
    high = *it;
    if(h[r] - h[i] == 0){
      srt = 1;
    }
    else if(!(p[l] < low && p[r] > high)){
      res ++ ;
    }
    cur.erase(cur.find(p[i]));
    cur.insert(p[r]);
  }
  cout << res + srt;
  return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    scanf("%d %d",&a,&b);
    int ans=0;
    int cnt=1;
    while(cnt <b){
        ans++;
        cnt=cnt-1+a;
    }
    
    

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


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: usize = read();
    println!("{}", n - k + 1);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
def even(A):
  for i in range(0, len(A)):
    if (A[i]%2==1):
      return False
  return True

N=int(input())
A=list(map(int, input().split()))
cnt=0
while(even(A)==True):
  cnt+=1
  for i in range(0, len(A)):
    A[i]/=2
print(cnt)

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

int main()
{
	string T;
	cin >> T;

	int N = T.size();
	string ans;
	for( int i = 0; i < N; i++ ) {
		if( T[i] == '?' ) ans += 'D';
		else ans += T[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 3916
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

L = list(map(int, read().decode("utf-8").split()))

import itertools
p = itertools.permutations(L, 5)
ans = INF
for dishes in p:
    tmp_ans = 0
    for i, d in enumerate(dishes):
        tmp_ans += d
        rest = 10 - (d % 10)
        if i != 4 and rest != 10:
            tmp_ans += rest
    ans = min(ans, tmp_ans)
print(ans)

Measured memory_bytes: 9120
from collections import defaultdict
N = int(input())
Ss = [input() for i in range(N)]

d = defaultdict(int)
for S in Ss:
    d[S] += 1

mx = max([d[k] for k in d.keys()])

ans = []
for k in d.keys():
    if d[k] == mx:
       ans.append(k)
       
for a in sorted(ans):
    print(a)

Measured memory_bytes: 35572
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




int main() {
    ll n;
    double t, a;
    cin >> n >> t >> a;
    double b = -1000000;
    ll ans = 0;
    REP(i, n){
        ll h;
        cin >> h;
        if(abs(a - (t - b * 0.006)) > abs(a - (t - h * 0.006))){
            b = h;
            ans = i;
        }
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main()
{
  int m, f, t, r;
  char g;
  while(1)
  {
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1)
      break;
    t = m + f;
    if (m == -1 || f == -1)
    {
      g = 'F';
    }
    else if (t >= 80)
    {
      g = 'A';
    }
    else if (t >= 65)
    {
      g = 'B';
    }
    else if (t >= 50)
    {
      g = 'C';
    }
    else if (t >= 30) {
      g = (r>=50) ? 'C' : 'D';
    } else {
      g = 'F';
    }
    printf("%c\n", g);
  }

  return 0;
}


Measured memory_bytes: 2704
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

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;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n, i, d[111111], ans;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> d[i];
	sort(d, d + n);
	ans = d[n / 2] - d[n / 2 - 1];
	cout << ans << endl;
}

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

int main() {
    //ifstream cin("d.in");

    int l; cin >> l;
    vector<int> a(l + 1, 0);

    for(int i = 1; i <= l; i += 1) {
        cin >> a[i];
    }

    vector<vector<long long>> dp(l + 1, vector<long long> (6, 1e9));
    
    for(int i = 0; i <= 4; i += 1)
        dp[0][i] = 0;

    for(int i = 1; i <= l; i += 1) {
        long long base = dp[i - 1][0];
        dp[i][0] = base + a[i];
        base = min(base, dp[i - 1][1]);
        dp[i][1] = base + (a[i] == 0 ? 2 : a[i] % 2);
        base = min(base, dp[i - 1][2]);
        dp[i][2] = base + (1 - (a[i] % 2));
        base = min(base, dp[i - 1][3]);
        dp[i][3] = base + (a[i] == 0 ? 2 : a[i] % 2);
        base = min(base, dp[i - 1][4]);
        dp[i][4] = base + a[i];
    }
    
    long long ans = 1e9;

    for(int i = 0; i <= 4; i += 1)
        ans = min(ans, dp[l][i]);
    cout << ans << "\n";
}

Measured memory_bytes: 18304
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    double t, x;

    cin >> t >> x;

    cout << setprecision(10) << t / x << endl;

    return 0;
}

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

const int INF = 1001001001;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> key;
	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		int s = 0;
		rep(j, b)
		{
			int c;
			cin >> c;
			--c;
			s |= 1 << c;
		}
		key.emplace_back(s, a);
	}

	vector<int> dp(1 << n, INF);
	dp[0] = 0;
	rep(s, 1 << n)
	{
		rep(i, m)
		{
			int t = s | key[i].first;
			int cost = dp[s] + key[i].second;
			dp[t] = min(dp[t], cost);
		}
	}
	int ans = dp.back();
	if (ans == INF)
		ans = -1;
	cout << ans << endl;
	return 0;
}

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

int h, w;

bool search(int x, int y, vector<vector<char>> &vvc) {
    for (int dx = -1, dy = 0, i = 0; i < 4; dx += dy, dy = dx - dy, dx = dy - dx, i++) {
        int nx = x + dx;
        int ny = y + dy;
        if (nx >= 0 && nx < w && ny >= 0 && ny < h && vvc[ny][nx] == '#') {
            return true;
        }
    }
    return false;
}

int main() {
    cin >> h >> w;
    vector<vector<char>> canvas(h, vector<char> (w));
    rep(i,h)rep(j,w) {
        cin >> canvas[i][j];
    }
    rep(i,h)rep(j,w) {
        if(canvas[i][j] == '#' && search(j, i, canvas)) {
            continue;
        }
        else if (canvas[i][j] == '.') {
            continue;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;

struct UnionFind {
    vector<int> par, rank, sz;
    
    UnionFind(int n) : par(n), rank(n, 0), sz(n, 1) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    void init(int n) {
        par.resize(n); rank.resize(n); sz.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, sz[i] = 1;
    }

    int root(int n)
    {
      if(par[n] == n) return n;
      else {
        return par[n] = root(par[n]);
      }
    }

    bool is_same(int a, int b)
    {
      return root(a) == root (b); 
    }

    int size(int n)
    {
      return sz[root(n)];
    }

    bool merge(int a, int b)
    {
      int rt_a = root(a);
      int rt_b = root(b);
      if(rt_a == rt_b) return false;
      if (rank[rt_a] < rank[rt_b]) swap(rt_a, rt_b);
      if (rank[rt_a] == rank[rt_b]) ++rank[rt_a];
      par[rt_b] = rt_a;
      sz[rt_a] += sz[rt_b];
      return true;
    }

};

int 
main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> arr(M);
  rep(i, 0, M){
    int first, second;cin >> first >> second;
    arr[i].push_back(first);
    arr[i].push_back(second);
  }

  int ans = M;
  rep(i, 0, M){
    UnionFind uf(N + 1);
    rep(k, 0, M){
      if(i == k) continue;
      int a = arr[k][0];
      int b = arr[k][1];
      uf.merge(a, b);
    }

    rep(i, 1, N + 1){
      if(uf.size(i) == N){
        ans--;
        break;
      }
    }
    uf = NULL;
  }

  cout << ans << endl;

}




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

struct Trie {
    Trie* next[26];
    int s;
    int count;

    Trie(): s(0), count(0) {
        for (int i = 0; i < 26; i++)
            next[i] = NULL;
    }
};

vector<string> vs;
string rnk;
int idx;

void add (Trie* node, int k) {
    for (int i = 0; i <= (int)vs[k-1].size(); i++) {
        node->count++;
        if ((int)vs[k-1].size() == i) {
            node->s = k;
            return ;
        }

        int c = vs[k-1][i];
        if (node->next[c-'a'] == NULL)
            node->next[c-'a'] = new Trie();

        node = node->next[c-'a'];
    }

}

// int dfs (Trie* node, int sum) {
//     // cout << "suffix: " << vs[k-1] << ", sum=" << sum << endl;
//
//     for (int i = 0; i <= (int)vs[idx-1].size(); i++) {
//         if (node->s == idx) return sum+1;
//         if (node->count == 1) return sum+1;
//         if (node->s) sum++;
//
//         int c = vs[idx-1][i];
//         for (int i = 0; rnk[i] != c; i++) {
//             if (node->next[(int)rnk[i]-'a'] != NULL)
//                 sum += node->next[(int)rnk[i]-'a']->count;
//         }
//
//         node = node->next[c-'a'];
//     }
// }

int main() {
    int N;
    cin >> N;
    vs.resize(N);
    Trie* tr = new Trie();
    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        vs[i] = str;
        add(tr, i+1);
    }

    vector<vector<vector<int> > >
        dp(N, vector<vector<int> >(26, vector<int>(26)));

    for (int i = 0; i < N; i++) {
        Trie* now = tr;
        for (int j = 0; j < (int)vs[i].size(); j++) {
            int c = vs[i][j] - 'a';
            if (now->s) dp[i][c][c]++;
            for (int k = 0; k < 26; k++) {
                if (c == k) continue;

                if (now->next[k] != NULL)
                    dp[i][c][k] += now->next[k]->count;
            }

            now = now->next[c];
        }
    }

    cin >> N;
    for (int c = 0; c < N; c++) {
        cin >> idx >> rnk;

        int ans = 1;
        for (int i = 25; i > -1; i--) {
            for (int j = i; j > -1; j--) {
                ans += dp[idx-1][rnk[i]-'a'][rnk[j] - 'a'];
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 381440
#include<stdio.h>
#include<stdlib.h>

int main(){
int A,B,C,a,b,c;
int counter=0;
scanf("%d%d%d",&A,&B,&C);
if ( A==B && B==C )
{
  (A%2 == 0) ? puts("-1"):puts("0");
  exit(0);
}

while (A%2==0 && B%2==0 && C%2==0)
{
    counter++;
    a = B/2 + C/2;
    b = A/2 + C/2;
    c = A/2 + B/2;
    A = a;
    B = b;
    C = c;
}
  
printf("%d",counter);

return 0;

}

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

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> E;
  for(int i = 0, e; i < m; i++) cin >> e, E.push_back(e);
  reverse(E.begin(), E.end());
  bool used[200020] = {false};
  for(int e : E) if(!used[e]) cout << e << endl, used[e] = true;
  for(int i = 1; i <= n; i++) if(!used[i]) cout << i << endl;
  return 0;
}

Measured memory_bytes: 3644
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
void fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	cin>>n;
	int cnt=0;
	int bol=1;
	while(n--)
	{
		ll a,b;
		cin>>a>>b;
		if(a==b)
		{
			cnt++;
		}
		else
		{
			cnt=0;
		}
		if(cnt==3){
		bol=0;
		break;
		}
		
	}
	if(bol==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  if (A < B){
    if (A == 1) cout << "Alice" << endl;
    else cout << "Bob" << endl;
  }
  if (A > B){
    if (B == 1) cout << "Bob" << endl;
    else cout << "Alice" << endl;
  }
  if (A == B) cout << "Draw" << endl;
}

Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0

for i in range(N):
    s1=A[i]
    s2=A[i+1]
    if s1-B[i]>0:   #i街で勇者君は心置きなくぶっ倒せる
        cnt=cnt+B[i]
        s1=s1-B[i]
    else:   #s1-B[i]<=0i街で勇者君は倒したりない
        cnt=cnt+s1
        B[i]=B[i]-s1
        s1=0
        if s2-B[i]>0:   #i+1街で勇者君は心置きなくぶっ倒せる
            cnt=cnt+B[i]
            s2=s2-B[i]
            B[i]=0
        else:           #i+1でも倒したりなかった勇者君
            cnt=cnt+s2
            B[i]=B[i]-s2
            s2=0
    A[i]=s1
    A[i+1]=s2
    #print(A,B)
print(cnt)


Measured memory_bytes: 82148
#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>>;
#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
#define 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; }

signed main(){
	int n,m; cin>>n>>m;
	vl vec(n);
	rep(i,0,n)cin>>vec[i];
	sort(all(vec));
	while(m--){
		ll k=vec[n-1];
		vec.pop_back();
		k/=2;
		auto ind=lower_bound(all(vec),k);
		vec.insert(ind,k);
	}
	ll ans=0;
	rep(i,0,n)ans+=vec[i];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, X, T;
    cin >> N >> X >> T;
    OUT((N+X-1)/X*T)

    return 0;
}

Measured memory_bytes: 3564
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll n,m;

vector<vector<ll>> G;
ll dp[100100];

ll rec(ll v){
    if(dp[v]!=-1){
        return dp[v];
    }
    ll res=0;
    for(auto x:G[v]){
        chmax(res,rec(x)+1LL);
    }
    return dp[v]=res;
}

int main()
{
    cin >> n >> m;
    G.assign(n,vector<ll>());
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
    }
    rep(v,n){
        dp[v]=-1;
    }
    ll res=0;
    rep(v,n){
        chmax(res,rec(v));
        //cout << res << endl;
    }
    cout << res << endl;
    return 0;
} 

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < n-2; i++) {
    if (p[i] < p[i+1] && p[i+1] < p[i+2]) ans++;
    else if (p[i] > p[i+1] && p[i+1] > p[i+2]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
import math
a = input().split()
b = [input().split() for i in range(int(a[0]))]

d = 0
for i in range(int(a[0])):
    if math.sqrt(int(b[i][0])**2+int(b[i][1])**2) <= int(a[1]):
        d += 1
print(d)


Measured memory_bytes: 67584
#include <bits/stdc++.h>
using namespace std;
#define printArr(harry, tam) range(tam) cout << harry[i] << " \n"[i == tam -1];
#define range(n) for(int i = 0; i < n; i++)
#define maxn 100000
#define mod 1000000007
#define md(x) ((((x) % mod) + mod) % mod)
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF INT_MAX
#define INFd 1e9

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;

//Trace dinamico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

//DP debug
int recNum = 0;
void prTabs() { range(recNum) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}
int n, m, a, b, c;
int s[100010];
int accum[100010][26];

int main(){
    sc("%d\n", &n);
    memset(accum, 0, sizeof accum);
    memset(s, 0, sizeof s);
    for(int i = 1; i <= n; i++) {
        char ch = getchar();
        s[i] = ch-'a';
        accum[i][s[i]]++;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 26; j++) {
            accum[i][j] += accum[i-1][j];
        }
    }
    ll resp = 0;
    for(int i = 1; i <= n; i++) {
        ll s1 = 1LL;
        for(int j = 0; j < 26; j++) {
            if (j != s[i]) {
                s1 = (s1 * (accum[n][j] - accum[i][j] + 1LL)) % 1000000007LL;
            }
        }
        resp = (s1 + resp) % 1000000007LL;
    }
    pr("%lld\n", resp);
 	return 0;
}


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

import sys

a, b, c, d = map(int, input().split())

# testing stderr
print(abs(c - a), abs(c - b), abs(b - a), d, file=sys.stderr)

if abs(c - a) > d and (abs(c - b) > d or abs(b - a) > d):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3316
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

NEXA = 26
dic = {chr(97+i): i for i in range(NEXA)}

s = lc()
k = ni()

ans = []

for si in s:
    to_nexa = (NEXA - dic[si]) % NEXA
    if to_nexa <= k:
        k -= to_nexa
        ans.append('a')

    else:
        ans.append(si)

if k > 0:
    ans[-1] = chr(97 + (dic[ans[-1]] + k) % NEXA)

print("".join(ans))

Measured memory_bytes: 5048
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int early[200005]={0},late[200005]={0};
int main(void){
	int n,k,c;
	string s;
	cin>>n>>k>>c;
	cin>>s;
	int last=-1,cnt=0;
	REP(i,n){
		if(s[i]=='o'){
			if(last==-1||i-last-1>=c){
				cnt++;
				early[i]=cnt;
				last=i;
//				cout<<i<<' ';
			}
		}
		if(cnt>=k)break;
	}
//	cout<<endl;
	last=-1;
	cnt=0;
	REP(i,n){
		if(s[n-i-1]=='o'){
			if(last==-1||last-(n-i-1)-1>=c){
				late[n-i-1]=k-cnt;
				cnt++;
				last=n-i-1;
//				cout<<n-i-1<<' ';
			}
		}
		if(cnt>=k)break;
	}
//	cout<<endl;
	REP(i,n){
		if(early[i]==late[i]&&early[i]!=0){
			cout<<i+1<<endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 3332
n = int(input())
a = list(map(int, input().split())) 

a.sort()

c = [0]*a[-1]

for ai in a:
    if c[ai-1] >= 1:
        c[ai-1] += 1
        continue
    i = ai
    while i <= a[-1]:
        c[i-1] += 1
        i += ai
print(sum(c[ai-1] == 1 for ai in a))

Measured memory_bytes: 33340
#include<iostream>
#include <cstring>
#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;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N, M; cin >> N >> M;
  bool ans[M];
  rep(i, M){
    ans[i] = true;
  }
  rep(i, N){
    int K; cin >> K; bool check[M] = {};
    rep(i, K){
      int a; cin >> a;  a--; check[a] = true;
    }
    rep(i, M){
      if(!(check[i])) ans[i] = false;
    }
  }
  int tmp = 0;
  rep(i, M){
    if(ans[i]) tmp++;
  }
  cout << tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a[100005],gl[100005],gr[100005];
ll G;
ll gcd(ll a,ll b){
    if(b%a==0) return a;
    else return gcd(b%a,a);
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    gl[1]=a[0];
    gr[1]=a[n-1];
    for(int i=2;i<=n;i++){
        gl[i]=gcd(gl[i-1],a[i-1]);
        gr[i]=gcd(gr[i-1],a[n-i]);
    }
    G=max(gr[n-1],gl[n-1]);
    for(int i=1;i<n-1;i++){
        G=max(G,gcd(gl[i],gr[n-i-1]));
    }
    cout<<G<<endl;

}


Measured memory_bytes: 5952
/**
 *   author: Shubham Srivastava
 *   created: 26 January 2020  00:16:03
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;cin>>n;
    vector <pair<int,pair<int,int> > > v;
    for(int i=0;i<n;i++){
    	ll a,b,c;cin>>a>>b>>c;
    	v.push_back({a,{b,c}});
    }
    int dp[n][3];
    dp[0][0] = v[0].first;
    dp[0][1] = v[0].second.first;
    dp[0][2] = v[0].second.second;
    for(int i=1;i<n;i++){
    	dp[i][0] = v[i].first + max(dp[i-1][1], dp[i-1][2]);
    	dp[i][1] = v[i].second.first + max(dp[i-1][0], dp[i-1][2]);
    	dp[i][2] = v[i].second.second + max(dp[i-1][0], dp[i-1][1]);
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct BIT {
private:
	vector<ll> node; int n;
public:
	BIT(int n_) {
		n = n_; node.resize(n, 0);
	}
	//0-indexed
	void add(int a, ll w) {
		for (int i = a; i < n; i |= i + 1)node[i] += w;
	}
	//[0,a)
	ll sum(int a) {
		ll ret = 0;
		for (int i = a - 1; i >= 0; i = (i&(i + 1)) - 1)ret += node[i];
		return ret;
	}
	//[a,b)
	ll sum(int a, int b) {
		return sum(b) - sum(a);
	}
};

ll t2[1 << 18];
void init() {
	t2[0] = 1;
	rep(i, (1 << 18) - 1) {
		t2[i + 1] = t2[i] * 2 % mod;
	}
}
void solve() {
	vector<int> vx, vy;
	int n; cin >> n;
	vector<P> v;
	rep(i, n) {
		int x, y; cin >> x >> y;
		vx.push_back(x); vy.push_back(y);
		v.push_back({ x,y });
	}
	{
		sort(vx.begin(), vx.end());
		sort(vy.begin(), vy.end());
		map<int, int> mpx, mpy;
		rep(i, n) {
			mpx[vx[i]] = i;
			mpy[vy[i]] = i;
		}
		rep(i, n) {
			v[i].first = mpx[v[i].first];
			v[i].second = mpy[v[i].second];
		}
	}
	ll ans = 0;
	rep(i, n) {
		ans += t2[n] - 1;
	}
	ans %= mod;
	rep(i, n) {
		int memo = ans;
		int idx = v[i].first, idy = v[i].second;
		ans -= t2[idx] - 1;
		ans -= t2[idy] - 1;
		ans -= t2[n - 1 - idx] - 1;
		ans -= t2[n - 1 - idy] - 1;
		ans = (ans%mod + mod) % mod;
		//cout << i << " " << memo << " " << ans << endl;
	}
	//cout << ans << endl;
	sort(v.begin(), v.end());
	BIT b(n);
	rep(i, n) {
		int idy = v[i].second;
		int le = b.sum(0, idy); int ri = b.sum(idy,n);
		ans += t2[le] - 1;
		ans += t2[ri] - 1;
		b.add(idy, 1);
		ans %= mod;
	}
	BIT rb(n);
	per(i, n) {
		int idy = v[i].second;
		int le = rb.sum(0, idy);
		int ri = rb.sum(idy, n);
		ans += t2[le] - 1;
		ans += t2[ri] - 1;
		rb.add(idy, 1);
		ans %= mod;
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 24644
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

// #include <bits/extc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> // tree
// #include <ext/pb_ds/hash_policy.hpp> // hash
// #include <ext/pb_ds/trie_policy.hpp> // trie
// #include <ext/pb_ds/priority_queue.hpp> // priority_queue
// using namespace __gnu_pbds;

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

#define X first
#define Y second
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define Push push_back

using lli = long long;
using pll = pair<lli, lli>;
using Double = long double;
template<typename T>
using priority = priority_queue<T>;

const lli mod = 1E9 + 7;
const Double PI = 3.1415926535846;
const Double eps = 1e-8;

lli fastPow(lli base, lli exp, lli module = mod) {
	lli ans = 1;
	base %= module;
	while (exp) {
		if (exp & 1) ans = ans * base % module;
		base = base * base % module;
		exp >>= 1;
	}
	return ans;
}

bool millerRabin(lli n, lli a) {
	if (n < 2 or n % 2 == 0) return n == 2;
	lli u, t;
	for (u = n-1, t = 0; u & 1; u >>= 1, ++t);
	a = fastPow(a, u, n);
	if (a == 1 or a == n - 1) return true;
	for (int i = 0; i < t; ++i) {
		a = a * a % n;
		if (a == 1) return false;
		if (a == n - 1) return true;
	}
	return false;
}

int ls(int x) {return x << 1;}
int rs(int x) {return x << 1 | 1;}

const int maxn = 131072;

struct Path {
	lli L, R, C;
};

vector<lli> tree(2 * maxn, 1E16);

void ChangeMin(int L, int R, lli val, int np = 1, int lp = 1, int rp = maxn) {
	if (L > rp or R < lp) return;
	if (L <= lp and R >= rp) {
		tree[np] = min(tree[np], val);
		return;
	}
	if (tree[np] != (lli)1E16) {
		tree[ls(np)] = min(tree[ls(np)], tree[np]);
		tree[rs(np)] = min(tree[rs(np)], tree[np]);
		tree[np] = 1E16;
	}
	ChangeMin(L, R, val, ls(np), lp, (lp + rp) / 2);
	ChangeMin(L, R, val, rs(np), (lp + rp) / 2 + 1, rp);
}

lli GetValue(int x) {
	x += maxn - 1;
	lli minVal = 1E16;
	while (x) {
		minVal = min(minVal, tree[x]);
		x >>= 1;
	}
	return minVal;
}

bool cmp(Path a, Path b) {
	return a.L < b.L;
}

void solve() {
	int n, m;
	cin >> n >> m;
	
	vector<Path> path(m);
	for (auto &x : path) cin >> x.L >> x.R >> x.C;
	
	sort(ALL(path), cmp);
	
	tree[maxn] = 0;
	
	for (int i = 0; i < m; ++i) {
		ChangeMin(path[i].L, path[i].R, GetValue(path[i].L) + path[i].C);
	}
	
	if (GetValue(n) == (lli)1E16) cout << -1 << "\n";
	else cout << GetValue(n) << "\n";
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 4608
#include <stdio.h>

int binary (int S[], int key, int n) {
  int mid, left = 0, right = n, f = 0;
  while (left < right) {
        mid = (left + right) / 2;
        if (S[mid] == key) {
            f = 1;
            break;
        }
        else if (key < S[mid]) {
            right = mid;
        }
        else if (key > S[mid]) {
            left = mid + 1;
        }
  }
  return f;
}

int main (void) {
  int S[100000], n, q, i, key, cnt = 0;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%d", &key);
    if (binary (S, key, n)) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
}



Measured memory_bytes: 2128
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
    char s[256];
    s[0]=' ';
    while (~scanf("%s", s+1)) {
        int x;
        for(x=0;x<=10;++x) {
            unsigned a[3][128]={0};
            int l=strlen(s), j=0, k=0, i;
            int ok=1;
            for(i=l-1;i>=0;--i) {
                if (isdigit(s[i])) a[j][k++]=s[i]-'0';
                else if (s[i]=='X') a[j][k++]=x;
                else {
                    if (x==0 && k>1 && s[i+1]=='X') ok=0;
                    j++, k=0;
                }
            }
            if (!ok) continue;

            for(i=0;i<l;++i) {
                int t=a[1][i]+a[2][i];
                a[1][i]=t%10;
                a[1][i+1]+=t/10;
            }
            ok=1;
            for(i=0;i<l;++i) if(a[0][i]!=a[1][i]) ok=0;
            if (ok) break;
        }
        x<10 ? printf("%d\n", x) : puts("NA");
    }
    return 0;
}

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


int main() {
  int n, l;
  cin >> n >> l;
  vector<int> a(n);
  rep(i,n){
    a[i] = l+i;
  }
  int sum = 0;
  rep(i,n){
    sum += a[i];
  }
  int ans = 1e9;
  rep(i,n){
    int t = sum-a[i];
    if(abs(t-sum) < abs(ans-sum)) ans = t;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	unsigned long long a=100;
	unsigned long long n,k=0;
	scanf("%lld",&n);
	while(a)
	{
		if(a>=n)
		break;
		a=a+a/100;
		k++;
	}
	printf("%lld",k);
	return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
long long n,test,black,res,k,h,w;
char s[10][10];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
\
    //cin>>test;
    test=1;
    res=0;
    while (test--)
    {
        cin>>h>>w>>k;
        for (int i=0;i<h;i++)
        for (int j=0;j<w;j++) cin>>s[i][j];
        //cout<<s[1][2]<<endl;
        for (int r=0;r<(1<<h);r++)
        for (int c=0;c<(1<<w);c++)
        {
            black=0;
            for (int i=0;i<h;i++)
            for (int j=0;j<w;j++)
            if (s[i][j]=='#' && ((r>>i)&1)==0 && ((c>>j)&1)==0 ) black++;
            //cout<<black<<" "<<r<<" "<<c<<endl;
            if (black==k) res++;
        }
        cout<<res<<endl;
    }


 }

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,m;
    cin >> n >> m;
    if(n>m){
        for(int i=0;i<n;i++){
            cout << m;
        }
    }
    else {
        for(int i=0;i<m;i++){
            cout << n ;
        }
    }
}


Measured memory_bytes: 256
A = input()
B = A[0:2]
C = A[2:4]
if 12 >= int(B) > 0:
    if 12 >= int(C) > 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 12 >= int(C) > 0:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int k;
    int a,b;
    cin>>k;
    cin>>a>>b;
    int flag=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            flag=1;
        }
    }
    if(flag==1){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }

}

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

#define int unsigned long long
using namespace std;

signed main()
{
    int a;
    string b;
    cin >> a >> b;
    int num = std::atoi(b.erase(1, 1).c_str());
    cout << (int)(a * num / 100);

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

int main(){
  int N;
  long long int X;
  
  cin >> N >> X;
  vector<long long int> c(N);
  for(int i = 0; i < N; i++) cin >> c[i];
  vector<long long int> d(N);
  for(int i = 0; i < N; i++) d[i] = abs(c[i] - X);
  
  long long int ans = 0LL;
  for(int i = 0; i < N; i++){
    if(N == 1){
      ans = d[0];
      break;
    }
    if(i == 0){
    ans = gcd(d[0],d[1]);
    continue;
    }
    ans = gcd(d[i], ans);
  }
  cout << ans;
}


Measured memory_bytes: 1792
import bisect
n,m = map(int,input().split())
l = list(input())
check = []
for i in range(n-1):
    if l[i] == "A" and l[i+1] == "C":
        check.append(i+1)
for i in range(m):
    a,b = map(int,input().split())
    left = bisect.bisect_left(check,a)
    right = bisect.bisect_left(check,b)
    print(right-left)

Measured memory_bytes: 6520
#include <stdio.h>

int main(void){
    
    int num1 =0;    // 1つ目の数値
    int num2 =0;    // 2つ目の数値
    int answer =0;  // 算出した最大公約数を入力
    
    
    // 数値取得（空白区切りで2個入力されると、私は信じている。）
    scanf("%d%d", &num1, &num2);
    
    // 最大公約数の算出
    while(1){

        // "大きい値"を"小さい値"で割って余りを取得する。余りがゼロの場合、終了。
        // そうでないなら、"余り"と"小さい値"を使って、次回ループで再度計算する。
        if (num2>=num1)
        {
            num2=num2%num1;
            if(num2==0)
            {
                answer = num1;
                break;
            }
        }
        else
        {
            num1=num1%num2;
            if(num1==0)
            {
                answer = num2;
                break;
            }
        }
    }
    
    // 回答表示
    printf("%d\n",answer);
    
    return 0;
}



Measured memory_bytes: 2076
#include <cstdio>
using namespace std;
int main() {
	int w;
	while(scanf("%d",&w),w!=-1) {
		int sum=1150;
		if(w>=30) {
			sum+=(w-30)*160;
			w=30;
		}
		if(w>=20) {
			sum+=(w-20)*140;
			w=20;
		}
		if(w>=10) {
			sum+=(w-10)*125;
			w=10;
		}
		printf("%d\n",4280-sum);
	}
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    printf("%c%c%c\n",s1[0]-'a'+'A', s2[0]-'a'+'A', s3[0]-'a'+'A');
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007 
#define MM 998244353
#define PI 3.14159265 
using namespace std;
 
int main()
{
	int a;

	cin >> a;

	cout << a + a*a + a*a*a;

  	return 0;
}

Measured memory_bytes: 3636
// {{{ by unolight
#pragma region
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion
// }}}

void main() {
    LL n,c,d;
    R(n);
    LL tot=0, sum=0;
    REP(i,n) {
        R(d,c);
        tot+=c;
        sum+=d*c;
    }
    W(tot-1+(sum-1)/9);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int n,ans=0;
    cin>>n;
    int p[n];
    rep(i,n)    cin>>p[i];
    rep(i,n-2){
        if(min(p[i+2],p[i])<p[i+1]&&max(p[i+2],p[i])>p[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int m,d,i,d1,d2,ans=0;
  cin >> m >> d;
  for (i=22;i<=d;i++){
    d1=i/10;
    d2=i%10;
    if (d1<2 || d2<2) continue;
    if (d1*d2<=m) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {

  int left, right;
  int sum;
  int ans;
  int n;
  
  for(;;) {
    std::cin >> n;
    if( n == 0 ) break;

    left = right = 1;
    ans = 0;
    sum = 1;
    for(;;) {
      if( left > n ) break;
      if( sum == n ) {
        if( right - left >= 1 ) ans += 1; 
        sum -= left;
        left += 1;
        continue;
      }
      if( sum > n ) {
        sum -= left;
        left += 1;
        continue;
      }
      else {
        right += 1;
        sum += right;
        continue;
      }
    }
    std::cout << ans << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(void){
    
    string s;
    cin>>s;
    bool a=false,b=false,c=false;
    for(int i=0;i<3;++i){
        if(s[i]=='a')a=true;
        if(s[i]=='b')b=true;
        if(s[i]=='c')c=true;
        
    }
    
    if(a&&b&&c)cout<<"Yes";
    else cout<<"No";
    
    
    return 0;
    
}


Measured memory_bytes: 256
def A_MealDelivery(lst):
    x, a, b = lst[0], lst[1], lst[2]
    if abs(x - a) < abs(x - b):
        return 'A'
    else:
        return 'B'

l = [int(i) for i in input().split()]
print(A_MealDelivery(l))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int n=s.length(),tmp=0;
  for(int i=0;i<n;i++){
    if(s[i]=='x')tmp++;
  }
  if(tmp>=8){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
}


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

int dp[3005][3005];
int main() {
  string s,t;
  cin >> s >> t;

  for(int i = 0; i < s.size(); i++) {
    for(int j = 0; j < t.size();j++) {
      if(s[i] == t[j]) {
	dp[i+1][j+1] = dp[i][j] + 1;
      }
      else {
	dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }
      int n = s.size();
      int m = t.size();
      string ans;
      while(n != 0 && m != 0) {
	if(dp[n][m] == dp[n-1][m]) {
	  n--;
	}
	else if(dp[n][m] == dp[n][m-1]) {
	  m--;
	}
	else {
	  n--;
	  m--;
	  ans += s[n];
	}
	
      }

      reverse(ans.begin(),ans.end());
      cout << ans << endl;
}


Measured memory_bytes: 35456
//JAI SAI RAM.//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll P=1000000007;
int main()
{
    ll i,j,k,l,m,n,o,p,q,r,s,t,a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

    cin>>k;
    cout<<a[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 256