akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int n, m, k, ans;
pair<int, int> a[100000];

vector<int> rmq;

void _update(int i) {
    rmq[i] = max(rmq[i * 2 + 1], rmq[i * 2 + 2]);
    if (i > 0)
        _update((i - 1) / 2);
}

void update(int i, int v) {
    rmq[i] = v;
    _update((i - 1) / 2);
}

void init() {
    k = 1;
    while (k < n)
        k *= 2;
    rmq.resize(k * 2);
    for (int i = 0; i < n; ++i) {
        update(i + k - 1, a[i].second);
    }
    rmq[k * 2 - 1] = 0;
}

int getmax(int i, int L, int R, int l, int r) {
    if (L <= l && r <= R)
        return i;
    if (l >= R || r <= l)
        return k * 2 - 1;
    int i1 = getmax(i * 2 + 1, L, R, l, (l + r) / 2);
    int i2 = getmax(i * 2 + 2, L, R, (l + r) / 2, r);
    if (rmq[i1] > rmq[i2])
        return i1;
    return i2;
}

int getsuf(int i, int v) {
    while (i < k - 1) {
        if (rmq[i * 2 + 1] == v)
            i = i * 2 + 1;
        else if (rmq[i * 2 + 2] == v)
            i = i * 2 + 2;
    }
    return i;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n);
    init();
    for (int i = 1; i <= m; ++i) {
        int r = upper_bound(a, a + n, make_pair(i, INF)) - a;
        int maxi = getmax(0, 0, r, 0, k);
        if (rmq[maxi] > 0) {
            ans += rmq[maxi];
            update(getsuf(maxi, rmq[maxi]), 0);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll loop = N / (A+B);
    N -= loop * (A+B);

    cout << loop*A + min(A, N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    Vi num(10050,0);
    repi(x,1,103){
        repi(y,1,103){
            repi(z,1,103){
                if(x*x+y*y+z*z+x*y+y*z+z*x<10020){
                    num[x*x+y*y+z*z+x*y+y*z+z*x]++;
                }
            }
        }
    }
    ll sum=0;
    repi(i,1,n+1){
        print(num[i]);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int nisin = 0;
  string s = to_string(N);
  for (int i = 0; i < s.size(); i++)
  {
    int a = s[i] - '0';
    nisin += a;
  }
  if (N % nisin)
    cout << "No" << endl;

  else
    cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n;
	int k,ans;
	ans =0;
	cin >>n;
	vector<int> v;
	for(int i=0;i<2*n;i++){
		cin >> k;
		v.push_back(k);
	}
	sort(v.begin(),v.end());
	for(int j=0;j<n;j++){
		ans +=v[2*j];
	}
	cout << ans << endl;
}

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

const int MAX_N = 100005;

typedef long long i64;

int A[MAX_N];
i64 sum1[MAX_N], sum2[MAX_N];

void update(int l, int r, int st) {
  sum2[l]++, sum2[r + 1]--;
  sum1[l] += st, sum1[r + 1] -= r - l + 1 + st;
}

int main() {
  int N, M;
  
  scanf("%d%d", &N, &M);

  for (int i = 1; i <= N; ++i)
    scanf("%d", &A[i]);

  i64 result = 0;
  for (int i = 1; i < N; ++i) {
    int d = A[i + 1] - A[i];
    if (d < 0) d += M;
    
    result += d;
    if (A[i + 1] > A[i]) {
      if (A[i] + 2 <= A[i + 1]) update(A[i] + 2, A[i + 1], 0);
    } else {
      if (A[i] + 2 <= M) update(A[i] + 2, M, 0);
      update(1, A[i + 1], M - A[i] - 1);
    }
  }

  i64 mx = 0;
  for (int i = 1; i <= M; ++i) sum2[i] += sum2[i - 1];
  for (int i = 1; i <= M; ++i) {
    sum1[i] += sum1[i - 1] + sum2[i];
    mx = max(mx, sum1[i]);
  }

  printf("%lld\n", result - mx);
  
  return 0;
}


Measured memory_bytes: 2176
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut a = vec![vec![0; 10]; 10];

    for i in 1..=n {
        let m = i % 10;
        let mut s = i;
        while s > 9 {
            s /= 10;
        }
        a[s][m] += 1;
    }

    let mut ans = 0;
    for i in 0..10 {
        for j in 0..10 {
            ans += a[i][j] * a[j][i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll H, N;
    cin >> H >> N;
    int A[N], B[N];
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
    
    int dp[H];
    for(int j = 0; j < H; j++)
        dp[j] = -1;
    
    dp[0] = 0;
    int ans = inf;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < H; j++){
            if(dp[j] == -1) continue;
            
            if(j + A[i] >= H){
                ans = min(ans, dp[j] + B[i]);
                continue;
            }
            if(dp[j + A[i]] == -1) dp[j + A[i]] = dp[j] + B[i];
            else dp[j + A[i]] = min(dp[j + A[i]], dp[j] + B[i]);
        }
    }

    cout << ans;
    return 0;
}


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++)

int func(int N, int K){
    int ans = 1;
    while(1){
        if(N / K > 0){
            ans++;
            N /= K;
        }else{
            break;
        }
    }
    return ans;
}
int main(){
    int N, K;
    cin >> N >> K;
    cout << func(N, K) << endl;
    return 0;
}

Measured memory_bytes: 3612
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m + f < 30 or m == -1 or f == -1:
        print("F")
    elif m + f >= 80 :
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65 or 30 <= m + f < 50 and r >= 50:
        print("C")
    else :
        print("D")

Measured memory_bytes: 7708
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
    }
 
    int ans,tmp;
    public void input(){
        ArrayList<Integer> li = new ArrayList<Integer>();
        Scanner sc = new Scanner(System.in);
        li.add(sc.nextInt());
        li.add(sc.nextInt());
        li.add(sc.nextInt());
        Collections.sort(li);
        Collections.reverse(li);
        int k = sc.nextInt();
        for(int i = 0; i < k; i++){
            li.set(0, li.get(0) * 2);
        }
        ans = li.get(0) + li.get(1) + li.get(2);
        sc.close();
        System.out.println(ans);
    }
    
}

