akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
A = list(map(int, input().split()))
sum_v = sum(A)
cnt = 0
for i in range(n):
    if A[i] < sum_v / (4*m):
        continue
    else:
        cnt += 1

if cnt >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
aa = int(input())
bb = int(input())
cc = int(input())
x = int(input())

count = 0

for a in range(aa+1):
    for b in range(bb+1):
        for c in range(cc+1):
            if 500 * a + 100 * b + 50 * c > x:
                break
            elif 500 * a + 100 * b + 50 * c == x:
                count += 1

print(count)

Measured memory_bytes: 3060
"""
方針
Uを求める(u)
0を含まないA(a)
9を含まないB(b=a)
AかつB(c)

ans = U - (2*a -c)
"""
n=int(input())
p=10**9+7
u=1

def clock(v, cnt):
  ret = 1
  for i in range(cnt):
    ret = (ret * v) % p
  return ret

u = clock(10, n)
a = clock(9, n)
c = clock(8, n)
ans = (u - (2*a - c))%p
print(ans)

Measured memory_bytes: 9172
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        if(s[0].equals(s[1]) && s[1].equals(s[2]) && s[2].equals(s[0])){
            System.out.println("No");
            return;

        }
        System.out.println("Yes");


    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,hang[8],lie[8],zuo[15],you[15];//标记行，列，斜下，斜上
int book[8][8];//控制输出
void print()
{

    for(int i=0; i<8; i++)
    {
        for(int j=0; j<8; j++)
        {
            if(book[i][j])
            {
                if(hang[i]!=j)
                    return ;
            }
        }
    }
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            if(hang[i]==j)
                printf("Q");
            else printf(".");
        }
        printf("\n");
    }
}
void dfs(int x)
{
    if(x==8)//判断输出
    {
        print();//输出后直接返回
        return ;
    }
    for(int i=0; i<8; i++)
    {
        if(lie[i]==1||zuo[i+x]==1||you[x-i+8-1]==1)
        {
            continue;
        }
        hang[x]=i;
        lie[i]=zuo[i+x]=you[x-i+8-1]=1;//标记列，斜下，斜上
        dfs(x+1);//往下递归
        hang[x]=lie[i]=zuo[x+i]=you[x-i+8-1]=-1;//取消标记
    }
    return ;
}
int main()
{
    while(~scanf("%d",&n))
    {
        memset(hang,-1,sizeof(hang));
        memset(lie,-1,sizeof(lie));
        memset(zuo,-1,sizeof(zuo));
        memset(you,-1,sizeof(you));
        memset(book,0,sizeof(book));
        int a,b;
        for(int i=0; i<n; i++)
        {
            scanf("%d%d",&a,&b);
            book[a][b]=1;
        }
        dfs(0);
    }
    return 0;
}



Measured memory_bytes: 2684
import java.io.*;
import java.util.*;

class XY{
    int x;
    int y;
    XY(int x_, int y_){
        x = x_;
        y = y_;
    }
}

class Main{
    void run() throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            int num = Integer.parseInt(in.readLine());
            int maxX = 0;
            int maxY = 0;
            int minX = 0;
            int minY = 0;
            if(num == 0)
                break;
            XY[] map = new XY[num];
            map[0] = new XY(0,0);
            maxX = 0;
            maxY = 0;
            minX = 0;
            minY = 0;
            for(int i = 1;i < num;i++){
                String[] str = in.readLine().split(" ",0);
                int kiten = Integer.parseInt(str[0]);
                int houkou = Integer.parseInt(str[1]);

                map[i] = new XY(map[kiten].x, map[kiten].y);
                // System.out.println(map[i].x+":"+map[i].y);
                switch(houkou){
                    case 0:
                        map[i].x -= 1;
                        if(map[i].x < minX){
                            minX = map[i].x;
                        }
                        // System.out.println("minX:"+minX);
                        break;
                    case 1:
                        map[i].y -= 1;
                        if(map[i].y < minY){
                            minY = map[i].y;
                        }
                        // System.out.println("minY:"+minY);
                        break;
                    case 2:
                        map[i].x += 1;
                        if(map[i].x > maxX){
                            maxX = map[i].x;
                        }
                        // System.out.println("maxX:"+maxX);
                        break;
                    case 3:
                        map[i].y += 1;
                        if(map[i].y > maxY){
                            maxY = map[i].y;
                        }
                        // System.out.println("maxY:"+maxY);
                        break;
                }
            }
            int ansX = maxX - minX + 1;
            int ansY = maxY - minY + 1;
            System.out.println(ansX+" "+ansY);
            // for(int i = 0;i < num;i++){
            //     System.out.printf("%d, %d, %d\n", i, map[i].x, map[i].y);
            // }

        }

    }
    public static void main(String[] args) throws IOException{
        Main ma = new Main();
        ma.run();
    }
}

