akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc073_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  map<ll, int> m;
  rep(i, N) {
    ll a;
    cin >> a;
    m[a]++;
  }

  ll ans = 0;
  for (auto kv : m) {
    if (kv.second % 2 != 0) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 6528
import sys

input = sys.stdin.readline


n = int(input())

s = list(input())

c = 0
for e in s:
    if e == 'R':
        c += 1

res = min(c,n-c)

tmp = 0
for i in range(c):
    if s[i] != 'R':
        tmp += 1

res = min(res,tmp)

print(res)


Measured memory_bytes: 76988
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=1;i<N;i++)

signed main(){
  int A,B,K;
  cin>>A>>B>>K;
  vector<int> ans;
  rep(i,101){
    if(A%i==0&&B%i==0){
      ans.push_back(i);
    }
  }
  sort(rbegin(ans),rend(ans));
  cout<<ans[K-1]<<endl;
}

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

using namespace std;

const int mod = 1e9 + 7;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(M);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < M; i++)
    cin >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  long long ans = 1;
  int Nu = N, Mu = M;
  for (int i = N * M; 0 < i; i--)
    if (A[Nu - 1] == i && B[Mu - 1] == i && 0 < N * M)
    {
      Nu--;
      Mu--;
    }
    else if (A[Nu - 1] == i && 0 < N)
    {
      ans = (ans * (M - Mu)) % mod;
      Nu--;
    }
    else if (B[Mu - 1] == i && 0 < M)
    {
      ans = (ans * (N - Nu)) % mod;
      Mu--;
    }
    else
      ans = (ans * ((N - Nu) * (M - Mu) - (N * M - i))) % mod;
  cout << ans << endl;

  return 0;
}


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

int main() {
	long long N, h, n, w;
	cin >> N;
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			long long X = 4 * i * j - N * (i + j);
			if (X > 0 && (N * i * j) % X == 0) {
				h = i;
				n = j;
				w = (N * i * j) / X;
				goto END;
			}
		}
	}
END:
	cout << h << " " << n << " " << w;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string a, b;
  cin >> a >> b;
  string ans = "H";
  if (a == b)
    ans = "H";
  else if (a != b)
    ans = "D";

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

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 1e5+100;
ll n;
ll a[SIZE], mem[SIZE];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >>a[i];
    }

    ll co = 0,num = 0;
    while(mem[co] == 0){
        mem[co]++;
        co = a[co]-1;
        ++num;
        if(co == 1){
            cout << num << endl;
            return 0;
        }
        
    }
    cout << "-1\n";
}

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

int main(){
                                                                     

    int a, b;

    
    cin >> a >> b;


    if( a > 8 || b > 8 ){

        cout << ":(" << endl;

        return 0;

        }


    cout << "Yay!" << endl;

    return 0;

    }

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

#define INFL 1000000000000000LL

using namespace std;

typedef long long ll;

int main() {
    ll n;
    scanf("%lld", &n);
    vector<ll> a(n + 1);
    vector< vector<ll> > dp(n + 1, vector<ll>(n + 1, INFL));
    for (ll i = 1; i <= n; ++i) {
        scanf("%lld", a.begin() + i);
        a.at(i) += a.at(i - 1);
        dp.at(i).at(i) = 0;
    }
    for (ll i = 1; i < n; ++i) for (ll j = 1; j <= n - i; ++j) {
        for (ll k = 0; k < i; ++k) dp.at(j).at(j + i) = min(dp.at(j).at(j + i), dp.at(j).at(j + k) + dp.at(j + k + 1).at(j + i));
        dp.at(j).at(j + i) += a.at(j + i) - a.at(j - 1);
    }
    printf("%lld\n", dp.at(1).at(n));
    return 0;
}

Measured memory_bytes: 1536
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll a,b,c,d;

    cin>>a>>b>>c>>d;

    bool val = 0;

    while(a > 0 && c > 0)
    {

        c -= b;

        if(c <= 0)
        {
            val = 1;
            break;
        }

        a -= d;

        if(a <= 0)
        {
            val = 0;
            break;
        }
    }
        
    if(!val)
    {
        cout<<"No";
    }    
    else
    {
        cout<<"Yes";
    }












    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>

