akhauriyash/Code-Regression huggingface dataset:
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{


ll a,b,c,k;
cin>>a>>b>>c>>k;
swap(a,c);
ll s=0;
s+=(min(c,k));

k-=c;

if(k>0)
{
k-=b;
}

if(k>0)
{
	s-=(min(k,a));
}


cout<<s;









}return 0;}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 20100;
const int OFF = 500000000;
int n, a[N], b[N], c[N], p[N];

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(int i = 1; i <= n; i++) a[i]= i;
	for(int i = 1; i <= n; i++) {
		cin >> p[i];
		c[p[i]] = i + OFF;
	}

	a[1] = 1;
	b[1] = c[p[1]] - 1;
	for(int i = 2; i <= n; i++) {
		int diff = c[i] - c[i - 1];
		dbg(i, diff);
		a[i] = a[i - 1] + 1;
		b[i] = b[i - 1] - 1;
		if(diff < 0) b[i] += diff;
		else a[i] += diff;
	}

	for(int i = 1; i <= n; i++) cout << a[i] << ' ';
	cout << '\n';
	for(int i = 1; i <= n; i++) cout << b[i] << ' ';
	cout << '\n';
}	

	

Measured memory_bytes: 896
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def judge(S):
    for i in range(len(S) // 2):
        if S[i] != S[-(i+1)]:
            return False
    return True

S = ns()
N = len(S)
p = S[:(N-1)//2]
l = S[(N+3)//2 - 1:]
if judge(S) and judge(p) and judge(l):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 10956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class D052
    {
        public static void Main(string[] args)
        {

            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = h[0], A = h[1], B = h[2];
            int[] X = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            long fatigue = 0;
            for (int i = 1; i < N; i++)
            {
                long distance = X[i] - X[i - 1];
                fatigue += Math.Min(distance * A, B);
            }
            Console.WriteLine(fatigue);
        }

    }
}


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

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

    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    int answer = a + b;
    int all = 0;
    int bppl = 0;
    int ok = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'a')
        {
            if (all < answer)
            {
                cout << "Yes" << endl;
                all++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        if (s[i] == 'b')
        {
            ok++;
            if (all < answer && ok <= b)
            {
                cout << "Yes" << endl;
                all++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        if (s[i] == 'c')
        {
            cout << "No" << endl;
        }
    }
}

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

int main() {
  int N,a,b,c,d;
 cin >> N;
  a = N / 1000;
  b = N % 1000 / 100;
  c = N % 100 / 10;
  d = N % 10;
  
  if (a == b && b == c ){
  cout << "Yes" << endl;
  }
  else if (b == c && c == d ){
  cout << "Yes" << endl;
  }

  else{
  cout << "No" << endl;
  }
}



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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans = a + b + c;
  int d = max((a,b),c);
  ans -= d;
  int i = 1;
  while(i <= k){
    d *= 2;
    ++i;
  }
  cout << d + ans << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i]=-a[i]

import heapq
heapq.heapify(a)
for i in range(m):
    mx = heapq.heappop(a)
    tmp = (-mx)//2
    heapq.heappush(a,-tmp)

print(-sum(a))


Measured memory_bytes: 72300
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
# 塗ることができないケースを考察してみる
# 愚直にシミュレーションしてもいけるかもしれない

H, W =  map(int, sys.stdin.readline().split())
L =  [list(list(sys.stdin.readline().rstrip())) for i in range(H)]

PL = [["0"] + l + ["0"] for l in L]

t = ["0"] * (W + 2)

PL.insert(0, t)
PL.append(t)

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if PL[i][j] == "#":
            if PL[i][j - 1] == "#" or PL[i - 1][j] == "#" or PL[i][j + 1] == "#" or PL[i + 1][j] == "#":
                continue
            else:
                print("No")
                exit()

print("Yes")

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

using namespace std;

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

    vector<int> li(n);

    for (int i = 0; i < n; i ++)
        cin >> li[i];

    sort(li.begin(), li.end(), greater<int>());

    int sum = 0;
    for (int i = 0; i < k; i ++)
        sum += li[i];

    cout << sum << endl;

    return 0;
}



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

using namespace std;
using ll = long long;

int main() {
    int h,w,k = 0;
    cin >> h >> w >> k;
    vector<vector<char>> origin(h,vector<char>(w));
    vector<vector<char>> changer(h,vector<char>(w));
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            char tmp;
            cin >> tmp;
            origin[i][j] = tmp;
        }
    }
    /*
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w - 1;j++){
            cout << c[i][j];
        }
        cout << c[i][w - 1] << endl;
    }
    */
    int ans = 0;
    for(int hBit = 0;hBit < (1<<h);hBit++){
        for(int wBit = 0;wBit < (1<<w);wBit++){
            for(int i = 0;i < h;i++){
                for(int j = 0;j < w;j++){
                    changer[i][j] = origin[i][j];
                }
            }
            for(int i = 0;i < h;i++){
                if (hBit & (1<<i)) { 
                    for(int ic = 0;ic < w;ic++){
                        changer[i][ic] = 'r';
                    }
                }
            }
            for(int j = 0;j < w;j++){
                if (wBit & (1<<j)) { 
                    for(int jc = 0;jc < h;jc++){
                        changer[jc][j] = 'r';
                    }
                }
            }

/*
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w - 1;j++){
            cout << changer[i][j];
        }
        cout << changer[i][w - 1] << endl;
    }
*/
            int cnt = 0;
            for(int i = 0;i < h;i++){
                for(int j = 0;j < w;j++){
                    if(changer[i][j] == '#'){
                        cnt ++;
                    }
                }
            }
            if(cnt == k){
                ans++;
            }
            //cout << endl;
        }
    }
    cout <<ans <<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