Measured memory_bytes: 20948
#include <cstdio>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int N_MAX = 100000;

typedef long long ll;

int N, x;
int a[N_MAX];

void solve() {
  ll ans = 0;
  REP(i, N - 1)
  if (a[i] + a[i + 1] > x) {
    int d = a[i] + a[i + 1] - x;
    if (d > a[i + 1]) {
      a[i + 1] = 0;
      a[i] -= d- a[i + 1];
    } else {
      a[i + 1] -= d;
    }
    ans += d;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d", &N, &x);
  REP(i, N) scanf("%d", a + i);
}

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


Measured memory_bytes: 512
<?php
// Your code here!
$N = fgets(STDIN);
$sum =0;
for($i=1; $i <= $N; $i++){
    if($i%3 !=0 && $i%5 !=0 && $i % 15 !=0){
        $sum += $i;
    }
}

echo $sum.PHP_EOL;


Measured memory_bytes: 16104
#include <iostream>
using namespace std;
int main(void){
    int n,a;
    bool flag = false;
    bool loop = true;
    cin >> n;
    a = n;
    
    // ループ回数を決める
    int i;
    i = n % 7;
    int set = (n - i) / 7;
    
    int j;
    for(int i = 0;i <= set; i++){
        // 引いたもの
        j = n - 7*i;
        if(j == 0){
            cout << "Yes";
            flag = true;
            break;
        }
        if(j % 4 == 0){
            
            cout << "Yes";
            flag = true;
            break;
        }
    }
    if(!flag){
        cout << "No";
    }
}


Measured memory_bytes: 888
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<double> v;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  v.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  double ans = v[0];
  for (int i = 1; i < N; i++) {
    ans = (ans + v[i]) / 2.0;
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

struct Combination{
    vector<ll> fac,finv,inv;
    Combination(int mx){init(mx);}
    void init(int mx){
        fac.resize(mx+1);
        finv.resize(mx+1);
        inv.resize(mx+1);
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for(int i=2;i<=mx;i++){
            fac[i]=fac[i-1]*i%MOD;
            inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
            finv[i]=finv[i-1]*inv[i]%MOD;
        }
    }
    ll calc(int n,int k){
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
    }
};

ll dp[3001];

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    pair<int,int> p[n+1];
    for(int i=0;i<n;i++){
        int r,c;
        cin>>r>>c;
        p[i]={r,c};
    }
    p[n]={h,w};
    sort(p,p+n+1);
    Combination comb(200000);
    dp[0]=1;
    for(int i=0;i<n+1;i++){
        int ri=p[i].first;
        int ci=p[i].second;
        dp[i]=comb.calc(ri+ci-2,ri-1);
        for(int j=0;j<i;j++){
            int rj=p[j].first;
            int cj=p[j].second;
            if(rj<=ri&&cj<=ci){
                ll t=comb.calc(ri-rj+ci-cj,ri-rj);
                dp[i]-=(dp[j]*t)%MOD;
            }
        }
        dp[i]=(dp[i]%MOD+MOD)%MOD;
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int N;
    cin >> N;
    int minsum = 1e9;
    for (int i = 1; i < N; i++)
    {
        int j = N - i;
        int ii = i, jj = j;
        int ti = 0, tj = 0;
        rep(k, 6)
        {
            ti += ii % 10;
            tj += jj % 10;
            ii /= 10;
            jj /= 10;
        }
        int sum = ti + tj;
        minsum = min(minsum, sum);
    }
    cout << minsum << endl;
    return 0;
}

Measured memory_bytes: 3568
#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<ld,ld> pd; 

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

#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)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int N, M, total, cnt;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    vi a(N);
    F0R(i, N) {
        cin >> a[i];
        total += a[i];
    }
    
    int threshold = ceil((double)total / (M * 4));
    F0R(i, N) {
        if (a[i] >= threshold) cnt++;
    }
    
    if (cnt >= M) cout << "Yes";
    else cout << "No";
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define GYOU_RETSU_MAX 100
using namespace std;

int main()
{
	int gyouretsu[GYOU_RETSU_MAX][GYOU_RETSU_MAX];
	int bekutoru[GYOU_RETSU_MAX];
	int gyou_beku[GYOU_RETSU_MAX];
	for (int g = 0; g < GYOU_RETSU_MAX; g++)
	{
		for (int r = 0; r < GYOU_RETSU_MAX; r++)
		{
			gyouretsu[g][r] = 0;
			bekutoru[r] = 0;
			gyou_beku[r] = 0;
		}
	}

	int n,m;
	cin >> n >> m;
	
	vector<int> input;

	int z;
	for (int i = 0; i < (n*m) + m; i++)
	{
		cin >> z;
		input.push_back(z);
	}

	int in = 0;
	for (int g = 0; g < n; g++)
	{
		for (int r = 0; r <m ; r++)
		{
			gyouretsu[g][r] = input[in];
			in++;
		}
	}
	
	int beku = 0;
	for (int i = n*m; i < (n*m)+m; i++)
	{
		bekutoru[beku] = input[i];
		beku++;
	}

	int g = 0;
	for (int i = 0; i < n; i++)
	{
		for (int r = 0; r < m; r++)
		{
			gyou_beku[i] = gyou_beku[i] + (gyouretsu[g][r] * bekutoru[r]);
		}
		g = g + 1;
	}

	for (int i = 0; i < n; i++)
	{
		cout << gyou_beku[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3276
N = int(input())

same = [0] * 10
diff = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, N + 1):
  s = str(i)
  if s[0] == s[-1]:
    same[int(s[0])] += 1
  else:
    diff[int(s[0])][int(s[-1])] += 1

answer = 0
for i in range(1, 10):
  answer += same[i] ** 2
for i in range(1, 10):
  for j in range(1, 10):
    answer += diff[i][j] * diff[j][i]

print(answer)

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

int main() {
    int k;
    cin >> k;

    int i = 0;
    int c = 0;
    while (i < k) {
        i++;
        c = c * 10 + 7;
        if (c%k == 0) {
            cout << i << endl;
            return 0;
        }
        c %= k;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3600
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
a = list(map(int, input().split()))

mx = 0
count = 0
for i in a:
    if i >= mx:
        count += 1
        mx = max(i, mx)
print(count)




Measured memory_bytes: 7752
#include <stdio.h>
#include <math.h>
int main(){
    int i,j;
    double s[10001],n,ave,dec;
 
    while(1){
        scanf("%lf",&n);
        if(n==0) break;
        for(s[0]=0,i=1;i<=n;i++){
            scanf("%lf",&s[i]);
            s[0]+=s[i];
        }
        ave=s[0]/n;
        for(dec=0,i=1;i<=n;i++) dec+=(s[i]-ave)*(s[i]-ave);
        printf("%f\n",sqrt(dec/n));
    }
 
    return 0;
}


Measured memory_bytes: 2128
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){

    string S;
    cin >> S;
    int length_new,length;

    //cout << S[0] << endl;
    length = 0;
    length_new = 0;

    char A ='A';
    char C ='C';
    char G ='G';
    char T ='T';

    for(int i=0;i<S.size();i++){
    
        if(S[i]==A || S[i]==C || S[i]==G || S[i]==T){    //==は文字列比較で使わない方が良い。一文字ならchar型で格納してから
            length+=1;

            if(i==S.size()-1){
                if(length_new <=length){
                    length_new=length; }
            }
        }

        else{
            if(length_new <=length){
                length_new=length; }
            
            length = 0;
        }

    }

    cout << length_new << endl;
}

Measured memory_bytes: 256
n = list(map(int, list(input())))

if len(n) == 1:
    print(n[0])
elif n[0] == 9:
    print(max(sum(n), 9 * len(n) - 1))
elif n[1] == 9:
    print(max(sum(n), n[0] + 9 * len(n) - 10))
else:
    print(max(sum(n), n[0] + 9 * len(n) - 10))

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL N, K, Q;
    cin >> N >> K >> Q;
    vector<LL> v(N, K - Q);
    REP(i, Q) {
        LL x;
        cin >> x;
        v[x - 1]++;
    }
    REP(i, N) {
        if(0 < v[i]) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 1408
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] V = new int[N];
    int[] C = new int[N];

    for (int i = 0; i < N; i++) {
      V[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      C[i] = sc.nextInt();
    }

    sc.close();

    int[] R = new int[N];

    for (int i = 0; i < N; i++) {
      R[i] = V[i] - C[i];
    }

    int sum = 0;

    for (int i = 0; i < N; i++) {
      if (0 < R[i]) {
        sum += R[i];
      }
    }

    System.out.println(sum);

  }

}

Measured memory_bytes: 21844
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    s = [2 if i&1 else 1 for i in a]
    ans = 0
    for b in range(1,1<<n):
        res = 1
        c = 0
        for i in range(n):
            if 1&(b>>i):
                res *= s[i]
                c ^= 1
            else:
                res *= 3
        ans += (2*c-1)*res
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,k;cin>>n>>k;
  vector<int> a(n);rep(i,n)cin>>a[i];
  vector<vector<int>> v(n);
  int c=0;
  rep(i,k){
    int x,y;cin>>x>>y;x--;y--;
    v[x].push_back(y);v[y].push_back(x);
  }
  rep(i,n){
    bool f=true;
    for(auto au:v[i]){
      if(a[i]<=a[au]){
        f=false;break;
      }
    }
    if(f)c++;
  }
  cout<<c;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N), F(N);

    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> F[i];

    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    ll l = -1;
    ll r = 1e12;

    while(l+1 < r){
        ll mid = (l+r)/2;
        ll sum = 0;
        
        bool ok = [&]{
            for(int i = 0; i < N; i++){
                sum += max(A[i] - mid/F[i], 0LL);
            }
            return sum <= K;
        }();
        
        if(ok) r = mid;
        else l = mid;
    }

    cout << r << endl;

    return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        s[i] = (s[i]-'A' + n)%26 + 'A';
    }
    cout << s << endl;
   return 0;
}

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

int main(){
  int r, c, sum=0;
  int e[100][100], sor[100]={}, soc[100]={};

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

  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cout<<e[i][j]<<" ";
    }
    sum+=sor[i];
    cout<<sor[i]<<endl;
  }
  for(int i=0;i<c;i++) cout<<soc[i]<<" ";
  cout<<sum<<endl;
  
  return 0;
}

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