Measured memory_bytes: 29292
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int sum = 0;
        for (int i = 0; i < m; i++) {
            sum += sc.nextInt();
        }

        int res = n - sum;
        if(res < 0) res = -1;

        System.out.println(res);


    }
}

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

int main(void)
{
	int max=101,count=0;;
	bool all[max];
	
	for(int i=0;i<max;i++)
	{
		all[i]=false;
	}
	int N,K;
	cin>>N>>K;
	for(int i=0;i<K;i++)
	{
		int num,test;
		cin>>num;
		for(int j=0;j<num;j++)
		{
			cin>>test;
			all[test]=true;
		}
	}
	for(int i = 1;i<=N;i++)
	{
		if(all[i]==false)count++;
	}
	cout<<count;
}


Measured memory_bytes: 3596
a=int(input())
b=1
total2=0
for i in range(1,a+1):
    total=0
    a=i
    while True:
        if a%2==0:
            a=a/2
            total+=1
        else:
            if total2<total:
                total2=total
                b=i
            break
print(b)      

Measured memory_bytes: 9244
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))


    N = NI()
    ans = (N-1) * 2 - 1
    for i in range(2,N//2+1):
        j = 2
        while i * j < N:
            ans += 1
            j += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 69808
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, c[200005];
ll z = 0, p[200005] = {1};
vector<int> g[200005];

void dfs(int x, int y) {
    c[x] = 1;
    vector<int> a;
    for (int i : g[x]) if (i != y) {
        dfs(i, x);
        c[x] += c[i];
        a.push_back(c[i]);
    }
    a.push_back(n - c[x]);
    z = (z + p[n - 1] - 1) % mod;
    for (int i : a) z = (z - p[i] + 1 + mod) % mod;
}

int main() {
    ios::sync_with_stdio(false);
    int u, v;
    cin >> n;
    for (int i = 1; i <= n; i++) p[i] = p[i - 1] * 2 % mod;
    for (int i = 1; i < n; i++) cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    dfs(1, 1);
    for (int i = 1; i <= n; i++) z = z * 500000004 % mod;
    cout << z;
}


Measured memory_bytes: 34900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  ll arr[n+1][3],dp[n+1][3];
  ll i,j;
  for(i=1;i<=n;i++)
  {
      for(j=0;j<3;j++)
      {
          cin>>arr[i][j];
      }
  }
  dp[1][0]=arr[1][0];
  dp[1][1]=arr[1][1];
  dp[1][2]=arr[1][2];
  for(i=2;i<=n;i++)
  {
    dp[i][0]=max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
    dp[i][1]=max(dp[i-1][2]+arr[i][1],dp[i-1][0]+arr[i][1]);
    dp[i][2]=max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]);
  }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
  return 0;
}

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

using namespace std;

int main(){
	string s;
	cin>>s;
	int t=0,r=0;
	for(int i=0;i<3;i++){
		if(s[i]=='R'){
			r++;
		}
		else{
			r=0;
		}
		t=max(t,r);
	}
	cout<<t<<endl;
}