ll a,b;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>a>>b;
    if((a+b)%2==0)cout<<(a+b)/2<<newl;
    else cout<<"IMPOSSIBLE\n";
}


Measured memory_bytes: 256
# B - Five Dishes
import math

price = []

for i in range(5):
    price.append(int(input()))

kiriage = [10*(math.ceil(i/10)) for i in price]

amari = [i%10 for i in price]


if max(amari) == 0:
    print(sum(kiriage))

else:
    while min(amari) == 0:
        amari.remove(0)

    print(sum(kiriage)-10+ min(amari))


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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    int N = S.size(), s[2] = {0, 0};
    rep(i, N) {
        s[S[i] - '0']++;
    }
    cout << min(s[0], s[1]) * 2 << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< int > a(n); std::cin >> a;
  std::sort(all(a), std::greater< int >{});
  auto x = 0;
  while (x + 1 < n && x + 1 < a.at(x + 1))
    { x++; }
  auto y = x;
  while (y + 1 < n && x < a.at(y + 1))
    { y++; }
  auto win = ((a.at(x) - x) % 2 == 0) || ((y - x + 1) % 2 == 0);
  std::cout << (win ? "First" : "Second") << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,a,b;
	cin>>k>>a>>b;
	bool f=0;
	for(int i=a;i<=b;++i){
		if(i%k==0) f=1; 
	}
	if(f) puts("OK");
	else puts("NG");
	return 0;
} 

