akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1010
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int g[N][5010],f[N],head[N],a[N],tot;
struct Edge{int v,next;Edge(int _v=0,int _n=0):v(_v),next(_n){}}edge[1000000];
inline void add(int x,int y){edge[++tot]=Edge(y,head[x]);head[x]=tot;}
void dfs(int x)
{	g[x][0]=0;
	for(rint i=head[x];i;i=edge[i].next)
	{	dfs(to);
		for(rint j=a[x];j>=max(a[to],f[to]);j--)
		g[x][j]=min(g[x][j-a[to]]+f[to],g[x][j-f[to]]+a[to]);
		if(a[to]>=f[to])
		{	for(rint j=a[to]-1;j>=f[to];j--) g[x][j]=g[x][j-f[to]]+a[to];
			for(rint j=f[to]-1;j>=0;j--) g[x][j]=1e9;
		}
		else
		{	for(rint j=f[to]-1;j>=a[to];j--) g[x][j]=g[x][j-a[to]]+f[to];
			for(rint j=a[to]-1;j>=0;j--) g[x][j]=1e9;
		}
	}
	for(rint i=0;i<=a[x];i++) f[x]=min(f[x],g[x][i]);
	if(f[x]==1e9){printf("IMPOSSIBLE");exit(0);}
}
int main()
{	int n,x; scanf("%d",&n);
	for(rint i=1;i<=n;f[i]=1e9,i++)
	for(rint j=0;j<=5000;j++) g[i][j]=1e9;
	for(rint i=2;i<=n;i++) scanf("%d",&x),add(x,i);
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]);
	dfs(1); printf("POSSIBLE");
	return 0;
}


Measured memory_bytes: 27648
N = int(input())
S = list(input())
ans = 0
fl = [False] * 10
sl = [False] * 10
tl = [False] * 10

for i in range(N - 2):
    if not fl[int(S[i])]:
        fl[int(S[i])] = True
        for j in range(i + 1, N - 1):
            if not sl[int(S[j])]:
                sl[int(S[j])] = True
                for k in range(j + 1, N):
                    if not tl[int(S[k])]:
                        tl[int(S[k])] = True
                        ans += 1
                tl = [False] * 10
        sl = [False] * 10

print(ans)


