akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int N = 2000 + 7;

long long n, x;
long long a[N];
long long mn[N], p[N], res;

int main() {
	cin >> n >> x;
	for (long long i = 1; i <= n; i++)
		cin >> a[i], res += a[i], p[i] = i, mn[i] = a[i];
	for (long long k = 1; k <= n; k++) {
		long long nres = 0;
		for (long long i = 1; i <= n; i++) {
			p[i]--;
			if (p[i] == 0)
				p[i] = n;
			mn[i] = min(mn[i], a[p[i]]); 
			nres += mn[i];	
		}
		res = min(res, nres + k * x);
	//	cout << k << " " << nres + k * x << " " << res << endl;
	}
	cout << res;
	return 0;
}
 














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

int main() {
	ld l;
	cin >> l;

	ld L = l / 3;
	ld ans = L * L * L;
	cout << setprecision(14);
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
Nahid Hossain
Jahangirnagar University
Roll:54
*/
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 105



ll sum(ll x)
{
    return (x*(x+1))/2;
}

ll a[ma],n;

ll check(ll x)
{
    ll i,j;
    for(i=1;i<=n;i++)
    {
        ll p=a[i]-x;
        if(p==i)return 0;
    }
    return 1;
}
ll e[ma][ma];
int main()
{
    ll i,j;
    while(cin>>n)
    {
        for(i=1;i<=n;i++)a[i]=sum(n)-i;

        for(i=1;i<=n;i++)
        {
            for(j=i+1;j<=n;j++)e[i][j]=1;
        }
        ll sum=0;
        for(i=a[n];i>=1;i--)
        {
            if(check(i))
            {
                sum=i;
                break;
            }
        }

        for(i=1;i<=n;i++)
        {
            ll p=a[i]-sum;
            e[i][p]=e[p][i]=0;
        }

        vector<pair<ll,ll> > v;
        for(i=1;i<=n;i++)
        {
            for(j=i+1;j<=n;j++)if(e[i][j])v.pb(mk(i,j));
        }

        cout<<v.sz<<endl;

        for(i=0;i<v.sz;i++)cout<<v[i].ff<<" "<<v[i].ss<<endl;


    }
    return 0;
}


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

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define int llong
#define be(x) x.begin(), x.end()
typedef pair<int, int> P;


signed main(){
	float t, x;
	cin >> t >> x;

	printf("%f\n", t/x);

	return 0;
}

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

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

    ll n, k;
    cin >> n >> k;
    double arr[n];
    arr[0]=0;
    for(int i=1; i<=n; i++) cin >> arr[i];

    double expectedValues=0;
    double answer=0;

    for(int i=1; i<=k; i++){
        expectedValues+=(double)((arr[i]+1)/2);
    }
    answer=expectedValues;
    int i=k+1;
    while (i<=n){
        expectedValues-=(double)((arr[i-k]+1)/2);
        expectedValues+=(double)((arr[i]+1)/2);
        answer=max(answer,expectedValues);
        i++;
    }
    
    cout << setprecision(20) << answer << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int A,B,X;
	int c,ans;
	
	cin>>A>>B>>X;
	if(A>=2*B)ans=((X-1)/500+1)*B;
	else{
		ans=X/1000*A;
		c=X%1000;
		if(c){
			if(c<=500&&B<A)ans+=B;
			else ans+=A;
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

int main(){
  int n;
  int x,y,z,w,l;
  int total;
  int s1,s2;

  while(1){
    cin >> n;
    if(!n)break;

    total = 0;

    for(int i=0;i<n;i++){
      cin >> x >> y >> z >> w;
      l = x + y + z;
      if(l>160)s1 = 6;
      else if(l>140)s1 = 5;
      else if(l>120)s1 = 4;
      else if(l>100)s1 = 3;
      else if(l>80)s1 = 2;
      else if(l>60)s1 = 1;
      else s1 = 0;
      if(w>25)s2 = 6;
      else if(w>20)s2 = 5;
      else if(w>15)s2 = 4;
      else if(w>10)s2 = 3;
      else if(w>5)s2 = 2;
      else if(w>2)s2 = 1;
      else s2 = 0;

      if(s1<s2)s1 = s2;

      if(s1==0)total += 600;
      else if(s1==1)total += 800;
      else if(s1==2)total += 1000;
      else if(s1==3)total += 1200;
      else if(s1==4)total += 1400;
      else if(s1==5)total += 1600;
    }
    cout << total << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,t,var;
    cin>>n>>x>>t;
    if(n%x==0)
    {
            var=n/x;
    }
    else
    {
            var=n/x+1;
    }
    cout<<t*var<<'\n';
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
int main()
{
    int n,k,l,a=1;
    scanf("%d%d",&n,&k);
    while(n--)
    {
        a=min(a+k,a*2);
    }
    printf("%d\n",a);
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int X;
    cin >> X;
    if (X > (K / 2)) {
    sum += ((K - X) * 2); 
    }
    else {
      sum += (X * 2);
    }
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3)if (s[i] == t[i])ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n, m;
	cin >> n >> m;
	vector<queue<int>> q(n);
	rep(i,n)rep(j,m){
		int a;
        cin >> a;
		q[i].push(--a);
	}
	int ans = INF;
	vector<bool> hold(m, true);
	rep(ri,m){
		vector<int> cnt(m,0);
		rep(i,n){
			while(!hold[q[i].front()]){
				q[i].pop();
			}
			cnt[q[i].front()]++;
		}
		int j = max_element(cnt.begin(), cnt.end()) - cnt.begin();
		hold[j] = false;
		chmin(ans, cnt[j]);
	}
	cout << ans << endl;
}

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


void solve(long long W, long long H, long long x, long long y){
    double ans_region = double(W)*double(H) / 2.0;
    int num = 0;
    if(2*x == W and 2 * y == H) num = 1;
    else num = 0;
    printf("%lf %d\n",ans_region, num);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long W;
    scanf("%lld",&W);
    long long H;
    scanf("%lld",&H);
    long long x;
    scanf("%lld",&x);
    long long y;
    scanf("%lld",&y);
    solve(W, H, x, y);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j,n,p,c=0,list[200005],mod[200005];
  long m=0;
  char s[200005];
  scanf("%d",&n);
  scanf("%d",&p);
  scanf("%s",&s);
  if((p==2)|(p==5)){
    for(i=0;i<n;i++){
      if((s[n-i-1]-'0')%p==0) m+=n-i;
    }
  }else{
    list[0]=1;
    mod[0]=(s[n-1]-'0')%p;
    for(i=1;i<n;i++){
      list[i]=(list[i-1]*10)%p;
      mod[i]=((s[n-i-1]-'0')*list[i]+mod[i-1])%p;
    }
    for(i=0;i<p;i++) list[i]=0;
    for(i=0;i<n;i++){
      if(mod[i]==0) m++;
      m+=list[mod[i]];
      list[mod[i]]++;
    }
  }
  printf("%ld",m);
  return(0);
}


Measured memory_bytes: 1920
import java.util.Scanner;

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

		for (int i = N; i > 0; i--) {
			if (Math.sqrt(i) - Math.floor(Math.sqrt(i)) == 0) {
				System.out.println(i);
				break;
			}
		}

		sc.close();
	}
}

Measured memory_bytes: 23124
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <time.h>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define reps(x, c) for (auto x : c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a)
#define mp(a, b) make_pair((a), (b))
#define pl pair<ll, ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x "=" << (x) << "\n"
#define dbgv(x) \
    cerr << #x << "\n"; \
    reps(y, x) { cerr << y << " "; } \
    cerr << "\n"
int main() {
    int temp;
    ll ans = 0, ans_res = 0, res;
    rep(i, 5) {
        cin >> temp;
        res     = temp % 10;
        res     = (10 - res) % 10;
        ans_res = max(ans_res, res);
        ans += temp + res;
    }

    cout << ans - ans_res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define N 1010
typedef long long ll;
typedef pair<int,int> pii;
const int Mod=1000000007;

const double INF=1e18;
typedef long long ll;

int x[N],dp[N][N];
int c[N][N],fac[N],fac_inv[N];

int Power(int a,int p)
{
	int res=1;
	for (;p;p>>=1)
	{
		if (p&1) res=1ll*res*a%Mod;
		a=1ll*a*a%Mod;
	}
	return res;
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	int n,A,B,C,D;
	fac[0]=1;
	for (int i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	for (int i=0;i<N;i++) fac_inv[i]=Power(fac[i],Mod-2);
	cin >> n >> A >> B >> C >> D;
	c[0][0]=1;
	for (int i=1;i<N;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%Mod;
	}
	dp[0][0]=1;
	for (int i=0;;i++)
	{
		int v=i+A;
		if (v>B) break;
		for (int j=0;j<=n;j++)
		{
			if (dp[i][j]==0) continue;
			dp[i+1][j]+=dp[i][j];
			dp[i+1][j]%=Mod;
			int t=n-j,tmp=1;
			for (int k=1;t>=0;k++)
			{
				tmp=1ll*tmp*c[t][v]%Mod;
				if (k>=C && k<=D) 
				{
					dp[i+1][j+k*v]+=(1ll*dp[i][j]*tmp%Mod)*fac_inv[k]%Mod;
					dp[i+1][j+k*v]%=Mod;
				}
				t-=v;
			}
		}
	}
	printf("%d\n",dp[B-A+1][n]);
	return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
        if(s[i] == '7')
        {
            cout<<"Yes\n";
            return 0;
        }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
ll MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS

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

    sort(all(d));
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ans += (lower_bound(all(d), d[i] + d[j]) - d.begin()) - j - 1;
        }
    }
    cout << ans;

    return 0;
}


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


struct combination {
  ll operator()(int n, int r) {
    ll num = 1;
       for(int i = 1; i <= r; i++){
           num = num * (n - i + 1) / i;
       }
       return num;
  }
};


int main(){
  int n,p;

  ll test=1;
  rep(i,20){
    test*=(i+1);
  }
  std::vector<int> a(2);
  combination c;


  std::cin >> n>>p;
  rep(i,n){
    int temp;
    std::cin >> temp;
    a[temp%2]++;
  }

  // std::cout << "偶数:" <<a[0]<<'\n';
  // std::cout << "奇数:" <<a[1]<<'\n';


  ll ans=0;



  //偶数の袋のみをとる。
  ll evenall=0;
  // std::cout << "max" <<a[0]<<'\n';
  rep(i,a[0]+1){

    // std::cout << evenall <<" "<< a[0] <<":"<< i<<'\n';
    evenall+=c(a[0],i);
  }



  if(p==0){
    ans+=evenall;
    //奇数の2n個
    for (int i = 2; i <=a[1]; i+=2) {
      ans+=c(a[1],i)*evenall;
    }
  }else{
    // std::cout << evenall << '\n';
    for (int i = 1; i <= a[1] ; i+=2) {
      ans+=c(a[1],i)*evenall;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;

int main(){
  int n, m; scanf("%d %d", &n, &m);
  vector<ll> a(n);
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    ans += a[i];
  }
  sort(a.begin(), a.end());

  vector<P> data(m);
  for(int i = 0; i < m; i++){
    scanf("%lld %lld", &data[i].second, &data[i].first);
  }
  sort(data.begin(), data.end(), greater<P>());

  int now = 0, sum = 0;
  for(int i = 0; i < n; i++){
    if(data[now].first > a[i]){
      ans += (data[now].first - a[i]);
      sum++;
    }
    if(sum == data[now].second){
      sum = 0;
      now++;
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 5656
N,K=map(int,input().split())
x=sorted(list(map(int,input().split())))

ans=1000000000
for i in range(N-K+1):
  tmp1=abs(x[i])+abs(x[i+K-1]-x[i])
  tmp2=abs(x[i+K-1])+abs(x[i+K-1]-x[i])
  tmp=min(tmp1,tmp2)
  ans=min(tmp,ans)

print(ans)

           

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

/* ANSWER 1 */

int x[3], k, n;
long a[3][1000];
long d[106307];

int main(){
    for (int i = 0; i < 3; i++) cin >> x[i];
    cin >> k;
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < x[i]; j++){
            cin >> a[i][j];
        }
        sort(a[i], a[i]+x[i], greater<long>());
    }

    n = 0;
    for (int p = 1; p <= x[0]; p++){
        for (int q = 1; q <= x[1]; q++){
            for (int r = 1; r <= x[2]; r++){
                if (p*q*r <= k) {
                    d[n] = a[0][p-1] + a[1][q-1] + a[2][r-1];
                    n++;
                }
                else{
                    break;
                }
            }
        }
    }
    sort(d, d+n, greater<long>());
    for (int i = 0; i < k; i++){
        cout << d[i] << endl;
    }
}

Measured memory_bytes: 1152
# INPUT
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
    A.append(int(input()))
# PROCESS
points = [0 for x in range(N+1)]
for x in A:
    points[x]+=1
threshold = K - Q
# OUPUT
for y in range(1, N+1):
    if threshold + points[y] > 0:
        print("Yes")
    else:
        print("No") 

Measured memory_bytes: 8640
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    counter = 0
    for i in range(1000):
        c = i % 10
        b = (i // 10) % 10
        a = (i // 100) % 10
        aa = S.find(str(a))
        if aa != -1 and aa < N - 2:
            bb = S[aa+1:].find(str(b))
            if bb != -1 and bb < N - 1:
                cc = S[aa+bb+2:].find(str(c))
                if cc != -1:
                    counter += 1
    print(counter)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: int
    solve(N, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from math import *
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
for x in range(1,n+1):
    ans = 0
    m = ceil(sqrt(x))+1
    for i in range(1, m):
        for j in range(i, m):
            tmp = (i+j)**2 - 4*(i**2+j**2+i*j-x)
            if tmp > (i+j)**2:
                k = ( -(i+j) + sqrt(tmp) ) // 2
                if k >= j and i**2 + j**2 + k**2 + i*j + j*k + k*i == x:
                    if i == j == k:
                        ans += 1
                    elif i == j or j == k or k == i:
                        ans += 3
                    else:
                        ans += 6
    print(ans)

Measured memory_bytes: 71324
data Num = Odd | Even deriving Eq
flip n = if n == Odd then Even else Odd

f oe [] _ = if oe == Odd then True else False

f oe (d:ds) n =
  if n `mod` d == 0
  then if oe == Odd
       then True
       else False
  else f (Main.flip oe) ds n

ans' l r d =
  length $ filter (\x -> x) $ map (f Odd d) [l .. r]


ans ([0,0,0]:_) = []
ans ([n,l,r]:x) =
  let y = concat $ take n x
      z = drop n x
  in
    (ans' l r y):(ans z)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o



Measured memory_bytes: 4952
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000LL
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int dp[5060][5060],n,m,rui[105][105],rev[105][105],rev2[105][105],c,c2,x,y;
string s[105];
P p[5060],p2[5060];
int val(int a,int b,int c,int d){
	a=max(a,0);c=max(c,0);b=min(b,n-1);d=min(d,m-1);
	if(a>b||c>d) return 0;
	return rui[b][d]-(a?rui[a-1][d]:0)-(c?rui[b][c-1]:0)+(a&&c?rui[a-1][c-1]:0);
}
int calc(int a,int b,int c,int d,int e,int f,int g,int h){
	a = max(a,e); b = min(b,f);
	c = max(c,g); d = min(d,h);
	return val(a,b,c,d);
}
int rec(int a,int b,int c,int d){
	if(a>b||c>d) return 0;
	if(dp[rev[a][b]][rev2[c][d]] >= 0) return dp[rev[a][b]][rev2[c][d]];
	int &X = dp[rev[a][b]][rev2[c][d]];
	if(val(a,b,c,d) == 0) return X = 0;
	X = max(X,rec(a,b-1,c,d)+calc(x-(n-1-b),x+a,y-(m-1-d),y+c,b,b,c,d));
	X = max(X,rec(a+1,b,c,d)+calc(x-(n-1-b),x+a,y-(m-1-d),y+c,a,a,c,d));
	X = max(X,rec(a,b,c,d-1)+calc(x-(n-1-b),x+a,y-(m-1-d),y+c,a,b,d,d));
	X = max(X,rec(a,b,c+1,d)+calc(x-(n-1-b),x+a,y-(m-1-d),y+c,a,b,c,c));
	return X;
}
int main(){
	cin>>n>>m;
	rep(i,n)cin>>s[i];
	rep(i,n)rep(j,m){
		if(i) rui[i][j]+=rui[i-1][j];
		if(j) rui[i][j]+=rui[i][j-1];
		if(i&&j) rui[i][j]-=rui[i-1][j-1];
		rui[i][j] += (s[i][j]=='o');
		if(s[i][j]=='E')x=i,y=j;
	}
	rep(i,n)for(int j=i;j<n;j++){
		rev[i][j] = c;
		p[c] = mp(i,j);
		c++;
	}
	rep(i,m)for(int j=i;j<m;j++){
		rev2[i][j] = c2;
		p2[c2] = mp(i,j);
		c2++;
	}
	memset(dp,-1,sizeof(dp));
	cout<<rec(0,n-1,0,m-1)<<endl;
}

Measured memory_bytes: 100480
n = int(input())
int_list = list(map(int, input().split()))
count = 0
while True:
    isOdd = False
    for i in range(n):
        if(int_list[i] % 2 != 0):
            isOdd = True
    if isOdd:
        break
    for i in range(n):
        int_list[i] = int_list[i]/2
    count = count + 1
print(count)


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;

	cin >> n;
	int odd = 0;
	for (int i = 1; i <= n; i ++) {
		if (i % 2) odd ++;
	}
	cout << setprecision(9) << fixed << 1.0 * odd / (1.0 * n) << '\n';
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
c = []
for i in range(N):
    c += ["{0}".format(i+1) for _ in range(a[i])]

for i in range(H):
    print(' '.join(c[i*W : (i+1)*W][::(i%2)*2-1]))    

Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

struct node {
	int key;
	node* left, * right,* parent;
};

node *nil, *root;

void insert(int k) {
	node *y = nil;
	node *x = root;
	node* z;

	z = (node*)malloc(sizeof(node));
	z->key = k;
	z->left = nil;
	z->right = nil;

	while (x != nil) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;

	if (y == nil) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(node* root) {
	if (root == nil) return;
	if (root->left != nil) inorder(root->left);
	cout << " " << root->key;
	if (root->right != nil) inorder(root->right);
}

void preorder(node* root) {
	if (root == nil) return;
	cout << " " << root->key;
	if (root->left != nil) preorder(root->left);
	if (root->right != nil) preorder(root->right);
}

int main()
{
	int key, m;
	char com[20];
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		cin >> com;
		if (com[0] == 'i') {
			cin >> key;
			insert(key);
		}
		else if (com[0] == 'p') {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 26660
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
const int maxn = 1e5 + 100;
typedef long long ll;
vector<pair<int, int> > e[maxn];
ll dis[maxn];
bool vis[maxn];
int n, m,flag=0;

void dfs(int x)
{
	vis[x] = 1;
	for (int i = 0; i < e[x].size(); i++)
	{
		pair<int, int> cur=e[x][i];
		if (vis[cur.first]) {
			if (dis[cur.first] - dis[x] != cur.second) {
				flag = 1; break;
			}
		}
		else {
			dis[cur.first] = dis[x] + cur.second;
			dfs(cur.first);
		}
	}
}

int main()
{
	cin >> n >> m;
	memset(vis, 0, sizeof(vis));
	for (int i = 0; i < m; i++) {
		int l, r, d;
		cin >> l >> r >> d;
		e[l].push_back({ r,d });
		e[r].push_back({ l,-d });
	}
	flag = 0;
	for (int i = 0; i <n; i++) {
		if (!vis[i]) 
			dfs(i);
		if (flag) {
			break;
		}
	}
	if (flag) {
		cout << "No" << endl;
	}
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 12416
#include<iostream>
#include<string.h>
using namespace std;

int main(){
    int n;
    string str;
    int x = 0;
    int max = 0;

    cin >> n >> str;

    for(int i = 0; i < n; i++){
        if(str[i] == 'I'){
            x++;
        }
        else{
            x--;
        }
        //cout << x << endl;
        if(max < x){
            max = x;
        }
    }

    cout << max << endl;

    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-8
#define int long long 
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector< vi >
#define vb vector<bool>
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second


signed main()
{
    int SCORE = 10001;
    //int SCORE = 101;
    int2(n, c);
    vector< pair<i_i, int> > data(n);
    rep(i, n) {
        cin >> data[i].ffir >> data[i].fsec >> data[i].sec;
    }
    static int dp[2][102][10010];
    memset(dp, 0, sizeof(dp));
    //cout << "ok" << endl;

    rep(i, n) {
        for (int j = c; j > 0; j--) {
            for (int k = SCORE; k >= 0; k--) {
                dp[(i+1)%2][j][k] = max(dp[(i+1)%2][j][k], dp[i%2][j][k]);
                if (dp[i%2][j][k] && j + data[i].sec <= c) {
                    int yui = k + data[i].ffir, 
                        kyoko = dp[i%2][j][k] + data[i].fsec;
                    dp[(i+1)%2][j+data[i].sec][max(yui,kyoko)] =
                        max(dp[(i+1)%2][j+data[i].sec][max(yui,kyoko)],
                                min(yui, kyoko));

                    yui = k + data[i].fsec; 
                    kyoko = dp[i%2][j][k] + data[i].ffir;
                    dp[(i+1)%2][j+data[i].sec][max(yui,kyoko)] =
                        max(dp[(i+1)%2][j+data[i].sec][max(yui,kyoko)],
                                min(yui, kyoko));
                }
            }
        }
        int yui = data[i].ffir, 
            kyoko = data[i].fsec;
        dp[(i+1)%2][data[i].sec][max(yui,kyoko)] =
            max(dp[(i+1)%2][data[i].sec][max(yui,kyoko)], min(yui, kyoko));
    }

    int ans = 0;
    /*
    rep(i, n) {
        cout << "====" << i << "=====" << endl;
        rep(j, c+1) {
            rep(k, SCORE+1) {
                cout << dp[i][j][k] << " ";
            }
            cout << endl;
        }
    }
    */
    rep(i, c+1) {
        rep(j, SCORE+1) {
            //cout << dp[n][i][j] << " ";
            ans = max(ans, dp[n%2][i][j]);
        }
        //cout << endl;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 19052
import math
while True:
    n = int(input())
    if n == 0:
        break
    else:
        datas = list(map(int, input().split()))
        total = sum(datas)
        avg = total / n
        total2 = 0
        for data in datas:
            total2 += (data - avg) ** 2
        print(math.sqrt(total2 / n))



Measured memory_bytes: 5696
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
const long long MAXN=100005;
long long n;
long long s[MAXN];
long long vis[MAXN],pr[MAXN],tot;
long long a[MAXN],b[MAXN];
map<long long ,long long >M;
void Init()
{
	for(long long i=2;i<=3000;i++)
	{
		if(!vis[i])
			pr[++tot]=i;
		for(long long j=1;i*pr[j]<3000;j++)
		{
			vis[i*pr[j]]=1;
			if(i%pr[j]==0)
				break;
		}
	}
}
void work(long long o,long long x)
{
	a[o]=b[o]=1;
	for(long long i=1;pr[i]*pr[i]*pr[i]<=x;i++)
	{
		long long jl=0;
		while(x%pr[i]==0)
		{
			x/=pr[i];
			jl++;
		}
		jl%=3;
		if(jl==1)
			a[o]*=pr[i],b[o]*=pr[i]*pr[i];
		if(jl==2)
			b[o]*=pr[i],a[o]*=pr[i]*pr[i];
	}
	if(x!=1)
	{
		long long k=sqrt(x);
		if(k*k==x)
			a[o]*=k*k,b[o]*=k;
		else
			a[o]*=x,b[o]*=x*x;
	}
}
int main()
{
	//freopen("anticube.in","r",stdin);
	//freopen("anticube.out","w",stdout);
	Init();
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&s[i]);
		work(i,s[i]);
	}
	for(long long i=1;i<=n;i++)
		M[a[i]]++;
	long long ans=0;
	for(long long i=1;i<=n;i++)
	{
		if(!M[a[i]])
			continue;
		if(a[i]==b[i])
			ans++,M[a[i]]=0;
		else
		{
			ans+=max(M[a[i]],M[b[i]]);
			M[a[i]]=M[b[i]]=0;
		}
	}
	printf("%lld\n",ans);
	fclose(stdin);
	fclose(stdout);
}

Measured memory_bytes: 15104
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int m[15][15];
void no()
{
	printf("Impossible\n");
	exit(0);
}
typedef pair<int, int>pii;
typedef pair<pii, int>pi3;
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	for (int i = 1; i <= mx; i++)for (int j = 1; j <= my; j++)scanf("%d", &m[i][j]);
	set<pi3>se;
	for (int i = 1; i <= mx; i++)
	{
		for (int j = 1; j <= my; j++)
		{
			for (int k = 0; k <= 100; k++)
			{
				for (int l = 0; l <= 100; l++)
				{
					int c = m[i][j] - k*i - l*j;
					if (c < 0)continue;
					bool f = true;
					for (int p = 1; p <= mx; p++)
					{
						for (int q = 1; q <= my; q++)
						{
							if (c + k*p + l*q < m[p][q])f = false;
						}
					}
					if (f)
					{
						se.insert(make_pair(make_pair(k, l), c));
						goto l01;
					}
				}
			}
			no();
		l01:;
		}
	}
	printf("Possible\n");
	printf("%d %d\n", 222, 220 + se.size());
	for (int i = 1; i < 111; i++)printf("%d %d X\n", i, i + 1);
	for (int i = 112; i < 222; i++)printf("%d %d Y\n", i, i + 1);
	set<pi3>::iterator it = se.begin();
	for (;;)
	{
		if (it == se.end())break;
		pi3 z = *it;
		it++;
		printf("%d %d %d\n", 1 + z.first.first, 222 - z.first.second, z.second);
	}
	printf("%d %d\n", 1, 222);
}

Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
  i64 n;
  vi64 a;
  cin>>n;
  forn(i,n)
  {
    i64 v;
    cin>>v;
    a.pb(v);

  }
sort(all(a));
i64 mid=n/2;
cout<<a[mid]-a[mid-1];

    return 0;
  }


Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
struct ff
{
	string place;
	int num;
	int xuhao;
}f[105];
bool cmp(ff a,ff b)
{
	if(a.place==b.place){
		return a.num>b.num;
	}
	return a.place<b.place;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>f[i].place>>f[i].num;
		f[i].xuhao=i+1;
	}
	sort(f,f+n,cmp);
	for(int i=0;i<n;i++){
		cout<<f[i].xuhao<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
L = []
for _ in range(N):
    L.append(int(input()))

ans = float('inf')
for mask in range(pow(4, N)):
    cost = 0
    for i, l in enumerate([A, B, C]):
        grp = []
        for digit in range(N):
            if mask // pow(4, digit) % 4 == i:
                grp.append(L[digit])

        if not grp:
            cost = float('inf')

        cost += (len(grp) - 1) * 10
        cost += abs(l - sum(grp))
    ans = min(ans, cost)

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

int main() {
	long long N, K;
	string S;

	cin >> N >> S >> K;

	char s = S[K-1];
	for (int i = 0; i < N; i++) {
		if (S[i] != s) {
			S[i] = '*';
		}
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

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

	return 0;
}

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

//	long long dp[2000][2000] = {};
int main(){
//	string t,b;
//	cin >> t >> b;
//	dp[0][0] = 1LL;
//
//	for(int i=0; i<t.size(); i++){
//		for(int j=0; j<b.size(); j++){
//			dp[i+1][j] += dp[i][j];
//			if(t[i] == b[j]){
//				dp[i+1][j+1] += dp[i][j];
//			}
//			dp[i+1][j] %= 1000000007;
//			dp[i+1][j+1] %= 1000000007;
//		}
//		dp[i+1][b.size()] += dp[i][b.size()];
//	}
//
//	cout << dp[t.size()][b.size()]%1000000007 << endl;
//
//	return 0;
/*	int p, m, c;
	cin >> p >> m >> c;

	cout << p + m + c << endl;*/
	/*int ha, hb, ka, kb, a, b, c, d, x, y;
	cin >> ha >> hb >> ka >> kb >> a >>b >>c >>d;

	x = ha*a+hb*b+(ha/10)*c+(hb/20)*d;
	y = ka*a+kb*b+(ka/10)*c+(kb/20)*d;

	if(x > y){
		cout << "hiroshi" << endl;
	}

	else if(y > x){
		cout << "kenjiro" << endl;
	}

	else{
		cout << "even" << endl;
	}*/
	/*
	int D, L;
	cin >> D >> L;

	cout << D/L+D%L << endl;
	*/
	/*
	int n;
	cin >> n;

	int x[100],y[100],z[100],X,Y,Z,a=0,sol[100][3] = {};

	//A

	cin >> X;

	for(int i=0; i<X; i++){
		int xm;
		cin >> xm;
		x[i] = xm;
	}

	//B

	cin >> Y;

	for(int i=0; i<Y; i++){
		int ym;
		cin >> ym;
		y[i] = ym;
	}


	//C
	cin >> Z;

	for(int i=0; i<Z; i++){
		int zm;
		cin >> zm;
		z[i] = zm;
	}

	//(NA && C) || (B && C) - 

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			//A
			if(i+1 == x[j])sol[i][1] = 1;
			//B
			if(i+1 == y[j])sol[i][2] = 1;
			//C
			if(i+1 == z[j])sol[i][3] = 1;

		}
	}

	for(int i=0; i<n; i++){
		if(sol[i][1] == 0)sol[i][1] = 2;
	}

	for(int i=0; i<n; i++){
		if(sol[i][1] == 2 && sol[i][3] == 1)
			a++;
		else if(sol[i][2] == 1 && sol [i][3] == 1)
			a++;
	}

	cout << a << endl;
	*/

	int n;
	cin >> n;

	int P[100];

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

	int j=0,nol=1;

	while(true){
		for(int i=0; i < n; i++){
			if(P[i] >= nol)j++;
		}
		if(j < nol)break;
		nol++;
		j=0;
	}



	cout << nol-1 << endl;

	return 0;

}



Measured memory_bytes: 3108
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

h,w=LI()
h,w,g,_=GGI(h,w,boundary=0)
ans=['']*(h*w)
for i in range(h*w):
    if 0==i//w or i//w==h-1 or i%w==0 or i%w==w-1:
        continue
    if g[i]==1:
        ans[i]='#'
    else:
        ans[i]=str(sum([g[i+d]for d in (-1,1,w,-w,w-1,-w-1,w+1,-w+1)]))

for i in range(1,h-1):
    print(''.join(ans[i*w+1:(i+1)*w-1]))

Measured memory_bytes: 41452
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int main(){
  int A, B; cin >> A >> B;

  if (A < B){
    cout << "a < b" << endl;
  }else if (A == B){
    cout << "a == b" << endl;
  }else{
    cout << "a > b" << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	string S=in<string>();
	int upper,lower;
	upper = (S[0]-'0')*10+(S[1]-'0');
	lower = (S[2]-'0')*10+(S[3]-'0');
	auto check = [](int v){
		if(v>=1 && v<=12) return 1;
		return 0;
	};
	auto res = check(upper)*10+check(lower);
	switch(res){
	case 0:
		cout << "NA" << endl;
		break;
	case 1:
		cout << "YYMM" << endl;
		break;
	case 10:
		cout << "MMYY" << endl;
		break;
	case 11:
		cout << "AMBIGUOUS" << endl;
		break;
	default:
		break;
	}

	return 0;
}


Measured memory_bytes: 256
//15:47
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abs(ll a){return(a<0)?-a:a;}

ll gcd(ll a, ll b){
        if(b > a){
                ll tmp = b;
                b = a;
                a = tmp;
        }
        if(b == 0) return a;
        else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
        ll gcdi = gcd(a,b);
        return a/gcdi*(b);
}

ll diff(ll a, ll b, ll c){
        return max(a,max(b,c))-min(a,min(b,c));
}
#define MOD (1000000000+7)
int main(){
        ll H,W;
        scanf("%lld %lld",&H,&W);

        ll mindiff = 10000000000;

        if(W % 3 == 0 || H % 3 == 0){
                puts("0");
                return 0;
        }
        if(W % 3 != 0) {
                mindiff = min(mindiff, H);
        }
        if(H % 3 != 0){
                mindiff = min(mindiff, W);
        }
        for(ll x = 1; x <= W-1; x++){
                if(H % 2 == 0){
                        mindiff = min(mindiff, diff(x*H, (W-x)*(H/2), (W-x)*(H/2)));
                }else{
                        mindiff = min(mindiff, diff(x*H, (W-x)*(H/2), (W-x)*(H/2+1)));
                }
        }

        for(ll y = 1; y <= H-1; y++){
                if(W % 2 == 0){
                        mindiff = min(mindiff, diff(y*W, (H-y)*(W/2), (H-y)*(W/2)));
                }else{
                        mindiff = min(mindiff, diff(y*W, (H-y)*(W/2), (H-y)*(W/2+1)));
                }
        }
        printf("%lld\n",mindiff);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int K = Integer.parseInt(br.readLine());
		int X = Integer.parseInt(br.readLine());
		int Y = Integer.parseInt(br.readLine());
		
		int res;
		
		if ( (N-K) < 0  ){
			res = N * X;
		}else{
			res = (K * X) + ((N-K) * Y);
		}
		System.out.println(res);
		
	}	
}


Measured memory_bytes: 8148
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max;
		
		if(a<=b){
			if(b<=c){
				max = c;
			}else{
				max = b;
			}
		}else{
			if(a<=c){
				max = c;
			}else{
				max = a;
			}
		}

		System.out.println(a+b+c-max);
		
	}

	private static int calc(int[] a,int ans,int n) {
		int sum=a[0];
		boolean plusFlag;
		// TODO 自動生成されたメソッド・スタブ
		if(a[0] > 0){
			plusFlag = true;
		}else{
			plusFlag = false;
		}



		for(int i = 1;i<n;i++){
			sum += a[i];
			if(plusFlag){
				if(sum >= 0){
					ans += Math.abs(sum)+1;
					sum = -1;

				}
			}else{
				if(sum <= 0){
					ans += Math.abs(sum)+1;
					sum = 1;
				}
			}
			plusFlag = !plusFlag;
		}


		return ans;
	}


}

Measured memory_bytes: 23764
l=list(map(int,input().split()))
cnt=0
while True:
    l=sorted(l)
    if l[0]==l[1]==l[2]:break
    if l[0]==l[1]:
        l[0]+=1
        l[1]+=1
    else:l[0]+=2
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
N = int(input())
F = []
P = []
for _ in range(N):
    F.append(list(map(int, input().split())))
for _ in range(N):
    P.append(list(map(int, input().split())))
a = [0] * 20


def dfs(pos):
    if pos == 10:
        if a.count(0) == 20:
            return -1000000000
        score = 0
        for f, p in zip(F, P):
            c = 0
            for aa, ff in zip(a, f):
                if aa == ff == 1:
                    c += 1
            score += p[c]
        return score
    a[pos] = 0
    x = dfs(pos + 1)
    a[pos] = 1
    y = dfs(pos + 1)
    return max(x, y)


def main():
    print(dfs(0))


main()


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

int main() {
	int N, W;
	cin >> N >> W;
	vector<pair<int, int>> vw(1 + N);
	for (int i = 1; i <= N; ++i) cin >> vw[i].first >> vw[i].second;
	vector<vector<int>> a(1 + N, vector<int>(1 + W));
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (j < vw[i].second) a[i][j] = a[i - 1][j];
			else a[i][j] = max(a[i - 1][j - vw[i].second] + vw[i].first, a[i - 1][j]);
		}
	}
	cout << a.back().back() << endl;
}


Measured memory_bytes: 6796
#include <stdio.h>
#include <math.h>

int main(){
	int n,a,MIN=1000000,MAX=-1000000;
	long long sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		if(a<MIN) MIN=a;
		if(a>MAX) MAX=a;
		sum+=a;
	}
	printf("%d %d %lld\n",MIN,MAX,sum);
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//












int n;
int a[110];

int memo[110][10010];

int dfs(int x, int sum){
        if(x == n){
                if(sum%10 == 0) return 0;
                else return sum;
        }
        if(memo[x][sum] != -1) return memo[x][sum];

        int ret = 0;
        int val1 = dfs(x+1, sum + a[x]);
        int val2 = dfs(x+1, sum);
        ret += max(val1,val2);

        return memo[x][sum] = ret;
}

int main(){
        cin >> n;
        rep(i,n) cin >> a[i];
        memset(memo,-1,sizeof(memo));

        int ans = dfs(0, 0);
        cout << ans << endl;
}




Measured memory_bytes: 4608