int N;
int A[200];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i){
      cin >> A[i];
    }
    
	int res = 0;

   
    while (true) {
        bool exist_odd = false;
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;
}

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

int main(){
  long int a, b;
  cin >> a >> b;
  string out = "Negative";
  if(a > 0){
    out = "Positive";
  }else if(a * b <= 0){
    out = "Zero";
  }else if((b - a) % 2 == 1){
    out = "Positive";
  }
  cout << out;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if strings.Count(s, "a") == 1 && strings.Count(s, "b") == 1 && strings.Count(s, "c") == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string.h>
#include<functional>
#include<set>
#include<string>
#include<bitset>
//aoj 0121
using namespace std;
char zzzt[8]={0,1,2,3,4,5,6,7};
char bj[8];
bitset<80000000> vis;
#define ck(x) vis[x]
#define sb(x) vis[x]=1
/*char vis[80000000/8];
#define ck(x)   (vis[(x)>>3]&(1<<((x)&7)))
#define sb(x)   (vis[(x)>>3]|=(1<<((x)&7)))
#define cb(x)   (vis[(x)>>3]&=~(1<<((x)&7)))
*/
struct pt{
	int ztt;
	int lwz;
	int step;
};
int bs;
pt dl[1<<16];
int front=1,back=1;
int tt;
int ddd[8]={10000000,1000000,100000,10000,1000,100,10,1};
void bfs()
{
	tt=0;
	front=1;
	back=1;
	bs=0;
	vis.reset();
//	memset(vis,0,sizeof(vis));
	
	int cs=atoi(bj);
	sb(cs);
	pt lsss;
	lsss.ztt=cs;
	lsss.lwz=strchr(bj,'0')-bj;
	lsss.step=0;
	dl[back]=lsss;
	back++;
	while(front<back)
	{
		pt ls1=dl[front];
		front++;
		if(ls1.ztt==1234567)
		{
			bs=ls1.step;
			tt=1;
			return;
		}
		pt lsjr;
		int kkk[4]={-1,1,-4,4};
		for(int i=0;i<4;i++){
			lsjr.lwz=ls1.lwz+kkk[i];
			if((ls1.lwz==3&&lsjr.lwz==4) || (ls1.lwz==4&&lsjr.lwz==3)) continue;
			if(lsjr.lwz>=0&&lsjr.lwz<=7){
					int  a,b;
					a=ls1.ztt/ddd[ls1.lwz]%10;
					b=ls1.ztt/ddd[lsjr.lwz]%10;
					lsjr.ztt=ls1.ztt+(b-a)*ddd[ls1.lwz]+(a-b)*ddd[lsjr.lwz];
					if(!ck(lsjr.ztt))
					{
						lsjr.step=ls1.step+1;
						sb(lsjr.ztt);
						dl[back]=lsjr;
						back++;
					}
			}
		}
	}
}
int main()
{
//	freopen("in","r",stdin);
	while(1)
	{
		if(scanf("%c",&bj[0])==EOF)
		{
			return 0;
		}
		scanf("%*c");
		for(int i=1;i<=6;i++)
		{
			scanf("%c%*c",&bj[i]);
		}
		scanf("%c",&bj[7]);
		bfs();
		if(tt)
		{
			printf("%d\n",bs);
		}else{
			printf("-1\n");
		}
		while(getchar()!='\n');
	}
	return 0;
}



Measured memory_bytes: 12628
#include <iostream>
using namespace std;
int main()
{
  for(;;){
    int e;
    cin >> e;
    if(e == 0) break;
    int ret = 1000000;
    for(int z = 0; z*z*z <= e; z++){
      for(int y = 0; z*z*z+y*y <= e; y++){
        int x = e - z*z*z - y*y;
        if(x+y+z < ret){
          ret = x+y+z;
        }
      }
    }
    cout << ret << endl;
  }
  return 0;
}

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

int main(){
   int n ; int sum = 0;
	 cin>>n;
	 vector<int>uu(n);
	 for(int i = 0 ; i< n ; i++){
		 cin>>uu[i];
	 }
	 sort(uu.begin(),uu.end());

	 for(int i = 0 ; i< n-1 ; i++){
		 sum=sum+uu[i];
	 }
	 if(sum>uu[n-1]){
		 cout<<"Yes";
	 }
	 else{
		 cout<<"No";
	 }
}

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

int main()
{
  string S, T;
  cin >> S >> T;
  // Sのi+1文字目まで、Tのj+1文字目までのLCSの長さ
  vector<vector<int64_t>> DP(MAXN, vector<int64_t>(MAXN, 0));
  for (int i = 1; i <= S.size(); i++)
  {
    for (int j = 1; j <= T.size(); j++)
    {
      if (S.at(i - 1) == T.at(j - 1))
      {
        DP.at(i).at(j) = DP.at(i - 1).at(j - 1) + 1;
      }
      else
      {
        DP.at(i).at(j) = max(DP.at(i - 1).at(j), DP.at(i).at(j - 1));
      }
    }
  }
  stack<char> Ans;
  int64_t s_idx = S.size(), t_idx = T.size();
  while (s_idx > 0 && t_idx > 0)
  {
    if (DP.at(s_idx).at(t_idx) == DP.at(s_idx).at(t_idx - 1))
    {
      t_idx--;
    }
    else if (DP.at(s_idx).at(t_idx) == DP.at(s_idx - 1).at(t_idx))
    {
      s_idx--;
    }
    else
    {
      Ans.push(S.at(s_idx - 1));
      t_idx--;
      s_idx--;
    }
  }
  while (!Ans.empty())
  {
    cout << Ans.top();
    Ans.pop();
  }
  cout << endl;
}


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

int main() {
    int n ;
    cin >> n;
    vector<int> list(n);

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

    int ans = 0;
    int lowest = INT_MAX;
    for(int i = 0;i < n;i++){
        if(list[i] <= lowest){
            ans++;
        }

        lowest = min(list[i],lowest);
    }

    cout << ans;
}

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

int n,m;
long long d[105][105],D[105][105];

void warshall_floyd() {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
    cin>>n>>m;
    for(int i=0;i<=n;++i){
        for(int j=0;j<=n;++j){
            d[i][j]=1e9;
            D[i][j]=1e9;
        }
    }
    for(int i=0;i<m;++i){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
        D[a][b]=c;
        D[b][a]=c;
    }
    warshall_floyd();
    int cnt=0;
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
            if(i!=j&&d[i][j]==D[i][j])cnt++;
        }
    }
    cout<<m-cnt<<endl;
}