Measured memory_bytes: 3624
n=int(input())
A=[]
B=[]
for i in range(n):
    a,b=input().split()
    A.append(a)
    B.append(b)
A.reverse()
B.reverse()
A.append(0)
B.append(0)
A=list(map(int,A))
B=list(map(int,B))

x=0
for i in range(0,n):
    cnt=0
    if A[i]%B[i]!=0:
        cnt+=(B[i]-A[i]%B[i])
        A[i]+=(B[i]-A[i]%B[i])
    x+=cnt
    A[i+1]+= x
print(x)

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

using namespace std;

int main(){
    string s,t;
    long long int ans=0,now=0;
    cin >> s;
    cin >> t;
    vector<vector<long long int>> num(26);

    for(int i=0;i<s.size();i++){
        num[s[i]-'a'].push_back(i);
    }

    if(num[t[0]-'a'].size()==0){
        cout << -1 << endl;
        return 0;
    }else{
        now = num[t[0]-'a'][0];
    }

    for(int i=1;i<t.size();i++){

        if(num[t[i]-'a'].size()==0){
            cout << -1 << endl;
            return 0;
        }

        if(num[t[i]-'a'].back() < now+1){
            now = num[t[i]-'a'][0];
            ans += s.size();
        }else{
            auto itr = upper_bound(num[t[i]-'a'].begin(),num[t[i]-'a'].end(),now);
            now = *itr;
        }
    }

    cout << ans + now + 1<< endl;
}

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

int main() {
  char s[201], p[101], t[101];
  cin >> s >> p;
  strcpy (t, s);
  strcat (s, t);
  if (strstr(s, p) == NULL) cout << "No" << endl;
  else cout << "Yes" << endl;
  
}



Measured memory_bytes: 3120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


 
public class Main {
 
    void solve() throws IOException {
        BigInteger md = BigInteger.valueOf(mod);
        int K = ni();
        String S = ns();
        int N = S.length();
        final int MAX = (int)2e6+10;
        fact = new int[MAX];
        fact[0] = 1;
        for (int j = 1; j < fact.length; j++) {
            fact[j] = mul(fact[j-1],j);
        }
        factInv = new int[MAX];
        factInv[MAX-1] = BigInteger.valueOf(fact[MAX-1]).modInverse(md).intValue(); 
        for (int j = MAX-1; j >=1; j--) {
            factInv[j-1] = mul(factInv[j],j);
        }
        int[] d25 = new int[K+1];
        d25[0] = 1;
        for (int i = 1; i < d25.length; i++) {
            d25[i] = mul(d25[i-1],25);
        }
        int[] d26 = new int[K+1];
        d26[0] = 1;
        for (int i = 1; i < d26.length; i++) {
            d26[i] = mul(d26[i-1],26);
        }
        int ans = 0;
        for (int i = N-1; i <N+K; i++) {
            int addv = c(i, N-1);
            addv = mul(addv,d25[i+1-N]);
            addv = mul(addv,d26[K-(i+1-N)]);
            ans = add(ans,addv);
        }
        out.println(ans);
    }

    int c(int n, int k) {
        if (k < 0 || k > n) {
            return 0;
        }
        return mul(fact[n], mul(factInv[k], factInv[n - k]));
    }
    int mod = 1000000007;
    int[] fact;
    int[] factInv;

