akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    repi(i,1,b+1){
        if((a*i)%b==c){
            cout<<"YES"; return 0;
        }
    }
    cout<<"NO";
}

Measured memory_bytes: 3628
def main():
    class unionfind():
        #size:要素数,tree：unionfind木
        def __init__(self,size):#self,要素数
            self.size=size
            self.tree=[i for i in range(self.size)]#root,depth
        
        #rootを探す
        def root(self,index):
            temp_list=[]
            temp=self.tree[index]
            while index!=temp:
                temp_list.append(index)
                index=temp
                temp=self.tree[index]
            for i in temp_list:
                self.tree[i]=index
            return index
        
        #結合
        def unite_r(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            if r1<r2:
                self.tree[r1]=r2
            else:
                self.tree[r2]=r1

        def unite_l(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            if r1>r2:
                self.tree[r1]=r2
            else:
                self.tree[r2]=r1

        #同じか判定
        def same(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            return r1==r2
    
    
    n=int(input())
    a=list(map(int,input().split()))
    d=[0]*n
    for i,j in enumerate(a):
        d[j-1]=i+2
    vis=[False]*(n+4)
    u_r=unionfind(n+4)
    u_l=unionfind(n+4)
    ans=0
    #print(d)
    for j,i in enumerate(d[:-1]):
        vis[i]=True
        if vis[i+1]==True:
            u_r.unite_r(i,i+1)
            u_l.unite_l(i,i+1)
            k1=u_r.root(i+1)+1
        else:
            k1=i+1
        if vis[k1+1]==True:
            cnt1=u_r.root(k1+1)+1
        else:
            cnt1=k1+1
        cnt1=min(cnt1,n+2)
        if vis[i-1]==True:
            u_r.unite_r(i,i-1)
            u_l.unite_l(i,i-1)
            k2=u_l.root(i-1)-1
        else:
            k2=i-1
        if vis[k2-1]==True:
            cnt2=u_l.root(k2-1)-1
        else:
            cnt2=k2-1
        cnt2=max(cnt2,1)
        ans+=((k2-cnt2)*(k1-i)+(cnt1-k1)*(i-k2))*(j+1)
        #print(cnt2,k2,i-2,k1,cnt1)
    print(ans)
main()


Measured memory_bytes: 118508
#include<iostream>

int main(){
  int w,h,x,y,r;
  std::cin >> w >> h >> x >> y >> r;

  if(y + r > h || x + r > w || x - r < 0 || y - r < 0)
    std::cout << "No" << std::endl;
  else
    std::cout << "Yes" << std::endl;
  return 0;
}

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

int main()
{
    int n, y; cin >> n >> y;
    int a = 0, b = 0, c = 0;
    
    y /= 1000;

    bool ok = true;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (i + j > n) continue;
            if (y == 10 * i + 5 * j + 1 * (n - i - j)) {
                a = i; b = j; c = n - i - j;
                ok = false;
            }
        }
    }

    if (ok) {
        cout << "-1 -1 -1" << endl;
        return 0;
    } else {
        cout << a << " " << b << " " << c << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
const int MAXK=100000;
int mulai[MAXK+5],awal[MAXK+5],akhir[MAXK+5],simulasi[MAXK+5],posbalik[MAXK+5],totalbalik,totalgram,q;
int gradien(int indeks){
	return (indeks&1)?1:-1;
}
int perbaikigram(int gram){
	gram=max(0,gram);
	gram=min(totalgram,gram);
	return gram;
}
void simulasikan(int awal){			//simpan hasil simulasinya di array simulasi
	simulasi[0]=awal;
	for(int i=1;i<=totalbalik;i++)
		simulasi[i]=perbaikigram(simulasi[i-1]+gradien(i-1)*(posbalik[i]-posbalik[i-1]));
}
void hitungawal(){
	simulasikan(0);
	for(int i=0;i<=totalbalik;i++)
		awal[i]=simulasi[i];
}
void hitungakhir(){
	simulasikan(totalgram);
	for(int i=0;i<=totalbalik;i++)
		akhir[i]=simulasi[i];
}
void hitungmulai(){			//mirip simulasi
	simulasi[0]=0;
	mulai[0]=0;
	for(int i=1;i<=totalbalik;i++)
	{
		simulasi[i]=simulasi[i-1]+gradien(i-1)*(posbalik[i]-posbalik[i-1]);
		mulai[i]=mulai[i-1];
		if(simulasi[i]<0)
			mulai[i]+=abs(simulasi[i]);
		simulasi[i]=perbaikigram(simulasi[i]);
	}
}
int binser(int waktu){			//return waktu terdekat di sebelah kirinya
	int bawah=1,atas=totalbalik,mid;
	while(bawah<=atas)
	{
		mid=(bawah+atas)>>1;
		if(posbalik[mid]>=waktu)
			atas=mid-1;
		else
			bawah=mid+1;
	}
	if(bawah>totalbalik||posbalik[bawah]>waktu)
		return atas;
	return bawah;
}
int main()
{
	scan(totalgram,totalbalik);
	posbalik[0]=0;
	for(int i=1;i<=totalbalik;i++)
		scan(posbalik[i]);
	hitungawal();
	hitungakhir();
	hitungmulai();
	scan(q);
	for(int i=1;i<=q;i++)
	{
		int waktu,gramawal;
		scan(waktu,gramawal);
		int terdekat=binser(waktu);
		int ans=(gramawal<=mulai[terdekat])?awal[terdekat]:(min(akhir[terdekat],awal[terdekat]+gramawal-mulai[terdekat]));
		ans=perbaikigram(ans+(gradien(terdekat))*(waktu-posbalik[terdekat]));
		printf("%d\n",ans);
	}
}

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


int main(){
	string ppp;cin>>ppp;
	int a=ppp[0]-'0',b=ppp[1]-'0',c=ppp[2]-'0',d=ppp[3]-'0';
	int s1=a,s2=b,s3=c,s4=d;
	int op1,op2,op3;
	char x,y,z;
	for(int i=0;i<2;i++)
	for(int j=0;j<2;j++)
	for(int k=0;k<2;k++){
		a=s1;b=s2;c=s3;d=s4;
		
		if(i==0) a+=b;else a-=b;
		if(j==0) a+=c;else a-=c;
		if(k==0) a+=d;else a-=d;
		if(a==7) {
			op1=i;op2=j;op3=k;
			break;
		}
	}
	if(op1==0) x='+';else x='-';
	if(op2==0) y='+';else y='-';
	if(op3==0) z='+';else z='-';
	cout<<s1<<x<<s2<<y<<s3<<z<<s4<<'='<<7<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
       char s[11];

       scanf("%s", s );

       if( s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I' )
              puts("Yes");
       else
              puts("No");


       return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	ll a;
	float b;
	cin >> a >> b;
	int n = b * 100 + 0.5;
	ll ans = (a * n) / 100;
	cout << ans << endl;
}

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

	solve();
}


Measured memory_bytes: 3744
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

ll K,S,ans;

int main(){
    cin>>K>>S;
    rep(i,K+1){
        rep(j,K+1){
            if(S-i-j>=0&&S-i-j<=K)ans++;
        }
    }
    out(ans);

    
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,s;
    char c;

        scanf("%d %c %d",&a,&c,&b);
        if(c=='+'){
            s=a+b;
            printf("%d\n",s);
        }
        else if(c=='-'){
            s=a-b;
            printf("%d\n",s);
        }


    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 1;

	if(b != a) cnt++;
	if(c != a && c != b) cnt++;

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = (int)sc.nextLong();
		char[] cset = s.toCharArray();
		for(int i = 0; i < cset.length; i++) {
			if(cset[i] != '1') {
				System.out.println(cset[i]);
				return;
			}
			if(i == k - 1) {
				System.out.println("1");
				return;
			}
		}
	}
}


Measured memory_bytes: 23764
n = int(input())

a = []
for _ in range(2):
  a.append(list(map(int, input().split())))

ans = 0
for i in range(n):
  upper_ = sum(a[0][:i+1])
  lower_ = sum(a[1][i:])
  ans = (upper_ + lower_ if ans < upper_ + lower_ else ans)
  
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, char const *argv[])
{
  double a, b, c, d, e, f;
  double x, y;

  while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
    y = (c * d - a * f) / (b * d - e * a);
    x = (c - (b * y)) / a;

    printf("%.3lf %.3lf\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans = 0;
	for (int i = 0; i <= 100; i++)
	{
		if (A<=i&&i<=B&& C <= i && i <= D)
		{
			ans++;
		}
	}
    if(ans!=0)
     	ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    int k=s.length();
    int cnt=0;
    for(int i=0;i<k;i++)
    {
        if(s[i]!=t[i])
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int dp[10010];

int solver(int x){
	if(dp[x]!=-1)return dp[x];
	vector<int> a;
	for(int i=0;i<4;i++){
		a.push_back(x%10);
		x/=10;
	}
	sort(a.begin(),a.end());

	int L=0,S=0;
	for(int i=3;i>=0;i--){
		L*=10;
		L+=a[i];
	}
	for(int i=0;i<4;i++){
		S*=10;
		S+=a[i];
	}

	return dp[x]=solver(L-S)+1;
}
		
int main(){
	for(int i=0;i<10010;i++)dp[i]=-1;
	dp[6174]=0;
	int N;
	while(1){
		cin>>N;
		if(N==0)break;

		bool c=true;

		for(int i=1;i<=9;i++){
			if(N==1111*i){printf("NA\n"); c=false; }
		}

		if(c)printf("%d\n",solver(N));
	}
}

Measured memory_bytes: 1240
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;
int n;
vector<int> que[200];
map<int,P> dex;

int getEmptyArea(){
  for(int i=1;i<=n;i++){
    if(que[i].size() == 0)return i;
  }
  assert(false);
}

int main(){
 

  while(true){
    cin >> n;
    
    if(n == 0)break;

    dex.clear();
    que[0].clear();
    for(int i=1;i<=n;i++){
      que[i].clear();
      que[i].pb(i);
      dex[i] = P(i,0); //P(テ・ツ?エテヲツ可?テァツ閉ェテ・ツ慊ー)
    }


    while(true){//
      int I,J;
      cin >> I >> J;
      
      if(I+J == 0)break;
      if(que[dex[I].F].size() == 0)continue;//テ」ツ?ィテ」ツつ凝」ツつづ」ツ?ョテ」ツ?古」ツ?ェテ」ツ??
      if(dex[I].S == 0 && J == 0)continue;
      if(dex[I].F == dex[J].F && dex[I].S >= dex[J].S)continue;//テァツスツョテ」ツ?湘・ツ?エテヲツ可?」ツ?古、ツクツ凝」ツ?ォテ」ツ?づ」ツつ?
      
      int pos = que[dex[I].F].size()-1;

      while(que[dex[I].F][pos] != I){
	int emp = getEmptyArea(),val =que[dex[I].F][pos];
	que[dex[I].F].pop_back();
	que[emp].pb(val);
	dex[val] = P(emp,0);
	pos--;
	assert(pos >= -1);
      }

      assert(I == que[dex[I].F][pos]);
      que[dex[I].F].pop_back();
      int emp = getEmptyArea();
      J==0?que[emp].pb(I):que[dex[J].F].pb(I);
      J==0?dex[I] = P(emp,0):dex[I] = P(dex[J].F,que[J].size()-1);
   

    }//
    vector<int> stac;
    for(int i=1;i<=n;i++){
      if(que[i].size() == 0)continue;
      stac.pb(que[i].size());
    }
    sort(all(stac));
    rep(i,stac.size()){
      cout << stac[i] << endl;
    }
    cout << "end" << endl;

  }
return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s,t,jwb="";
ll dp[5000][5000];
ll f(ll n, ll m){
	if (n<0 || m<0) return 0;
	if(dp[n][m]!=-1)return dp[n][m];
	if (s[n]==t[m]){
		dp[n][m]=f(n-1,m-1)+1;
	}
	else{
		dp[n][m]=max(f(n-1,m),f(n,m-1));
	}
	return dp[n][m];
}
void rec(ll n, ll m){
	if(n<0 || m<0)return;
	if (s[n]==t[m]){
		jwb+=s[n];
		rec(n-1,m-1);
	}
	else{
		if(f(n-1,m)>=f(n,m-1))rec(n-1,m);
		else rec(n,m-1);
	}
}
int main(){
	cin >> s >> t;
	memset(dp,-1,sizeof dp);
	rec(s.size()-1, t.size()-1);
	reverse(jwb.begin(),jwb.end());
	cout << jwb << endl;
}//a

Measured memory_bytes: 195712
#include<stdio.h>

int main(){

int N;
scanf("%d",&N);
int A,B,C,D;
A=N/1000;
B=(N/100)%10;
C=(N/10)%10;
D=N%10;
int op[3];
char OP[3];
int i=0;
while(i<8){
		op[0]=i/4;
		op[1]=(i/2)%2;
		op[2]=i%2;
		for(int j=0;j<3;j++){
			op[j]=op[j]*2-1;
			if(op[j]==1){
				OP[j]='+';
			}else{
				OP[j]='-';
			}
		}
		if((A+op[0]*B+op[1]*C+op[2]*D)==7){
			printf("%d%c%d%c%d%c%d=7\n",A,OP[0],B,OP[1],C,OP[2],D);
			i=8;
		}
		i++;
}	
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 505;

int ans[MN*MN];
ii x[MN];

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N; cin >> N;
    set<int> S;
    for (int i = 0; i < N*N; ++i) S.insert(i);
    for (int i = 0; i < N; ++i) {
        cin >> x[i].f;
        S.erase(--x[i].f), ans[x[i].f] = x[i].s = i;
    }
    sort(x, x+N);
    for (int i = 0; i < N; ++i) {
        int j = 0;
        while (S.size() && *begin(S) < x[i].f && j < x[i].s)
            ans[*begin(S)] = x[i].s, S.erase(begin(S)), ++j;
        if (j < x[i].s) {
            cout << "No";
            return 0;
        }
    }
    for (int i = 0; i < N; ++i) {
        int j = 0;
        auto it = S.upper_bound(x[i].f);
        while (it != end(S) && j < N-x[i].s-1)
            ans[*it] = x[i].s, it = S.erase(it), ++j;
        if (j < N-x[i].s-1) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    for (int i = 0; i < N*N; ++i) cout << ans[i]+1 << ' ';
}

Measured memory_bytes: 16356
n = int(input())
s = []
t = []
for i in range(n):
    ss,tt = map(str,input().split())
    s.append(ss)
    t.append(int(tt))
x = input()
flag = False
ans = 0
for i in range(n):
    if flag:
        ans += t[i]
    if x == s[i]:
        flag = True
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a%c==0)d=a/c;else d=a/c+1;e=b/c;
    printf("%lld",e-d+1);
    return 0;
}

Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C++ (GCC 9.2.1)
*/

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

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod int(1e9+7)

// fact(n)
template <typename T>
T fact(T n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// nCr(n, r)
template <typename T>
T nCr(T n, T r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (nCr(n - 1, r - 1) + nCr(n - 1, r));
}

// swap(&a, &b);
template <typename T>
void swap(T *a, T *b){
	T tmp;
	tmp = *a;	*a = *b;	*b = tmp;
	return;
}

// gcd(a, b)
template <typename T>
T gcd(T a,T b){
	if(a == 0) return b;
	else if(b == 0) return a;
	else return gcd(b,a % b);
}

// lcm(a, b)
template <typename T>
T lcm(T a,T b){
	return a / gcd(a,b) * b;
}

// divisor(type n)
template <typename T>
vector<T> divisor(T n)
{
  vector<T> ret;
  for(T i = 1; i * i <= n; i++)
	{
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

// eratosthenes(type n)
template <typename T>
vector<T> eratosthenes(T n){
	vector<bool> is_prime(n + 2, true);
	vector<T> primes;

	for (T i = 2; i <= n; i++)
	{
		if(is_prime[i]){
			for (T j = 2 * i; j <= n; j += i)	is_prime[j] = false;
			primes.push_back(i);
		}
	}
	return primes;
}

// vector scanner
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
	for(T& x : vec)	is >> x;
	return is;
}

int main(int argc, char const *argv[])
{
	// DON'T CHANGE
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	// here
	int sum = 0;
	string s;
	cin >> s;
	for(char ch : s){
		sum += (ch - '0');
	}
	OUT(sum % 9 == 0 ? "Yes" : "No") BR;
	RET;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <string>

std::vector<int> A;
std::vector<int> dA;
int K, N;
int max_dA;

int main() {
  std::cin >> K >> N;
  A.assign(N, 0);
  dA.assign(N, 0);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    if (i == N-1) {
      dA[N-1] = K + A[0] - A [i];
    } else {
      dA[i] = A[i+1] - A[i];
    }
  }
  std::cout << K - *std::max_element(dA.begin(), dA.end()) << std::endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	REP(i, N) { cin >> p[i]; }
	SORT(p);
	int res = 0;
	REP(i, K) { res += p[i]; }
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3652
//@author yash
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	fast();
	int a,b;
	cin>>a>>b;
	int x=1;
	while(1)
	{
		int x1=(x*8)/100;
		int y1=(x*10)/100;
		if(x1==a&&y1==b)
		{
			cout<<x<<endl;
			break;
		}
		else
		x++;
		if(x>1500)
		{
			cout<<"-1"<<endl;
			break;
		}
	}	
}



Measured memory_bytes: 256
from collections import deque

n = int(input())
gr = { i:[] for i in range(1, n + 1)}
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    gr[a].append((b, c))
    gr[b].append((a, c))
q, k = map(int, input().split())
dmax = 10**14 + 1
dist = [dmax for _ in range(n + 1)]
dist[k] = 0
ls = deque([k])
while 0 < len(ls):
    u = ls[0]
    for v, c in gr[u]:
        if dist[v] == dmax:
            dist[v] = dist[u] + c
            ls.append(v)
    ls.popleft()

for _ in range(q):
    x, y = map(int, input().split())
    print(dist[x] + dist[y])

Measured memory_bytes: 88208
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    vector<ll> b(n, 0);
    vector<ll> c(n, 0);
    for (ll i = 0; i < n; i++)
    {
        for (ll t = i + 1; t < n; t++)
        {
            if (a[i] > a[t])
            {
                b[i]++;
            }
        }
        
        for (ll t = 0; t < n; t++)
        {
            if (a[i] > a[t])
            {
                if (i != t)
                {
                    c[i]++;
                }
            }
        }
        ans += b[i] * k;
        ans %= 1000000007;
        ans += c[i] * (k * (k - 1) / 2 % 1000000007);
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		System.out.println(A + B >= C ? "Yes" : "No");
	}
}


Measured memory_bytes: 21716
#include <iostream>
int main(){
    int N;
    scanf("%d",&N);

    float A[N];
    for(int i=0; i<N; i++){
        scanf("%f", &A[i]);
    }

    float sum1 = 0;
    for(int i=0; i<N; i++){
        sum1 += 1/A[i];
    }

    printf("%f", 1/sum1);

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define PI  3.141592653589

int main(void) {
	double r;
	scanf("%lf", &r);
	printf("%0.8lf %.8lf\n", r*r*PI, 2*r*PI);
	return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
#define fri(i,n) for(int i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define ol(v) v.begin(),v.end()
#define forc(v) for(auto it:v)
#define se second
#define fi first
#define pb push_back
#define pf push_front
#define MX 1e18
#define MN -MX

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

template <typename T> istream&operator>>(istream &inp, vector<T> &vec){
	fri(i,vec.size()) inp>>vec[i];
	return inp;
}

template <typename T> ostream&operator<<(ostream &oup, vector<T> vec){
	forc(vec) oup<<it<<" ";
	oup<<"\n";
	return oup;
}

bool check(string s){
	int n = s.length();
	if(n&1) return 0;
	else if(s.substr(0, n/2) == s.substr(n/2, n/2)) return 1;
	else return 0;
}

int main(){
	ios::sync_with_stdio(false);
	#ifdef DBG
		freopen("in", "r", stdin);
	#endif
	string s;
	cin>>s;
	int n = s.length();
	fr(i, 1, n-1){
		if(check(s.substr(0, n-i))) {cout<<n-i<<"\n";return 0;}
	}
	
	return 0;
}

Measured memory_bytes: 256
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
#define mod  100007
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline ll add(ll a, ll b) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bpw(ll a, ll p){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

ll ar[1<<17], br[1<<17], cr[1<<17];

int main(){
	ll n; read(n);
	FER(i, 0, n) read(ar[i]), ar[i]--;
	FER(i, 0, n) read(br[i]);
	FER(i, 0, n-1) read(cr[i]);
	ll ans = 0;
	FER(i, 0, n){
		ans += br[i];
		if(i < n-1 and  ar[i] + 1 == ar[i+1]){
			ans += cr[ar[i]];
		}
	}	
	cout<<ans<<"\n";
	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll n,m;

    Scll2(n,m);

    ll ans = 0;

    if( m/2 <= n ){
        ans = m/2;
    }else{
        ans += n;
        m -= n * 2;
        ans += m / 4;
    }

    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, T): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (A, B): (Vec<usize>, Vec<usize>) = {
        let (mut A, mut B) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B)
    };

    let I = {
        let mut I = (0..N).collect::<Vec<_>>();
        I.sort_by_key(|&i| A[i]);
        I
    };

    let M = T + 3000;
    // let M = T + 30;
    let mut dp = vec![0; M + 1];
    for &i in &I {
        for k in (A[i]..(T + A[i])).rev() {
            dp[k] = std::cmp::max(dp[k], dp[k - A[i]] + B[i]);
        }
        // println!("{:?}", dp);
    }

    let ans = *dp.iter().max().unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){

    string s;
    cin >> s;
    int ans =0;
    //int n=s.length
    rep(i,s.length()/2){
        if(s[i]!=s[s.length()-1-i])
            {s[i]='o';ans++;}
    }
    cout << ans  << endl;
    return 0;

}

Measured memory_bytes: 3584
#include<stdio.h>

int  main(void){
 int a,b,c,r;

 scanf("%d %d %d",&a,&b,&c);
 if(a==b){
   if(b==c)
     r=1;
   else r=2;}
 else if(b==c){
      if(a==c) r=2;
      else if(b==c)  r=2;
      else   r=3;
      }
 else if(a==c) r=2;
 else          r=3;
 
 
 
 
printf("%d",r);
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int arr[maxn];
bool v[maxn];

pair < int , int > get(int m, int d){

    int tot=m+1;
    int val=m;
    int i=0;
    while(i<=val){
        if(abs(val-i)==d){
            return {i,val};
        }
        i++;
        val--;
    }
    return {-1, -1};
}

ll bigmod(ll a, ll b) {
    if(!b) return 1;
    ll mod = 1e9+7;

    ll x = bigmod(a, b>>1);
    x = (x * x) % mod;
    if(b & 1) x = (x * a) % mod;
    return x;
}

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

    int n;
    cin>> n;

    f0(i,n){
        cin >> arr[i];
    }

    int m=n-1;
    int start=1;
    bool ok=1;
    f0(i,n){
        pair < int , int > a;
        a= get(m,arr[i]);

        int f=a.ff;
        int e=a.ss;

        if(f==-1 && e==-1){
            ok=0;
            break;
        }
        if(!v[f]){
            v[f]=start;
        }else if(!v[e]) {
            v[e]=start;
        }else {
            ok =0;
            break;
        }
    }

    if(!ok){
        cout <<"0"<< endl;
    }else {
        int cnt=0;
        int a[n+1]={0};
        f0(i,n){
            a[arr[i]]++;
        }

        for(int i=0 ; i<=n ; i++){
            if(a[i]==2) cnt++;
        }

        //cout << pow(2,cnt) << endl;

        cout << bigmod(2, cnt) << endl;

    }

    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
using ll = long long;
using ld = long double;

int const nmax = 200000;
int target[1 + nmax], v[1 + nmax];

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

  int n;
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> target[i];
  for(int i = 0;i < n; i++)
    cin >> v[i];
  queue<int> q;
  for(int i = 0;i < n; i++)
    q.push(i);
  ll result = 0;
  while(0 < q.size()){
    int pos = q.front();
    q.pop();
    if(v[pos] < v[(pos + n - 1) % n] || v[pos] < v[(pos + 1) % n])
      continue;
    if(v[pos] <= target[pos])
      continue;

    int stop = max(target[pos], max(v[(pos + 1) % n], v[(pos + (n - 1)) % n]));
    int jumps = (v[pos] - stop) / (v[(pos + 1) % n] + v[(pos + (n - 1)) % n]);
    jumps = max(jumps, 1);
    if(0 < jumps){
      v[pos] -= jumps * (v[(pos + 1) % n] + v[(pos + (n - 1)) % n]);
      q.push((pos + 1) % n);
      q.push((pos + n - 1) % n);
      q.push(pos);
      result += jumps;
    }
    if(v[pos] < target[pos])
      break;
  }
  for(int i = 0;i < n; i++)
    if(v[i] != target[i]) {
      cout << -1;
      return 0;
    }
  cout << result;
  return 0;
}


Measured memory_bytes: 3200
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

hasuu = N % 1000
if hasuu==0:
    print(0)
else:
    print(1000-hasuu)


Measured memory_bytes: 27108
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int dp[n+1];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<n-1;i++){
    dp[i+1]=max(dp[i+1],dp[i]);
    if(s[i-1]!='1'||s[i]!='0'||s[i+1]!='1') continue;
    for(int k=1;k<=i&&s[i-k]=='1';k++)
      dp[i+2]=max(dp[i+2],dp[i-k]+k);
    for(int k=1;i+k<n&&s[i+k]=='1';k++)
      dp[i+k+1]=max(dp[i+k+1],dp[i-1]+k);
  }
  cout<<*max_element(dp,dp+n+1)<<endl;
  return 0;
}


Measured memory_bytes: 2820
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct edge{
  int to, cost;
};

vector<edge> G[100000];

pair<int, int> maxdist(int v, int st){
  int i, j, infty = 2020002000;
  int d[v];
  queue<int> Q; Q.push(st);
  rep(i, v)d[i] = infty;
  d[st] = 0;
  pair<int, int> res = mp(st, 0);
  for(;!Q.empty();){
    int now = Q.front();
    Q.pop();
    rep(i, G[now].size()){
      if(d[G[now][i].to] == infty && d[G[now][i].to] > d[now] + G[now][i].cost){
        d[G[now][i].to] = d[now] + G[now][i].cost;
        Q.push(G[now][i].to);
        if(res.second < d[G[now][i].to])res = mp(G[now][i].to, d[G[now][i].to]);
      }
    }
  }

  return res;
}

int diameter(int v){
  int i, j, res = 0;
  pair<int, int> l = maxdist(v, 0);
  pair<int, int> r = maxdist(v, l.first);
  return r.second;
}

signed main(void){
  int i, j;
  int(n);
  rep(i, n - 1){
    int3(s, t, w);
    G[s].pb((edge){t, w});
    G[t].pb((edge){s, w});
  }
  pri(diameter(n));

  return 0;
}

Measured memory_bytes: 8000
n,m = map(int,input().split())
l = []
for i in range(n):
    l.append(list(map(int,input().split())))
    del l[i][0]
l2 = []
for i in range(n):
    for j in l[i]:
        l2.append(j)
ans = 0
for i in range(m+1):
    if l2.count(i) == n:
         ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int my_abs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> C(Q);
    vector<long long> point(N);
    for (int i = 0; i < N; i++) {
        point.at(i) = K;
    }
    for (int j = 0; j < Q; j++) {
        cin >> C.at(j);
    }
    long long border = Q + 1;
    for (int k = 0; k < Q; k++) {
        point.at(C.at(k)-1)++;
    }
    for (int l = 0; l < N; l++) {
        if (point.at(l) >= border) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double PI = acos(-1.0);

int main()
{
    for(;;){
        vector<double> area(2, 0.0);
        for(int i=0; i<2; ++i){
            int n;
            cin >> n;
            if(n == 0)
                return 0;

            int rest = 360;
            while(--n > 0){
                int a;
                cin >> a;
                area[i] += sin(a/180.0*PI);
                rest -= a;
            }
            area[i] += sin(rest/180.0*PI);
        }

        if(area[0] > area[1])
            cout << '1' << endl;
        else if(area[0] < area[1])
            cout << '2' << endl;
        else
            cout << '0' << endl;
    }
}

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

int main() {
    int N;
    cin >> N;
    int X[N];
    int m = 0;
    rep(i, N) {
        int x;
        cin >> x;
        m = max(m, x);
        X[i] = x;
    }
    int Ans = 1000000;
    rep(i, m+1) {
        int sum = 0;
        rep(j, N) {
            sum += (X[j]-i) * (X[j]-i);
        }
        Ans = min(Ans, sum);
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int result = 0;
            int N = Convert.ToInt32(Console.ReadLine());
            int[] a = new int[N];
            a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            for(int i = 0; i < N; i++)
            {
                if (a[i] % 2 == 1 && (i+1) % 2 == 1)
                    result++;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27680
#include<bits/stdc++.h>
using namespace std;
int a[1010];
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=0; i<n; i++) scanf("%d",&a[i]);
	if(prev_permutation(a, a+n))
	{
		for(i=0; i<n; i++)
		{
			if(i == n-1) printf("%d\n",a[i]);
			else printf("%d ",a[i]);
		}
	}
	next_permutation(a, a+n);
	for(i=0; i<n; i++)
	{
		if(i == n-1) printf("%d\n",a[i]);
		else printf("%d ",a[i]);
	}
	if(next_permutation(a, a+n))
	{
		for(i=0; i<n; i++)
		{
			if(i == n-1) printf("%d\n",a[i]);
			else printf("%d ",a[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
double a, b, x;
int main(void)
{
	cin >> a >> b >> x;
	if (a * a * b - 2 * x > 0)
	{
		printf("%.6f", atan((a * b * b / 2 / x)) * 180 / 3.1415926535);
	}
	else
	{
		printf("%.6f", atan(2 * (a * a * b - x) / a / a / a) * 180 / 3.1415926535);
	}
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if 0 > self.parents[x]:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if 0 > x]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
	
N, M = MAP()
tree = UnionFind(N)

for _ in range(M):
	A, B = MAP()
	tree.union(A-1, B-1)

print(tree.group_count()-1)

Measured memory_bytes: 14296
#include <iostream>
using namespace std;
int main()
{
	int s, a, b, c, s1, s2, s3, s4;
	cin >> a >> s1;
	cin >> b >> s2;
	cin >> c >> s3;
	cin >> s >> s4;
	if (a == 1)
		cout << s1 * 6000 << endl;
	else if (a == 2)
		cout << s1 * 4000 << endl;
	else if (a == 3)
		cout << s1 * 3000 << endl;
	else if (a == 4)
		cout << s1 * 2000 << endl;

	if (b == 1)
		cout << s2 * 6000 << endl;
	else if (b == 2)
		cout << s2 * 4000 << endl;
	else if (b == 3)
		cout << s2 * 3000 << endl;
	else if (b == 4)
		cout << s2 * 2000 << endl;

	if (c == 1)
		cout << s3 * 6000 << endl;
	else if (c == 2)
		cout << s3 * 4000 << endl;
	else if (c == 3)
		cout << s3 * 3000 << endl;
	else if (c == 4)
		cout << s3 * 2000 << endl;


	if (s == 1)
		cout << s4 * 6000 << endl;
	else if (s == 2)
		cout << s4 * 4000 << endl;
	else if (s == 3)
		cout << s4 * 3000 << endl;
	else if (s == 4)
		cout << s4 * 2000 << endl;
}

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

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

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

    // start
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << (a + b <= n ? 0 : a + b - n) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
N = int(input())
V = list(map(int, input().split(" ")))

while len(V) > 1:
    x_ind = V.index(min(V))
    x = V.pop(x_ind)
    y_ind = V.index(min(V))
    y = V.pop(y_ind)
    V.append((x + y)/2)

print(V[0])

Measured memory_bytes: 3060
N = gets.chomp.to_i
$ryuka = []
$ryuka[0] = 1
$ryuka[1] = 3
$pp = 2
85.times do
  $ryuka[$pp] = $ryuka[$pp-1] + $ryuka[$pp-2]
  $pp+=1
end
print $ryuka[N-1]


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define inf 100000000000000ll
using namespace std;

int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9')
    f = (c == '-') ? -1 : f, c = getchar();
  while (c >= '0' && c <= '9')
    x = x * 10 + c - '0', c = getchar();
  return x * f;
}

int n;
long long f[100005][3];
// void chmax(long long &x, long long y) { x = x > y ? x : y; }

int main() {
  n = read();
  f[0][0] = 0, f[0][1] = f[0][2] = -inf;
  for (int i = 1, x; i <= n; ++i) {
    x = read();
    {
      f[i][0] = max(f[i - 1][0], f[i - 1][1]),
      f[i][1] = max(f[i - 1][1], f[i - 1][2]);
      f[i][2] = f[i - 1][2];
    }
    f[i][0] += x, f[i][1] -= x, f[i][2] += x;
    if (x < 0)
      f[i][2] = max(f[i][2], f[i][1]), f[i][1] = max(f[i][1], f[i][0]);
    // chmax(f[i][2], f[i][1]), chmax(f[i][1], f[i][0]);
  }
  printf("%lld\n", max(f[n][0], max(f[n][1], f[n][2])));
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef long long LL;
typedef pair<pair<int,int>,pair<LL,LL>> pr;

const int maxn=20;

int n;
LL a[maxn];

map<pr,LL> f;
LL dfs(int l,int r,LL x,LL y)
{
	if (l+1>=r) return 0;
	pr now=make_pair(make_pair(l,r),make_pair(x,y));
	if (f.count(now)) return f[now];
	LL re=5e18;
	fo(i,l+1,r-1) re=min(re,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));
	return f[now]=re;
}

int main()
{
	scanf("%d",&n);
	fo(i,1,n) scanf("%lld",&a[i]);
	
	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);
}


Measured memory_bytes: 22656