Measured memory_bytes: 3592
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<long long Mod>
struct mint{
    long long x;
    mint(long long x=0) :x((x% Mod+Mod)%Mod){}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if((x += a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if((x += Mod-a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= Mod;
        return *this;
    }

    mint operator^(long long t) const {
        mint ret(1);
        mint a = *this;
        while(t){
            if(t&1){
                ret *= a;
            }
            a *= a;
            t >>= 1;
        }
        return ret;
    }
    mint inv() const { return *this ^ (Mod-2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }

    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint operator/(const mint a) const { return mint(*this) /= a; }

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x; }
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
};

int N;

bool vis[1000000][2][2] ={};
mint<MOD> dp[1000000][2][2];
mint<MOD> solve(int n, int zero, int nine){
    if(n == N){
        if(zero == 1 && nine == 1) return 1;
        else return 0;
    }
    if(vis[n][zero][nine]) return dp[n][zero][nine];
    vis[n][zero][nine] = true;
    return dp[n][zero][nine] = solve(n+1, zero, nine)*8 + solve(n+1, zero|1, nine) + solve(n+1, zero, nine|1);
}

signed main(){
    cin >> N;
    cout << solve(0,0,0) << endl;
}

Measured memory_bytes: 132300
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,k;
vl a;

int main(){
	cin>>n>>k;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	ll res=INF;
	for(int i=0;i<1<<n;i++) if(i&1){
		vl b;
		for(int j=0;j<n;j++) if(i&1<<j) b.push_back(j);
		if(b.size()<k) continue;
		vl a_=a;
		ll S=b.size(),tmp=0;
		for(int j=0;j<S;j++){
			ll L=0,R=0,I=b[j];
			for(int k=0;k<I;k++) L=max(L,a_[k]+1);
			for(int k=I+1;k<(j==S-1?n:b[j+1]);k++) R=max(R,a_[k]);
			a_[I]=max(a[I],max(L,R));
			tmp+=a_[I]-a[I];
		}
		res=min(res,tmp);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, k, q := scanInt(),scanInt(),scanInt()

	p := make([]int, n)

	for i := 0; i < q; i++ {
		a := scanInt()-1
		p[a]++
	}

	for i := 0; i < n; i++ {
		if k-q+p[i] > 0 {
			fmt.Fprintln(wr, "Yes")
		} else {
			fmt.Fprintln(wr, "No")
		}
	}

	wr.Flush()

}


Measured memory_bytes: 3968
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solver();
	}

	@SuppressWarnings("unchecked")
	void solver() {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[V];
		for (int i = 0; i < g.length; i++)
			g[i] = new ArrayList<>();
		for (int i = 0; i < E; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			g[a].add(b);
			g[b].add(a);
		}
		Integer[] color = new Integer[V];
		Arrays.fill(color, -1);
		int base = 0;
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < V; i++) {
			if (color[i] == -1) {
				color[i] = 0;
				counter[0] = 1;
				counter[1] = 0;
				if (!dfs(g, color, i)) {
					System.out.println(-1);
					return;
				} else {
					base += Math.min(counter[0], counter[1]);
					if (counter[0] != counter[1]) {
						int value = Math.abs(counter[0] - counter[1]);
						map.put(Math.abs(value), map.containsKey(value) ? map.get(value) + 1 : 1);
					}
				}
			}
		}
		boolean[] dp = new boolean[V / 2 - base + 1];
		dp[0] = true;
		Iterator<Entry<Integer, Integer>> it = map.entrySet().iterator();
		int x = 0;
		while (it.hasNext()) {
			Entry<Integer, Integer> entry = it.next();
			int value = entry.getKey();
			int c = entry.getValue();
			for (int i = dp.length - 1; i >= 0; i--) {
				if (dp[i]) {
					for (int j = 1; j <= c && i + j * value < dp.length; j++) {
						dp[i + j * value] = true;
						x = Math.max(x, i + j * value);
					}
				}
			}
		}
		System.out.println((long) (base + x) * (long) (V - x - base) - E);
	}

	int[] counter = new int[2];

	boolean dfs(ArrayList<Integer>[] g, Integer[] color, int cur) {
		for (int v : g[cur]) {
			if (color[v] == -1) {
				color[v] = 1 ^ color[cur];
				counter[color[v]]++;
				if (!dfs(g, color, v)) {
					return false;
				}
			} else {
				if (color[cur] != (1 ^ color[v]))
					return false;
			}
		}
		return true;
	}
}

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

#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
// const ll mod = 1e9+7;
const ll mod = 998244353;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 1e6+9;
pair<int, int> a[N], b[N], d[N];
int g[N], vis[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].ft;
        a[i].sd = i;
    }
    for(int i = 1; i <= n; i++) {
        cin >> b[i].ft;
        b[i].sd = i;
    }
    bool tot = 1;
    sort(b+1, b+n+1);

    for(int i = 1; i <= n; i++) {
        d[i].ft = a[b[i].sd].ft;
        d[i].sd = i;
        // cout << d[i].ft << "(" << d[i].sd << ") ";
    }
    // cout << "\n";

    sort(d+1, d+n+1);

    for(int i = 1; i <= n; i++) {
        // cout << d[i].ft << "(" << d[i].sd << ") ";
        // cout << d[i].sd << " " << i << endl;
        g[d[i].sd] = i;
    }
    int u = 1;
    int cnt = 1;
    vis[u] = 1;
    while(1) {
        int v = g[u];
        if(vis[v]) break;
        cnt++;
        vis[v] = 1;
        u = v;
    }

    sort(a+1, a+n+1);
    bool can = 1;
    for(int i = 1; i <= n; i++) {
        if(a[i].ft > b[i].ft) {
            can = 0;
            // cout << "# " << i << endl;
            break;
        }
    }
    bool pos = 0;
    for(int i = 1; i < n; i++) {
        if(a[i+1].ft <= b[i].ft) {
            pos = 1;
            // cout << "# " << i << endl;
            break;
        }
    }
    // cout << "# " << cnt << endl;
    if(can && (cnt < n || cnt == n && pos)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    
    


    return 0;
    
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

ll n,m;
vector<int> G[100010];
int color[100010];

bool dfs(int v,int c){
    color[v]=c;
    for(int u:G[v]){
        if(color[u]==c)return false;
        if(color[u]==0&&!dfs(u,-c))return false;
    }
    return true;
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    ll ans;
    if(dfs(0,1)){
        ll cnt=0;
        for(int i=0;i<n;i++){
            if(color[i]==1)cnt++;
        }
        ans=cnt*(n-cnt)-m;
    }else{
        ans=n*(n-1)/2-m;
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long int;
#define long ll

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

    string s;
    cin >> s;
    ll k;
    cin >> k;

    char c = '1';
    for(ll i=0; i<k; i++)
        if(s[i] != c) {
            c = s[i];
            break;
        }
    cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str; cin >> str;
	long MAX=0;
	for(long i=0;i<str.size(); )
	{
		long cnt_J=0, cnt_O=0, cnt_I=0;
		while(i<str.size() && str[i]=='J') cnt_J++,i++;
		while(i<str.size() && str[i]=='O') i++,cnt_O++;
		while(i<str.size() && str[i]=='I') i++,cnt_I++;
		if(cnt_J>=cnt_O && cnt_I>=cnt_O) MAX=max(MAX,cnt_O);
	}
	cout << MAX << endl;
}

Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if(m == -1&&f == -1&&r == -1){
            return 0;
        }
        if(m == -1||f == -1||m+f < 30){
            cout << "F" << endl;
        }
        else if(m+f < 50){
            if(r < 50){
                cout << "D" << endl;
            }
            else{
                cout << "C" << endl;
            }
        }
        else if(m+f < 65){
            cout << "C" << endl;
        }
        else if(m+f < 80){
            cout << "B" << endl;
        }
        else{
            cout << "A" << endl;
        }
    }
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  VI a(n);
  REP(i, n) cin >> a[i], a[i] -= i+1;

  sort(ALL(a));
  int b = a[n/2];

  int ret = 0;
  REP(i, n) ret += abs(a[i] - b);

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << "i" << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll p,q,r; cin >> p >> q >> r;
    cout << min(p+q,min(q+r,p+r)) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;

    long long ans = A - B;

    if (K % 2 == 1){
        ans = -1 * ans;
    }
    

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
import math
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]