    int mul(int x, int y) {
        return (int) ((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 61016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;

  int count = 0;
  for (int i = 0; i < A.size(); i++){
      char a = A.at(i);
      char b = B.at(i);
      char c = C.at(i);


      if (A.at(i) != B.at(i) && A.at(i) == C.at(i)) {
          char b = A.at(i);
          count++;
      } else if (A.at(i) != B.at(i) && B.at(i) == C.at(i)) {
          char a = B.at(i);
          count++;
      } else if (A.at(i) != B.at(i) && B.at(i) != C.at(i)) {
          char b = A.at(i);
          char c = A.at(i);
          count = count + 2;
      } else if (A.at(i) == B.at(i) && A.at(i) != C.at(i)) {
          char c = A.at(i);
          count++;
      }
  }

  cout << count << endl;
}

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

 

int main()
{
   int a, b;     
   cin >> a >> b;
   
   if (a == b)
      cout << "a == b" << endl;
   else if(a > b)
      cout << "a > b" << endl;
   else
      cout << "a < b" << endl;
   
   return 0;
}


Measured memory_bytes: 3060
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

ll ncr(ll n, ll r){
    if(n < r) return 0ll;
    ll res = 1;
    rep(i, 0, r) res *= (n - i);
    repp(i, 2, r) res /= i;
    return res;
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    string s;
    cin >> s;
    int n = s.size();
    int k;
    cin >> k;
    s += '0';

    ll x = n, y = n;
    rep(i, 1, n) if(s[i] != '0'){x = i; break;}
    rep(i, x + 1, n) if(s[i] != '0'){y = i; break;}

    ll res = ncr(n, k);
    rep(i, 0, k) res *= 9;

    if(k == 1) res -= (9 - s[0] + '0');

    if(k == 2){
        if(x == n) res -= (10 - s[0] + '0')*(n-1)*9;
        else
            res -= (9 - s[x] + '0'),
            res -= (x - 1)*9,
            res -= (9 - s[0] + '0')*(n-1)*9;
    }

    if(k == 3){
        if(x == n && y == n) res -= (10 - s[0] +'0')*ncr(n-1, 2)*9*9;
        if(x < n && y == n){
            res -= (10 - s[x] + '0')*(n - x - 1)*9,
            res -= (x - 1) * (n - x) * 81,
            res -= (9 - s[0] + '0')*ncr(n-1, 2)*81;
        }
        if(x < n && y < n){
            res -= (9 - s[y] + '0'),
            res -= (y - x - 1)*9,
            res -= (9 - s[x] + '0')*(n - x - 1)*9,
            res -= (x - 1)*9*(n - x)*9,
            res -= (9 - s[0] + '0')*ncr(n-1, 2)*9*9;
        }
    }

    ll ans = 0;
    rep(i, 2, n-1) ans += (i*(i-1))/2 * 9 * 9 * 9;
	ans += max(0,(s[0]-'0'-1) * (n-1) * (n-2) / 2 * 9 * 9);
    rep(i, 1, n){
		if(s[i] != '0'){
			ans += max(0,(s[i]-'0'-1) * (n-i-1) * 9);
			ans += max(0,(n-i-1)*(n-i-2) / 2 * 9 * 9);
			for(int j=i+1;j<n;j++){
				if(s[j] != '0'){
					
					ans += s[j]-'0';
					ans += max(0,(n-j-1)*9);
					
					break;
				}
			}
			break;
		}
	}

    if(k == 3 && x < n && y == n) cout << ans;
    else cout << res;
}

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

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int h,w,k;
  int count_bk=0,ans=0;
  cin >> h >> w >> k;
  vector<vector<char>>c(h+1,vector<char>(w+1));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c.at(i).at(j);
      if(c.at(i).at(j) == '#'){
        count_bk++;
      }
    }
  }
  for(int i=0;i<(1<<h);i++){
    for(int j=0;j<(1<<w);j++){
      int temp=count_bk;
      for(int x=0;x<h;x++){
        for(int y=0;y<w;y++){
          if(i&(1<<x) || j&(1<<y)){
            if(c.at(x).at(y)=='#'){
              temp--;
            }//if
          }//if
        }//for y
      }//for x
      if(temp == k){
        ans++;
      }
    }//for j
  }//for i
  cout << ans << endl;
}

Measured memory_bytes: 3552
#!/usr/bin/ruby
# encoding: utf-8

# input
a,b,c,d = gets.split.map(&:to_i)