Measured memory_bytes: 384
N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

def yaku(N):
    res = []
    for i in range(1, round(N**(1/2)) + 3 ):
        if N%i == 0:
            res.append(i)

    res2 = [N//i for i in res]
    res = list(set(res + res2))
    return res

ys = yaku(sum(A))
ys.sort(reverse=True)
for y in ys:
    M = [a%y for a in A if a%y]
    ma = 0
    mi = y*len(M) - sum(M)
    M.sort()
    for m in M:
        ma += m
        mi -= (y - m)
        if ma == mi:
            break
    if ma <= K:
        print(y)
        exit()
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> a;
  for(int i = 0; N > i; i++){
    int tmp;cin>>tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end(),greater<int>());
  long long ret = 0;
  for(int i = 1; N > i; i++){
    if(a[i] == a[i-1]){
      if(ret != 0){
        ret *= a[i];
        break;
      }else{
        ret += a[i];
        i++;
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define fastIO ios::sync_with_stdio(false);cin.tie(0);
#define ll long long
#define f(i, l, r) for(i = l; i < r; i++)
#define fd(i, l, r) for(i = l; i > r; i--)
#define mod 1000000007
#define pb push_back
using namespace std;
typedef pair <int, int> pi;

int main(){
	fastIO
    int test = 1;
    // cin >> test;
    while(test--){
        string s, t; cin >> s >> t;
        vector <char> output_string;
        int i, j;
        int dp[s.length()+1][t.length()+1];
        f(i,0,s.length()+1){
            f(j,0,t.length()+1){
                if(i==0 || j==0)
                    dp[i][j] = 0;
                else if(s[i-1] == t[j-1])
                    dp[i][j] = 1 + dp[i-1][j-1];
                else
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }

        int max = 0;
        i = s.length();
        j = t.length();
        while(i>0 && j>0){
            if(s[i-1] == t[j-1]){
                output_string.pb(s[i-1]);
                i--; j--;
            }
            else if(dp[i-1][j] > dp[i][j-1])
                i--;
            else j--;
        }
        fd(i,output_string.size()-1, -1)
            cout << output_string[i];
    }
}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

	int x;
	cin >> x;
	if (x >= 30) cout << "Yes\n";
	else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=1e6+10;

LL Q[int(1e7)],l=1,r=0;
vector<LL> num;
void init() {
    for (int i=1;i<10;i++) {
        Q[++r]=i;
    }
    while (r>=l) {
        LL f=Q[l++];
        if (f>1e11) break;
        num.push_back(f);
        LL back=f%10;

        Q[++r]=f*10+back;
        if (back!=0) Q[++r]=f*10ll+back-1;
        if (back!=9) Q[++r]=f*10ll+back+1;
    }
}

int main() {
    init();
    int k;
    cin>>k;
    sort(num.begin(),num.end());
    cout<<num[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 22892
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){

	int X,Y,Z;
	cin>>X>>Y>>Z;
	X-=Z;
	
	cout<<X / (Y+Z)<<endl;
	
    return 0;
}



Measured memory_bytes: 256
l,r = gets.split(' ').map(&:to_i)

if l + 4039 < r
	r = l + 4039
end

minmod = 2018
l.upto(r) do |i|
	(i+1).upto(r) do |j|
		ijmod = (i*j) % 2019
		if minmod > ijmod
			minmod = ijmod
		end
	end
end

p minmod

Measured memory_bytes: 1788
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;

int H, W, d[100][100];
char s[100][100];
int dy[4] = {1, -1, 0, 0}, dx[4] = {0, 0, 1, -1};

void bfs() {
    queue<P> que;
    que.push(P(0, 0));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) d[i][j] = -1;
    }
    d[0][0] = 0;
    while (que.size()) {
        P p = que.front();
        que.pop();
        if (p.first == H - 1 && p.second == W - 1) break;
        for (int i = 0; i < 4; ++i) {
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if (ny >= 0 && ny < H && nx >= 0 && nx < W && d[ny][nx] == -1 && s[ny][nx] != '#') {
                que.push(P(ny, nx));
                d[ny][nx] = d[p.first][p.second] + 1;
            }
        }
    }
    return;
}

int main() {
    cin >> H >> W;
    int cnt = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> s[i][j];
            if (s[i][j] == '.') ++cnt;
        }
    }
    bfs();
    if (d[H - 1][W - 1] == -1) cout << -1 << endl;
    else cout << cnt - d[H - 1][W - 1] - 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
memo = [0] * 100

def l(i):
    if i == 0:
        return 2
    elif i == 1:
        return 1
    else:
        if memo[i] != 0:
            return memo[i]
        else:
            memo[i] = l(i-1) + l(i-2)
        return memo[i]


n = int(input())
print(l(n))



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

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n), b(n), c(n);

  for (auto &i : a) {
    std::cin >> i;
  }
  for (auto &i : b) {
    std::cin >> i;
  }
  for (auto &i : c) {
    std::cin >> i;
  }

  std::sort(a.begin(), a.end());
  std::sort(b.begin(), b.end());
  std::sort(c.begin(), c.end());

  std::vector<int64_t> b_num(n);

  for (int64_t i = 0; i < n; i++) {
    b_num[i] = std::distance(std::upper_bound(c.cbegin(), c.cend(),
    b[i]), c.cend());
  }

  int64_t count = 0;

  for (int64_t i = n - 1; 1 <= i; i--) {
    b_num[i - 1] += b_num[i];
  }

  for (int64_t i = 0; i < n; i++) {
    const auto j = std::distance(std::upper_bound(b.cbegin(), b.cend(),
    a[i]), b.cend());
    if (0 != j) {
      count += b_num[n - j];
    }
  }

  std::cout << count << std::endl;
  return 0;
}


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

int main(){
    int h;
    while(cin >> h, h){
        int mat[h][5];
        for(int i = 0; i < h; i++){
            for(int j = 0; j < 5; j++){
                cin >> mat[i][j];
            }
        }

        int score = 0;
        bool update = true;

        while(update){
            update = false;

            // vanish
            for(int i = h; i >= 0; i--){
                for(int j = 0; j < 3; j++){
                    if(mat[i][j] == 0)  continue;
                    int pos = j;
                    while(pos+1 < 5 && mat[i][j] == mat[i][pos+1])  pos++;

                    // vanish!
                    if(pos-j+1 >= 3){
                        update = true;
                        for(int d = j; d <= pos; d++){
                            score += mat[i][d];
                            mat[i][d] = 0;
                        }
                        j = pos;
                    }
                }
            }

            // fall
            for(int i = h-2; i >= 0; i--){
                for(int j = 0; j < 5; j++){
                    if(mat[i][j]){
                        int cpi = i;
                        while(cpi+1 < h && mat[cpi+1][j] == 0){
                            swap(mat[cpi+1][j], mat[cpi][j]);
                            cpi++;
                        }
                    }
                }
            }
        }

        cout << score << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
main = do
  [n, k] <- map read . words <$> getLine :: IO [Integer]
  print $ solve n n k

solve :: Integer -> Integer -> Integer -> Integer

solve 0 n k = if k == 0 then (-n) else 0
solve i n k = res + solve (i - 1) n k
  where res = max 0 (div n i * (i - k)) + max 0 (mod n i - k + 1)

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

int main() {
  string s;
  cin >> s;
  vector<int> result(256, 0);
  for(int a = 0; a < s.size(); a++) {
    result[s[a]]++;
  }
  for(int a = 97; a < 123; a++) {
    if(result[a]%2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

count = 0

for a_count in 0..a do
  for b_count in 0..b do
    for c_count in 0..c do
      count += 1 if a_count * 500 + b_count * 100 + c_count * 50 == x
    end
  end
end

puts count

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

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
	cin >> n;
	ll ans = 1;
	for(int i=1;i<=n;i++){
		ans = ans*i % mod;
	}
	cout << ans << "\n";
    
	return 0;
}

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

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var X = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var p = (long)Math.Round(X.Average());

            Console.WriteLine($"{X.Select(x => (x - p) * (x - p)).Sum()}");
        }
    }
}

Measured memory_bytes: 13524
#include <stdio.h>

int main(){
  char line[100];
  int a, b;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d %d", &a, &b);
  printf("%d %d %f\n", a/b, a%b, (double)a/b);
  return 0;
}



Measured memory_bytes: 2100
//https://atcoder.jp/contests/abc142/tasks/abc142_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//return first  素数
//return second いくつ
template< typename T >
std::pair<std::vector<T>, std::vector<T>> prime_factor_decomp(T n) {
    std::vector<T> p, e;
    T m = n;
    for (T i = 2; i * i <= n; i++) {
        if (m % i != 0) continue;
        T c = 0;
        while (m % i == 0) c++, m /= i;
        p.push_back(i);
        e.push_back(c);
    }
    if (m > 1) {
        p.push_back(m);
        e.push_back(1);
    }
    return std::make_pair(p, e);
}

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll A,B; cin>>A>>B;    
    ll gcdv = __gcd(A,B);
    auto ans = prime_factor_decomp<ll>(gcdv);
    cout<<ans.first.size()+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	std::string S;
	std::string T;
	cin >> S >> T;
	
	T.pop_back();
	if(S == T){
		cout << "Yes" << endl;
		
	}else{
		cout << "No" << endl;
		
	}

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
void chmax(t &a, u b)
{
    if (a < b)
        a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
    if (b < a)
        a = b;
}

bool is_guumojiretu(string s)
{
    int l = s.size();
    for (size_t i = 0; i < l / 2; i++)
    {
        if (s[i] != s[l / 2 + i])
        {
            return false;
        }
    }

    return true;
}

int main()
{
    string s;
    cin >> s;
    for (size_t i = s.size() - 2; i >= 0; i -= 2)
    {
        if (is_guumojiretu(s.substr(0, i)))
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

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

	string key = "keyence";
	bool flag = false;

	int i = 0;
	int k = 0;

	int diff = moji.length() - key.length();

	if (diff < 0){
		cout << "NO" << endl;
		return 0;
	}

	for (int i=0; i < moji.length() - diff + 1; i++){
		string check = moji.substr(0, i) + moji.substr(i + diff);
		if (check == key){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

string inputString(){
  string a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> inputVectorString(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> inputVector2D(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 1
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, vector<string>& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<vector<LL>>& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code

  auto n = inputValue();
  auto k = inputValue();
  auto q = inputValue();
  auto as = inputVector(q);

  vector<LL> scores;
  REP(i, n) {
    scores.push_back(0);
  }

  REP(i, q) {
    scores.at(as.at(i)-1)++;
  }

  REP(i, n) {
    if (k - q + scores.at(i) <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int maxa=a;
    if(k<=a+b) {cout<<min(k,a); return 0;}
    int more=k-(a+b);
    if(more>c) more=c;
    cout<<a-more;  

}

Measured memory_bytes: 3632
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;






int main(){
    ll q;
    cin>>q;
    while(q--){
        
        
    string a,b;
    cin>>a>>b;
    
    vector<set<ll>> w(300);
    vector<vector<ll>> dp(2000);
    for(int i=0;i<dp.size();i++){dp[i].resize(2000,E);}
    
    for(int i=0;i<b.size();i++){
        w[b[i]].insert(i);
    }
    
    ll mx=0;
    
    for(int i=0;i<a.size();i++){
        for(int t=0;t<b.size()+100;t++){
            if(t==0 && !w[a[i]].empty() && *w[a[i]].begin()<dp[i][t]){
                dp[i+1][t]=*w[a[i]].begin();
                mx=max(mx,(ll)t+1);
            }
            else if(w[a[i]].upper_bound(dp[i][t-1])!=w[a[i]].end() && *w[a[i]].upper_bound(dp[i][t-1])<dp[i][t]){
                dp[i+1][t]=*w[a[i]].upper_bound(dp[i][t-1]);
                mx=max(mx,(ll)t+1);
            }
            else{dp[i+1][t]=dp[i][t];}
        }
    }
    cout<<mx<<endl;
        
        
    }
    
    return 0;
}





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

#define ll long long

int arr[105][2];
int n, w;

ll memo[105][1000005];

ll ks(int pos, int curw) {
	if(curw == 0 || pos == -1) {
		return 0;
	} else if(memo[pos][curw] != -1) {
		return memo[pos][curw];
	} else if(curw-arr[pos][0] < 0) {
		return memo[pos][curw] = ks(pos-1, curw);
	} else {
		return memo[pos][curw] = max(ks(pos-1, curw), ks(pos-1, curw-arr[pos][0])+arr[pos][1]);
	}
}

int main () {
	scanf("%d %d", &n, &w);
	
	memset(memo, -1, sizeof(memo));
	
	for(int i = 0; i < n; i++) {
		scanf("%d %d", &arr[i][0], &arr[i][1]);
	}
	
	printf("%lld\n", ks(n-1, w));
}

Measured memory_bytes: 820608
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	if (n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var list = new string[] { "dream", "dreamer", "erase", "eraser" };

            while (s != "")
            {
                var t = s;
                for (var i = 0; i < 4; i++)
                {
                    if (s.Length - list[i].Length < 0)
                        continue;
                    var sub = s.Substring(s.Length - list[i].Length, list[i].Length);
                    if (sub == list[i])
                    {
                        s = s.Substring(0, s.Length - list[i].Length);
                        // Console.WriteLine(s);
                    }
                }
                if (s == t)
                    break;
            }

            Console.WriteLine(s == "" ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 48068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<thread>
#include<random>
using namespace std;

struct node {
	vector<int> link;
	int cnt;
	int parent;
};
int main() {
	int n, q;
	cin >> n >> q;
	vector<node> nod(n);
	for (int i = 0; i < n; ++i) {
		nod[i].cnt = 0;
		nod[i].parent = -1;
	}
	for(int i = 0; i < n - 1; ++i) {
		int l1, l2;
		cin >> l1 >> l2;
		l1--;
		l2--;
		nod[l1].link.push_back(l2);
		nod[l2].link.push_back(l1);
	}
	for (int i = 0; i < q; ++i) {
		int p, x;
		cin >> p >> x;
		nod[p - 1].cnt += x;
	}
	vector<int> s_stack;
	s_stack.push_back(0);
	for (int i = 0; i < s_stack.size(); ++i) {
		for (int j : nod[s_stack[i]].link) {
			if (j == nod[s_stack[i]].parent) continue;
			nod[j].cnt += nod[s_stack[i]].cnt;
			nod[j].parent = s_stack[i];
			s_stack.push_back(j);
		}
	}
	for (int i = 0; i < n; ++i) cout << nod[i].cnt << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 16372
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] arg){
        string[] read = Console.ReadLine().Split(' ');
        int N = int.Parse(read[0]);
        int M = int.Parse(read[1]);

        Console.WriteLine(N*M);

        return;
    }
}


Measured memory_bytes: 27492