akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3


def solve(n, k, q, a):

    sorted_pairs = [(ai, i) for i, ai in enumerate(a)]
    sorted_pairs.sort()


    ans = 10 ** 10
    segments = [(0, n)]
    ly = 0
    for i in range(n - q + 1):
        y, _ = sorted_pairs[i]
        if y == ly:
            continue
        ly = y
        b = []
        for left, right in segments:
            if k <= right - left:
                c = a[left:right].copy()
                c.sort()
                b += c[:right - left - k + 1]
        if q <= len(b):
            b.sort()
            x = b[q - 1]
            ans = min(ans, x - y)
        i_end = n - q + 1
        for i2 in range(i + 1, n - q + 1):
            if sorted_pairs[i2][0] != y:
                i_end = i2
                break
        for i2 in range(i, i_end):
            _, j = sorted_pairs[i2]
            for h, seg in enumerate(segments):
                left, right = seg
                if left <= j and j < right:
                    segments.pop(h)
                    segments.append((left, j))
                    segments.append((j + 1, right))
                    break

    return ans


def main():
    n, k, q = input().split()
    n = int(n)
    k = int(k)
    q = int(q)
    a = list(map(int, input().split()))

    print(solve(n, k, q, a))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3572
N=int(input())
A=[int(i) for i in input().split()]
B=[int(j) for j in input().split()]
a=sum(A)
b=sum(B)
res=b-a
cnt=0
s=0
t=0

for i in range(N):
  if A[i]%2==0:
    s+=1
  if B[i]%2==0:
    t+=1
  if A[i]>B[i]:
    cnt+=(A[i]-B[i])
  elif A[i]<B[i] and (B[i]-A[i])%2==0:
    cnt+=(B[i]-A[i])/2
  elif A[i]<B[i] and (B[i]-A[i])%2==1:
    cnt+=(B[i]-A[i]+3)/2

if res<0:
  print("No")
elif res*2<cnt:
  print("No")
elif abs(s-t)>res:
  print("No")
elif (res-abs(s-t))%2==1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 4600
#include<bits/stdc++.h>
#define INF 1e9
#define N 500000
using namespace std;

int cnt=0;

void merge(int A[],int left,int mid,int right)
{
  int n1 = mid - left;
  int n2 = right - mid;

  int L[n1+1],R[n2+1];
  for(int i=0;i < n1;i++){
    L[i] = A[left+i];
  }
  for(int i=0;i < n2;i++){
    R[i] = A[mid+i];
  }
  
  L[n1]=R[n2]=INF;
  int i=0,j=0;
  for(int k=left;k < right;k++){
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
    cnt++;
  }
}