template <typename T> inline bool chkmax(T &x, T y) {
  return x<y? x=y, true : false;
}

enum {
  MAXN = 3000 + 5,
};

const int MOD = 1000000007;

int n, m;
char s[MAXN];

int dp[MAXN][MAXN];
int pre[MAXN];
int R[MAXN];

void clear() {
  int i;
  for (i=0; i<MAXN; ++i)
    R[i] = i+1;
}

void exec() {
  int i, l, r, nj, j;
  clear();
  scanf("%d%d%s", &n, &m, s);
  for (i=0; i<m; ++i) {
    scanf("%d%d", &l, &r), --l;
    chkmax(R[l], r);
  }

  for (i=1; i<n; ++i)
    chkmax(R[i], R[i-1]);

  R[n] = n;
  for (i=0; i<n; ++i)
    pre[i+1] = pre[i] + (s[i] == '1');

  for (i=0; i<=R[0]; ++i)
    dp[1][i] = (pre[R[0]] == i);
  for (i=1; i<=n; ++i) {
    for (j=1; j<=R[i-1]-(i-1); ++j) {
      nj = j + pre[R[i]] - pre[R[i-1]] - 1;
      (dp[i+1][nj] += dp[i][j]) %= MOD;
    }
    for (j=0; j< R[i-1]-(i-1); ++j) {
      nj = j + pre[R[i]] - pre[R[i-1]];
      (dp[i+1][nj] += dp[i][j]) %= MOD;
    }
  }
  printf("%d\n", dp[n+1][0]);
}

