akhauriyash/Code-Regression huggingface dataset:
//
// Created by 10940 on 2020/7/25.
//

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5 + 10;
int a[MAX_N];

int main() {
    int n;
    cin >> n;
    /// w = 0, r = 1
    /// x = 白色石头个数, y = 红色石头个数
    int x = 0, y = 0;
    for (int i = 0; i < n; i++ ) {
        char c;
        cin >> c;
        if (c == 'W') {
            x++;
            a[i] = 0;
        } else {
            y++;
            a[i] = 1;
        }
    }
    int Y = y;
    int counts = 0;
    for (int i = 0; i < Y;i++) {
        if (a[i] == 0 && y > 0) {
            counts++;
        }
        if (a[i] == 1) {
            y--;
        }
    }
    cout << counts << endl;
    return 0;
}

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

int cnt[3][3];
int cntR[3], cntC[3];

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

    int cell[3][3];

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> cell[i][j];
        }
    }

    int n;  cin >> n;

    set<int> se;

    while(n--){
        int x;  cin >> x;
        se.insert(x);
    }

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if(se.count(cell[i][j])){
                cnt[i][j]++;
                cntR[i]++;
                cntC[j]++;

                if(cntR[i] == 3 || cntC[j] == 3){
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
    }

    bool flag = true;
    for(int i = 0; i < 3; i++){
        if(!cnt[i][i]){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "Yes\n";
        return 0;
    }

    flag = true;

    for(int i = 0; i < 3; i++){
        if(!cnt[3 - i - 1][i]){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";

    return 0;
}


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

signed main() {
  int n, k;
  char s[10];
  scanf("%d %d %s", &n, &k, s);
  int i = 0;
  for (; i < k; i++) {
    puts(s);
  }
  for (; i < n; i++) {
    puts("7");
  }
}


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

int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  
  for(int i=0;i<k;i++)
  {
    if(b <= a)
      b = 2*b;
    else if(c <= b)
      c = 2*c;
  }
  
  if(c > b && b > a)
    cout<<"Yes";
  else
    cout<<"No";
  
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
bool vis[100005];
vector<int> v[100005];
bool dfs(int node,int p,int avoid)
{
	if (vis[node])
	return 1;
	vis[node]=1;
	for (int u:v[node])
	{
		if (u!=p && u!=avoid && dfs(u,node,avoid))
		return 1;
	}
	return 0;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	while (m--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	bool ok=1;
	for (int i=1;i<=n;i++)
	ok&=(v[i].size()%2==0);
	if (!ok)
	{
		printf("No");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		if (v[i].size()>=6)
		{
			printf("Yes");
			return 0;
		}
	}
	for (int i=1;i<=n;i++)
	{
		if (v[i].size()==4)
		{
			for (int j:v[i])
			{
				memset(vis,0,sizeof(vis));
				if (dfs(j,0,i))
				{
					printf("Yes");
					return 0;
				}
			}
			printf("No");
			return 0;
		}
	}
	printf("No");
}

Measured memory_bytes: 8192
#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int d[100][100];
		bool b[100][100]={};
		rep(u,n) rep(v,n) d[u][v]=(u==v?0:INF);
		rep(i,m){
			int u,v,c; scanf("%d%d%d",&u,&v,&c); u--; v--;
			d[u][v]=d[v][u]=min(d[u][v],c);
			b[u][v]=b[v][u]=true;
		}

		rep(k,n) rep(i,n) rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

		int ans=d[0][n-1];
		rep(u,n) rep(v,n) {
			bool ok=false;
			rep(w,n) if(w!=u && w!=v && b[u][w] && b[w][v]) { ok=true; break; }
			if(ok){
				ans=min(ans,d[0][u]+d[v][n-1]);
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 808
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, ANSWER;
	string S;
	cin >> N >> S;
	vector <int> count_W(N);//リーダーが左から数えてi番目の時の左にいる西を向いている人
	vector <int> count_E(N);//リーダーが左から数えてi番目の時の右にいる東を向いている人
	ANSWER = N;
	count_W.at(0) =0;
	for (int i=0; i<N-1; i++){
		if(S.at(i) == 'W'){
			count_W.at(i+1)=count_W.at(i)+1;
		}
		else{
			count_W.at(i+1)=count_W.at(i);
		}
	}
	
	count_E.at(N-1) = 0;
	for (int i=0; i<N-1; i++){
		if(S.at(N-1-i) == 'E'){
			count_E.at(N-2-i)=count_E.at(N-1-i)+1;
		}
		else{
			count_E.at(N-2-i)=count_E.at(N-1-i);
		}
	}
	
		for (int i=0; i<N; i++){
		if (count_W.at(i) + count_E.at(i) < ANSWER){
			//cout << ANSWER << i << endl;
			ANSWER = count_W.at(i) + count_E.at(i);
			//cout << ANSWER << endl;
		}
	}
    
	cout << ANSWER << endl;
  return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
const int N=3005;
ll dp[N][N];
ll solve(vector<ll>&a,int c,int start,int end)
{
  if(start>end)
    return 0;

  if(dp[start][end])
    return dp[start][end];

  ll ans=0;
  if(c==0)
  {
    ans=a[start]+solve(a,1-c,start+1,end);
    ans=max(ans,a[end]+solve(a,1-c,start,end-1));
  }
  else
  {
    ans=solve(a,1-c,start+1,end)-a[start];
    ans=min(ans,solve(a,1-c,start,end-1)-a[end]);
  }

  return dp[start][end]=ans;

}


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

  ll ans=solve(a,0,0,n-1);
  cout<<ans<<endl;
}


Measured memory_bytes: 49988
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N >> K;
	vector<int>p(N);
	for (auto &i : p) {
		cin >> i;
		i--;
	}
	int ans = 0;
	if (p[0]) {
		p[0] = 0;
		ans++;
	}
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		edge[i].push_back(p[i]);
		edge[p[i]].push_back(i);
	}
	vector<int>depth(N, MOD);
	Calculate_Depth(edge, depth, 0);
	priority_queue<pair<int, int>>PQ;
	for (int i = 0; i < N; i++) {
		PQ.push({ depth[i],i });
	}
	vector<int>deep(N);
	while (!PQ.empty()) {
		auto cn = PQ.top().second;
		auto c = PQ.top().first;
		PQ.pop();
		deep[cn] = max(deep[cn], depth[cn]);
		if (deep[cn] <= K)continue;
		if (deep[cn] - depth[cn] + 1 == K) {
			ans++;
			deep[cn] = 1;
		}
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn])continue;
			deep[i] = max(deep[i], deep[cn]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8444
#include<iostream>
using namespace std;
int main(void) {
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d) cout<<"Left"<<endl;
  else if(a+b<c+d) cout<<"Right"<<endl;
  else cout<<"Balanced"<<endl;
  return 0;
}


Measured memory_bytes: 256
N,A,B = map(int,input().split())
maxN,minN = 0,0

if N >= A + B:
  minN = 0
  maxN = min([A,B])
else:
  minN = A + B - N
  maxN = min([A,B])
  
print('{} {}'.format(maxN,minN))


Measured memory_bytes: 2940
//abc162D
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int k, i, len, b=0;
  long long sum=0;
  scanf("%d", &len);
  char n[len];
  scanf("%s", n);

  for(i=0; i < len; i++)if(n[i]=='B')
    b++;
  for(i=0; i < len; i++){
    for(k=i + 1; k < len; k++){
      if((n[i] == 'R' && n[k] == 'G') || (n[i] == 'G' && n[k] == 'R')){
        if(2 * k - i < len && n[2 * k - i] == 'B') sum--; //RGB or GRB
        if((i + k) % 2 == 0 && n[(i + k) / 2] == 'B') sum--; //RBB or GBR
        if((2 * i - k) >= 0 && n[2 * i - k] == 'B') sum--; //BRG or BGR
        sum+=b;
      }
    }
  }
  printf("%lld\n", sum);
}

Measured memory_bytes: 1732
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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


const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n){
        cin >> l[i];
    }
    sort(l.begin(),l.end());
    ll ans=0;
    rep(i,n){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                set<ll> s;
                s.insert(l[i]);
                s.insert(l[j]);
                s.insert(l[k]);
                if(s.size()==3 && l[i]+l[j]>l[k]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s;
  cin >>s;
  int res = 0;
  rep(i, s.size()/2){
    if(s[i] != s[s.size()-1-i]) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n,m,a[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;
  LL s=0;
  for(int i=1;i<=m;i++)cin>>a[i],s+=a[i];
  	if(s>n)cout<<-1<<'\n';
  else cout<<n-s<<'\n';
 	return 0;
}

Measured memory_bytes: 3684
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
    int r, c;
    cin >> r >> c;

    int a[r+1][c+1];
    for (int i = 0; i < r+1; i++)
    {
        for (int j = 0; j < c+1; j++)
        {
            a[i][j] = 0;
        }
        
    }
    

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> a[i][j];
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
        }
        
    }
    
    for (int i = 0; i < r+1; i++)
    {
        for (int j = 0; j < c+1; j++)
        {
            printf("%d",a[i][j]);
            if(j<c)printf(" ");
        }
        printf("\n");
        
    }
    

    return 0;
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
	string t;
	cin>>t;
	int l=t.length();
	for(int i=0;i<l;i++)
	{
		if(t[i]=='?')cout<<'D';
		else cout<<t[i];
	 } 
 } 

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> e(n,vector<int>(0));
    vector<int> a(n,0),b(n,0);
    vector<pair<ll,ll>> c(n);
    rep(i,n){
        c.at(i)=mk(1,1);
    }
    queue<pair<int,pair<ll,ll>>> q;
    rep(i,n-1){
        int f,g;
        cin >> f >> g;
        e.at(f-1).push_back(g-1);
        e.at(g-1).push_back(f-1);
        a.at(f-1)++;
        a.at(g-1)++;
    }
    rep(i,n){
        if (a.at(i)==1){
            q.push(mk(i,mk(1,1)));
        }
    }
    ll ans=2;
    while(!q.empty()){
        int m=q.front().first;
        ll w=q.front().second.first,r=q.front().second.second;
        q.pop();
        ans=(w+r)%MOD;
        a.at(m)--;
        b.at(m)=1;
        rep(i,e.at(m).size()){
            if (b.at(e.at(m).at(i))==0){
                (c.at(e.at(m).at(i)).first*=(w+r)%MOD)%=MOD;
                (c.at(e.at(m).at(i)).second*=w)%=MOD;
                a.at(e.at(m).at(i))--;
                if (a.at(e.at(m).at(i))<=1){
                    q.push(mk(e.at(m).at(i),mk(c.at(e.at(m).at(i)).first,c.at(e.at(m).at(i)).second)));
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
    int n;
    cin>>n;
    double tax=1.08;
    int ans=-1;
    rep(i,50001){
        if(floor(i*tax)==(int)n){
            ans=i;
        }
    }
    if(ans!=-1){
        cout<<ans<<endl;
    }else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    vector<int>a(n);
    cin >> s;
    for(int i=0;i<n;i++){
        if(i>=1)a[i]=a[i-1];
        if(s[i]=='W'){
            a[i]--;
        }else{
            a[i]++;
        }
    }
    int idx=max_element(a.begin(),a.end())-a.begin();
    cout << count(s.begin(),s.begin()+idx,'W')+count(s.begin()+idx+1,s.end(),'E');
}


Measured memory_bytes: 1872
#include <iostream>
using namespace std;
int N,K;
int A[100005];
int nr=0;
int gcd(int a,int b)
{
    if(!b)return a;
    return gcd(b,a%b);
}
int main()
{
    cin>>N>>K;
    for(int i=1;i<=N;i++)
    {
        cin>>A[i];
        nr=gcd(nr,A[i]);
    }
    for(int i=1;i<=N;i++)
    {
        if(A[i]>=K&&(A[i]-K)%nr==0)
        {
            cout<<"POSSIBLE";return 0;
        }
    }
    cout<<"IMPOSSIBLE";return 0;
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll n;
	cin>>n;
	vll A(n);
	for(int i=0;i<n;i++)
		cin>>A[i];
	sort(all(A));
	cout<<A[n/2]-A[n/2-1]<<"\n";

}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int n,m;
string s[1005];
int dp[1005][1005];

bool safe(int x,int y){
  if (x>=n || y>=m) return false;
  if (s[x][y] == '#') return false;
  return true;
}

int f(int x, int y){
  if (!safe(x,y)) return 0;
  if (x==n-1 && y==m-1) return 1;
  int &ret = dp[x][y];
  if (ret != -1 ) return ret;
  return ret = (f(x+1,y) + f(x,y+1)) % ((int)1e9+7);
}
int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> m;
  for(int i=0; i<n; i++){
    cin >> s[i];
  }
  memset(dp,-1,sizeof dp);
  cout << f(0,0) << '\n';

}

Measured memory_bytes: 5376
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

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

    int N; cin >> N;
    vi A(N); 
    int cnt = 0;
    int lo = INF;
    REP(i, N) {
        cin >> A[i];
        if (A[i] < 0) cnt++;
        lo = min(lo, abs(A[i]));
    }
    ll sum = 0;
    REP(i, N) sum += abs(A[i]);

    ll ans;
    if (cnt%2==0) {
        ans = sum;
    } else {
        ans = sum - lo*2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(all(a));
	cout << a[2] * 10 + a[1] + a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define ll long long
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl

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

    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i += 2)
    {
        char a = s[i];
        if (a == 'L')
        {
            cout << "No\n";
            return 0;
        }
    }
    for (int i = 1; i < s.size(); i += 2)
    {
        char a = s[i];
        if (a == 'R')
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math
import itertools


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    H, W, M = LI()

    HList = [0]*H
    WList = [0]*W
    graph = set()
    for m in range(M):
        h, w = LI()
        HList[h-1] += 1
        WList[w-1] += 1
        graph.add((h-1, w-1))

    Hmax = max(HList)
    Wmax = max(WList)

    HIndex = [i for i, v in enumerate(HList) if v == Hmax]
    WIndex = [i for i, v in enumerate(WList) if v == Wmax]

    ans = Hmax + Wmax
    for h in HIndex:
        for w in WIndex:
            if not (h, w) in graph:
                print(ans)
                return

    print(ans-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84352
n = gets.to_i
n.times{
    y, m, d = gets.chomp.split.map(&:to_i)
    days = 0
    1.upto(y - 1){|year| days += (year % 3 == 0) ? 200 : 195}
    1.upto(m - 1){|month| days += (month % 2 == 0) ? (y % 3 == 0 ? 20 : 19) : 20}
    1.upto(d){|day| days += 1}
    puts 196471 - days
}



Measured memory_bytes: 6860
x, n = map(int, input().split())
p = set(map(int, input().split()))
ans = -1
d = float("inf")

for i in range(101, -1, -1):
    if i in p: continue
    c = abs(x-i)
    if c <= d:
        ans = i
        d = c

print(ans)


Measured memory_bytes: 9048
#include <iostream>

using namespace std;

int main(){
    float a,b,c,d,e,f,g,h;
    int t;

    cin >> t;
    while(t--){
        cin >> a >> b >> c >> d >> e >> f >> g >> h;
        if((d-b)/(c-a) == (h-f)/(g-e)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }

    return 0;
}
/*
#include <iostream>
#include <limits>
using namespace std;

struct Point2D {
    double x, y;

    Point2D() {}
    Point2D(double ax, double ay) {
        x = ax;
        y = ay;
    }
    Point2D operator -(Point2D &p) {
        return Point2D(x - p.x, y - p.y);
    }
    double slope(Point2D &p) {
        return (p.x != x) ? (p.y - y) / (p.x - x) : numeric_limits<double>::infinity();
    }
    double cross(Point2D &p) { // only z
        return x * p.y - y * p.x;
    }
};

namespace std {
    istream &operator>>(istream &is, Point2D &p) {
        is >> p.x >> p.y;
        return is;
    }

    ostream &operator<<(ostream &os, Point2D &p) {
        os << fixed << p.x << " " << p.y;
        return os;
    }
}

int main()
{
    int n;
    cin >> n;
    for (Point2D a, b, c, d; n-- && cin >> a >> b >> c >> d;)
        cout << ((a.slope(b) == c.slope(d)) ? "YES" : "NO") << endl;

    return 0;
}
*/

Measured memory_bytes: 1228
# Problem A - Colorful Subsequence

# input
N = int(input())
S = list(input())

# initialization
word_dic = {}
ans = 1
INF = 10**9 + 7

# word count
for s in S:
    if not s in word_dic:
        word_dic[s] = 1
    else:
        word_dic[s] += 1

# output
for w in word_dic:
    tmp = word_dic[w]
    ans = (ans * (tmp + 1))%INF
ans -= 1
print(ans % INF)


Measured memory_bytes: 49392
#include <iostream>
using namespace std;
int main(){
	int a[1010], n, b;
	for (int i = 0; i < 9; i++)
		cin >> a[i];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b;
		for (int j = 0; j < 9; j++)
			if (a[j] == b)
				a[j] = 0;
	}
	if (a[0] + a[1] + a[2] == 0 || a[3] + a[4] + a[5] == 0 || a[6] + a[7] + a[8] == 0)
		cout << "Yes";
	else if (a[0] + a[3] + a[6] == 0 || a[1] + a[4] + a[7] == 0 || a[2] + a[5] + a[8]==0)
		cout << "Yes";
	else if (a[0] + a[4] + a[8] == 0 || a[2] + a[4] + a[6] == 0)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3580
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int ans = 700 + 100 * count(s.begin(), s.end(), 'o');
	cout << ans << endl;
	return 0;
}


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

class ShopInfo
{
   public int Volume { get; private set; }
   public int Price { get; private set; }
   public int DiscountCount { get; private set; }
   public int DiscountRate { get; private set; }  // [%]

   public int purchaseCount { get; private set; }

   public ShopInfo(int volume, int price, int discountCount, int discountRate)
   {
      Volume = volume;
      Price = price;
      DiscountCount = discountCount;
      DiscountRate = discountRate;
   }

   public int TotalPrice
   {
      get
      {
         int standardCount = purchaseCount % DiscountCount;
         int standardPrice = standardCount * Price;
         int discountedCount = (purchaseCount / DiscountCount) * DiscountCount;
         int discountedPrice = discountedCount * Price * (100 - DiscountRate) / 100;
         return standardPrice + discountedPrice;
      }
   }
   public int TotalVolume { get { return purchaseCount * Volume; } }

   public void Purchase(int count)
   {
      purchaseCount += count;
   }

   public void Clear()
   {
      purchaseCount = 0;
   }
}

class ShopCalculator
{
   private List<ShopInfo> shopList = new List<ShopInfo>();

   public void AddShop(int volume, int price, int discountCount, int discountRate)
   {
      var shopInfo = new ShopInfo(volume, price, discountCount, discountRate);
      shopList.Add(shopInfo);
   }

   public int TotalPrice { get { return (from shop in shopList select shop.TotalPrice).Sum(); } }
   public int TotalVolume { get { return (from shop in shopList select shop.TotalVolume).Sum(); } }
   public int TotalCount { get { return (from shop in shopList select shop.purchaseCount).Sum(); } }

   public int GetMinPrice(int volume)
   {
      foreach (var shop in shopList)
      {
         shop.Clear();
      }

      int minPrice = int.MaxValue;

      while (true)
      {
         if (TotalVolume == volume)
         {
            minPrice = Math.Min(TotalPrice, minPrice);
         }

         shopList[0].Purchase(1);

         for (int i = 0; i < shopList.Count; i++)
         {
            if (TotalVolume <= volume)
            { break; }

            if (i == shopList.Count - 1)
            { return minPrice; }

            shopList[i].Clear();
            shopList[i + 1].Purchase(1);
         }
      }
   }
}

class MainClass
{
   static void Main(string[] args)
   {
      var stringBuilder = new StringBuilder();

      var shopCaluculator = new ShopCalculator();
      shopCaluculator.AddShop(200, 380, 5, 20);
      shopCaluculator.AddShop(300, 550, 4, 15);
      shopCaluculator.AddShop(500, 850, 3, 12);

      while (true)
      {
         int volume = int.Parse(Console.ReadLine());
         if (volume == 0) { break; }

         int minPrice = shopCaluculator.GetMinPrice(volume);
         stringBuilder.AppendLine(minPrice.ToString());
      }

      Console.Write(stringBuilder.ToString());
   }
}


Measured memory_bytes: 9696
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main(){
    ll H, N;
    cin >> H >> N;
    VL A(N);
    FOR(i, 0, N) cin >> A[i];

    for (ll i = 0; i < N; i++) H -= A[i];

    if(H <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int Check_AB(char *Moji, int length);
int Min(int A, int B);
int main(void) {
   
   int N;
   
   scanf("%d",&N);
   
   char S[N][20];
   int Length[N];
   int i;
   
   for (i = 0; i < N; i++) {
      scanf("%s",S[i]);
      Length[i] = strlen(S[i]);
   }
   
   int r_A = 0;
   int l_B = 0;
   int l_B_r_A = 0;
   
   for (i = 0; i < N; i++) {
      if (S[i][0] == 'B') {
         l_B++;
      }
      if (S[i][Length[i] - 1] == 'A') {
         r_A++;
      }
      if (S[i][0] == 'B' && S[i][Length[i] - 1] == 'A') {
         l_B_r_A++;
      }
   }
   
   l_B = l_B - l_B_r_A;
   r_A = r_A - l_B_r_A;
   
   //printf("%d %d %d\n",l_B,r_A,l_B_r_A);
   
   int ans_int;
   if (l_B >= 1 && r_A >= 1) {
      ans_int = l_B_r_A + 1;
      l_B = l_B - 1;
      if (l_B < 0) {
         l_B = 0;
      }
      r_A = r_A - 1;
      if (r_A < 0) {
         r_A = 0;
      }
      l_B_r_A = 0;
      ans_int = ans_int + Min(r_A,l_B);
   }
   else if ((l_B >= 1 && r_A == 0) || (r_A >= 1 && l_B == 0)) {
      ans_int = l_B_r_A;
   }
   else {
      ans_int = l_B_r_A - 1;
      if (ans_int < 0) {
         ans_int = 0;
      }
   }
   
   int ans_on = 0;
   for (i = 0; i < N; i++) {
      ans_on = ans_on + Check_AB(S[i],Length[i]);
   }
   
   
   //printf("%d %d %d\n",ans_on, ans_int, ans_on + ans_int);
   
   printf("%d\n",ans_on + ans_int);
   
   
  
   return 0;
   
}

int Min(int A, int B) {
   if (A < B) {
      return A;
   }
   else {
      return B;
   }
}

int Check_AB(char *Moji, int length) {
   
   int i;
   int count = 0;
   
   for (i = 0; i < length - 1; i++) {
      if (Moji[i] == 'A' && Moji[i+1] == 'B') {
         count++;
      }
   }
   
   return count;
   
}



Measured memory_bytes: 384
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



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

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{

	int n, k;
	cin >> n >> k;

	vi a(n);
	invec(a, n);

	sort(all(a));

	vi dp(k+1, 0);

	dp[0] = 0;

	fr(i,1,k+1)
	{
		ll res = 1;
		fr(j,0,n)
		{
			if(a[j] > i)
				break;

			res = res & dp[i-a[j]];
		}

		if(res)
			dp[i] = 0;
		else
			dp[i] = 1;
	}

	// fr(i,1,k+1)
	// 	cout << dp[i] << " ";
	// cout << "\n";

	if(dp[k])
		cout << "First";
	else
		cout << "Second";

}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.Ia;
		Array.Sort(a);
		long ans=0;
		for(int i = 0;i<s[1];i++) {
			ans+=a[i];
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] train = Console.ReadLine().Split(' ');
            int N = int.Parse(train[0]);
            int I = int.Parse(train[1]);

            Console.WriteLine(N - I + 1);
            Console.Read();


        }
    }
}


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

int main(void){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll cou=n-k;
    ll i=1;
    while(cou--){
        if(a[i]<a[i+k]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
        i++;
    }
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,v,q;
  cin>>n;
  vector<int>vec;
  for(int i=0;i<n;i++)
  {
    cin>>q;
    if(q==0)
    {
      cin>>v;
      vec.push_back(v);
    }
    else if(q==1)
    {
      cin>>v;
      cout<<vec[v]<<endl;
    }
    else
    {
      vec.pop_back();
    }
  }
  return 0;
}


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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2==0){
  	cout << a-b <<endl;
  }
  else{
    cout << b-a << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        
        int nextSunday;
        Scanner scan = new Scanner(System.in);
        String day = scan.next();

            if(day.equals("SUN")) nextSunday = 7;
            else if(day.equals("MON")) nextSunday = 6;
            else if(day.equals("TUE")) nextSunday = 5;
            else if(day.equals("WED")) nextSunday = 4;
            else if(day.equals("THU")) nextSunday = 3;
            else if(day.equals("FRI")) nextSunday = 2;
            else nextSunday = 1;
            
            System.out.println(nextSunday);
    } 
}

Measured memory_bytes: 21844
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr =input.trim().split("\n");
var [a,b] = arr.shift().split(" ").map(Number);
var n = arr.shift() - 0;
var flag = 0;
while(n--){
   var [s,f] = arr.shift().split(" ").map(Number);
   if(f<=a || b<=s)continue;
   else flag = 1;
}
console.log(flag);


Measured memory_bytes: 17188
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A.at(i);
    ll step[2] = {0,0};
    ll sum[2] = {0,0};

    rep(i,2) {
        rep(j, N) {
            sum[i] += A[j];
            if ((i+j)%2 == 0) {
                if (sum[i] <= 0) {
                    step[i] += abs(sum[i] - 1);
                    sum[i] = 1;
                }
            } else {
                if (sum[i] >= 0) {
                    step[i] += sum[i] + 1;
                    sum[i] = -1;
                }
            }
        }
    }
    cout << min(step[0], step[1]) << endl;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


bool solve(){
    int n, m, st, en;
    cin >> n >> m >> st >> en;
    if(!n)
        return false;
    struct Edge{
        int from, to;
        string str;
        Edge(int from, int to, string str) : from(from), to(to), str(str){}
    };
    vector<Edge> edge_list;
    for(int i = 0; i < m; ++i){
        int from;
        int to;
        string s;
        cin >> from >> to >> s;
        edge_list.emplace_back(from, to, s);
    }

    vector<string> dp(n, "{");
    dp[en] = "";

    for(int _ = 0; _ < max(n, m) * 2; ++_){
        for(auto& edge : edge_list){
            if(dp[edge.to] == "{")
                continue;
            chmin(dp[edge.from], edge.str + dp[edge.to]);
        }
    }
    bool fl = false;
    for(int _ = 0; _ < max(n, m) * 2 && !fl; ++_){
        for(auto& edge : edge_list){
            if(dp[edge.to] == "{")
                continue;
            if(chmin(dp[edge.from], edge.str + dp[edge.to])){
                if(edge.from == st){
                    fl = true;
                    break;
                }
            }
        }
    }

    if(fl || dp[st] == "{"){
        cout << "NO" << endl;
    }
    else{
        cout << dp[st] << endl;
    }
    return true;
}

signed main(){
    while(solve());
}



Measured memory_bytes: 5600
#include<iostream>
#include<cstring>
using namespace std;
char s[100001];
int i,l,ans;
int main()
{
	cin>>s;
	l=strlen(s);
	for (i=1;i<=l-1;i++)
	  if (s[i-1]!=s[i]) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int s;
int t[1000001];

int search_dup(int i) {
	int j;

	for (j = 0; j < i; j++) {
		if (t[j] == t[i]) {
			return 1;
		}
	}

	return 0;
}

int main(int argc, char const *argv[]) {

	scanf("%d", &s);
	int i = 0;

	while (1) {
		t[i] = s;

		if (s % 2 == 0) {
			s /= 2;
		} else {
			s *= 3;
			s += 1;
		}

		// printf("%d\n", s);

		if (search_dup(i)) {
			break;
		}

		i++;
	}

	printf("%d\n", i+1);

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Formatter;
public class Main
{
	public static void main(String args[])
	{
		Scanner inp = new Scanner(System.in);
		Formatter frm = new Formatter();
		int a, b;
		double c;
		a = inp.nextInt();
		b = inp.nextInt();
		frm.format("%.5f",(double)a/b);
		System.out.println(a/b + " " + a%b + " " + frm);
	}
}

Measured memory_bytes: 26476
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a = [LI() for _ in range(3)]
    n = I()
    b = [I() for _ in range(n)]
    f = [[False]*3 for _ in range(3)]
    for c in b:
        for i in range(3):
            for j in range(3):
                if c == a[i][j]:
                    f[i][j] = True

    for i in range(3):
        if all(f[i][j] for j in range(3)):
            return "Yes"
        if all(f[j][i] for j in range(3)):
            return "Yes"
    if all(f[i][i] for i in range(3)):
        return "Yes"
    if all(f[i][2-i] for i in range(3)):
        return "Yes"

    return "No"


print(main())





Measured memory_bytes: 5404
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."						*/
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define ld double 
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define deb cerr << "Line no." << __LINE__
#define nl '\n'
#define pb push_back
#define all(a) a.begin(),a.end()
#define P pair<ll,ll> 
#define F first
#define S second
const ll p_mod=9999999999999983;
const long double pi = 3.14159265358979323;
const ll N=1e6+9;
const ll mod=1e9+7;
typedef double f80;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){uniform_int_distribution<int> uid(l, r); return uid(rng); }
ll powerk(ll x, ll y);

ll a[N],b[N],c[N];
ll dp[N][3],n;
ll go()
{
	dp[1][0]=a[1];
	dp[1][1]=b[1];
	dp[1][2]=c[1];
	
	rep(i,2,n)
	{
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i] ;
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i] ;
		dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c[i] ;
		//cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<nl; 
	}
	return max(dp[n][0],max(dp[n][1],dp[n][2]));
}

void solve()
{    
	ll m;
	cin>>n;
	rep(i,1,n)cin>>a[i]>>b[i]>>c[i];
	cout<<go();

}


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}
ll powerk(ll x, ll y)
{
  if(y==0)return 1;
  if(y==1)return x%mod;
  if(y&1)
    return ((powerk((x*x)%mod, y/2)%mod)*x)%mod;
  else return powerk((x*x)%mod,y/2)%mod;
}

// Xorawar

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+6;
int main()
{
	int n,k,q,a,vis[maxn],flag[maxn];
	scanf("%d%d%d",&n,&k,&q);
	memset(vis,0,sizeof(vis));
	memset(flag,0,sizeof(flag));
	for(int i=1;i<=q;i++)
	{
		scanf("%d",&a);
		vis[a]++;
	}
	for(int j=1;j<=n;j++)
	{
		if(q-vis[j]<k)
		{
			flag[j]=1;
		}
		else
		{
			flag[j]=0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(flag[i]==1)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
int main(){
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;
    printf("%d %d %.5lf\n", d, r, f);
    
    return 0;
}


Measured memory_bytes: 2100
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> mpq;

const ll INF = 1e18;
const int mod = 1e9+7;
const int dX[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

#define whatis(x) cerr << #x << " is " << x << endl;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ft front()
#define bk back()
#define sz(x) (long long)x.size()
#define all(x) (x).begin(), (x).end()
#define ub upper_bound
#define lb lower_bound
#define FOR(i, a) for(int i = 0; i < a; i++)
#define FoR(i, a) for(int i = 1; i <= a; i++)
#define ROF(i, a) for (int i = (a)-1; i >= 0; i--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//-----------------------| Template By: DakDak |----------------------------
int arr[1001][1001];
int dp[1001][1001];
int main(){
    int x, y; cin >> x >> y;
    FOR(i, x){
        FOR(j, y){
            char curr; cin >> curr;
            if(curr == '.'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 1;
            }
        }
    }
    dp[0][0] = 1;
    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            if(i == 0 && j == 0){
                continue;
            }
            else if(i == 0 && j != 0){
                dp[i][j] = dp[i][j-1];
            }
            else if(i != 0 && j == 0){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
            if(arr[i][j] == 1){
                dp[i][j] = 0;
            }
            dp[i][j] %= mod;
        }
        cout << endl;
    }
    cout << dp[x-1][y-1] << endl;
    return 0;
    // Read notes to self
}

/* NOTES TO SELF:
 * Check for int vs ll, worst case just switch everything to ll
 * Check for array bounds if you SEGFAULT, especially in range based loops
 * Always initialize everything in global 
 * Edge cases such as n = 1 or 0
 * Make sure to calculate big O complexity
 * You are geniosity you got this
 */





Measured memory_bytes: 8064
n=int(input())
c=[0]*n
s=[0]*n
f=[0]*n
for i in range(n-1):
    c[i],s[i],f[i]=map(int,input().split())
for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<s[j]:
            t=s[j]
        else:
            num=t-s[j]
            if num%f[j]==0:
                pass
            else:
                t=(num//f[j]+1)*f[j]+s[j]
        t+=c[j]
    print(t)



Measured memory_bytes: 3064
N, W = map(int, input().split())

dp = [[float('inf') for i in range(10**5+1)] for j in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
    w, v = map(int, input().split())
    for j in range(0, 10**5+1):
        if (j-v) >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v]+w)
        else:
            dp[i][j] = dp[i-1][j]
    #print(dp)  
    
ans = 10**5
while(dp[N][ans])>W:
  ans -= 1
print(ans)

Measured memory_bytes: 269640
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c,x;
int main()
{
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d %d %d",&a,&b,&c,&x);
	int ans=0;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(i*500+j*100+k*50==x)ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
//#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 N, K;
ll A[int(1e5 + 5)], L[int(1e5 + 5)], R[int(1e5 + 5)], sum[int(1e5 + 5)];

int main(){
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; i++) scanf("%lld", A + i);

  for (int i = 1; i <= N; i++){
    sum[i] = sum[i - 1] + A[i];
    L[i] = L[i - 1] + max(0ll, A[i]);
  }
  for (int i = N; i >= 0; i--){
    R[i] = R[i + 1] + max(0ll, A[i]);
  }

  ll ans = 0;
  for (int i = 0; i + K <= N; i++){
    ll now = max(0ll, sum[i + K] - sum[i]);
    now += L[i] + R[i + K + 1];
    ans = max(ans, now);
  }
  cout << ans << endl;

  return 0;
}


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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

int main()
{
	int N, H, W;
	cin >> N >> H >> W;

	vector<int> A(N), B(N);

	FOR(i, 0, N){
		cin >> A[i] >> B[i];
	}

	int cnt = 0;

	FOR(i, 0, N){
		if(A[i] >= H && B[i] >= W){
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int v[1024];

int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main(void) {
  int n;
  scanf("%d", &n);

  for(int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }

  qsort(v, n, sizeof(int), cmpfunc);

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

  printf("%f", res);

  return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define uset unordered_set
#define umap unordered_map
#define all(x) (x).begin(),(x).end()

int chmin(int &a, int b) { if (a > b) { a = b; return 1; } return 0; }
int chmax(int &a, int b) { if (a < b) { a = b; return 1; } return 0; }

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  if (n % 2) {
    cout << 0 << '\n';
    return 0;
  }
  int ans = 0;
  for (int i = 10; i <= n; i *= 5) {
    ans += n / i;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256