Measured memory_bytes: 3444
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        --A[i];
    }
    vector<int> B(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> B[i];
    }
    vector<int> C(N - 1);
    for (int i = 0; i < N; ++i)
    {
        cin >> C[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        ans += B[A[i]];
        if (i > 0 && A[i] == A[i - 1] + 1)
        {
            ans += C[A[i - 1]];
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 200200;

VI A[MAX];

LL F[MAX];

LL bpow(LL a, LL b)
{
	LL res = 1;
	while(b)
	{
		if (b & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

LL inv(LL a)
{
	return bpow(a, MOD - 2);
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	F[0] = 1;
	FOR (i, 1, MAX)
	{
		F[i] = (F[i-1] * i) % MOD;
	}

	int n, x, y;
	scanf("%d%d%d", &n, &x, &y);

	FOR (i, 0, n)
	{
		int c, w;
		scanf("%d%d", &c, &w);
		A[c].PB(w);
	}

	FOR (i, 0, MAX)
	{
		sort(ALL(A[i]));
	}

	PII mn = MP(INF, INF);
	PII mn2 = MP(INF, INF);
	FOR (i, 0, MAX)
	{
		if (A[i].empty()) continue;

		mn2 = min(mn2, MP(A[i][0], i));
		if (mn2 < mn) swap(mn, mn2);
	}

	VI cnt;
	int sum = 0;

	FOR (i, 0, MAX)
	{
		if (A[i].empty()) continue;

		int val = mn.first;
		if (mn.second == i) val = mn2.first;

		if (val + A[i][0] > y) continue;

		int cur = 0;
		FOR (j, 0, SZ(A[i]))
		{
			if (A[i][j] + val <= y || A[i][j] + A[i][0] <= x) cur++;
		}

		cnt.PB(cur);
		sum += cur;
	}

	LL res = F[sum];
	FOR (i, 0, SZ(cnt))
	{
		res = (res * inv(F[cnt[i]])) % MOD;
	}

	cout<<res<<endl;



}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int X[MAXN];
int Y[MAXN];
int T[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,t,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    int dis;

    for(int i=1;i<=n;i++)
        cin>>T[i]>>X[i]>>Y[i];

    for(int i=1;i<=n;i++){
        dis = abs(X[i]-X[i-1])+abs(Y[i]-Y[i-1]);
        if(T[i]-T[i-1]<dis){
            cout<<"No\n";
            return 0;
        }
        if((T[i]-T[i-1]-dis)&1){
            cout<<"No\n";
            return 0;
        }
    }

    cout<<"Yes\n";

    return 0;
}


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


int main()
{
    ll i,j,k,l,m,n;

    cin >> n;

    ll ar[n+10],fir[n+10];

    for(i= 0 ; i <= n; i++)
        cin>>ar[i];

    ll ekn = 0,sum = 0;

    fir[n] = ar[n];

    for(i = n-1 ; i >= 0 ; i--)fir[i] = ar[i] + fir[i+1];

    for(i=0; i<=n; i++)
    {

       if(!i)ekn = 1;
       else
       {
           ekn = ekn*2;
       }
       ekn = min(ekn,fir[i]);
       sum += ekn;

       ekn -= ar[i];

       if(ekn < 0)return cout << -1 << endl,0;

    }

    cout << sum << endl;


}


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

int main() {
  int N,K,Q;cin>>N>>K>>Q;
  vector<int> A(Q);
  for(int i=0;i<Q;i++) cin>>A.at(i);
  map<int,int> score;
  for(int i=1;i<=N;i++) score[i]=K-Q;
  for(int i=0;i<Q;i++) score[A.at(i)]++;
  for(int i=1;i<=N;i++){
    if(score.at(i)>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}






Measured memory_bytes: 8312
var
	n,i,m,d:Longint;
	a:array[1..100000]of Longint;
begin
	read(n);
	for i:=1 to n do begin
		read(a[i]);
		if m<a[i] then m:=a[i];
	end;
	d:=-1;
	for i:=1 to n do begin
		if a[i]=m then continue;
		if abs(m-2*a[i])<abs(m-2*d)then d:=a[i];
	end;
	writeln(m,' ',d);
end.


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static int res = 0;

	public static void main(String[] args) throws Exception {


		int k=sc.nextInt();
		

		System.out.println(helper(k));

	}

	private static int helper(int k) {
		// TODO Auto-generated method stub
		int n=(int) Math.sqrt(k);
		return n*n;
	}

}

Measured memory_bytes: 23764
h, n = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
MOD = 10 ** 18
D = [MOD] * (h + 10 ** 4)
D[0] = 0
 
for i in range(h):
    for a, b in AB:
        D[i + a] = min(D[i + a], D[i] + b)
print(min(D[h:]))

Measured memory_bytes: 43640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,sum=0;
    cin>>a>>b;
    sum=a+b;
    if(a%3==0||b%3==0||sum%3==0)
    {
    	cout<<"Possible"<<endl;
	}
	else
		cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string[] abc = Console.ReadLine().Split(' ');

            a = int.Parse(abc[0]);
            b = int.Parse(abc[1]);
            c = int.Parse(abc[2]);

            List<int> abcList = new List<int>();
            abcList.Add(a);
            abcList.Add(b);
            abcList.Add(c);
            abcList.Sort();

            int price;
            price = abcList[0] + abcList[1];

            Console.WriteLine(price);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main(){
    string str;
    getline(cin,str);
    for(int i=0;i<(int)str.size();i++){
        if( islower(str[i]) ){
            str[i]=toupper(str[i]);
        }else if( isupper(str[i]) ){
            str[i]=tolower(str[i]);
        }
    }
    cout<<str<<endl;
    return 0;
}



Measured memory_bytes: 3180
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n) {
  int ret = 1;
  for (int i = 1; i < n + 1; ++i) {
    ret = ret * i;
  }
  return ret;
}

/* 最大公約数 */
template <typename T>
T gcd(T x, T y) { return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>
T lcm_n(vector<T> &numbers) {
  T l;
  l = numbers[0];
  for (int i = 1; i < numbers.size(); ++i) {
    l = lcm(l, numbers[i]);
  }
  return l;
}

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

/**
 * @param N 素因数分解する整数
 * @param result N = 2^3 * 3^2の場合、{{2, 3}, {3, 2}}のような形式のvectorが生成される
 * @brief 2, 3,..., √Nまでの整数をNで割っていき、割り切れる数と割った回数を保存することで、素因数分解を行う。
 *        O(√N)
*/
void prime_factorize(ll N, vector<pair<ll, ll>> &result) {
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    ll ex = 0;  // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    result.emplace_back(pair<ll, ll>{a, ex});
  }

  // 最後に残った数
  if (N != 1) result.emplace_back(pair<ll, ll>{N, 1});
}

ll type_num(ll v) {
  ll i = 0;
  while (1) {
    if (i * (i + 1) <= 2 * v && 2 * v < (i + 1) * (i + 2)) break;
    ++i;
  }
  return i;
}

int main() {
  long double a;
  long double b;
  cin >> a >> b;

  mpint ans = mpint(a * b);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3848
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> vv[4];
    vector<ll> svv[4];
    int w0;
    int i;
    for (i = 0; i < n; i++) {
        int w, v;
        scanf("%d%d", &w, &v);
        if (i == 0) w0 = w;
        int tmp=w - w0;
        vv[tmp].push_back(v);
    }
    int k;
    for (k = 0; k < 4; k++) {
        sort(vv[k].rbegin(), vv[k].rend());
        svv[k].resize(vv[k].size() + 1);
        for (i = 0; i < (int)vv[k].size(); i++) {
            svv[k][i + 1] = svv[k][i] + vv[k][i];
        }
    }
    
    ll ans = 0;
    int j;
    for (i = 0; i <= (int)vv[0].size(); i++) {
        for (j = 0; j <= (int)vv[1].size(); j++) {
            for (k = 0; k <= (int)vv[2].size(); k++) {
                ll sum = (ll)i * (w0)+(ll)j * (w0 + 1) + (ll)k * (w0 + 2);
                ll sumval = svv[0][i] + svv[1][j] + svv[2][k];
                if (sum <= W) {
                    int k0 = (W - sum) / (w0 + 3);
                    k0 = MIN(k0, (int)vv[3].size());
                    sumval += svv[3][k0];
                    ans = MAX(ans, sumval);
                }
            }
        }
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.HashSet;
import java.util.List;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        HashMap<Character,Integer> map = new HashMap<>();
        for (int i=0;i<4;i++){
            if (map.containsKey(S.charAt(i))){
                map.put(S.charAt(i),map.get(S.charAt(i))+1);
            } else {
                map.put(S.charAt(i),1);
            }
        }
        int cnt = 0;
        if (map.size()==2){
            cnt = 0;
            for (Character c:map.keySet()){
                if (map.get(c)==2){
                    cnt++;
                }
            }
        }
        if (cnt==2){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23252
n = int(input())
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c = collections.Counter(prime_factorize(n))

ans = 0
for i in c:
    tmp = c[i]
    num = 1
    while tmp >= 0:
        tmp -= num 
        if tmp >= 0:
            ans += 1
        num += 1
        
print(ans)

Measured memory_bytes: 9464
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int mp[505][505];
int fff[55][55];
int n,c;
long long dd[3][55];
int main()
{
	read(n);
	read(c);
	for(int i=1;i<=c;i++)
		for(int j=1;j<=c;j++)
			read(fff[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			read(mp[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			for(int nc=1;nc<=c;nc++)
				dd[(i+j)%3][nc]+=fff[mp[i][j]][nc];
		}
	long long ans=123456789877654ll;
	for(int i=1;i<=c;i++)
		for(int j=1;j<=c;j++)
			for(int k=1;k<=c;k++)
			{
				if(i==j || i==k || j==k)	continue;
				ans=min(ans,dd[0][i]+dd[1][j]+dd[2][k]);//cout<<ans<<endl;
			}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(void)
{
    int a,b,c,d,e,f,g;
    e=0;f=0;g=0;
    char N,A;
    N='N';
    A='A';
    while(1){
        scanf("%d",&a);
        if(a==0){
            break;
        }
        for(d=0;d<=11;d++){
        scanf("%d %d",&b,&c);
        e=e+b-c;
        if(a<=e&&f==g){
            f=d+1;
        }
    }if(a<=e){
        printf("%d\n",f);
    }else if(e<a){
    printf("%c%c\n",N,A);
    }
    f=0;e=0;}
    return 0;
}

Measured memory_bytes: 596
import sys
_allinput = []
for inp in sys.stdin:
	_allinput += inp.strip().split(" ")
def _input():
	for put in _allinput:
		yield put
_obj = _input();
def __input():
	return _obj.__next__()
def nextInt():
	return int(__input())
def check(lst,L):
	tot = 1
	curSum = 0
	for i in lst:
		if curSum + i <= L:
			curSum += i
		else:
			curSum = i
			tot += 1
	return tot

def solve(lst,m):
	l = max(lst)
	r = 1000000 * m;
	while l != r:
		mid = int((l+r)/2);
		if check(lst,mid) <= m: r = mid
		else: l = mid + 1
	return l
try:
	while True:
		m,n = nextInt(),nextInt()
		if m > 0 or n > 0:
			lst = [nextInt() for i in range(0,n)]
			print(solve(lst,m))
		else:
			break
except:
	'''
	'''

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  // Failed to predict input format
  int n, K; cin >> n >> K;
  vi v(n,0);
  rep(k,K){
    int d;
    cin >> d;
    int ai;
    rep(i,d){
      cin >> ai; ai--;
      v[ai]++;
    }
  }
  ll ret = 0;
  rep(i,n){
    if(v[i]==0) ret++;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	int n,k;
  
  	cin>>n>>k;
  	
  if(n>= 10){
    cout<<k<<endl;
  }else{
   cout<<k + (100*(10-n))<<endl; 
    
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int fa[301],sizes[301];
int root(int node){
    while(node!=fa[node]){
        fa[node]=fa[fa[node]];
        node=fa[node];
    }
    return(node);
}
void link(int i,int j){
    i=root(i);j=root(j);
    if(i==j) return;
    if(sizes[i]>sizes[j]) swap(i,j);
    sizes[j]+=sizes[i];
    fa[i]=j;
    return;
}
void solve(){
    int n;
    cin>>n;
    ll tot=0;
    ll dist[n+1][n+1];
    memset(dist,0,sizeof dist);
    for(int i=1;i<=n;i++){
        sizes[i]=1;
        fa[i]=i;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++) cin>>dist[i][j];
    }

    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    if(dist[i][j]>dist[i][k]+dist[k][j]){
        cout<<-1;
        return;
    }

    /*
    vector<pair<ll,pii> > v;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=i-1;j++){
           // cout<<dist[i][j];
           v.push_back(make_pair(dist[i][j],pii(i,j)));
        }

    sort(v.begin(),v.end());
    for(auto pp:v){
        ll w=pp.first;
        int i=pp.second.first;
        int j=pp.second.second;
        if(root(i)==root(j)) continue;
        link(i,j);
        tot+=w;
    }
    */
    bool imp[n+1][n+1];
    memset(imp,true,sizeof imp);
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(i==j || j==k || k==i) continue;
                if(dist[i][j]==dist[i][k]+dist[k][j]) {imp[i][j]=false;}

            }
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    if(imp[i][j]) {tot+=dist[i][j];}
    cout<<tot/2;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 1024
N = int(input())
def count_yakusu(n):
    yakusu = []
    for i in range(1,n+1):
        if n%i == 0:
            yakusu.append(i)
    return len(yakusu)
#print(count_yakusu(105))
ans = 0
for i in range(1,N+1,2):
    #print(i)
    if count_yakusu(i) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3060
n=int(input())
a=[int(i) for i in input().split()]
i=0
m=max(a)+1
c=0
while i+1<n:
    if a[i]==a[i+1]:
        a[i+1]=m
        m+=1
        c+=1
    i+=1
    #print(a)
print(c)

Measured memory_bytes: 3060
import java.util.*;

class Main{
    
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        double D = scan.nextInt();
        double T = scan.nextInt();
        double S = scan.nextInt();
        if((D/S)<=T){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

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

template<class T> inline bool chmin(T &a, T b) {
    if (b < a) {
        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() {
    int N; cin >> N;
    long long W; cin >> W;
    long long weight[110], value[110];
    for (int i = 0; i < N; i++) {
        cin >> weight[i] >> value[i];
    }
    long long dp[110][100100] = {0};
    for (int i = 0; i < N; i++) {
        for (int sumw = 0; sumw <= W; sumw++) {
            if (0 <= sumw - weight[i]) {
                chmax(dp[i+1][sumw], dp[i][sumw-weight[i]] + value[i]);
            }
            chmax(dp[i+1][sumw], dp[i][sumw]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 86272
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, string>	P;
typedef vector<ll>		VLL;
typedef vector<VLL>		VVLL;
typedef vector<VVLL>	VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
bool comp(const P &a, const P &b)
{
	if (a.first > b.first) {
		return true;
	}
	return false;
}


int main()
{
	int N;
	cin >> N;
	map<string, int> S;
	REP(i, N) {
		string one;
		cin >> one;
		S[one]++;
	}
	
	vector<P> ans;
	for (auto one : S) {
		ans.emplace_back(one.second, one.first);
	}
	sort(ALL(ans));
	reverse(ALL(ans));

	vector<string> ansStr;
	ll cntNum = ans[0].first;
	for (auto &ansOne : ans) {
		if (cntNum == ansOne.first) {
			ansStr.emplace_back(ansOne.second);
		} else {
			break;
		}
	}

	sort(ALL(ansStr));
	for (auto &ansOne : ansStr) {
		cout << ansOne << endl;
	}

	return 0;
}


Measured memory_bytes: 31984
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[50];
    const char *a = "KIHBR";
    const char *b = "AKIHABARA";
    //a <= s <= b;
    scanf("%s", s);
    int len = strlen(s);
    int x = 0, y = 0;
    for (int i = 0; i < len; i++)
        if (s[i] == a[x]) x++;
    for (int i = 0; i < 9; i++)
        if (b[i] == s[y]) y++;
    if (x == 5 && y == len) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
// define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

set<ll> diviser(ll n) {
  set<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.insert(i);
      if (i * i != n) ret.insert(n / i);
    }
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N, X;
  cin >> N >> X;
  Vl x;
  REP(i, N) {
    ll tmp;
    cin >> tmp;
    x.push_back(abs(tmp - X));
  }
  set<ll> D = diviser(x.at(0));
  for (auto m : x) {
    for (auto a : D) {
      if (m % a != 0) D.erase(a);
    }
  }

  cout << *rbegin(D) << endl;
  return 0;
}

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

bool get(string a,int p,string b,int k){
if (k>=b.size()) return 1;
for (int i=p+1;i<a.size();++i){
  if (a[i]==b[k]) return get(a,i,b,k+1);
  }return 0;
}

int main(){
string a;cin>>a;
puts(get(a,-1,"CF",0)?"Yes":"No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
// typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
// const int inf = 1e9;
const int mod = 1e9 + 7;

typedef tuple<double, int, int, int> TUPLE;
const double inf = 1e12;

struct edge {
    int to, d, c;
    edge(){}
    edge(int _to, int _d, int _c) : to(_to), d(_d), c(_c) {}
};
typedef vector<vector<edge>> Graph;
double dijkstra(const Graph& G, int s, int g) {
    int n = G.size();
    priority_queue<TUPLE, vector<TUPLE>, greater<TUPLE>> pq;   // cost, i, j, pre
    vector<vector<vector<double>>> d(n, vector<vector<double>>(31, vector<double>(n + 1, inf)));
    d[s][0][n] = 0;
    pq.push(make_tuple(0, s, 0, n));

    while (!pq.empty()) {
        double cost;
        int i, j, pre;
        tie(cost, i, j, pre) = pq.top(); pq.pop();
        // cout << cost << " " << i << " " << j << endl;
        // if (i == g && j == 1) return cost;
        if (d[i][j][pre] < cost) continue;
        for (const auto& e : G[i]) {
            for (int k = -1; k <= 1; k++) {
                if (e.to == pre) continue;
                // if (e.to == g && j + k != 1) continue;
                if (1 <= j + k && j + k <= e.c && d[e.to][j + k][i] > d[i][j][pre] + 1. * e.d / (j + k)) {
                    d[e.to][j + k][i] = d[i][j][pre] + 1. * e.d / (j + k);
                    pq.push(make_tuple(d[e.to][j + k][i], e.to, j + k, i));
                }
            }
        }
        // cerr << "hey!" << endl;
    }

    return *min_element(all(d[g][1]));;
}

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

    int n, m;
    int t = 0;
    while (cin >> n >> m, n) {
        // cout << "--- t = " << t++ << " ---" << endl;

        int s, g;
        cin >> s >> g;
        s--, g--;
        Graph G(n);
        rep(i, m) {
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            x--, y--;
            G[x].emplace_back(y, d, c);
            G[y].emplace_back(x, d, c);
        }

        double ans = dijkstra(G, s, g);
        if (ans < inf) {
            cout << fixed << setprecision(10) << ans << endl;
        } else {
            cout << "unreachable" << endl;
        }
    }

}

Measured memory_bytes: 4060
#include <iostream>

using namespace std;

int main(){
    int a, b,k;
    int c;
    cin >> a >> b;
    c = (b - a) % 2;
    if (c == 0){
        k = (a+b)/2;
        if (k < 0){
            k *= -1;
        }
        cout << k;
    }else{
        cout << "IMPOSSIBLE";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[500],s=0;
	cin>>n;
	for(int i=1;i<=2*n;i++)
	 cin>>a[i];
	sort(a+1,a+1+n*2);
	for(int i=1;i<=2*n;i+=2)
	 s+=a[i];
	cout<<s;
}

Measured memory_bytes: 256
N = int(input())
A = [int (x) for x in input().split(" ")]

for i in range(1, N):
    print(" ".join([str(x) for x in A]))
    v = A[i]
    j = i -1
    while j>=0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1

    A[j+1] = v
print(" ".join([str(x) for x in A]))

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

int main(){

  int n,m;
  while(cin >> n >> m) {

    if(n > m) swap(n,m);

    while(n != 0) {
      int t = n;
      n = m % n;
      m = t;
    }
    cout << m <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#coding:UTF-8

def gcd(x,y):
    r = x % y

    if r==0: return y
    else: return gcd(y,r)

def lcm(x,y):
    return x * y / gcd(x,y)

while True:
    try:
        n = map(int, raw_input().split())

        print "%d %d"%(gcd(n[0],n[1]),lcm(n[0],n[1]))

    except Exception:
        break;

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

long long solver(vector<int> A, int flip)
{
	long long ans = 0;
	int sum = 0;
	switch (flip)
	{
	case 0:
		if (A[0] <= 0)
		{
			ans += abs(A[0]) + 1;
			sum = 1;
		}
		else
			sum = A[0];
		break;

	case 1:
		if (A[0] >= 0)
		{
			ans += abs(A[0]) + 1;
			sum = -1;
		}
		else
			sum = A[0];
		break;
	}
	flip = 1 - flip;

	for (int i = 1; i < A.size(); i++)
	{
		sum += A[i];

		switch (flip)
		{
		case 0:
			if (sum <= 0)
			{
				ans += abs(sum) + 1;
				sum = 1;
			}
			break;

		case 1:
			if (sum >= 0)
			{
				ans += sum + 1;
				sum = -1;
			}
			break;
		}

		flip = 1 - flip;
	}

	return ans;
}

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

	vector<int>  A(N);

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

	cout << min(solver(A, 1), solver(A, 0)) << endl;

	return 0;
}

Measured memory_bytes: 1408
n=gets.to_i
max_a=Math.sqrt(n).to_i
a=0
b=0
f=[]
1.upto(max_a) do |i|
  if n%i==0
    a=i
    b=n/a
    f<<[a.to_s.length, b.to_s.length].max
  end
end
puts f.min


Measured memory_bytes: 14272
def find(x):#xの親を見つける
  if par[x] < 0:
    return x
  else:
    par[x] = find(par[x])
    return par[x]

def unite(x,y):#要素xとｙを併合させる
  x,y=find(x),find(y)#xとyの親の検索
  if x!=y:#親が異なる場合併合させる
    if x>y:
        x,y=y,x#小さい方をxとする. これにより要素の値が小さいものを優先して木の根とする. 
    par[x]+=par[y] #値を無向木の要素数の和にする.
    par[y]=x #枝側は根の位置を格納

def same(x, y):#要素xと要素yが同じ無向木に所属しているかを判定する
  return find(x) == find(y)#同じ値を持つか否か

def size(x):#要素xが所属する無向木の大きさを返す
  return-par[find(x)]

N, M = map(int, input().split())
par = [-1] * N

def main():
  for i in range(M):
    x, y, z = map(int, input().split())
    unite(x-1, y-1)
  ans = set([])
  for i in range(N):
    ans.add(find(i))
  print(len(ans))
if __name__ ==  "__main__":
  main()

Measured memory_bytes: 12652
import java.util.Scanner;

class Main{





	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N =sc.nextInt();
		int W = sc.nextInt();
		int[] w = new int[N+1];
		int[] v = new int[N+1];
		int V = 0;
		for(int  i = 1;i <= N;i++){
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			V = (int)Math.max(V, v[i]);
		}
		long[][] dp = new long[N+1][V*N+1];		//dp[i][j] i番目までで価値jの時の重さ
		long pow =  1000000001*10000;
		for(int  i = 0;i <= N;i++){
			for(int j = 0;j <= V*N;j++){
				dp[i][j] = pow;
			}
		}


		for(int i = 1;i <= N;i++){
			dp[i][v[i]] =(long)Math.min(dp[i-1][v[i]], w[i]);

			for(int j = 0;j <= V*N;j++){
				if(dp[i-1][j] != pow){
					dp[i][j+v[i]] =(long)Math.min(dp[i][j+v[i]], dp[i-1][j] + w[i]);
				}
			//	System.out.println("i "+i +" j "+ j+" "+dp[i][j]);
			}
			for(int j  =0;j <= V*N;j++){
				dp[i][j] = Math.min(dp[i][j], dp[i-1][j]);
			}
		}
		
		long max = 0;
		for(int i = 0;i <= N*V;i++){
			if(dp[N][i] > 0 && dp[N][i] <= W){
				//	System.out.println(i);
				max = i;
			}
		}
		System.out.println(max);



	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 129620
#include <iostream>

using namespace std;

int max_score(int N)
{
	int x;
	for (x = 1; ; ++x) {
		if (x * (x + 1) / 2 >= N) {
			break;
		}
	}
	return x;
}

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

	int S = 0;

	for (int x = max_score(N); x >= 1; --x) {
		if (S + x <= N) {
			S += x;
			cout << x << endl;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N; cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
        A[i] -= i+1;
    }
    sort(A.begin(),A.end());
    ll b = A[N/2];
    ll ans = 0;
    rep(i,N){
        ans += abs(A[i]-b);
    }
    cout << ans << endl;
	
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long d,i,cm[25],ans;
long long read(){
	long long xx=0,flag=1;
	char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')
		ch=getchar();
	if(ch=='-'){
		flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		xx=xx*10+ch-'0';
		ch=getchar();
	}
	return flag*xx;
}
long long ss(long long x,long long y,long long z){
	if(z==0)
		return 0;
	if(x==((i+1)>>1)){
		if(i&1){
			if(y==0){
				if(i!=1)
					ans=ans+z*10;
				else
					ans=ans+z*9;
			}
		}
		else{
			if(y==0)
				ans=ans+z;
		}
		return 0;
	}
	for(long long j=-9;j<=9;j++)
		if(y+cm[x-1]*j-cm[i-x]*j<cm[x-1]&&(-cm[x-1])<y+cm[x-1]*j-cm[i-x]*j){
			if(x!=i)
				ss(x-1,y+cm[x-1]*j-cm[i-x]*j,z*(10-abs(j)));
			else
				ss(x-1,y+cm[x-1]*j-cm[i-x]*j,z*(9-abs(j)));
		}
}
int main(){
	d=read();
	cm[0]=1;
	for(i=1;i<=18;i++)
		cm[i]=cm[i-1]*10;
	for(i=1;i<=18;i++)
		ss(i,d,1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define DISCONNECT 0
#define CONNECT 1000
#define WHITE 2000
#define GRAY 3000
#define BLACK 4000
#define MAX 100
void push(int);
int pop(void);
void dfs();
void visit(int);
int next(int);
int n, G[MAX+1][MAX+1], stack[MAX+1], top = 1,
  d[MAX+1], f[MAX+1], color[MAX+1], time=0;

int main(){
  int vertex, degree, adj, i, j;
  for(i = 1; i <= MAX; i++){
    for(j = 1; j <= MAX; j++){
      G[i][j] = DISCONNECT;
    }
  }

  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    scanf("%d %d",&vertex,&degree);
    color[vertex] = DISCONNECT;
    color[vertex] = WHITE;
    for(j = 1; j <= degree; j++){
      scanf("%d",&adj);
      G[vertex][adj] = CONNECT;
    }
  }
  dfs();

  for(i = 1; i <= n; i++) printf("%d %d %d\n",i,d[i],f[i]);
  
  return 0;
}

void dfs(){
  int i;
  for(i = 1; i <= n; i++){
    if( color[i] == WHITE ) visit(i);
  }
}

void visit(int r){
  int i;
  int u, v;
  
  push(r);
  color[r] = GRAY;
  d[r] = ++time;
  while( top != 1 ){ //Stack is not empty
    u = stack[top-1];
    v = next(u);
    if( v != DISCONNECT ){
      if( color[v] == WHITE ){
	push(v);
	color[v] = GRAY;
	d[v] = ++time;
      }
    }
    else{
      pop();
      color[u] = BLACK;
      f[u] = ++time;
    }
  } 
}

int next(int x){
  int i;
  for(i = 1; i <= n; i++){
    if( G[x][i] == CONNECT && color[i] == WHITE ) return i;
  }
  return DISCONNECT;
}

void push(int x){
  stack[top] = x;
  top++;
}

int pop(void){
  top--;
  return stack[top];
}



Measured memory_bytes: 2052
import sys

string = raw_input()
string_list = list(string)
#print string_list
q = input()

for i in range(q):
    x = map(str, raw_input().split())
    if(x[0] == 'replace'):
        k = 0
        for j in range(int(x[1]), int(x[2])+1):
            string_list[j] = x[3][k]
            k += 1
        #print "".join(string_list)
    if(x[0] == 'reverse'):
        temp = []
        for j in range(int(x[1]), int(x[2])+1):
            temp.append(str(string_list[j]))
        temp.reverse()
        #print temp        
        temp_list = list(temp)
        k = 0
        for j in range(int(x[1]), int(x[2])+1):
           string_list[j] = temp[k]
           k += 1
        #print "".join(string_list)
    if(x[0] == 'print'):
        for i in range(int(x[1]), int(x[2])+1):
          sys.stdout.write(string_list[i])
        print

Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

    // input
    ll N, K, Q;
    cin >> N >> K >> Q;

    VI CNT(N);

    rep(i, Q){
      ll a; cin >> a;
      a--;
      CNT[a]++;
    }

    rep(i, N){
      CNT[i] += K;
      CNT[i] -= Q;
      if(CNT[i]>0){
        p_yes();
      }else{
        p_no();
      }
    }
    
    return 0;
}


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

int main() {
	string s;
	cin >> s;
  
	for (int i = 0; i < s.size()/2; ++i) {
		if(s[i] != s[s.size() -1 - i]) {cout << "No" << endl; return 0;}
		if(i < s.size()/2 - i - 1 && s[i] != s[s.size()/2 - 1 - i] ) {cout << "No" << endl; return 0;}
		if(i < s.size()/2 - i - 1 && s[i + s.size()/2 + 1] != s[s.size() - i - 1]) {cout << "No" << endl; return 0;}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N){
        cin >> A[i];
    }

    ll ans = 0;
    rep(i, N-1){
        if(A[i] > A[i+1]){
            ans += A[i] - A[i+1];
            A[i+1] = A[i];
        }
    }
    cout << ans;
}


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

int main()
{
    int n,flag = 0;
    cin >> n;

    for(int i = n; i <= 999; i++){
        int x = i,a1,a2,a3;
        a1 = x % 10;
        x /= 10;
        a2 = x % 10;
        a3 = x /= 10;

        if(a1 == a2 && a1 == a3){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<double> a(N);
  long long bou = 0;
  long long ans = 0;
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
    bou += a.at(i);
  }
  vector<double> b(N);
  b.at(0) = a.at(0);
  for(int i = 1; i < N; i++){
    b.at(i) = b.at(i - 1) + a.at(i);
    if(bou / 2 == b.at(i)){
      cout << 0 << endl;
      return 0;
    }
  }
  int i = 0;
  if(b.at(N - 2) < bou / 2){
    ans = a.at(N - 1) - b.at(N - 2);
  }
  else if(a.at(0) > bou / 2){
    ans = a.at(0) - (bou - a.at(0));
  }
  else{
    while(bou / 2 > b.at(i)) i++;
    ans = min(2 * b.at(i) - bou, bou - 2*b.at(i - 1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=2000010,O=1000000007;
inline int fpow(int x,int n){
	int a=1;
	for(;n;n>>=1,x=(lint)x*x%O){
		if(n&1){
			a=(lint)a*x%O;
		}
	}
	return a;
}
inline int inv(int x){
	return fpow(x,O-2);
}
int fac[N],invfac[N];
inline int c(int n,int k){
	return (lint)fac[n]*invfac[k]%O*invfac[n-k]%O;
}
inline void gmath(int n){
	fac[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=(lint)fac[i-1]*i%O;
	}
	invfac[n]=inv(fac[n]);
	for(int i=n;i>=1;i--){
		invfac[i-1]=(lint)invfac[i]*i%O;
		assert((lint)fac[i]*invfac[i]%O==1);
	}
}
int main(){
	int h=ni,w=ni,a=ni,b=ni;
	gmath(h+w);
	lint ans=0;
	for(int i=1;i<=b;i++){
		ans+=(lint)c(i-1+h-a-1,i-1)*c(a-1+w-i,a-1)%O;
	}
	ans=(c(h-1+w-1,h-1)-ans%O+O)%O;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5120
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	cin >> S;
	cout << S.substr(0, 4) << " " << S.substr(4, 12) << "\n";
	return 0;
}

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


int main(){
	int n,x;
	cin>>n>>x;
	ans=n;
	int a[n];
	for(int i;i<n;i++){
		cin>>a[i];
		x-=a[i];
	}
	sort(a,a+n);
	ans+=x/a[0];
	cout<<ans<<endl;
	return 0;
}

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

void main() {
	int[string] a;
	ubyte N = readln.chomp.to!ubyte;
	foreach(_; 0..N) {
		a[readln.chomp]++;
	}
	ubyte M = readln.chomp.to!ubyte;
	foreach(_; 0..M) {
		a[readln.chomp]--;
	}
	max(a.values.reduce!max, 0).writeln;
}

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

#define from(i, x, N) for (int i = x; i < N; i++)
#define forn(i, N) for (int i = 0; i < N; i++)

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  forn(i, N) cin >> H[i];

  vector<int> dp(N);
  dp[0] = 0;
  dp[1] = abs(H[1] - H[0]);

  from(i, 2, N)
  {
    dp[i] = min(abs(H[i] - H[i - 1]) + dp[i - 1], abs(H[i] - H[i - 2]) + dp[i - 2]);
  }
  cout << dp[N - 1] << endl;

  return 0;
}


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

using namespace std;

int f(int n){
	int sum=1;
	for(int i=1;i<=n;i++)
		sum=sum*i;
	return sum;
}
int C(int n,int m){
	int t=f(m)*f(n-m);
	int ans=f(n)/t;
	return ans;
}
int  main(){
	int n;
	cin>>n;
	
	if(n==1){
		printf("1");return 0;
	}
	if(n==2){
		printf("8");return 0;
	}
	if(n==3){
			printf("27");return 0;
	} 
	
	
		int ans=6*(C(n,2)+C(n,3))+n;
		printf("%lld\n",ans);
	
	return 0;
}
/*
1
8
27
64
125
216
343
512
729
*/

/*
1
8
27

*/ 

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	char str1[17] = "CODEFESTIVAL2016";
	char tmp[17];
	int i,count=0;
	
	scanf("%s",tmp);
	
	for(i=0; i < 16; i++){
		if(str1[i] != tmp[i]){
			count++;
		}
	}
	
	printf("%d",count);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
        cout << s << "es" << endl;
    else
        cout << s << "s" << endl;
}

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

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

  char c;cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


int MOD=1000000007;
int N,M;
int x[10],y[10];
char S[1000];
signed main(){
    scanf("%lld",&N);
    vector<int> v;
    rep(i,N){
        scanf("%lld %lld",&x[i],&y[i]);
        v.pb(i);
    }
    double ans=0;
    double count=1;
    rep(i,N){
        count*=(i+1);
    }
    do {
        double sans=0;
        rep(i,v.size()-1){
           sans+= sqrt((x[v[i+1]]-x[v[i]])*(x[v[i+1]]-x[v[i]])+(y[v[i+1]]-y[v[i]])*(y[v[i+1]]-y[v[i]]));
        }
        ans+=sans/count;
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
    printf("%lf\n",ans);
    return 0;
    
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  char c;
  cin >> c;

  cout << (char)(c+1) << endl;
  
  return 0;
}


Measured memory_bytes: 256