int main() {
  if (fopen("F.in", "r") != NULL) {
    freopen("F.in", "r", stdin);
    freopen("F.out", "w", stdout);
  }
  exec();
  return 0;
}


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int n,m;
     cin >> n >> m;
     vector<string> v(n);
     vector<string> v1(m);
     for(int i=0;i<n;i++)cin >> v[i];
     for(int j=0;j<m;j++)cin >> v1[j];
     for(int i=0;i+m-1<n;i++){
       for(int j=0;j+m-1<n;j++){
         bool ok = true;
          for(int k=0;k<m;k++){
             for(int h=0;h<m;h++){
                 if(v[i+k][j+h]!=v1[k][h]){ok=false;break;}
             }
             if(!ok)break;
          }
          if(ok){cout << "Yes";return;}
       }
     }
     cout << "No";
  }


  int main(){
    IOS
       solve();
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


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

int Manhattan(int a, int b, vector<int> c, vector<int> d){
  int place;
  int dist=-1;
  for(int i=0; i<c.size(); i++){
    int temp;
    temp=abs(a-c[i])+abs(b-d[i]);
    if(dist==-1){
      dist=temp;
      place=i+1;
    }
    if(dist>temp){
      dist=temp;
      place=i+1;
    }
  }
  return place;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  vector<int> b(N);
  for(int i=0; i<N; i++) cin >> a[i] >> b[i];
  vector<int> c(M);
  vector<int> d(M);
  for(int i=0; i<M; i++) cin >> c[i] >> d[i];
  
  for(int i=0; i<N; i++){
    cout << Manhattan(a[i], b[i], c, d)<<endl;
  }
}

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

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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


int main() {

	string a,b,c;
	cin >> a >> b >> c;

	int flg = 0;
	int i1 = 0;
	int i2 = 0;
	int i3 = 0;

	while (true) {
		if (flg == 0) {
			if (i1 >= a.size()) {
				cout << 'A' << endl;
				return 0;
			}
			if (a[i1] == 'a') {
				i1++;
			} else if (a[i1] == 'b') {
				flg = 1;
				i1++;
			} else {
				flg = 2;
				i1++;
			}
		} else if (flg == 1) {
			if (i2 >= b.size()) {
				cout << 'B' << endl;
				return 0;
			}
			if (b[i2] == 'a') {
				flg = 0;
				i2++;
			} else if (b[i2] == 'b') {
				i2++;
			} else {
				flg = 2;
				i2++;
			}
		} else {
			if (i3 >= c.size()) {
				cout << 'C' << endl;
				return 0;
			}
			if (c[i3] == 'a') {
				flg = 0;
				i3++;
			} else if (c[i3] == 'b') {
				flg=1;
				i3++;
			} else {
				i3++;
			}
		}
	}

	
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

const int MAXN=210;

int v;
int e;
int r;
int route[10];
int dis[MAXN][MAXN];

int main(){
	memset(dis,0x3F,sizeof(dis));
	scanf("%d%d%d",&v,&e,&r);
	for(int i=0;i<r;i++){
		scanf("%d",route+i);
	}
	std::sort(route,route+r);
	for(int i=0,a,b,c;i<e;i++){
		scanf("%d%d%d",&a,&b,&c);
		dis[a][b]=dis[b][a]=c;
	}
	for(int i=1;i<=v;i++)
		dis[i][i]=0;
	for(int k=1;k<=v;k++){
		for(int i=1;i<=v;i++){
			for(int j=1;j<=v;j++){
				dis[i][j]=std::min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	int ans=0x7FFFFFFF;
	do{
		int sum=0;
		for(int i=1;i<r;i++){
			sum+=dis[route[i-1]][route[i]];
		}
		ans=std::min(sum,ans);
	}while(std::next_permutation(route,route+r));
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int n; cin >> n;
    set<int> nums;
    for (int i=0; i<n; i++) {
        int num; cin >> num;
        nums.insert(num);
    }
    if (n == nums.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main() {
  int n;
  int sum;

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

    sum = 0;
    for(int i = 0; i < n/4; i++) {
      int num;
      cin >> num;
      sum += num;
    }
    cout << sum	<< endl;
  }
  return 0;
}



Measured memory_bytes: 3084
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    total = sum(A)
    candidate = []
    
    for i in range(1, int(total**0.5)+1):
        if not total % i:
            candidate.extend([i, total//i])
    
    ans = 0
    
    for c in candidate:
        d = sorted([a % c for a in A])
        j = N - sum(d) // c
        
        if sum(d[:j]) <= K:
            ans = max(ans, c)
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
	long long int a,b,c;
	cin>>a>>b>>c;
	long long int s=b,i=2;
	while(i<=100000)
	{s=b*i;
	s+=c;
	if(s%a==0)
	{
	    cout<<"YES"<<endl;
	    return 0;
	}
	s=0;
	i++;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Echizen
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x, a, b;
            x = in.nextInt();
            a = in.nextInt();
            b = in.nextInt();
            if (a >= b) {
                out.println("delicious ");
            } else if (a < b && (x >= Math.abs(a - b))) {
                out.println("safe");
            } else {
                out.println("dangerous");
            }
        }

    }
}



Measured memory_bytes: 21716
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/19 4:15 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[200005];
        int[] b = new int[200005];
        int left = -1,right = -1;
        int flag = -1;
        for(int i = 0;i<n;i++){
            a[i] = scanner.nextInt();
        }
        for(int i = n-1;i>=0;i--){
            b[i] = scanner.nextInt();
            if(b[i] == a[i]){
                if(right == -1){
                    right = i;
                    flag = b[i];
                }
                left = i;
            }
        }
        int[] indexArray = new int[200005];
        int index = 0;
        for(int i = 0;i<n;i++){
            if(i == left){
                i = right;
                continue;
            }
            if(b[i] != flag && a[i] != flag){
                indexArray[index++] = i;
            }
        }
        if(left == -1 || index >= (right - left +1)){
            System.out.println("Yes");
            index = 0;
            for(int i = left;i<= right;i++){
                if (i == -1){
                    break;
                }
                int tmp = b[i];
                b[i] = b[indexArray[index]];
                b[indexArray[index]] = tmp;
                index++;
            }
            for(int i = 0;i<n;i++){
                if(i != 0) System.out.print(" ");
                System.out.print(b[i]);
            }
            System.out.println();
        }else{
            System.out.println("No");
        }

    }
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    if(s=="Sunny")cout<<"Cloudy";
    else if(s=="Cloudy")cout<<"Rainy";
    else cout<<"Sunny";
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n, m, x = map(int, input().split())
c = deque()
a = deque()
ans = float("inf")

for i in range(n):
    l = list(map(int, input().split()))
    c.append(l[0])
    a.append(l[1:])

for i in range(2**n):
    t = 0
    score = [0]*m
    for j in range(n):
        if i&(2**j) > 0:
            t += c[j]
            for k in range(m):
                score[k] += a[j][k]
    if min(score) >= x:
        ans = min(ans, t)

if ans==float("inf"):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 74772
/*input
98765432109876543210
58
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ld,ld>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=1e6+1;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a);
        if(res>1e10) return 1e11;
        a=(a*a);
        b>>=1;
    }
    return res;
}
const ll maxn=55;
const ll maxlg=__lg(maxn)+2;
int main(){
    string k;
    int d;
    cin>>k>>d;
    vector<vector<int>> dp(d,vector<int>(2));
    dp[0][0]=1;
    REP(i,sz(k)){
        vector<vector<int>> new_dp(d,vector<int>(2));
        REP(sum,d){
            REP(j,2){
                REP(dgt,10){
                    if(dgt>k[i]-'0' and !j) break;
                    new_dp[(sum+dgt)%d][j or dgt<(k[i]-'0')]+=dp[sum][j];
                    new_dp[(sum+dgt)%d][j or dgt<(k[i]-'0')]%=MOD;
                }
            }
        }
        dp=new_dp;
    }
    cout<<(dp[0][0]+dp[0][1]-1+MOD)%MOD;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M; cin >> N >> M;
	vector<ll> cnt(N, 0);
	vector<int> p(M); cin >> p;
	REP(i, M) p[i]--;
	REP(i, M-1) {
		int f = p[i], t = p[i+1];
		if (f > t) swap(f, t);
		cnt[f]++;
		cnt[t]--;
	}
	REP(i, N-1) cnt[i+1] += cnt[i];
	ll ans = 0;
	REP(i, N-1) {
		ll a, b, c; cin >> a >> b >> c;
		ans += min(a*cnt[i], b*cnt[i]+c);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4148
#include <stdio.h>

int main(void)
{

    long l_monsterHP;
    int i_skillNum;
    long l_totalDamage = 0;

    scanf("%ld%d", &l_monsterHP, &i_skillNum);

    int i_skillDetail[i_skillNum];

    for (int index = 0; index < i_skillNum; index++)
    {
        scanf("%d", &i_skillDetail[index]);
        l_totalDamage += i_skillDetail[index];
    }

    if (l_totalDamage >= l_monsterHP)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

}

Measured memory_bytes: 512
N = gets.chomp.to_i
S= []
S[0] = gets.chomp.split('')
S[1] = gets.chomp.split('')

land = []
N.times do |i|
  next if land[i - 1]
  if S[0][i] == S[0][i+1]
    land[i] = true
  else
    land[i] = false
  end
end
land.compact!

count = 1
land.each_with_index do |l, i|
  if i == 0
    count = l ? 6 : 3
  else
    a = 1
    if land[i-1]
      if l
        a = 3
      end
    else
      a = 2
    end
    count = count * a
  end
end

print "#{count % 1000000007}"

Measured memory_bytes: 1788
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto s = readStr;
  int[char] dic;

  foreach(c; s){
    dic[c]++;
  }

  foreach(i; dic.byValue){
    if(i != 2){
      writeln("No");
      return;
    }
  }
  writeln("Yes");
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char huruf;
	scanf("%c", &huruf);
	if (huruf >='a' && huruf <= 'z') {
		printf("a");
	}
	else if (huruf >= 'A' && huruf <= 'Z'){
		printf("A");
	}
	return 0;
	
}

Measured memory_bytes: 1592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e5+10;
const int maxm=1e3+10;
const int mod=1e9+7;
int n;
int A[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
            scanf("%d",&A[i]);
        sort(A+1,A+1+n);
        ll s=0,a=-1,b=-1;
        for(int i=n;i>=2;i--)
        {
            if(A[i]==A[i-1])
            {
                if(a==-1)
                    a=A[i];
                else if(b==-1)
                    b=A[i];
                i--;
            }
        }
        if(a!=-1&&b!=-1)
            s=1LL*a*b;
        printf("%lld\n",s);
    }
    return 0;
}


Measured memory_bytes: 640
import sys
S = input()
T = input()
if T in S:
  print(0)
  sys.exit(0)

maxSameCharCount = 0
for i in range(len(S)-len(T)+1):
  sameCharCount = 0
  for j in range(len(T)):
    if S[i+j]==T[j]:
      sameCharCount += 1
  if maxSameCharCount < sameCharCount:
    maxSameCharCount = sameCharCount
print(len(T)-maxSameCharCount)


Measured memory_bytes: 8952
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int s; cin >> s;
  vector<int> passed(10000000,-1);
  int i = 1;

  while (1){
    if (passed[s]==-1) passed[s] = i;
    else {
      cout << i << endl;
      break;
    }

    if (s%2==0) s = s/2;
    else s = 3*s + 1;

    i++;
  }

  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 39296
#include<stdio.h>

int main(){
	
	int A,B,C,X,i,j,k,ans=0;
	
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&X);
	
	for(i=0;i<=A;i++){
		for(j=0;j<=B;j++){
			for(k=0;k<=C;k++){
				
				if(500*i+100*j+50*k==X){
					ans++;
				}
			}
		}
	}
	
	printf("\n\n%d\n\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;string s;
    cin>>n>>s;
    string s1=s,s2=s;
    int ans=INF;
    int W=0,B=0;
    vector<int> black(n+1),white(n+1);
    for(int i=0;i<n;i++){
        if(s[i]=='.'){
            W++;
            white[i+1]=white[i]+1;
            black[i+1]=black[i];
        }
        else{
            B++;
            white[i+1]=white[i];
            black[i+1]=black[i]+1;
        }
    }
    ans = min(W,B);
    int w=0,b=0;
    REP(i,n+1){
        ans=min(ans,black[i]+W-white[i]);
    }
    cout<<ans<<endl;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

class union_find{
	private:
	vector<int> parent,rank,gs;
    int size;
	public:
    int count_group;
    union_find()=default;
    union_find(int n){ init(n); }

    void init(int n){
		size=n;
		count_group=n;
		parent.resize(size);
		rank.assign(size,0);
        gs.assign(size,1);
		for(int i=0; i<size; ++i) parent[i]=i;
	}

	int find(int x){
		if(parent[x]==x) return x;
		else return parent[x]=find(parent[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			parent[x]=y;
            gs[y]+=gs[x];
		} else {
			parent[y]=x;
            gs[x]+=gs[y];
			if(rank[x]==rank[y]) ++rank[x];
		}
		--count_group;
	}

	bool is_same_group(int x,int y){
		return find(x)==find(y);
	}

    int group_size(int x){
        return gs[find(x)];
    };
};

void solve(){
    i64 N;
    cin >> N;
    vector<i64> x(N),y(N);
    vector<pair<i64,i64>> xi,yi;
    rep(i,0,N){
        cin >> x[i] >> y[i];
        xi.push_back(make_pair(x[i],i));
        yi.push_back(make_pair(y[i],i));
    }
    sort(xi.begin(),xi.end());
    sort(yi.begin(),yi.end());

    vector<pair<i64,i64>> dx,dy;
    rep(i,0,N-1){
        dx.push_back(make_pair(xi[i+1].first-xi[i].first,i));
        dy.push_back(make_pair(yi[i+1].first-yi[i].first,i));       
    }
    sort(dx.begin(),dx.end());
    sort(dy.begin(),dy.end());

    i64 ans=0;
    union_find uf(N);
    i64 i=0,j=0;
    while(uf.count_group>1){
        if(i<N-1 and (j==N-1 or dx[i].first<dy[j].first)){
            i64 u=xi[dx[i].second].second,v=xi[dx[i].second+1].second;
            if(uf.is_same_group(u,v)){
                ++i;
                continue;
            }
            uf.unite(u,v);
            ans+=min(abs(x[u]-x[v]),abs(y[u]-y[v]));
        }else{
            i64 u=yi[dy[j].second].second,v=yi[dy[j].second+1].second;
            if(uf.is_same_group(u,v)){
                ++j;
                continue;
            }
            uf.unite(u,v);
            ans+=min(abs(x[u]-x[v]),abs(y[u]-y[v]));
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 10468
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int a, b;
void init(){
    a = read(), b = read();
}
void solve(){
    for (int i = 0; i <= 2000; ++i){
        if (i * 8 / 100 == a && i * 10 / 100 == b){
            printf("%d\n", i);
            return ;
        }
    }
    printf("-1\n");
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
res = pow(10,n,mod) 
res -= pow(9,n,mod)*2
res %= mod
res += pow(8,n,mod)
print(res%mod)

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

int main() {
  
  int H, W;
  cin >> H >> W;
  while ( H != 0 && W != 0) {
  
    for (int i=0; i<H; i++) {
	  for (int j=0; j<W; j++) {
	    cout << '#';
      }
      cout << endl;
    }
    
    cout << endl;
    cin >> H >> W;
  }
  
  return 0;
}



Measured memory_bytes: 3084
fun main(args: Array<String>){
    var (A, B, C, K) = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0

    for(i in 0 until K){
        if(A > 0) {
            ans += 1
            A --
        }else if(B > 0){
            ans+= 0
            B--
        }else{
            ans -= 1
            C --
        }
    }

    println(ans)

}


Measured memory_bytes: 36692
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int n;
int id[N << 1];
int lowbit (int x) {
    return x & -x;
}
int main () {
    scanf("%d", &n);
    for (int i = 0; (1 << i) <= (n << 1); i++) id[1 << i] = i + 1;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            printf("%d ", id[lowbit(i ^ j)]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-9)
#define INF (1e9 + 1)
#define PI (acos(-1))

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

ll lcm(ll a, ll b) {
	ll c = (b / gcd(a, b));
	return c * a;
}

int H, W, h, w;

int main() {
	cin >> H >> W >> h >> w;
	cout << H * W - h * W - w * H + w * h << endl;
}

Measured memory_bytes: 256
function Main(input) {
    var input = input.split('\n');
    var n = input[0];
    var a = input[1].split(' ').map(n => {
        return parseInt(n);
    })
    var ookii = a.sort((a, b) =>{
        return (a < b ? -1 : 1)
    }).reverse();
    var Alice = 0;
    var Bob = 0;
    for (i = 0; i < ookii.length; i++) {
        if (i % 2 === 0) {
            Alice += ookii[i];
        } else {
            Bob += ookii[i];
        }
    }
    console.log(Alice - Bob);
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int n;
  cin >> n;
  vector<int64_t> a(n);
  int64_t sum = 0;
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  int64_t wa = 0;
  for (int i = 0; i < n - 1; i++){
    sum -= a.at(i);
    wa += a.at(i) * (sum % 1000000007);
    wa %= 1000000007;
  }
  cout << wa << endl;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
    string S;
    cin >> S;
    lint K;
    cin >> K;
    REP(i, K)
    {
        int n = S[i] - '0';
        if (n == 1) continue;
        else {
            cout << n << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
void show(int a[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(i) putchar(' ');
        printf("%d",a[i]);
    }
}

void SelectionSort(int a[],int n)
{
    int i,j,min,t,count=0;
    for(i=0;i<n-1;i++)
    {
        min=i;
        for(j=i;j<n;j++)
            if(a[min]>a[j])
            {
                min=j;
            }
        t=a[min];a[min]=a[i];a[i]=t;
        if(min!=i) count++;
    }
    show(a,n);
    putchar('\n');
    printf("%d\n",count);
}
int main()
{
    int a[101];
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);

    SelectionSort(a,n);

}



Measured memory_bytes: 2040
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
cnt=0
for i in range(n-1):
  for j in range(i+1,n):
    a=l[i]
    b=l[j]
    c=bisect.bisect_left(l,a+b)
    cnt+=c-1-j
print(cnt)


Measured memory_bytes: 3188
object Main extends App {
  val input = io.Source.stdin.getLines.toSeq.head.split(' ').map(_.toLong)
  val a=input(0)
  val b=input(1)
  val x=input(2)
  
  if(x==1) println(b-a+1)
  else {
    val ax=if(a==0) -1 else (a-1)/x
  	val bx=b/x
  	val ret=bx-ax
  	println(ret)
  }
}


Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 999999999999;
using ll = long long;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}






int main(){
  ll N;
  cin>>N;
  ll a[N][3];
  for(ll i = 0;i<N;i++){
    for(ll k = 0;k<3;k++){
      cin>>a[i][k];
    }
  }
  ll dp[N][3];
  for(ll i = 0;i<N;i++){
    for(ll k = 0;k<3;k++){
      dp[i][k] = 0;
    }
  }
  dp[0][0] = a[0][0];
  dp[0][1] = a[0][1];
  dp[0][2] = a[0][2];
  for(ll i = 1;i<N;i++){
    for(ll k = 0;k<3;k++){
      for(ll m = 0;m<3;m++){
        if(k == m){
          continue;
        }
        else{
          dp[i][k] = max(dp[i][k],dp[i-1][m]+a[i][k]);
        }
      }
    }
  }
  ll ans = max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
#include <cctype>
using namespace std;

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;


int main(){
    //ios_base::sync_with_stdio(false);
	int a;
	scanf("%d", &a);
	int a1, a2, a3;
	a1 = a%10; a/=10;
	a2 = a%10; a/=10;
	a3 = a%10; a/= 10;
	if(a1 == a3) puts("Yes");
	else puts("No");


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    string st;
    cin >> st;
    int n=st.size(),l=21;
    int ans[n]={0},dp[n][l];
    for(int i=0;i<n;i++){
    	if(st[i]=='L')dp[i][0]=i-1;
    	else dp[i][0]=i+1;
    }
    for(int j=1;j<l;j++)
    for(int i=0;i<n;i++){
    	dp[i][j]=dp[dp[i][j-1]][j-1];
    }
    for(int i=0;i<n;i++){
    	ans[dp[i][20]]++;
    }
    for(int i=0;i<n;i++)
    	cout << ans[i] << " ";
}

Measured memory_bytes: 17872
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  int a, b, c; cin >> a >> b >> c;

  ll ans = 0;
  
  
  //cout << ans << endl;
  cout << (a == b && b == c ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int i,n;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
      if(i%3==0) {printf(" %d",i);}
      else if(i%10==3||(30<=(i%100)&&(i%100)<40)||(300<=(i%1000)&&(i%1000)<400)||(3000<=(i%10000)&&(i%10000)<4000)) printf(" %d",i);
   }
   printf("\n");
   return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,mod=1e9+7,inf=1e9+10;
int a[M];
main()
{
	string x;
	cin>>x;
	cout<<"2018";
	for(int i=4;i<x.size();i++)cout<<x[i];
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static final void main(String args[]) throws Exception {
        new Main().solve();
    }

    private static int max = 6;

    void solve() {
        try (Scanner in = new Scanner(System.in)) {
            int n = in.nextInt();
            int x[] = new int[n];
            for (int i = 0; i < n; ++i) {
                x[i] = in.nextInt();
            }
            long mod = 1000000007L;
            long a = 1;
            for (int i = 0, j = 1; i < n - 1; ++i) {
                while (j + 1 < n && x[j] - (j - i) > (j - i)) ++j;
                a = (a * (j - i + 1)) % mod;
            }
            System.out.println(a);
        }
    }

    void tr(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}

Measured memory_bytes: 50924
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n, k, q; scan(n, k, q);

    auto t = new int[n];
    for (int i = 0; i < q; i++) {
        int a = readint - 1;
        t[a]++;
    }

    for (int i = 0; i < n; i++) {
        int point = k - (q - t[i]);
        writeln(point > 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define Pb push_back
#define Mp make_pair
#define ff first
#define ss second
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MOD (ll)1000000007

signed main()
{
    IOS;
    int n,m,cnt=0,p=0;
    cin >> n >> m;
    int g[n+1][2];
    memset(g,0,sizeof(g));
    for(int i=0;i<m;i++)
    {
        int x;
        string y;
        cin >> x >> y;
        if(y=="AC" && g[x][1]<=0)
        {
            cnt++;
            p+=g[x][0];
            g[x][1]++;
        }
        else g[x][0]++;
    }
    cout << cnt << " " << p;
    return 0;
}


Measured memory_bytes: 1792
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
	else if (s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

lli N, arr[110], ans;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; ++i)
		cin >> arr[i];
	for (int i = 0; i < N; ++i)
		for (int j = i + 1; j < N; ++j)
			ans += arr[i] * arr[j];
	cout << ans;
}

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

#define int long long

signed main(){
    int n;
    cin >> n;
    map<int, int> mp;

    int a;
    mp[0] = 1;

    int ans = 0;
    int tmp = 0;
    for(int i = 0;i < n;i++){
        cin >> a;
        tmp += a;
        ans += mp[tmp];
        mp[tmp]++;
    }

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




Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
int r[18][100000],x[100000];
int main(){
    int n,L,Q,a,b;
    cin>>n;
    rep(i,n)cin>>x[i];
    cin >>L;
    rep(i,n)r[0][i]=upper_bound(x,x+n,x[i]+L)-x-1;
    rep(i,17)rep(j,n)r[i+1][j]=r[i][r[i][j]];
    cin >>Q;
    rep(q,Q){
        cin >>a >>b;--a;--b;
        if(a>b)swap(a,b);
        int ans=0,now=a;
        for(int i=17;i>=0;--i)if(r[i][now]<b){now=r[i][now];ans+=1<<i;}
        if(now<b){now=r[0][now];++ans;}
        cout<<ans<<'\n';
    }
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
 
 
void solve(){
	int n, m;cin>>n>>m;
	map<int, int>mp;
	int cnt = 0, anscnt = 0;
	for0(i,m){
		int x;string s;cin>>x>>s;
		if(mp[x]==-1) continue;
		if(s=="AC"){
			anscnt++;
			cnt += mp[x];
			mp[x] = -1;
		} else{
			mp[x]++;
		}
	}
	
	cout<<anscnt<<" "<<cnt<<endl;
}
 
int main(){
	
	motherfucker
	ll t = 1;
	//cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

Measured memory_bytes: 4992
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]


@lru_cache(maxsize=1024*1024)
def fact(n): return math.factorial(n)

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return fact(n) // (fact(r) * fact(n-r))

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")


class FactInv:
    def __init__(self, N, MOD=1000000007):
        fact, inv = [1]*(N+1), [None]*(N+1)
        for i in range(1, N+1): fact[i] = fact[i - 1] * i % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N)[::-1]: inv[i] = inv[i + 1] * (i + 1) % MOD
        self.N, self.MOD, self.fact, self.inv = N, MOD, fact, inv

    def perm(self, a, b):
        if a > self.N or b > self.N: raise ValueError("\nPermutaion arguments are bigger than N\n N = {}, a = {}, b = {}".format(self.N, a, b))
        return self.fact[a] * self.inv[a-b] % self.MOD

    def comb(self, a, b):
        if a > self.N or b > self.N: raise ValueError("\nCombination arguments are bigger than N\n N = {}, a = {}, b = {}".format(self.N, a, b))
        return self.fact[a] * self.inv[b] * self.inv[a-b] % self.MOD



def main():
    N, K = LI()
    A = sorted(LI())
    factinv = FactInv(N + 1)

    ans = 0
    for i, x in enumerate(A):
        maxc = factinv.comb(i, K - 1) if i >= K - 1 else 0
        minc = factinv.comb(len(A) - i - 1, K - 1) if len(A) - i - 1 >= K - 1 else 0
        ans = (ans + x * (maxc - minc)) % MOD

    print(ans % MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 94996
def gcd(a, b)
    return a < 1 ? b : gcd(b % a, a)
end

N = gets.to_i
A = gets.split.map(&:to_i)

gr = A.clone
gl = A.clone
(1...N).each {|i|
  gl[i] = gcd(gl[i-1], gl[i])
  gr[N-1-i] = gcd(gr[N-1-i], gr[N-i])
  }
max = 0
(0...N).each {|i|
  tmp = 0
  if i==0
    tmp = gr[i+1]
  elsif i==N-1
    tmp = gl[i-1]
  else
    tmp = gcd(gl[i-1], gr[i+1])
  end
  max = tmp if max < tmp
  }
puts max


Measured memory_bytes: 10124