lc = c.lcm(d)
divisible_c = b/c - (a-1)/c
divisible_d = b/d - (a-1)/d
divisible_lc = b/lc - (a-1)/lc

puts b-(a-1) - (divisible_c + divisible_d - divisible_lc)

Measured memory_bytes: 1788
open System

let inp = stdin.ReadLine().Split(' ') |> Array.map int
let N,A,B = (inp.[0],inp.[1],inp.[2])

let mutable ans = 0

let rec sum x = 
    if x = 0 then 0
    else (x%10) + (sum (x/10))

for i in 1..N do
    if (let s = sum i in (A <= s && s <= B)) then
        ans <- ans + i

printfn "%d" ans


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

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

    if(S[0]=='A'){
      if(!islower(S[1]))
      {
          cout << "WA" << endl;
          return 0;
      }

      int count = 0;
      for(int i=2; i<S.size()-1; i++)
      {  
        if(S[i]=='C') count++;
        else if(!islower(S[i])) 
        { 
          cout << "WA" << endl;
          return 0;
        }
      }
      if(count==1&&islower(S[S.size()-1])) cout << "AC" << endl;
      else cout << "WA" << endl;
    }
    
    else {
      cout << "WA" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_set>
using namespace std;
#define endl '\n'
#define ll long long
#define PI acos(-1)
#define watch(x) cerr<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define Mo7med_Sayed fast();
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0;
const double EPS = (1e-7);
const ll OO = INT_MAX, mod = 1e9 + 7;
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, k, t;
vector<ll>v;
ll dp[3005][3005][2];
ll solve(int x,int y,bool b) {
	if (x>y)return 0;
	ll& ret = dp[x][y][b];
	if (~ret)return ret;
	if (b) {
		ret = max(solve(x + 1, y, b ^ 1) + v[x], solve(x , y-1, b ^ 1) + v[y]);
	}
	else {
		ret= min(solve(x + 1, y, b ^ 1) , solve(x , y-1, b ^ 1));
	}
	return ret;
}

int main()
{
	//run();
	Mo7med_Sayed;
	cin >> n;
	v.resize(n);
	memset(dp, -1, sizeof dp);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i] ; sum += v[i];
	}
	cout << solve(0, n - 1, 1)*2-sum;

}