waru = 1
for i in range(N):
    waru*= i+1
a = [i+1 for i in range(N)]
c = 0
su = 0
for i in permutations(a,N):
    li = list(i)
    for j in range(len(li)-1):
        start = l[li[j]-1]
        g = l[li[j+1]-1]
        su += math.sqrt((start[0]-g[0]) ** 2 + (start[1]-g[1]) ** 2)
print(su/waru)

Measured memory_bytes: 68628
import numpy as np

h,w=map(int,input().split())
tmp=[]
for i in range(h):
        a=list(input())
        tmp.append(a)
ans1=[]
if(w!=1):
    for i in range(h):
        if(len(set(tmp[i]))==1 and tmp[i][0]!="#"):
            ans1.append(i)
ans2=[]
tmp=list(map(list,zip(*tmp)))
if(h!=1):
    for i in range(w):
        if(len(set(tmp[i]))==1 and tmp[i][0]!="#"):
            ans2.append(i)
# print(ans1,ans2)
tmp=list(map(list,zip(*tmp)))
tmp=np.delete(tmp,ans1,axis=0)
tmp=np.delete(tmp,ans2,axis=1)
for i in range(len(tmp)):
    for j in range(len(tmp[0])):
        print(tmp[i][j],end="")
    print()

Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int a,b;
int main(){
	cin >> a >> b;
	cout << a*b;
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)