void mergesort(int A[],int left,int right)
{
  if(left+1 < right){
    int mid = (left + right)/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main()
{
  int n;
  cin >> n;
  int a[N];
  for(int i=0;i < n;i++){
    cin >> a[i];
  }
  int left=0;
  int right=n;
  
  mergesort(a,left,right);

  for(int i=0;i < n;i++){
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}



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


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

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
//#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
//#include <stack>
//#include <limits>
#include <sstream>
//#include <functional>
#include <complex>
#include <ctime>

using namespace std;

#define len(array)  (sizeof (array) / sizeof *(array))
#define rep(i, s, e) for(int i = s;i < e;i++)
#define rrep(i, e, s) for(int i = e;s <= i;i--)
#define vrange(v) v.begin(), v.end()
#define vrrange(v) v.rbegin(), v.rend()
#define vsort(v) sort(vrange(v))
#define vrsort(v) sort(vrrange(v))
#define arange(a) a, a + len(a)
#define asort(a) sort(arange(a))
#define arsort(a, t) sort(arange(a), greater<t>())
#define afill(a, v) fill(arange(a), v)
#define afill2(a, v, t) fill((t *)a, (t *)(a + len(a)), v)
#define fmax(a, b) (a < b? b : a)
#define fmin(a, b) (a > b? b : a)
#define fabs(a) (a < 0? -a : a)
#define X real()
#define Y imag()
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef complex<double> p;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
//const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
//const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//const int weight[] = {0,1,10,100,1000,10000,100000,1000000,10000000};
//priority_queue< int, vector<int>, greater<int> > q;

//struct tm : http://www.tamasoft.co.jp/lc/hlp/F047.html

//閏年ならtrue
bool leap(int y){
  return y % 400 == 0? true : (y % 100 == 0? false : (y % 4 == 0? true : false));
}

void settime(struct tm *t, int y, int m, int d){
  t->tm_sec = 0;
  t->tm_min = 0;
  t->tm_hour = 0;
  t->tm_mday = d;
  t->tm_mon = m-1;
  t->tm_year = y-1900;
  // if(leap(y)) t->tm_yday = 365;
  // else t->tm_yday = 364;
  t->tm_isdst = -1;
  //cout << "yday = " << t->tm_yday << ", isdst = " << t->tm_isdst << endl;
}

int diffdays(struct tm *t1, struct tm *t2){
  double t = difftime(mktime(t1), mktime(t2));
  return fabs(t) / (60*60*24);
}

//AOJ0125
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0125
void doIt(){
  int y1,m1,d1,y2,m2,d2;
  struct tm t1, t2;
  int ans;
  while(1){
	cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
	if(y1 < 0) break;
	settime(&t1, y1, m1, d1);
	settime(&t2, y2, m2, d2);
	ans = diffdays(&t1, &t2);
	cout << ans << endl;
  }
}

void test(){
  struct tm t1, t2;
  settime(&t1, 2000, 2, 28);
  settime(&t2, 2000, 3, 1);
  cout << diffdays(&t1, &t2) << endl;
}

int main() {
  doIt();
  //test();
  return 0;
}

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



int main()
{
  int N,x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a.at(i);
  }
  int count=0;
  sort(a.begin(), a.end());
  //reverse(a.begin(), a.end());
  for (int i = 0; i < N; i++)
  {
    if(a.at(i) <= x && i != N-1){
      x -= a.at(i);
      ++count;
    }
    else if (i == N - 1){
      if(x==a.at(i)){
        ++count;
      }
    }
  }
  cout << count << endl;
}


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

vector<int> pre, in, post ;
int pos = 0;

void rec(int left, int right, int &i) {
    if (left < right) {
        int root = pre[i];
        i++;
        int m = distance(in.begin(), find(in.begin(), in.end(), root));
        rec(left, m, i);
        rec(m+1, right, i);
        post.push_back(root);
    }
}

int main() {
    int n;
    scanf("%d", &n);
    pre.resize(n);
    in.resize(n);
    rep(i, n) {
        scanf("%d", &pre[i]);
    }
    rep(i, n) {
        scanf("%d", &in[i]);
    }

    int i = 0;
    rec(0, n, i);
    rep(i, n) {
        printf("%d", post[i]);
        if (i != n-1) printf(" ");
        else printf("\n");
    }
}


Measured memory_bytes: 3296
import heapq
n,m = map(int, input().split())

a = list(map(int, input().split()))
heapq.heapify(a)

min_num = a[0]

tmp_array = []

for i in range(m):
  b,c = map(int, input().split())
  tmp_array.append([b,c])

sort_array = sorted(tmp_array, key=lambda x: -x[1])

for i in range(m):
  b = sort_array[i][0]
  c = sort_array[i][1]
  if min_num >= c:
    continue
  else:
    for j in range(b):
      if a[0] < c:
        heapq.heappop(a)
        heapq.heappush(a, c)
      else:
        break
    min_num = a[0]

#for i in range(m):
#  b,c = map(int, input().split())
#  if min_num >= c:
#    continue
#  else:
#    for j in range(b):
#      if a[0] < c:
#        heapq.heappop(a)
#        heapq.heappush(a, c)
#      else:
#        break
#    min_num = a[0]

print(sum(a))

Measured memory_bytes: 97560
#include "bits/stdc++.h"
using namespace std;

int main(){
	long long int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	long long int low=a+c*(n-1);
	long long int hig=a+d*(n-1);
	
	//cout<<low<<" "<<hig<<endl;
	
	if(low<=b&&b<=hig){
		cout<<"YES"<<endl;
		return 0;
	}
	
	for(int i=0;i<n;i++){
		low-=c+d;
		hig-=c+d;
		//cout<<low<<" "<<hig<<endl;
		if(low<=b&&b<=hig){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

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

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

int main() {

    ll N, K;
    vector<ll> A;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());

    ll x;
    sort(A.begin(),A.end());
    for (int i = 0; i < N; ++i) {
        ll a = A[i];
        if(i == 0){
            x = a;
        }else{
            ll t = gcd(x, a);
            x = t;
        }
    }

    if(K % x == 0 && A[A.size()-1] >= K){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

#define         eps         10e-9
#define         pi          2*acos(0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int

using namespace std;

///ISNNJB

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main() {
    /***freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

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

    lli t,a,b,n,x,total,ara[111],i;
    bool flag=true;
    memset(ara, 0, sizeof(ara));
    cin>>x>>n;

    for (i=1; i<=n; i++) {
        cin>>a;
        ara[a]=1;
    }
//
//    for (int i=1; i<=16; i++)
//        cout<<ara[i]<<" ";
//    cout<<endl;

    if(n==0)
        cout<<x<<endl;
    else {
        for (i=x; i>=1; i--) {
            if(ara[i]==0) {
                    ///cout<<ara[i]<<endl;
                a=i;
                flag=false;
                break;
            }
        }
        if(flag==true)
            a=i;
        for (i=x; i<=110; i++) {
            if(ara[i]==0) {
                b=i;
                break;
            }
        }

        ///cout<<a<<"\t"<<b<<endl;
        total=abs(x-a);
        t=abs(x-b);

        if(total<=t)
            cout<<a<<endl;
        else
            cout<<b<<endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include"custom_header.h"
#else
#define openfile 
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define vl vector<ll>
#define sz(x) (ll)x.size()
#define vvl vector<vl>
#define vpl vector<pll>
const ll mod = 1000000007;
void solve()
{
    ll n,i,j,k,ans = 0;cin>>n;
    vl arr(n);
    fo(0,i,n)
    {
        cin>>arr[i];
    }
    fo(1,i,n)
    {
        if(arr[i]<arr[i-1])
        {
            ans+=(arr[i-1]-arr[i]);
            arr[i] = arr[i-1];
        }
    }
    cout<<ans<<endl;
}
int main()
{
    //openfile;fastio;
    ll T = 1; 
    // cin>>T;
    while(T--)
    {solve();}
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

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

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	ll n,m;
	cin >> n >> m;
	if(n==1 && m==1){
		ANS(1);
	}else if(n <= 2 && m <= 2){
		ANS(0);
	}else if(n==1||m==1){
		ANS(max(n,m)-2);
	}else{
		ll ans = (n-2) * (m-2);
		ANS(ans);
	}
	return 0;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
x = 0
if K == 0:
    x = N*N
else:
    for i in range(N-K):
        A = K+1+i
        x += (A-K)*(N // A)
        T = (N%(A-K))-K+1
        if  T > 0:
            x += T

print(x)

Measured memory_bytes: 2940
N = int(input()) 
a = sorted(list(map(int, input().split())))[::-1]
f = int(0)
Ali = int(0)
Bob = int(0)

for i in range(N):
  if f == 0:
    Ali = Ali + a[0]
    del a[0]
    f = 1
  else:
    Bob = Bob + a[0]
    del a[0]
    f = 0
print(Ali-Bob)


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

set<char> st;
set<char>::iterator it;
char s[maxn];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	while (k--)
	{
		int x;
		scanf("%d", &x);
		st.insert(x+'0');
	}
	for (int i = n; 1; ++i)
	{
		sprintf(s, "%d", i);
		bool flag = true;
		for (int j = 0; s[j]; ++j)
			if (st.find(s[j]) != st.end()) flag = false;
		if (flag) 
		{
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<vector<int>> e(n);
    vector<int> x(n), w(n, 1e9);
    vector<int> dp(5050);
    for (int i = 1; i < n; i++) {
        int p; cin >> p;
        e[--p].emplace_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        if (e[i].empty()) w[i] = 0;
    }
    bool ok = true;
    auto f = [&](auto f, int curr) -> void {
        for (auto &to: e[curr]) {
            f(f, to);
        }
        for (int i = 0; i <= x[curr]; i++) dp[i] = 1e9;
        dp[0] = 0;
        for (auto &to: e[curr]) {
            for (int i = x[curr]; i >= 0; i--) {
                long long p = (i-x[to] >= 0) ? dp[i-x[to]]+w[to] : 1e9;
                long long q = (i-w[to] >= 0) ? dp[i-w[to]]+x[to] : 1e9;
                dp[i] = min(p, q);
            }
        }
        for (int i = 0; i <= x[curr]; i++) {
            w[curr] = min(w[curr], dp[i]);
        }
        //cout << curr << " " << w[curr] << "\n";
        if (w[curr] == 1e9) ok = false;
    };
    f(f, 0);
    if (ok) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	vector<pair<ll, ll> > h;
	FOR(i, 1, 151) {
		FOR(j, i + 1, 151) {
			h.pb(P(i * i + j * j, i));
		}
	}
	sort(ALL(h));
	while(true) {
		ll g, w;
		cin>>g>>w;
		if(g == 0 && w == 0) break;
		vector<P>::iterator ite;
		ite = lower_bound(ALL(h), P(g * g + w * w, g));
		++ite;
		cout<<ite->second<<" "<<(int)(sqrt(ite->first - (ite->second * ite->second)) + 0.0000000001)<<endl;
	}
}

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

int main(){
  bool len,d,l,u;
  string s;

  cin >> s;

  len = (s.size()<6)?false:true;
  
  d = l = u = false;
  for(int i=0;i<s.size();i++){
    if(isdigit(s[i]))d = true;
    if(islower(s[i]))l = true;
    if(isupper(s[i]))u = true;
  }

  if(len && d && l && u)cout << "VALID\n";
  else cout << "INVALID\n";
}

Measured memory_bytes: 1164
N = int(input())
Hs = list(map(int, input().split()))

c = 0
mc = 0
for i in range(1, N):
    if Hs[i] <= Hs[i - 1]:
        c += 1
    else:
        if c > mc:
            mc = c
        c = 0
else:
    if c > mc:
        mc = c
print(mc)

Measured memory_bytes: 63984
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define pb push_back
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void ram5564()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c)
    	cout<<"Yes"<<endl;
    else if(b==c&&b!=a)
    	cout<<"Yes"<<endl;
    else if(a==c&&b!=c)
    {
    	cout<<"Yes"<<endl;
    }
    else
    	cout<<"No"<<endl;
}

signed main()
{
		noob
		// #ifndef ONLINE_JUDGE
  //    	freopen("input.txt","r",stdin);
  //    	freopen("output.txt","w",stdout);
  //    	#endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

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

using namespace std;

int n, x[55], y[55], ma;
map<pair<int, int>, int> m;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", x + i, y + i);
		for (int j = 0; j < i; j++) {
			m[{x[i] - x[j], y[i] - y[j]}]++;
			m[{x[j] - x[i], y[j] - y[i]}]++;
		}
	}
	for (const auto i : m) {
		// printf("%d %d %d\n", i.first.first, i.first.second, i.second);
		ma = max(ma, i.second);
	}
	printf("%d\n", n - ma);
}


Measured memory_bytes: 384
//g++ C.cpp -I /usr/local/include/ac-library
#include<cmath>
#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define mod 1000000007
//#define mint=modint1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

int main(){
    int n,m;
    cin >> n>> m;
    dsu d(n);
    rep(i,m){
        int a,b;
        cin >> a>> b;
        a--;b--;
        d.merge(a,b);
    }
    set<int> S;
    rep(i,n){
        S.insert(d.leader(i));
    }
    cout<<S.size()-1<<endl;
    return 0;
}

Measured memory_bytes: 7432
#include <iostream>
using namespace std;
int n, m, a, b, s, c[55], v[55][55];

void f(int p) {
	if(c[p]!=1) return;
	int i;
	for(i=1; !v[p][i]; i++);
	s++;
	v[p][i] = v[i][p] = 0;;
	c[p]--, c[i]--;
	f(i);
}

int main() {
	cin>>n>>m;
	while(m--) {
		cin>>a>>b;
		v[a][b] = v[b][a] = 1;
		c[a]++, c[b]++;
	}
	for(int i=1; i<=n; i++) f(i);
	cout<<s;
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<long long> A(N), B(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
        
    vector<long long> plus;
    long long sum = 0;
    int num = 0;
    for (int i = 0; i < N; ++i) {
        long long dif = A[i] - B[i];
        if (dif < 0) sum -= dif, ++num;
        else plus.push_back(dif);
    }
        
    if (num == 0) cout << 0 << endl; // マイナスがなかったら変更の必要なし
    else {
        int res = num;
        sort(plus.begin(), plus.end(), greater<long long>());
        
        // 正の部分のうち、大きい方から優先的に削ってマイナスを埋め立てる
        long long p = 0;
        for (int i = 0; i < plus.size(); ++i) {
            p += plus[i];
            ++res;
            if (p >= sum) break;
        }
            
        if (p >= sum) cout << res << endl;
        else cout << -1 << endl;
    }
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int D,G; cin>>D>>G;
  vector<pii> P(D);
  rep(i,0,D) cin>>P[i].first>>P[i].second;
  int ans=MOD;
  rep(i,0,(1<<D)){
    bitset<10> B(i);
    int sum=0;
    int count=0;
    rep(j,0,D){
      if(B.test(j)){
        sum+=P[j].first*(j+1)*100+P[j].second;
        count+=P[j].first;
      }
    }
    for(int j=D-1;0<=j&&sum<G;j--){
      if(B.test(j)) continue;
      int K=G-sum;
      K/=100;
      K/=(j+1);
      K=min(K,P[j].first-1);
      sum+=(j+1)*100*K;
      count+=K;
    }
    if(sum>=G)
      ans=min(ans,count);
  }
  cout<<ans<<endl;
  }


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

# define fr first
# define sc second
# define ll unsigned long long
# define mk make_pair
# define pb emplace_back
# define sz(s) (int)s.size()
# define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

int n;

int get(int n) {
    int ans = 0;
    while(n) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

int main () {
    cin >> n;
    if(n % get(n) == 0) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string s; cin >> s;
    int a = -1, z = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' && a < 0)
            a = i;
        if (s[i] == 'Z')
            z = i;
    }
    int ans = z - a + 1;
    cout << ans << endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
	int a, b, d;
	char op;
	while(1){
	scanf("%d %c %d", &a, &op, &b);
		if (op == '?') {
			break;
		}
		else if (op == '+') {
			d = a + b;
		}
		else if (op == '-') {
			d = a - b;
		}
		else if (op == '*') {
			d = a * b;
		}
		else if (op == '/') {
			d = a / b;
		}
		printf("%d\n", d);
	}
	return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int K = sc.nextInt();
		int len = s.length();

		char[] ans = new char[len];
		for (int i = 0; i < len - 1; i++) {
			if ('z' - s.charAt(i) + 1 <= K && s.charAt(i) != 'a') {
				K = K - ('z' - s.charAt(i) + 1);
				ans[i] = 'a';
			} else {
				ans[i] = s.charAt(i);
			}
		}
		ans[len - 1] = (char) (s.charAt(len - 1) + (K % 26));
		if (ans[len - 1] > 'z') {
			ans[len - 1] = (char) (ans[len - 1] - 26);
		}
		System.out.println(new String(ans));
	}
}


Measured memory_bytes: 14236
# -*- coding: utf-8 -*-
from math import sqrt
from bisect import bisect

def inpl(): return tuple(map(int, input().split()))

def isprime(N, P):
    if N <= 1:
        return False
    for p in P[:bisect(P, sqrt(N))]:
        if N%p==0:
            return False
            break
    else:
        return True

def primes(N):
    P = [2]
    searched = [False]*(N+1)
    for i in range(3, N+1, 2):
        if searched[i]:
            continue
        P.append(i)
        for j in range(i, N+1, i):
            searched[j] = True
    return P

P = primes(int(sqrt(10**8)))

res = 0
for i in range(int(input())):
    res += isprime(int(input()), P)
print(res)


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

int main() {
    int r, c;
    int matrix[101][101];
    cin >> r >> c;

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> matrix[i][j];
        }
    }

    for (int i = 0; i <= r; i++) {
        matrix[i][c] = 0;
    }
    for (int j = 0; j <= c; j++) {
        matrix[r][j] = 0;
    }

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            matrix[i][c] += matrix[i][j];
            matrix[r][j] += matrix[i][j];
            matrix[r][c] += matrix[i][j];
        }
    }

    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            if (j) {
                cout << " ";
            }
            cout << matrix[i][j];
        }
        cout << endl;
    }

    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define LL long long
#define SZ(X) X.size()
#define pii pair<int,int>
#define ALL(X) X.begin(),X.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 2e5 + 11;
int main() {
	ios::sync_with_stdio(false);
	int x;
	cin>>x;
	cout<<x*x<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >>B;
  int c = 0;
  
  for(int i = A; i<=B; i++){
    int s = i/10000; //10000の位
    int t = i/1000 % 10;//1000の位
    int u = i%100 /10;//10の位
    int v = i%10;//1の位
      if(s == v && t == u){
        c++;
      }
  }
    cout << c << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    vector<int> v(3, 0); for(int i = 0; i < 3; i++) cin >> v[i];
    sort(v.begin(), v.end());
    
    cout << (v[0] * v[1]) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())
rules = [list(map(int, input().split())) for i in range(M)]
ans = '-1'
if N == 1:
    num = '0'
else:
    num = '1' + '0'*(N-1)
idxes = []
values = []

for rule in rules:
    num = num[:rule[0]-1] + str(rule[1]) + num[rule[0]:]

if num[0] != '0':
    ans = num
elif num[0] == '0' and N == 1:
    ans = '0'
    
for rule in rules:
    if rule not in values:
        values.append(rule)

for i in values:
    idxes.append(i[0])

idxes_set = set(idxes)
if len(idxes) != len(idxes_set):
    ans = '-1'

if len(num) != N:
    ans = '-1'

print(ans)

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

#define SWAP(a, b, v) v = a, a = b, b = v
#define left(i) (2 * (i))
#define right(i) (2 * (i) + 1)

void
max_heapify(int *a, int n, int i)
{
	int l = left(i);
	int r = right(i);
	int g;

	g = (l <= n && a[l] > a[i]) ? l : i;
	g = (r <= n && a[r] > a[g]) ? r : g;

	if (g != i) {
		SWAP(a[i], a[g], l);
		max_heapify(a, n, g);
	}
}

int
main(void)
{
	int i, n, p;
	int *a;

	scanf("%d", &n);
	n += 1; /* 1 origin */

	a = (int *)malloc(sizeof(int) * n);
	if (a == NULL)
		return 1;

	for (i = 1; i < n; i++)
		scanf("%d", a + i);

	for (i = n/2; i > 0; i--)
		max_heapify(a, n, i);

	for (i = 1; i < n; i++)
		printf(" %d", a[i]);
	printf("\n");

	return 0;
}



Measured memory_bytes: 3684
n = int(input())
x = map(int, input().split())
temp = sorted(zip(x, range(n)))
ans = [None] * n
for i in range(n):
    idx = n//2
    if i >= idx:
        idx -= 1
    ans[temp[i][1]] = temp[idx][0]
for item in ans:
    print(item)

Measured memory_bytes: 45444
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    ll N, K; cin >> N >> K;

    vector<ll> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    sort(H.begin(), H.end(), greater<ll>());

    ll ans = 0;
    for (int i = K; i < N; i++) {
        ans += H[i];
    }
    cout << ans << '\n';
}



Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
  if a[i]-b[i]<0:
    cnt+=a[i]
    b[i]-=a[i]
    if b[i]>a[i+1]:
      cnt+=a[i+1]
      a[i+1]=0
    else:
      cnt+=b[i]
      a[i+1]-=b[i]
  else:
    cnt+=b[i]
print(cnt)

Measured memory_bytes: 18624
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x := nextInt()
	x = abs(x)
	k := nextInt()
	d := nextInt()

	// 臨界に届かない場合
	if k < x/d {
		fmt.Println(x - k*d)
		return
	}
	k2 := x / d
	if (k-k2)%2 == 0 {
		fmt.Println(x % d)
		return
	}
	fmt.Println(d - x%d)

}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

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

constexpr ll MOD = 1000000007;

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

  int d[3];
  rep(i, 3) cin >> d[i];

  sort(d,d+3,greater<int>());
  cout << d[0] * 10 + d[1] + d[2] << endl;

  return (0);
}


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

#define ll long long
#define endl "\n"
#define FILEIN freopen("input.txt", "r", stdin)


int main(){
    // FILEIN;
    //ll n, flag = 1, sum = 0, sum2 = 0; cin>>n;
    //while(n--){
    //    ll ar[3] = {};
    //    for(int i = 0; i<3; i++){
    //        cin>>ar[i];
    //    }
    //    sort(ar, ar+3);
    //    if(flag){
    //        sum2 += ar[1];
    //        sum += ar[2];
    //    }else{
    //        sum2 += ar[2];
    //        sum += ar[1];
    //    }
    //    flag = !flag;
    //}
    //if(sum > sum2){
    //    cout<<sum<<endl;
    //}else{
    //    cout<<sum2<<endl;
    //}

    ll h, n, sum = 0, a;cin>>h>>n;
    for(int i = 0; i<n; i++){
        cin>>a;
        sum += a;
    }
    if(sum >= h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

const int MAXN = 50000 + 10;
const double pi = acos(-1.0);
const double inf = 1e100;
const double eps = 1e-12;

typedef struct point vec;
struct point { //点的基本数据结构
    double x, y;
    double poe;
    point(double _x = 0, double _y = 0)
        : x(_x)
        , y(_y)
    {
    }
    double len() //模长
    {
        return sqrt(x * x + y * y);
    }
    vec chuizhi()
    {
        return vec(-y, x);
    }
    double operator*(const point& i_T) const //点积
    {
        return x * i_T.x + y * i_T.y;
    }
    double operator^(const point& i_T) const //叉积
    {
        return x * i_T.y - y * i_T.x;
    }
    point operator*(double u) const
    {
        return point(x * u, y * u);
    }
    bool operator==(const point& i_T) const
    {
        return fabs(x - i_T.x) < eps && fabs(y - i_T.y) < eps;
    }
    point operator/(double u) const
    {
        return point(x / u, y / u);
    }
    point operator+(const point& i_T)
    {
        return point(x + i_T.x, y + i_T.y);
    }
    point operator-(const point& i_T)
    {
        return point(x - i_T.x, y - i_T.y);
    }
    friend bool operator<(point a, point b)
    {
        return fabs(a.y - b.y) < eps ? a.x < b.x : a.y < b.y;
    }
    void atn2()
    {
        poe = atan2(y, x);
    }
    friend ostream& operator<<(ostream& out, point& a)
    {
        //cout << a.x << ' ' << a.y;
        printf("%.8f %.8f", a.x, a.y);
        return out;
    }
    friend istream& operator>>(istream& in, point& a)
    {
        scanf("%lf%lf", &a.x, &a.y);
        return in;
    }
};
typedef struct Line Segment; //线段Segment
struct Line { //直线
    point a, b;
    double poe;
    Line(point _a = point(), point _b = point())
        : a(_a)
        , b(_b)
    {
    }
    double len()
    {
        return (a - b).len();
    }
    friend istream& operator>>(istream& in, Line& a)
    {
        cin >> a.a >> a.b;
        return in;
    }
    friend ostream& operator<<(ostream& out, Line& a)
    {
        out << a.a << ' ' << a.b;
        return out;
    }
    void atn2()
    {
        poe = atan2(b.y - a.y, b.x - a.x);
    }
};
bool xiangjiao(Segment l1, Segment l2)
{
    point a = l1.a, b = l1.b, c = l2.a, d = l2.b;
    if (!(min(a.x, b.x) <= max(c.x, d.x) && min(c.y, d.y) <= max(a.y, b.y) && min(c.x, d.x) <= max(a.x, b.x) && min(a.y, b.y) <= max(c.y, d.y)))
        return 0;
    double u, v, w, z;
    u = (c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y);
    v = (d.x - a.x) * (b.y - a.y) - (b.x - a.x) * (d.y - a.y);
    w = (a.x - c.x) * (d.y - c.y) - (d.x - c.x) * (a.y - c.y);
    z = (b.x - c.x) * (d.y - c.y) - (d.x - c.x) * (b.y - c.y);
    return (u * v <= eps && w * z <= eps);
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        point p1, p2, p3, p4;
        cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> p4.x >> p4.y;
        vec A = p2 - p1, B = p4 - p3;
        if (xiangjiao(Segment(p1, p2), Segment(p3, p4)))
            cout << 1 << endl;
        else {
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3224
#include<stdio.h>

int main(){
  long int n,k;
  char buff[1000];

  if(fgets(buff,sizeof(buff),stdin)!=NULL){
    sscanf(buff,"%ld%ld",&n,&k);
  }

  n = n % k;
  if(k-n >= n){
    printf("%ld",n);
    return 0;
  }else{
    printf("%ld",k-n);
    return 0;
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[100];
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=n-1; i>=0; i--){
        cout << a[i];
        if(i!=0) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include<iostream>
using namespace std;
const int MAXV = 100005; //素数表范围
int main()
{
    long long  a,b;
    while(~scanf("%lld%lld",&a,&b))
    {
        if(a<=b)
            printf("0\n");
        else printf("%lld\n",a-b);
    }
    return 0;
}


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

struct Query {int l, r, x;};

using I = long long;
const I MOD = 1e9 + 7;

I dp[301][301][301];

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<Query>> Q(N+1);
  for(auto i=0; i<M; ++i) {
    Query q;
    cin >> q.l >> q.r >> q.x;
    Q[q.r].emplace_back(q);
  }

  auto ok = [&](vector<int> v) {
    sort(begin(v), end(v));
    for(auto q: Q[v.back()]) {
      if(q.x==1) if(!(v[1]<q.l))               return false;
      if(q.x==2) if(!(v[0]<q.l && q.l<=v[1]))  return false;
      if(q.x==3) if(!(q.l<=v[0]))              return false;
    }
    return true;
  };

  dp[0][0][0] = 1;
  for(auto r=0; r<N; ++r) for(auto g=0; g<N; ++g) for(auto b=0; b<N; ++b) if(ok({r, g, b})) {
    auto k = max({r, g, b}) + 1;
    (dp[k][g][b] += dp[r][g][b]) %= MOD;
    (dp[r][k][b] += dp[r][g][b]) %= MOD;
    (dp[r][g][k] += dp[r][g][b]) %= MOD;
  }

  I res = 0;
  for(auto i=0; i<N; ++i) for(auto j=0; j<N; ++j) if(ok({N, i, j})) (res += dp[N][i][j] + dp[i][N][j] + dp[i][j][N]) %= MOD;
  cout << res << endl;
}


Measured memory_bytes: 213376
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			line = reader.readLine();
			char s[] = line.toCharArray();
			
			int ans = 0;

			for(int i = 0; i < (n-2); i++){
				if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
					ans ++;
				}
			}
			System.out.println(ans);
		} catch(IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e){
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
ll MOD=1e9+7;

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%13;
        a=a*a%13;
        x>>=1;
    }
    return res;
}

int main(){
    string s;cin>>s;
    int n=(int)s.size();
    vector<vector<ll> > dp(n+1,vector<ll>(13,0));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            if(s[i]=='?'){
                for(int k=0;k<10;k++){
                    dp[i+1][(j*10+k)%13]+=dp[i][j];
                    dp[i+1][(j*10+k)%13]%=MOD;
                }
            }else{
                int k=(int)(s[i]-'0');
                dp[i+1][(j*10+k)%13]+=dp[i][j];
                dp[i+1][(j*10+k)%13]%=MOD;
            }
        }
    }
    cout<<dp[n][5]<<endl;
    return 0;
}

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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> x(n, k-q);
    rep(i,q){
        int a;
        cin >> a;
        --a;
        x[a]++;
    }
    rep(i,n) {
        if(x[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
	int n,a[]={0,5,3,3,3,3,3,4,3,4};
	char*p,*q,s[1028],*t[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	scanf("%d",&n);
	while(n--)
	{
		memset(s,0,1028);
		scanf("%s",s);
		for(p=s;*p;)
		{
			q=strpbrk(p,"0\0");
			if(*p-'0')putchar(t[*p-'0'][(q-p-1)%a[*p-'0']]);
			p=q+1;
		}
		puts("");
	}
	return 0;
}

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

class line
{
public:
    long long a;
    long long b;

    line()
    {
        ;
    }

    line(long long A, long long B)
    {
        a = A;
        b = B;
    }

    long long eval(long long x)
    {
        return a*x + b;
    }
};

vector<line> L;

void insert(line k)
{
    if(L.size() <= 1)
    {
        L.push_back(k);
        return;
    }
    line l1 = L[L.size()-2];
    line l2 = L[L.size()-1];
    long long lhs, rhs;
    int b1, b2, b3, b4;
    b1 = (l2.b > l2.b) ? 1 : -1;
    b2 = (k.a > l2.a) ? 1 : -1;
    b3 = (l2.b > k.b) ? 1 : -1;
    b4 = (l2.a > l2.a) ? 1 : -1;
    lhs = (l2.b - l1.b)*(k.a - l2.a) > 0 ? (l2.b - l1.b)*(k.a - l2.a) : -1*(l2.b - l1.b)*(k.a - l2.a);
    rhs = (l2.b - k.b)*(l1.a - l2.a) > 0 ? (l2.b - k.b)*(l1.a - l2.a) : -1*(l2.b - k.b)*(l1.a - l2.a);

    bool bad;
    if(b1*b2 == 1 && b3*b4 == 1) bad = lhs > rhs;
    if(b1*b2 == 1 && b3*b4 == -1) bad = 1;
    if(b1*b2 == -1 && b3*b4 == 1) bad = 0;
    if(b1*b2 == -1 && b3*b4 == -1) bad = lhs < rhs;

    //if((l2.b - l1.b)*(k.a - l2.a) > (l2.b - k.b)*(l1.a - l2.a))
    if(bad)
    {
        L.pop_back();
        insert(k);
    }
    else L.push_back(k);
}

long long b_search(long long x, long long a, long long b)
{
    if(a == b) return L[a].eval(x);
    long long m = (a+b)/2;
    if((L[m+1].b - L[m].b) < x*(L[m].a - L[m+1].a)) return b_search(x, m+1, b);
    else return b_search(x, a, m);
}

int main()
{
    long long N, C;
    cin >> N >> C;

    long long h[N+1];
    for(long long i = 1; i <= N; i++) cin >> h[i];

    long long DP[N+1];
    DP[1] = 0;
    insert(line(-2*h[1], h[1]*h[1]));
    for(long long i = 2; i <= N; i++)
    {
        DP[i] = C + h[i]*h[i] + b_search(h[i], 0, L.size()-1);
        insert(line(-2*h[i], DP[i] + h[i]*h[i]));
    }
    cout << DP[N] << '\n';
    return 0;

    //DP[1] = 0;
    //DP[i] = C + h[i]^2 + min{1 <= j < i; (-2*h[j])*h[i] + (DP[j] + h[j]^2)}
}

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);

#define F first
#define S second
#define pb push_back
#define int long long
#define maxn 200000
#define mod 1000000007
#define inf 1000000000000000000

#define fr(i,a,b) for(int i=a;i<b;i++)
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
#define all(x) begin(x), end(x)
#define PII pair<int, int>
#define VI vector<int>
#define VII vector<PII>

using namespace std;

int dp[maxn], n, k, a[101];
signed main()
{
    
    FLASH

    cin>>n>>k;
    fr(i, 1, n + 1){
        cin>>a[i];
    }
    dp[0] = 0;

    fr(i, 1, k + 1){
        vector<bool> b(200);
        fr(j, 1, n + 1){
            if(i - a[j] >= 0){
                b[dp[i - a[j]]] = 1;
            }
        }
        
        fr(j, 0, 200) if(!b[j]){
            dp[i] = j;
            break;
        }
    }

    if(dp[k]) cout<<"First\n";
    else cout<<"Second\n";
}

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

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

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

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

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

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b);
}

Measured memory_bytes: 256
// Solution by ** Abhishek Mittal **
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 1000000007
#define ll long long
#define vll vector<long long>  

#define all(c) c.begin(), c.end()

// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())

// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;



int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO

    ll x, k, d;
    cin>>x>>k>>d;

    x = abs(x);
    ll t = x/d;
    if(t >= k)cout<<abs(x - d*k);
    else{
        k-= t;
        x = x%d;
        
        if(k%2 == 0)cout<<x<<endl;
        else cout<<abs(x-d)<<endl;
        
    }

    return 0;

}

Measured memory_bytes: 3180
import java.util.*;
import static java.lang.Integer.parseInt;
class Main{
	static			Scanner		s		= new Scanner(System.in);

	static	final	String		divide	= "####################";
	static			int[][][]	h		= new int[4][3][10];

	public static void main(String[] args){
		s.next();
		while (s.hasNext()) {
			h[parseInt(s.next())-1][parseInt(s.next())-1][parseInt(s.next())-1]+=parseInt(s.next());
		}
		output();
	}
	static void output() {
		for(int j=0;j<h.length;j++) {
			int[][] hh = h[j];
			for (int[] hhh : hh) {
				for (int hhhh:hhh) {
					System.out.printf(" %d",hhhh);
				}
				System.out.println();
			}
			if(j!=3)
			System.out.println(divide);
		}
	}
}

Measured memory_bytes: 29840