akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18
#define ret return

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll dp[111][111111];

int main(){
	int n, w;
	cin >> n >> w;
	for(int i = 1; i <= w; i++)dp[0][i]=-1;
	ll vv, ww;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= w; j++)dp[i][j]=dp[i-1][j];
		cin >> ww >> vv;
		for(int j = ww; j <= w; j++)dp[i][j]=max(dp[i][j],dp[i-1][j-ww]+vv);
	}
	ll ans = -1;
	for(int i = 0; i <= w; i++) ans = max(ans,dp[n][i]);
	cout << ans;
	
	
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int n;
// 頂点-頂点-距離
vector<pair<int, int >> g[100005];
int vis[100005];

void solve(int u, int c) {
  for(int i=0;i<g[u].size();i++){
    auto kv = g[u][i];
    int v = kv.first;
    int w = kv.second;
    if(vis[v])continue;
    if(w%2==0)vis[v]=c;
    else vis[v]=(3-c);
    solve(v, vis[v]);
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  cin>>n;
  for(int i=0;i<n-1;i++){
    int u,v,w;
    cin>>u>>v>>w;
    u--;v--;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  vis[0]=1;
  solve(0, 1);
  for(int i=0;i<n;i++)cout<<(vis[i]-1)<<endl;

  return 0;
}


Measured memory_bytes: 8448
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>a;
     double x;
     cin>>x;
     m=round(x*100);
     p=(a*m)/100;
     cout<<p<<endl;


     return EXIT_SUCCESS;
}





Measured memory_bytes: 3688
import math

D, G = map(int, input().split())
ans = 10**7
problems = [tuple(map(int, input().split())) for _ in range(D)]
for num in range(2**D):
  solve = 0
  point = 0
  last = -1
  for i in range(D):
    if num>>i&1:
      point += problems[i][1] + (i+1)*100*problems[i][0]
      solve += problems[i][0]
    else:
      last = i
  if last == -1:
    ans = min(ans, solve)
  else:
    rest = G - point
    if rest <= 0:
      ans = min(ans, solve)
    else:
      if rest <= (last+1)*100*problems[last][0]:
        ans = min(ans, solve+math.ceil(rest/((last+1)*100)))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define EB emplace_back
#define M(col) s[col].front()

typedef long long ll;
typedef std::vector <int> vector;
const int N = 200054, mod = 1000000007, INF = 0x3f3f3f3f;

int n, S, D;
int fact[N], finv[N];
vector s[N];

inline void down(int &x, const int y) {x > y ? x = y : 0;}
ll PowerMod(ll a, int n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

void init(int n) {
	int i;
	for (*fact = i = 1; i <= n; ++i) fact[i] = (ll)fact[i - 1] * i % mod;
	finv[n] = PowerMod(fact[n], mod - 2);
	for (i = n; i; --i) finv[i - 1] = (ll)finv[i] * i % mod;
}

int main() {
	int i, c, m = 0, v, min = INF, sec = INF; ll ans = 1;
	scanf("%d%d%d", &n, &S, &D), init(n);
	for (i = 0; i < n; ++i) scanf("%d%d", &c, &v), s[c].EB(v);
	for (i = 1; i <= n; ++i) if (!s[i].empty()) {
		std::iter_swap(s[i].begin(), std::min_element(s[i].begin(), s[i].end()));
		if (M(i) < min) sec = min, min = M(i);
		else down(sec, M(i));
	}
	for (i = 1; i <= n; ++i) if (!s[i].empty() && M(i) + min <= D) {
		c = 0, v = (M(i) == min ? sec : min);
		for (int u : s[i]) c += u + M(i) <= S || u + v <= D;
		m += c, ans = ans * finv[c] % mod;
	}
	printf("%d\n", int(ans * fact[m] % mod));
	return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18;



signed main(){
	string s;
	cin>>s;
	vector<int>v;
	int ans=0;
	vector<int>add(500050,0);
	REP(i,500049)add[i+1]+=add[i]+i+1;
	int now=0;
	while(now<s.size()){
		int cnt=0;
		while(now<s.size()&&s[now]=='<'){
			cnt++;
			now++;
		}
		v.push_back(cnt);
		cnt=0;
		while(now<s.size()&&s[now]=='>'){
			cnt++;
			now++;
		}
		v.push_back(cnt);
	}
	REP(i,v.size()){
		int ma=max(v[i],v[i+1]);
		int mi=min(v[i],v[i+1]);
		if(mi)mi--;
		ans+=add[ma]+add[mi];
		i++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  for (int i = 1;; i++){
    cin >> x;
    if (x == 0){
      return 0;
    }
    cout << "Case " << i << ": " << x << '\n';
  }
  return 0;
}


Measured memory_bytes: 3004
#include<iostream>
#include<set>
#include<string>
#include<vector>
#define MOD 1000000007ULL
#define MAXN 300100
using namespace std;

typedef unsigned long long ull;

//Rolling Hash
set<ull> hash;
ull acc_h[MAXN]; //hash value for interval [0,i]
ull power[MAXN];   //M power of i

void init_roll(string s){
  acc_h[0] = 0;
  power[0] = 1;
  for(int i=1;i<=s.size();i++){
    power[i] = power[i-1] * MOD;
    acc_h[i] = acc_h[i-1] * MOD + s[i-1];
  }
}

ull Rolling_Hash(string s,int l,int r){
  return acc_h[r] - acc_h[l] * power[r-l];
}

int main(){
  int n,m;
  string str,q;
  int l=0,r=1;
  set<ull> ans;

  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  cin >> str;

  init_roll(str);

  while(m--){
    cin >> q;
    if(q[0] == 'R'){
      if(q[1] == '+')r++;
      else r--;
    }else{
      if(q[1] == '+')l++;
      else l--;
    }
    ans.insert(Rolling_Hash(str,l,r));
  }
  cout << ans.size() << endl;
}

Measured memory_bytes: 20012
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gen(ll n)
{
    string s;
    while(n)
    {
        s = (char)(n % 10 + '0') + s;
        n /= 10;
    }
    ll ind = -1;
    for(ll i = s.size() - 1; i > 0; i--)
    {
        if(s[i] == '9')
            continue;
        else
        {
            if(abs((s[i] + 1 - '0') % 10 + '0' - s[i - 1]) <= 1)
            {
                s[i] = (char)(s[i] + 1);
                ind = i + 1;
                break;
            }
        }
    }
    if(ind == -1)
    {
        s = (s[0] == '9' ? "10" + s.substr(1) : (char)(s[0] + 1) + s.substr(1)), ind = 1;
        // cout << s << "is " << endl;
    }
    for(ll i = ind; i < s.size(); i++)
    {
        ll j;
        for(j = 0; j < 10; j++)
            if(abs(j + '0' - s[i - 1]) <= 1)
                break;
        // cout << j << ' ';
        s[i] = (char)(j + '0');
    }
    // cout << "done\n";
    ll ans = 0;
    for(ll i = s.size() - 1; i >= 0; i--)
        ans += (s[i] - '0') * pow(10, s.size() - 1 - i);
    // cout << ans << endl;
    return ans;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll k, i;
    cin >> k;
    vll s;
    while(s.size() < k)
    {
        if(s.size() <= 9)
            s.pb(s.size() + 1);
        else
            s.pb(gen(s[s.size() - 1]));
    }
    cout << s[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1400
a = [int(i) for i in input().split()]
if a[0]==a[1]:
    if a[1]==a[2]:
        print('No')
    else:
        print('Yes')
else:
    if a[1]==a[2]:
        print('Yes')
    elif a[0]==a[2]:
        print('Yes')
    else:
        print('No')

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


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String name=br.readLine();
		int num;
		int compare;

		int[] a=new int[2];
		int i=0;

		int tmp;
		int x,y;
		while(true){

			try{

				StringTokenizer st=new StringTokenizer(name," ");
			     while (st.hasMoreTokens()) {
			    	 a[i]=Integer.parseInt(st.nextToken());
			    	 i++;
			     }i=0;

			     if (a[0] > a[1]) {
			            x = a[0];
			            y = a[1];
			        } else {
			            x = a[1];
			            y = a[0];
			        }

			     while((tmp=x%y)!=0){
			    	 tmp=x%y;
			    	 x = y;
			         y = tmp;
			     }

			     System.out.println(y);
				a[0]=0;
				a[1]=0;
				x=0;
				y=0;
				tmp=0;
				name=br.readLine();
			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 24424
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i,n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define sz(x) (int)x.size()


int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vi a(n);
    vi b(n);
    vi c(n-1);
    int ans = 0;
    int x;
    forn(i,n){
        cin >> x;
        x--;
        a[i] =x;
    }
    forn(i,n){
        cin >> b[i];
    }
    forn(i,n-1){
        cin >> c[i];
    }
    ans = b[a[0]];
    for(int i = 1; i < n; i++){
        if(a[i-1] + 1 == a[i]){
            ans += c[a[i] - 1];
        }
        ans+= b[a[i]];
    }
    cout << ans;
    return 0;
}

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

long long cnt;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while ( j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n) {
  for (int h = 1; ;){
    if ( h > n ) break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for (int i = G.size() - 1; i >= 0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  for (int i = G.size() - 1; i >= 0; i--) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) printf("%d\n", A[i]);
  return 0;
}


Measured memory_bytes: 7196
N = int(input())
A = list(map(int,input().split()))
C = [0 for i in range(N+1)]
for a in A:
	C[a] += 1

def f(n):
	return (n*(n-1)) // 2

s = sum([f(c) for c in C])
for i in range(N):
	a = A[i]
	c = C[a]
	print(s - f(c) + f(c - 1))


Measured memory_bytes: 89280
S = input()
N = len(S)
V = []
for i in range(N):
    V.append(int(S[i]))

A = []
B = []
for i in range(N):
    if i%2 == 0:
        A.append(0)
        B.append(1)
    else:
        A.append(1)
        B.append(0)

def count_dif(X,Y):
    p = 0
    for i in range(len(X)):
        if X[i] != Y[i]:
            p += 1
    return(p)

print(min(count_dif(V,A), count_dif(V,B)))

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

namespace AtCoder.BC081
{
    public class B
    {
        public static void Main()
        {
            Console.ReadLine();
            var c = 0;
            var nums = Console.ReadLine().Split(" ").Select(n => int.Parse(n)).ToArray();

            while (nums.All(n => n % 2 == 0))
            {
                c++;
                for (int i = 0; i < nums.Length; i++)
                {
                    nums[i] /= 2;
                }
            }
            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 28556
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        FastScannerB fs = new FastScannerB();
        PrintWriter out = new PrintWriter(System.out);

        int n = fs.nextInt(), m = fs.nextInt();
        char[][] a = new char[n][n];
        for(int i = 0; i < n; i++) a[i] = fs.nextCharArray();
        char[][] b = new char[m][m];
        for(int i = 0; i < m; i++) b[i] = fs.nextCharArray();
        StringBuilder bCode = new StringBuilder();
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < m; j++) {
                bCode.append(b[i][j] == '#' ? 1 : 0);
            }
        }
        boolean good = false;
        all:
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if(i + m <= n && j + m <= n) {
                    String abc = getCode(a, i, j, m);
                    if(abc.equals(bCode.toString())) {
                        good = true;
                        break all;
                    }
                }
            }
        }
        out.println(good ? "Yes" : "No");

        out.close();
    }

    static String getCode(char[][] a, int i, int j, int m) {
        StringBuilder res = new StringBuilder();
        int lim = i+m, limj = j + m;
        for(int k = i; k < lim; k++) {
            for(int l = j; l < limj; l++) {
                res.append(a[k][l] == '#' ? 1 : 0);
            }
        }
        return res.toString();
    }
}


class FastScannerB {
    BufferedReader br;
    StringTokenizer st;

    public FastScannerB() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String next() {
        if (st.hasMoreTokens()) return st.nextToken();
        try {
            st = new StringTokenizer(br.readLine());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return st.nextToken();
    }

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

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

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

    public String nextLine() {
        String line = "";
        try {
            line = br.readLine();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return line;
    }

    public Integer[] nextIntegerArray(int n) {
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        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 char[] nextCharArray() {
        return next().toCharArray();
    }
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int a,b;

int main(){
  scanf("%d %d",&a,&b);
  if(a+b>=10){
    printf("error\n");
    return 0;
  }
  printf("%d\n",a+b);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int X; std::cin >> X;
    std::cout << (X >= 30 ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 3632
//コンパイラ最適化用
#pragma GCC optimize("O3")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
	long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long ad, ac, bc, bd;
	ad = a*d;
	ac = a*c;
	bc = b*c;
	bd = b*d;
	long long max[4] = {ad, ac, bc, bd};
	sort(max, max+(sizeof(max)/sizeof(max[0])), greater<>());
	cout << max[0];
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
using ULL=unsigned long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string A, B;
    cin >> A >> B;
    vector<char> S;
    for( int i = 0, j = 0; i <= (int)A.size(); i++, j++ )
    {
        if( i < (int)A.size() ) S.push_back( A[ i ] );
        if( j < (int)B.size() ) S.push_back( B[ j ] );
    }
    for( auto &x : S )
    {
        cout << x;
    }
    cout << endl;
    return 0;
}

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

const int maxn = 2e5 + 10;
int n;
int h[maxn], a[maxn];
long long bit[maxn];
long long dp[maxn];
long long val[maxn];


struct SegNode {
	int left, right;
	long long max;
 
	int mid() {
		return (left + right) >> 1;
	}
};
 
struct SegTree {
 
	SegNode tree[maxn*5];
 
	void pushUp(int idx) {
		tree[idx].max = max(tree[idx<<1].max, tree[idx<<1|1].max);
	}
 
	void build(int left, int right, int idx) {
		tree[idx].left = left;
		tree[idx].right = right;
		tree[idx].max = 0;
		if (left == right) {
			tree[idx].max = val[left];
			return ;
		}
		int mid = tree[idx].mid();
		build(left, mid, idx<<1);
		build(mid+1, right, idx<<1|1);
		pushUp(idx);
	}
 
	void update(int left, int right, int idx, long long value) {
		if (left == tree[idx].left && right == tree[idx].right) {
			tree[idx].max = value;
			return ;
		}
		int mid = tree[idx].mid();
		if (right <= mid)
			update(left, right, idx<<1, value);
		else if (left > mid)
			update(left, right, idx<<1|1, value);
		else {
			update(left, mid, idx<<1, value);
			update(mid+1, right, idx<<1|1, value);
		}
		pushUp(idx);
	}
 
	long long query(int left, int right, int idx) {
		if (tree[idx].left == left && tree[idx].right == right)
			return tree[idx].max;
		int mid = tree[idx].mid();
		if (right <= mid) 
			return query(left, right, idx<<1);
		else if (left > mid) 
			return query(left, right, idx<<1|1);
		return max(query(left, mid, idx<<1), query(mid+1, right, idx<<1|1));
	}
 
};
SegTree tree;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &h[i]);
        val[i] = 0;
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }
    tree.build(1, n, 1);
    long long result = 0;
    for (int i = 1; i <= n; ++i) {
        dp[i] = a[i] + tree.query(1, max(1, h[i] - 1), 1);
        // printf("%d %lld %lld\n", h[i], tree.query(1, h[i], 1), dp[i]);
        tree.update(h[i], h[i], 1, dp[i]);
        result = max(result, dp[i]);
    }
    printf("%lld\n", result);
}

Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,A,B,C,l[10];
int ans=2e9+7;
void dfs(int i,int a,int b,int c,int mp)
{
	if(i==n+1)
	{
		if(!a||!b||!c)return;
		else
		{
			ans=min(ans,abs(a-A)+abs(b-B)+abs(c-C)+mp);
			return;
		}
	}
	dfs(i+1,a,b,c,mp);
	dfs(i+1,a+l[i],b,c,mp+(a==0?0:10));
	dfs(i+1,a,b+l[i],c,mp+(b==0?0:10));
	dfs(i+1,a,b,c+l[i],mp+(c==0?0:10));
}
int main()
{
	cin>>n>>A>>B>>C;
	for(int i=1;i<=n;i++)cin>>l[i];
	dfs(1,0,0,0,0);
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MAX = 510000;
const int MOD = 1e9+7;

int main(){
  ll n;
  cin >> n;
  for(double i=0;i<=n;i++){
    if(floor(i*1.08)==n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main() {
	ll n, v, c = 1;
	cin >> n;
	ll ans = 1, M = 0;
	vector<int> d(n);
	cin >> v;
	if (v != 0) {
		puts("0");
		return 0;
	}
	rep(i, 1, n)cin >> v, d[v]++, M = max(M, v);
	if (d[0]) {
		puts("0"); return 0;
	}
	d[0]++;
	rep(i, 1, M + 1) {
		ans *= mpower(d[i - 1], d[i]);
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

int n,m;

int kitaichi(pair<int,int>* pd, int size){
    int sum = 0;
    for(int i=0;i<n;i++){
        sum += pd[i].first*pd[i].second;
    }
    return sum;
}

int solve(){
    pair<int,int> pd[10000];
    for(int i=0;i<n;i++){
        int d,p; cin >> d >> p;
        pd[i] = make_pair(p,d);
    }
    sort(pd,pd+n);
    reverse(pd,pd+n);
    int e = kitaichi(pd,n);
    int current = 0;
    while(m > 0 && current <= n-1){
        if(pd[current].second < m){
            m -= pd[current].second;
            e -= pd[current].second*pd[current].first;
            current++;
        }
        else{
            e -= m*pd[current].first;
            break;
        }
    }
    if(current > n-1)
        e = 0;
    return e;
}

int main(){
    while(cin >> n >> m && n!=0){
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1240
#include<stdio.h>
int main(){
  int i,j,k;
  int d;	//365
  int c[26];
  int score[9490];
  int t[365] = {0};
  int day1[26] = {0};
  double x = 0.36787944117;
  int tmp1=-999999,tmp2=-999999;
  int tmpi = 0;
  
  scanf("%d",&d);
  for(i=0;i<26;i++){
      scanf("%d ",&c[i]);
  }
  for(i=0;i<d*26;i++){
      scanf("%d ",&score[i]);
  }
  //st
  
  for(i=0;i<26;i++){
    if(c[i]>tmp1){
     tmp1 = c[i];
    }
    tmpi = i;
  }
  tmp1 = -999999;/*
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      if(score[i*26+j]-c[j]*(1+day1[j])>tmp1){
       	t[i] = j;
      }
    }
  }
  */
  //en
  int sp[26]={0};
  int pp=-999999;
  int pp2 = 0;
  for(i=0;i<d;i++){
    pp2=0;
    for(k=0;k<26;k++){  
    if(sp[k]==0&&score[k]>pp){	
      pp=score[k];
      pp2 = k;
    }}
    pp=-999999;
    sp[pp2]=1;
    printf("%d\n",pp2+1);
    //printf("%d\n",(tmpi+i)%26+1);
    if(i%26==25){
    	for(k=0;k<26;k++){
         sp[k]=0; 
        }
    }  
  }
 return 0; 
}






Measured memory_bytes: 2184
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	int ab[6];
	FOR(6) {
		cin >> ab[i];
	}
	int one=count(&ab[0], &ab[6], 1);
	int two = count(&ab[0], &ab[6], 2);
	int thr = count(&ab[0], &ab[6], 3);
	int fou = count(&ab[0], &ab[6], 4);
	if (one != 3 && two != 3 && thr != 3 && fou != 3) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
const ll INF = 1LL << 60;

int main(){
	int n;
	cin >> n;
	int a[110], b[110];
	rep(i, n){
		cin >> b[i];
	}
	int ans = 0;
	a[0] = b[0];
	a[n-1] = b[n-2];
	for(int i = 1; i <= n-2; ++i){
		a[i] = min(b[i], b[i-1]);
	}
	rep(i, n){
		ans += a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
        

def cntNum(n, x, y):
    return n - (n//x+n//y-n*gcd(x, y)//(x*y))


if A%C != 0 and A%D:
    print(cntNum(B, C, D) - cntNum(A, C, D) + 1)
else:
    print(cntNum(B, C, D) - cntNum(A, C, D))


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <functional>

using namespace std;

typedef pair<int, string> P;

int main() {
	int n, q;
	string name;
	int year;
	bool hantei = false;
	P kari;
	priority_queue< P, vector<P>, greater<P> > pq;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> year >> name;
		pq.push(P(year, name));
	}
	kari = pq.top();
	pq.pop();
	if (kari.first > q) {
		cout << "kogakubu10gokan" << endl;
		hantei = true;
	}
	while (!pq.empty()) {
		if (hantei == true) {
			break;
		}
		P p = pq.top();
		pq.pop();
		if (p.first > q) {
			cout << kari.second << endl;
			hantei = true;
			break;
		} else {
			kari = p;
		}
	}
	if (hantei == false) {
		cout << kari.second << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
from collections import defaultdict
import math


def make_prime_list(num):
    if num < 2:
        return []
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0
    num_sqrt = math.sqrt(num)
    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break
        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0
    return [prime for prime in prime_list if prime != 0]


def prime_factorization(num):
    if num <= 1:
        return {}
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)
        dict_counter = defaultdict(int)
        for prime in prime_list:
            while num % prime == 0:
                dict_counter[prime] += 1
                num //= prime
        if num != 1:
            dict_counter[num] += 1
        dict_counter = dict(dict_counter)
        return dict_counter


a, b = map(int, input().split())
buf = a
while buf!=0:
    a,b=b,buf
    buf=a%b
print(len(prime_factorization(b))+1)

Measured memory_bytes: 43644
#include <stdio.h>

int motomeru(int s, int d) {
	int i;
	int answer = 0;
	while (s < d) {
		int limit = -1;
		int umetai = -1;
		for (i = 0; (1 << i) <= d; i++) {
			int delta = 1 << i;
			if ((s & delta) && limit < 0) limit = delta;
			if (!(s & delta) && (d & delta)) umetai = delta;
		}
		s += limit > 0 && limit < umetai ? limit : umetai;
		answer++;
	}
	return answer;
}

int main(void) {
	int N;
	int s[128], d[128];
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &s[i], &d[i]) != 2) return 1;
	}
	for (i = 0; i < N; i++) {
		if (0 <= s[i]) printf("%d\n", motomeru(s[i], d[i]));
		else if (0 <= d[i]) printf("%d\n", motomeru(0, -s[i]) + motomeru(0, d[i]));
		else printf("%d\n", motomeru(-d[i], -s[i]));
	}
	return 0;
}



Measured memory_bytes: 2144
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    a: usize,
    b: usize,
    m: usize,
    aa: [i64; a],
    bb: [i64; b],
    ti: [(usize1, usize1, i64); m],
  }
  let mut ans = 1i64 << 60;
  for &(ai, bi, c) in &ti {
    ans = cmp::min(ans, aa[ai] + bb[bi] - c);
  }
  let am = aa.iter().min().unwrap();
  let bm = bb.iter().min().unwrap();
  ans = cmp::min(ans, am + bm);

  puts!("{}\n", ans);
}


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

using namespace std;

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

int a[110001];

int main(){
	for(int i=1;i<=3;i++){
		a[i]=read(); 
	} 
	sort(a+1,a+4);
	cout<<a[3]*10+a[2]+a[1];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
ll n;
ld a[3005];
ld dp[3005][3005];
ld solve(ll index,ll cnt)
{
    if(index==n)
    {
        if(cnt>(n/2))   return 1.00000;
        return 0.00000;
    }
    if(dp[index][cnt]!=-1)   return dp[index][cnt];
    ld ans = 0;
    ans += a[index]*solve(index+1,cnt+1);
    ans += (1-a[index])*solve(index+1,cnt);
    return dp[index][cnt] = ans;
}
int main()
{
    cin >> n;
    for(ll i=0;i<n;i++)          cin >> a[i];
   for(ll i=0;i<3005;i++)   for(ll j=0;j<3005;j++)   dp[i][j] = -1;
    ld ans = solve(0,0);
    cout<<setprecision(12)<<ans;
}

Measured memory_bytes: 141696
/**
 * @Author:      G_bg
 * @DateTime:    2019-08-04 19:57:40
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b),0) << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
int main()
{
	int a, b, n, x, y, dp[20][20], i, j;

	cin >> a >> b;
	while(a > 0 && b > 0){
		for(i = 0; i < 20; i++){
			for(j = 0; j < 20; j++){
				dp[i][j] = 0;
			}
		}
		dp[1][1] = 1;
		cin >> n;
		for(i = 0; i < n; i++){
			cin >> x >> y;
			dp[y][x] = INF;
		}
		for(i = 1; i <= b; i++){
			for(j = 1; j <= a; j++){
				if(dp[i][j] == INF)continue;
				if(dp[i + 1][j] != INF){
					dp[i + 1][j] += dp[i][j];
				}
				if(dp[i][j + 1] != INF){
					dp[i][j + 1] += dp[i][j];
				}
			}
		}
		cout << dp[b][a] << endl;;

		cin >> a >> b;
	}
 
	return 0;
}

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

int main(){
	
	int n;
	
	cin >> n;
	
	int d[n];
	
	for (int i = 0; i < n; i++){
		
		cin >> d[i];
		
	}
	
	int ans = 0;
	
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			ans += d[j]*d[i];
		}
	}
	
	cout << ans;
	
	
}


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

int main()
{
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  
  ll ans = a * c;
  if(a * d > ans){
    ans = a * d;
  }
  if(b*c > ans){
    ans = b*c;
  }
  if(b*d > ans){
    ans = b*d;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        v[i]={b,a};
    }

    sort(all(v));
    int pre=0;
    rep(i,n){
        if(pre>v[i].first){
            cout<<"No"<<endl;
            return 0;
        }
        pre+=v[i].second;
        if(pre>v[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;
    int t[n];
    int sum = 0;
    rep(i, n) {
        cin >> t[i];
        sum += t[i];  // 総和
    }
    int m;  //１本だけ
    cin >> m;
    int p[m];
    int x[m];
    rep(i, m) { cin >> p[i] >> x[i]; }  // p問題がx秒

    // 処理
    int ans[m] = {};
    rep(i, m) {
        // cout << t[p[i] - 1] << " " << x[i] << endl;
        ans[i] = sum - t[p[i] - 1] + x[i];
    }

    // 出力
    rep(i, m) { cout << ans[i] << endl; }

    return 0;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;


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


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool c[26] = {};
	for (auto&& si : s)
	{
		if (c[si-'a'])
		{
			cout << "no" << endl;
			return 0;
		}
		c[si-'a'] = true;
	}
	cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class  Main{
	public static void main(String args[]){
	  Scanner sc = new Scanner(System.in);
  	  int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int q = Integer.parseInt(sc.next());
      int tmp;
      
      int p[] = new int[n];
      int re[] = new int[n];
      
      for(int i=0;i<n;i++) p[i] = 0;
      
      for(int i=0;i<q;i++){
        tmp = Integer.parseInt(sc.next());
        p[tmp-1]++;
      }
      for(int i=0;i<n;i++){
        re[i] = q-p[i];
      }
      for(int i=0;i<n;i++){
        if(re[i] < k) System.out.println("Yes");
        else System.out.println("No");
      }
	}
}

Measured memory_bytes: 58272
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    // 標準入力
    int N, K;
    cin >> N >> K;
    int ans=N-K+1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n, h[40];
	int i, j, k;
	int ans = 1;
	int flg = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	for (i = 1; i < n; i++) {
		flg = 0;
		for (j = 0; j < i; j++) {
			if (!(h[j] <= h[i])) {
				flg = 1;
				break;
			}
		}
		if (flg == 0) {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
  char a,b,c;
  int i=0;
  scanf("%c%c%c",&a,&b,&c);
  if(a==b && b==c){
    i=1;
  }if(i==1){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(n):
  l+=[i+1]*a[i]
ans=[[0]*w for i in range(h)]
idx=0
for i in range(h):
  if i%2==0:
    for j in range(w):
      ans[i][j]=l[idx]
      idx+=1
  else:
    for j in range(w)[::-1]:
      ans[i][j]=l[idx]
      idx+=1
for i in range(h):
  print(*ans[i])

Measured memory_bytes: 3956
/*
 *  Created on: 21 / 6 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

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

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        char a; cin >> a;
    if (a >= 'a' && a <= 'z')
    {
        cout << 'a';
    }
    else
    {
        cout << 'A';
    }
}

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

class SparseTable {
public:
	int size_ = 1;
	vector<int> vec[19];
	vector<int> eval;

	void init(int sz) {
		while (size_ <= sz) size_ *= 2;
		for (int i = 0; i <= 18; i++) vec[i].resize(size_, 0);
		eval.resize(1 << 19);
		for (int i = 0; i <= 18; i++) {
			for (int j = (1 << i); j < (2 << i); j++) eval[j] = i;
		}
	}
	void update(int pos, int x) {
		vec[0][pos] = x;
	}
	void initq() {
		for (int i = 0; i < 18; i++) {
			for (int j = 0; j < size_; j++) {
				int v1 = j + (1 << i);
				vec[i + 1][j] = vec[i][j];
				if (v1 < size_) vec[i + 1][j] = max(vec[i + 1][j], vec[i][v1]);
			}
		}
	}
	int query(int cl, int cr) {
		// 閉区間 [cl, cr)
		int haba = cr - cl;
		int ev = eval[haba];
		return max(vec[ev][cl], vec[ev][cr - (1 << ev)]);
	}
};

class BIT {
public:
	int size_ = 1;
	vector<long long> bit;

	void init(int sz) {
		size_ = sz + 2;
		bit.resize(size_ + 2, 0);
	}
	void add(int pos, long long x) {
		pos++;
		while (pos <= size_) {
			bit[pos] += x;
			pos += (pos & -pos);
		}
	}
	long long sum(int pos) {
		long long s = 0; pos++;
		while (pos >= 1) {
			s += bit[pos];
			pos -= (pos & -pos);
		}
		return s;
	}
};

int N;
long long dp[1 << 18], mod = 998244353;
pair<int, int> X[1 << 18];

SparseTable Y;
BIT Z;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i].first >> X[i].second;
	sort(X + 1, X + N + 1);

	Y.init(N + 2);
	Y.update(0, 2100000000);
	for (int i = 1; i <= N; i++) Y.update(i, X[i].first + X[i].second);
	Y.initq();

	Z.init(N + 2);
	dp[0] = 1; Z.add(0, 1);

	for (int i = 1; i <= N; i++) {
		int cl = 0, cr = i, cm, maxn = -1;
		for (int j = 0; j < 22; j++) {
			cm = (cl + cr) / 2;
			int val = Y.query(cm, i);
			if (val > X[i].first) { maxn = max(maxn, cm); cl = cm; }
			else { cr = cm; }
		}
		dp[i] = (Z.sum(i - 1) - Z.sum(maxn - 1) + mod) % mod;
		Z.add(i, dp[i]);
	}

	long long ans = 0;
	for (int i = 0; i <= N; i++) { ans += dp[i]; ans %= mod; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i = x; i < (int)(n); i++)
#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    int n;
    double d;
    cin >> n >> d;
    vector<double> x(n), y(n), dis(n);
    int cnt=0;
    rep(i, 0, n) {
        cin >> x[i];
        cin >> y[i];
        dis[i]=sqrt(x[i]*x[i]+y[i]*y[i]);
        if(dis[i]<=d) cnt++;
    }
    
    cout << cnt;

    return 0;
}

Measured memory_bytes: 8068
class Deck

  def initialize(n)
    @cards = 1.upto(n).to_a
  end 

  def cut(r)
    r.times do
      p,c = gets.split(" ").map(&:to_i)
      @cards.concat(fetch_cards(p,c))
    end 
    @cards
  end 

  def fetch_cards(p,c)
    bundle = @cards[-p-c+1..-p]
    @cards.slice!(-p-c+1..-p)
    bundle
  end 

end

loop do
  input = gets.chomp
  break if input == "0 0"
  n,r = input.split(" ").map(&:to_i)
  deck = Deck.new(n)
  puts deck.cut(r).last
end

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n);
  rep(i, n + 1) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll ans = 0;
  rep(i, n) {
    if (b[i] > a[i]) {
      ans += a[i];
      b[i] -= a[i];
      if (b[i] > a[i + 1]) {
        ans += a[i + 1];
        a[i + 1] = 0;
      } else {
        ans += b[i];
        a[i + 1] -= b[i];
      }
    } else {
      ans += b[i];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (m (read))
         (lights (make-array m :element-type 'uint32))
         (ps (make-array m :element-type 'uint32)))
    (dotimes (i m)
      (let ((flag 0))
        (dotimes (j (read))
          (let ((s (- (read) 1)))
            (setf (ldb (byte 1 s) flag) 1)))
        (setf (aref lights i) flag)))
    (dotimes (i m) (setf (aref ps i) (read)))
    (println
     (loop for ons below (expt 2 n)
           count (every (lambda (l p) (= p (mod (logcount (logand l ons)) 2)))
                        lights
                        ps)))))

#-swank(main)


Measured memory_bytes: 22244