using namespace std;

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

using ll=long long;

//Appropriately Changed
using edge=struct{int to,cost;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to,int cost){ 
	graph[from].push_back({to,cost});
}

auto chuliu(const G &graph,int root){
	using W=int;
	const W inf=1<<28;
	
	const int n=graph.size();
	vector<int> cost(n,inf),pv(n,-1);

	rep(v,n) for(auto &e:graph[v]) if(chmin(cost[e.to],e.cost)) pv[e.to]=v;

	bool term=true;
	vector<int> comp(n,-1),used(n,-1);
	
	rep(v,n){
		if(used[v]!= -1 or cost[v]==inf or v==root) continue;

		int cur=used[v]=v;
		for(cur=pv[cur]; cur!=root && used[cur] == -1; cur=pv[cur]) used[cur]=v;

		if(used[cur]==v){
			term=false,comp[cur]=cur;	
			for(int w=pv[cur]; w != cur; w = pv[w]) comp[w]=cur;
			break;
		}
	}

	G ret(n);
	if(term){
		rep(v,n){
			if(v!=root and pv[v]!=-1)
				add_edge(ret,pv[v],v,cost[v]);
		}
		return ret;
	}

	const int nroot=(comp[root]==-1)?root:comp[root];
	G ngraph(n);
	using E=tuple<int,int,int>;
	map<E,E> dict;

	rep(v,n){
		for(auto &e:graph[v]){			
			int a=v,b=e.to,c=e.cost;
			if(comp[a]!=-1) a=comp[a];
			if(comp[b]!=-1) c-=cost[b],b=comp[b];
			if(a==b) continue;
			dict[E(a,b,c)]=E(v,e.to,e.cost);
			add_edge(ngraph,a,b,c);
		}
	}
	
	auto ntree=chuliu(ngraph,nroot);

	int unuse=-1;
	rep(v,n){
		for(auto &e:ntree[v]){
			int a,b,c;
			tie(a,b,c)=dict[E(v,e.to,e.cost)];
			if(comp[b]!=-1) unuse=b;
			add_edge(ret,a,b,c);
		}
	}

	rep(v,n){
		if(comp[v]==-1 or v==unuse) continue;
		add_edge(ret,pv[v],v,cost[v]); 
	}
	
	return ret;
}