Measured memory_bytes: 141568
#include<bits/stdc++.h>
typedef long long ll;
ll INF =1e15;
using namespace std;
int main(){
    int n;
    cin>>n;
    int h[n+1];
    ll dp[n+10];
    for(int i=0; i<n; i++){
        cin>>h[i];
    }
    for(int i=0; i<=n+1; i++){
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(int j=1; j<=2; j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
}


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

using namespace std;

int N,ans;
int cnt[100005];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

for(int i=0; i<N; i++){
	int n;
	cin>>n; n++;
	cnt[n-1]++;
	cnt[n]++;
	cnt[n+1]++;
}

for(int i=0; i<100002; i++){
	ans=max(ans,cnt[i]);
}

cout<<ans<<endl;

}



Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 10000;

int main(){
    int N,K;
    int p[MAX];

    cin >> N >> K;
    for(int i = 0;i < N;i++){
        cin >> p[i];
    }

    sort(p,p+N);

    int ans = 0;

    for(int i = 0;i < K;i++){
        ans += p[i];
    }

    cout << ans << endl;

    return 0;
}


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

/*
result can always be reduced to a cycle

lets say we have a cycle, i posit that even if there are extra stuff, we can still reduce it 

extra forward edge-> we can take one of the two

dfs down -> find a cycle (if none then no answer)

run through the elements in the cycle, chopping off ones

run through once-> establish a set & order.
run again, checking if the set has extra edge, if so, chop it off and repeat

*/

const int N = 1000 + 5;
int n,m;
vector<int> g[N];

vector<int> reduce_cycle(vector<int> v){
	vector<int> res = v;
	int in[N] = {};
	int cnt = 1;
	for(int e:v){
		in[e] = cnt++;
	}
	int len = v.size();
	for(int i = 0;i < v.size(); ++i){
		int e = v[i];
		for(int to:g[e]){
			if(to == v[ (i + 1) % len])continue;
			if(in[to]){ // chop it off
				vector<int> nxt;
				if(in[e] < in[to]){
					nxt.assign(res.begin(),res.begin() + in[e]);
					nxt.insert(nxt.end(), res.begin() + in[to] -1, res.end());
				}
				else{
					nxt.assign(res.begin() + in[to] - 1, res.begin() + in[e]);			
				}
				res.swap(nxt);
				return reduce_cycle(res);
			}
		}
	}
	return res;
}

int col[N];

vector<int> find_cycle(int cur, vector<int> &path){
	path.push_back(cur);
	col[cur] = 1;
	vector<int> res;
	for(int a: g[cur]){
		if(col[a] == 1){
			auto it = find(path.begin(), path.end(), a);
			assert(it != path.end());
			res.assign(it, path.end());
		}
		else{
			res = find_cycle(a, path);
		}

		if(res.size())break;
	}
	path.pop_back();
	col[cur] = 2;
	return res;
}

int main(){
	cin.tie(0);	
	cout.tie(0);	
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 0;i < m; ++i){
		int x,y;
		cin >> x >> y;
		g[x].push_back(y);
	}
	vector<int> ans;
	for(int i = 1;i <= n; ++i){
		if(!col[i]){
			vector<int> path;
			auto res = find_cycle(i, path);
			if(res.size()){
				ans = reduce_cycle(res)							;
				break;
			}
		}
	}
	if(ans.size()){
		cout << ans.size() << '\n';
		for(int a:ans){
			cout << a << '\n';
		}
	}
	else{
		cout << -1 << '\n';
	}
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[105][10];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w,k; cin>>h>>w>>k;
  k--;
  dp[0][0]=1;
  rep(i,h){
    rep(j,w){
      for(ll bit=0; bit<(1<<(w-1)); bit++){
        bool ok=true;
        rep(ki,w-2){
          if(bit>>ki&1 && bit>>(ki+1)&1){
            ok=false;
            break;
          }
        }
        if(!ok) continue;
        ll nj=j;
        if(bit>>j&1) nj=j+1;
        else if(j>0 && bit>>(j-1)&1) nj=j-1;
        dp[i+1][nj]+=dp[i][j];
        dp[i+1][nj]%=MOD;
      }
    }
  }
  cout<<dp[h][k]<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N, Q;
long long A[MAXN], d[MAXN], t[MAXN];
long long ans, tot;

int main() {
	register int i; long long x;
	scanf("%d%d", &N, &Q); A[++tot] = N;
	for(i = 1; i <= Q; ++i) {
		scanf("%lld", &x);
		while(tot && x <= A[tot]) --tot;
		A[++tot] = x;
	}
	for(t[tot] = 1, i = tot; i; --i) {
		long long tmp = A[i], j = upper_bound(A + 1, A + i, tmp) - A - 1;
		for(; j; j = upper_bound(A, A + j, tmp) - A - 1) t[j] += (tmp / A[j]) * t[i], tmp %= A[j];
		d[1] += t[i], d[tmp + 1] -= t[i];
	}
	for(i = 1; i <= N; ++i)
		printf("%lld\n", ans += d[i]);
	return 0;
}

Measured memory_bytes: 3968
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		if (N == 1) {
			System.out.println("Hello World");
		} else {
			System.out.println(sc.nextInt() + sc.nextInt());
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21076
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
    unsigned N;
    scanf("%u", &N);
    pair<unsigned, unsigned> work[N];
    for (size_t i = 0; i < N; i++){
        scanf("%u %u", &work[i].second, &work[i].first);
    }
    sort(work, work + N, greater<pair<unsigned, unsigned> >());
    unsigned now = work[0].first;
    for (size_t i = 0; i < N; i++){
        if(min(now, work[i].first) < work[i].second){
            printf("No\n");
            return 0;
        }
        now = min(now, work[i].first) - work[i].second;
    }
    printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long x = Math.abs(sc.nextLong());
        long k = sc.nextLong();
        long d = sc.nextLong();
        long chk = x/d;
        if(chk > k){
            pw.println(x-(d*k));
        }else if(chk == k){
            pw.println(x%d);
        }else{
            if((k-chk) % 2 == 0){
                pw.println(x%d);
            }else{
                pw.println(d-x%d);
            }
        }
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25424
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vc = vector<char>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll mod = 1000000007;

int main(){
    ll N, M;
    cin >> N >> M;
    vvll f(N+1, vll(0));
    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        f[a].emplace_back(b); f[b].emplace_back(a);
    }
    bool m = false;
    for(auto x: f[1]){
        if(x == N){m = true;}
    }
    if(m == true){cout << "POSSIBLE";}
    else{
        bool n = false;
        for(auto x:f[1]){
            for(auto y:f[x]){
                if(y == N){
                    n = true;
                }
            }
        }
        if(n == true){cout << "POSSIBLE";}
        else{
            cout << "IMPOSSIBLE";
        }
    }
}

Measured memory_bytes: 12776
import sys
input = sys.stdin.readline
from collections import Counter, deque

INF = float('inf')


def main():
    A = int(input())
    B = int(input())

    if A + B == 3:
        print(3)
    elif A + B == 4:
        print(2)
    else:
        print(1)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
#include <cstdlib>

using namespace std;

void solve(){
  int n, m; cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    h[0]--;
    bool f = false;
    for (int i = 1; i < n; i++) {
        if (h[i - 1] <= h[i] - 1) h[i]--;
        if (h[i - 1] > h[i]) f = true;
    }
    cout << (f ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int a,b,c;
  bool flag=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a==5||a==7){
    if(b==5||b==7){
      if(c==5||c==7){
        if(a+b+c==17){
          flag=1;
        }
      }
    }
  }
  if(flag==1) printf("YES\n");
  else printf("NO\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define _ 0
using namespace std;
const int maxn = 1e6 + 5;

int main(){
	int ans = 0;
	int n,t;cin >> n >> t;
	int vis = 0;
	cin >> vis;
	for(int i = 2, tmp = 0; i <= n; i++){
		cin >> tmp;
		if(tmp >= vis + t) ans += t, vis = tmp;
		else if(tmp < vis + t) ans += tmp - vis, vis = tmp;
	}
	ans += t;
	cout << ans << endl;
	return 0^_^0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  for (let i = 0; i < lines.length; i++) {
    let n = lines[i];
    if (n === "0") break;
    console.log(
      n
        .split("")
        .map(Number)
        .reduce((a, b) => a + b)
    );
  }
});



Measured memory_bytes: 18164
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

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

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    ll X,K,D; cin >> X >> K >> D;

    X = abs(X);

    ll rem = min(K,X/D);
    K -= rem;
    X -= rem*D;

    if (K&1) cout << D-X << "\n";
    else cout << X << "\n";

}	

Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
	int N;
	int count = 0;

	cin >> N;

	for(int i=1; i<=N; i++){
		if(i > 0 && i < 10){
			count++;
		}
		if(i > 99 && i < 1000){
			count++;
		}
		if(i > 9999 && i < 100000){
			count++;
		}
	} 
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int p[110000];
long long sum[110000];
long long Rsum[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	long long now=0;
	for(int i=0;i<a;i++){
		if((a+i)%2==1)now+=p[i];
		sum[i]=now;
	}
	for(int i=a-1;i>=0;i--){
		Rsum[i]=p[i]+Rsum[i+1];
	}
	for(int i=0;i<b;i++){
		int c;scanf("%d",&c);
		long long left=-3;
		long long right=mod*2;
		while(left<right){
			long long M=(left+right)/2;
			int lat=lower_bound(p,p+a,c-(M+1)/2)-p;
			int rat=upper_bound(p,p+a,c+M/2)-p-1;
			int ko=rat-lat+1;
			int ch=a-rat-1;
		//	printf("%lld %d %d\n",M,ko,ch);
			if(ko==ch||ko+1==ch){
				long long ret=Rsum[rat+1];
				if(lat)ret+=sum[lat-1];
				printf("%lld\n",ret);
				break;
			}else if(ko<ch){
				left=M;
			}else{
				right=M;
			}
		}
	}
}

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

int main(){
  vector<int> a(3);
  
  for(int i = 0; i< 3; i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  if(a[0] == a[1]){
    cout << a[2] << endl;
  } else if(a[0] == a[2]){
    cout << a[1] << endl;
  } else {
    cout << a[0] << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n,k,q; cin >> n >> k >> q;
    //vint score(n,k);

    map<int,int> ans;
    rep(i,q){
        int a; cin >> a;
        
        ans[a-1]++;
    }
    rep(i,n){
        yn((k-q+ans[i]>0));
    }

}

Measured memory_bytes: 9904
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    ll ans = 0;
    rep(i, n) {
        if (i == 0) ans++;
        else if (pq.top() > p[i]) ans++;
        pq.push(p[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3956
#include <iostream>
using namespace std;
long long gcd(int a, int b)
{
    if(b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}
int main()
{
    long long a, b, total = 0, c, d;
    cin >> a >> b >> c >> d;
    total += b / c - (a - 1) / c;
    total += b / d - (a - 1) / d;
    long long x = gcd(c, d);
    total -= b / (c * d / x) - (a - 1) / (c * d / x);
    total = b - a + 1 - total;
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3600
import java.io.*;
import java.util.*;

 
public class Main {            
    static StringBuilder out=new StringBuilder();
    static FastReader in=new FastReader();
    public static int[] getIntArray(int n){
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
        }
        return arr;
    }
 
    static int  mod=(int)1e9 +7;
    static int [][]dp;
    
    
    public static void solve(){
        int n=in.nextInt();
        out.append((1000-(n%1000))%1000);
    }

    public static void main(String args[]){
        int t=1;
        while(t-->0){
            solve();
            out.append('\n');
        }
        System.out.println(out);
    }
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class FastReader {
    BufferedReader br;
    StringTokenizer st;
 
    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }
 
    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    int nextInt() {
        return Integer.parseInt(next());
    }
 
    long nextLong() {
        return Long.parseLong(next());
    }
 
    double nextDouble() {
        return Double.parseDouble(next());
    }
 
    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}

class tree{
    int n, t[];
    public tree(int arr[]){
        n=arr.length;
        t=new int[n*4];
        build(arr, 1,0,n-1);
    }
    public int build(int arr[],int i,int l,int r){
        if(l==r){
            t[i]=arr[l];
            return 1;
        }
        int mid=l+(r-l)/2;
        int h=Math.min(build(arr,i*2,l,mid),build(arr,i*2+1,mid+1,r));
        if(h%2==0){
            t[i]=t[i*2] ^ t[i*2 +1 ];
        }else{
            t[i]=t[i*2] | t[i*2 + 1];
        }
        return ++h;
    }
    public int update(int i, int l,int r, int p,int b){
        if(l==r){
            t[i]=b;
            return 1;
        }
        int mid=l+(r-l)/2;
        int h=0;
        if(p>mid){
            h=update(i*2+1,mid+1,r,p,b);
        }else{
            h=update(i*2,l,mid,p,b);
        }
        if(h%2==0){
            t[i]=t[i*2] ^ t[i*2 +1 ];
        }else{
            t[i]=t[i*2] | t[i*2 + 1];
        }
        return ++h;
    }
}

Measured memory_bytes: 32800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    int count=0;
    cin>>a>>b;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3892