int main(void){
	int v,e,r;
	cin >> v >> e >> r;
	G graph(v);
	rep(i,e){
		int a,b,w;
		cin >> a >> b >> w;
		add_edge(graph,a,b,w);
	}

	auto tree=chuliu(graph,r);
	int ans=0;
	rep(i,v) for(auto &e:tree[i]) ans+=e.cost;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5100
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

int main(){
  char s[16];
  cin >> s;
  int cnt = 0;
  for( int i = 0; i < 6; i++ ){
    cnt += (s[i]=='1' ? 1 : 0);
  }
  cout << cnt << endl;
  return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    ll h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    const int v = h*w;
    ll d[v][v]={};
    ll INF = 1e9;
    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            if(i==j)continue;
            d[i][j] = INF;
        }
    }
    int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<4;k++){
                int x = i+dx[k], y=j+dy[k];
                if(x>=0 && x<h && y>=0 && y<w && s[i][j]=='.' && s[x][y]=='.'){
                    int from = i*w + j;
                    int to = x*w + y;
                    d[from][to] = 1;
                }
            }
        }
    }
    for(int k=0;k<v;k++)for(int i=0;i<v;i++)for(int j=0;j<v;j++){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
    ll ans = 0;
    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            if(d[i][j]==INF) continue;
            ans = max(ans, d[i][j]);
        }
    }
    cout << ans << endl;

}

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];

    vector<int> rows;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                rows.push_back(i);
                break;
            }
        }
    }

    int cnt = 0;
    vector<vector<int>> res(H, vector<int>(W));
    for (int i = 0; i < rows.size(); i++) {
        int rowStart = (i > 0) ? rows[i - 1] + 1 : 0;
        int rowEnd = (i == rows.size() - 1) ? H - 1 : rows[i];

        vector<int> cols;
        for (int j = 0; j < W; j++) {
            if (S[rows[i]][j] == '#') cols.push_back(j);
        }

        for (int j = 0; j < cols.size(); j++) {
            int colStart = (j > 0) ? cols[j - 1] + 1 : 0;
            int colEnd = (j == cols.size() - 1) ? W - 1 : cols[j];
            
            cnt++;
            for (int row = rowStart; row <= rowEnd; row++) {
                for (int col = colStart; col <= colEnd; col++) {
                    res[row][col] = cnt;
                }
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main()
{
    arena
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    ll ans=(a*x)/b;
    cout<<ans;
}

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

int main() {
  int x,y,z;
  cin >> x >> y >> z;
  for(int i=0;i<=pow(10,5);i++){
    if( ( x - i*(y+z) -z ) < 0 ){
      cout << i - 1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_((i), __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Thu Mar  5 10:47:21 JST 2020
 **/

void no() {
    cout << -1 << endl;
    exit(0);
}
signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, -1);
    REP(_, m) {
        int s, c;
        cin >> s >> c;
        s--;
        if (a[s] >= 0 && a[s] != c) no();
        a[s] = c;
    }
    if (n >= 2 && a[0] == 0) no();
    REP(i, n) {
        int x = a[i];
        if (x == -1) {
            if (n == 1) {
                x = 0;
            } else {
                x = i == 0 ? 1 : 0;
            }
        }
        cout << x;
    }
    cout << endl;
}


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

int main() {
    int M; cin >> M;
    long long ans = 0;
    long long x = 0;
    for (int i = 0; i < M; i++) {
        int d; long long c;
        cin >> d >> c;
        ans += c;
        x += c * d;
    }
    int k = (x - 1) % 9 + 1;
    cout << ans - 1 + (x - 1) / 9 << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int pot = 1;
		while (2 * pot - 1 <= N) pot = 2 * pot;
		if (pot != N && N != 1) {
			out.println("Yes");
			for (int i = 1; i + 1 <= pot - 1; i++) {
				out.println(i + " " + (i + 1));
			}
			out.println((pot - 1) + " " + (N + 1));
			for (int i = 1; i + 1 <= pot - 1; i++) {
				out.println((N + i) + " " + (N + i + 1));
			}
			int xor = 0;
			for (int i = pot; i <= N; i++) {
				xor ^= i;
			}
			int from = pot;
			if ((xor & pot) != 0) {
				xor ^= pot;
				from++;
			}
			int first = xor, last = xor;
			if (xor == 0) {
				first = 1;
				last = pot - 1;
			}
			for (int i = from; i + 1 <= N; i++) {
				out.println(i + " " + (i + 1));
			}
			if (pot - 1 < N) {
				out.println(N + " " + first);
				out.println(last + " " + (from + N));
			}
			for (int i = from; i + 1 <= N; i++) {
				out.println((N + i) + " " + (N + i + 1));
			}
			if (from != pot) {
				int nxor = pot ^ N ^ first;
				out.println(pot + " " + N);
				int curPos = first;
				while (nxor != 0) {
					if (curPos > N + pot - 1) throw new RuntimeException();
					if (curPos == pot -1) curPos = 1 + N;
					else curPos++;
					int toXor = curPos;
					if (toXor > N) toXor -= N;
					nxor ^= toXor;
				}
				out.println(curPos + " " + (pot + N));
			}
		} else {
			out.println("No");
		}
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 45428
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;


struct item{
	long val;
	long weight;
};


int compare(item left_item,item right_item){
	return left_item.weight <= right_item.weight;
}

int main(){

	int N,W;

	cin >> N >> W;

	vector<vector<long long>> DP(W+1,vector<long long>(N,0));

	item temp = {0,0};
	vector<item> items_arr(N,temp);

	//vector<int> Weights(N,0);
	//vector<int> Value(N,0);

	for(int k=0;k<N;k++){

		cin >> items_arr[k].weight >> items_arr[k].val;
	}

	//init
	//sort(items_arr.begin(),items_arr.end(),compare);

  //for(auto x:items_arr)cout<<x.weight<<endl;
	for(int i=1;i<=W;i++){
		if(i>=items_arr[0].weight){
			DP[i][0] = items_arr[0].val;
		}
	}

	for(int i=1;i<=W;i++){
		for(int j=1;j<N;j++){
			if(i>=items_arr[j].weight){
				DP[i][j] = max(items_arr[j].val+DP[i-items_arr[j].weight][j-1],DP[i][j-1]);
			  //if(i==3&&j==2)cout<<items_arr[j].val+DP[i-items_arr[j].weight][j-1]<<" "<<DP[i][j-1]<<endl;
			}else{
				DP[i][j] = DP[i][j-1];

			}
			//cout<<i<<" "<<j<<" "<<DP[i][j]<<endl;
		}
	}

	cout << DP[W][N-1] << endl;

	//system("pause");
	return 0;

}


Measured memory_bytes: 85204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
    int to;
    int cost;
};
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> v(n);
    rep(i, m)
    {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        edge e;
        e.to = r;
        e.cost = d;
        v[l].push_back(e);
        e.to = l;
        e.cost = -d;
        v[r].push_back(e);
    }
    vector<ll> dp(n, 1e18);
    queue<int> que;
    for (int i = 0; i < n; i++)
    {
        if(dp[i]!=1e18){
            continue;
        }
        dp[i]=0;
        que.push(i);
        while (!que.empty())
        {
            int it = que.front();
            que.pop();
            for (auto e : v[it])
            {
                if (dp[e.to] == 1e18)
                {
                    dp[e.to] = dp[it] + e.cost;
                    que.push(e.to);
                }
                else
                {
                    if (dp[e.to] != dp[it] + e.cost)
                    {
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 9728
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;

struct triplet {
  int x, y, z;
  triplet();
  triplet(int _x, int _y, int _z) {
    x = _x;
    y = _y;
    z = _z;
  }
};

const int da[] = {1,1,0,2,0,0};
const int db[] = {1,0,1,0,2,0};
const int dc[] = {0,1,1,0,0,2};

int bio[250][250][250];
int a, b, c;

queue<triplet> Q;

int main(void) {
  scanf("%d%d%d", &a, &b, &c);

  memset(bio, -1, sizeof bio);
  bio[a][b][c] = 0;

  Q.push(triplet(a, b, c));

  while (!Q.empty()) {
    a = Q.front().x;
    b = Q.front().y;
    c = Q.front().z;
    Q.pop();
    if (a == b && b == c) break;
    for (int i = 0; i < 6; ++i) {
      int _a = a + da[i], _b = b + db[i], _c = c + dc[i];
      if (bio[_a][_b][_c] == -1) {
        bio[_a][_b][_c] = bio[a][b][c] + 1;
        Q.push(triplet(_a, _b, _c));
      }
    }
  }

  printf("%d\n", bio[a][b][c]);
  return 0;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="776755555555555555555555555555555555555554555555555555555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    ll n;
    cin>>n;
    ll a[2][n];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n-1;i++){
        a[0][i+1] += a[0][i];
    }
    for(int i=n-2;i>=0;i--){
        a[1][i] += a[1][i+1];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        chmax(ans,a[0][i] + a[1][i]);
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if i == 0:
        ans += B[i]
    elif i == N-1:
        ans += B[i-1]
    else:
        ans += min(B[i], B[i-1])

print(ans)

Measured memory_bytes: 38404
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3];
    rep(i, 3) cin >> A[i];
    int ans = 0;
    sort(A, A + 3);
    while(A[0] != A[2]) {
        if(A[2] - A[0] >= 2) A[0] += 2;
        else {A[0]++; A[1]++;}
        sort(A, A + 3);
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int k;
	int a;
	int b;

	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	while (a <= b)
	{
		if (a % k == 0)
		{
			printf("OK\n");
			return;
		}
		a++;
	}
	printf("NG\n");
  	return;
}

Measured memory_bytes: 1620