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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, n; cin >> d >> n;
    if(n==100) n=101;
    switch (d)
    {
    case 0:
        cout<<n<<endl;
        break;
    case 1:
        cout<<n*100<<endl;
        break;
    case 2:
        cout<<n*10000<<endl;
        break;
    default:
        break;
    }
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
c = input() 

if (c == 'a'): 
    is_vowel = True
elif (c == 'i'):
    is_vowel = True
elif (c == 'u'):
    is_vowel = True
elif (c == 'e'):
    is_vowel = True
elif (c == 'o'): 
    is_vowel = True
else:
    is_vowel = False

if is_vowel:
    print('vowel')
else:
    print('consonant')

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

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

ss = list(map(nC2, s))
sss = sum(ss)

for i in range(N):
    print(sss - s[A[i]] + 1)

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

double eps = 1e-10;

int main() {
	string s[16], ans("R");
	for(int i = 0; i < 9; ++i){
		cin >> s[i];
	}
	int x = 0, y = 0;
	int d = 0; // 0:right, 1:down, 2:left, 3:up
	bool flag = false;
	while(1){
		if(d == 0){
			if(y >= 2 && s[y - 1][x + 1] == '1'){
				ans += 'U';
				y -= 1;
				x += 1;
				d = 3;
			}
			else if(s[y][x + 1] == '1'){
				ans += 'R';
				x += 1;
			}
			
			else if(s[y + 1][x + 1] == '1'){
				ans += 'D';
				x += 1;
				y += 1;
				d = 1;
			}
			else{
				ans += 'L';
				d = 2;
			}
		}
		else if(d == 1){
			if(s[y + 1][x] == '1'){
				ans += 'R';
				y += 1;
				d = 0;
			}
			else if(s[y + 2][x] == '1'){
				ans += 'D';
				y += 2;
			}
			else if(s[y + 1][x - 1] == '1'){
				ans += 'L';
				x -= 1;
				y += 1;
				d = 2;
			}
			else{
				ans += 'U';
				d = 3;
			}
		}
		else if(d == 2){
			if(s[y + 1][x] == '1'){
				ans += 'D';
				y += 1;
				d = 1;
			}
			else if(s[y][x - 1] == '1'){
				ans += 'L';
				x -= 1;
			}
			else if(y >= 2 && s[y - 1][x] == '1'){
				ans += 'U';
				y -= 1;
				d = 3;
			}
			else{
				ans += 'R';
				d = 0;
			}
		}
		else if(d == 3){
			if(s[y - 1][x - 1] == '1'){
				ans += 'L';
				y -= 1;
				x -= 1;
				d = 2;
			}
			else if(y >= 3 && s[y - 2][x] == '1'){
				ans += 'U';
				y -= 2;
			}
			else if(s[y - 1][x] == '1'){
				y -= 1;
				if(x == 0 && y == 0)
					break;
				ans += 'R';
				d = 0;
			}
			else{
				ans += 'D';
				d = 1;
			}
		}
		/*if(x == 1 && y == 8 && flag)
			break;
		if(x == 1 && y == 8){
			flag = true;
			//break;
		}*/
		if(x == 0 && y == 0)
			break;
	}
	/*cout << s[8][3] << endl;
	cout << d << endl;*/
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
using namespace std;
typedef vector<int> vi;
const string units[]={
  "","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan",
  "Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"
};
const int MD=405;

struct LongInt
{
  LongInt(int i=0)
  {
    memset(digits,0,sizeof(digits));
    n=0;
    while(i>0)
      {
	digits[n++]=i%10;
	i/=10;
      }
  }
  LongInt(const string &s)
  {
    memset(digits,0,sizeof(digits));
    n=0;
    bool f=false;
    for(int j=(int)s.size()-1;j>=0;j--)
      {
	if(!isdigit(s[j])){continue;}
	if(s[j]!='0')
	  {
	    digits[n++]=s[j]-'0';
	    f=true;
	  }
	else if(f)
	  {
	    digits[n++]=s[j]-'0';
	  }
      }
  }
  int digits[MD],n;
};

LongInt operator*(const LongInt& lhs,const LongInt& rhs)
{
  LongInt res;
  for(int i=0;i<MD;i++)
    {
      for(int j=0;j<MD;j++)
	{
	  if(i+j>=MD){continue;}
	  int x=lhs.digits[i]*rhs.digits[j]+res.digits[i+j];
	  res.digits[i+j]=x%10;
	  if(i+j+1<MD)
	    {
	      res.digits[i+j+1]+=x/10;
	    }
	}
    }
  return res;
}

LongInt operator+(const LongInt& lhs,const LongInt& rhs)
{
  LongInt res;
  for(int i=0;i<MD;i++)
    {
      int x=lhs.digits[i]+rhs.digits[i]+res.digits[i];
      res.digits[i]=x%10;
      if(i+1<MD)
	{
	  res.digits[i+1]=x/10;
	}
    }
  return res;
}

int main()
{
  int m,n;
  while(cin >> m >> n && (m || n))
    {
      LongInt num(1),a(m);
      while(n>0)
	{
	  if(n&1){num=num*a;}
	  a=a*a;
	  n>>=1;
	}
      int mx;
      bool f=false;
      for(int i=MD-1;i>=0;i--)
	{
	  if(num.digits[i]!=0){f=true;}

	  if(f)
	    {
	      mx=i;
	      break;
	    }
	}
      string S="";
      for(int i=mx;i>=0;)
	{
	  int x=0;
	  while(1)
	    {
	      x=x*10+num.digits[i];
	      if(i%4==0){break;}
	      i--;
	    }
	  if(x>0)
	    {
	      S+=to_string(x)+units[i/4];
	    }
	  i--;
	}
      cout << S << endl;
    }
  return 0;
}



Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,t; cin>>n>>t;
    ll dp[n+1][t+1]={};
    for(ll i=1;i<=n;i++)
    {
      ll x,y; cin>>x>>y;
      for(ll j=1;j<=t;j++)
      { if(x<=j)
       {
        dp[i][j]=max(dp[i-1][j],y+dp[i-1][j-x]);
       }
       else
       {
       dp[i][j]=dp[i-1][j];
       }
      }
   
    }
   
   cout<<dp[n][t];
    return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= 9; i++){
		if(n % i == 0 and n / i <= 9){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
} 

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

int main() {
    // input
    int N, M;
    cin >> N >> M;
    pair<int, int> ab[50];
    for (int i = 0; i < N; ++i) {
        cin >> ab[i].first >> ab[i].second;
    }
    pair<int, int> cd[50];
    for (int i = 0; i < M; ++i) {
        cin >> cd[i].first >> cd[i].second;
    }

    // solve & output
    for (int i = 0; i < N; ++i) {
        int min = 1000000000, ans = 0;
        for (int j = 0; j < M; ++j) {
            int tmp = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
            if (tmp < min) {
                min = tmp;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MOD 998244353
using namespace std;
typedef long long ll;

ll Expow(ll a, int d) {
	ll ans = 1;
	while (d > 0) {
		if ((d & 1) == 1)
			ans = ans * a % MOD;
		a = a * a % MOD;
		d >>= 1;
	}
	return ans;
}

int main(void) {
	int num, wid, i, j, a, sum;
	ll A = 0, B = 0, All;
	cin >> num >> sum;
	All = Expow(3LL, num);
	wid = 300 * num + 1;
	vector<int> d(num);
	vector<vector<int>> dp(num, vector<int>(wid, 0));
	d[0] = sum;
	dp[0][0] = 2;
	dp[0][d[0]] = 1;
	for (i = 0; i < num - 1; i++) {
		scanf("%d", &a);
		d[i + 1] = a;
		sum += a;
		for (j = 0; j <= sum; j++) {
			if (dp[i][j] == 0)
				continue;
			dp[i + 1][j] += (dp[i][j] << 1) % MOD;
			dp[i + 1][j] %= MOD;
			dp[i + 1][j + a] = dp[i][j];
		}
	}
	for (i = (sum >> 1) + (sum & 1); i <= sum; i++)
		A = (A + dp[num - 1][i]) % MOD;
	A = 3 * A % MOD;

	if ((sum & 1) == 0) {
		vector<vector<int>> dp(num, vector<int>(wid, 0));
		sum = d[0];
		dp[0][0] = 1;
		dp[0][d[0]] = 1;
		for (i = 0; i < num - 1; i++) {
			sum += d[i + 1];
			for (j = 0; j <= sum; j++) {
				if (dp[i][j] == 0)
					continue;
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= MOD;
				dp[i + 1][j + d[i + 1]] = dp[i][j];
			}
		}
		B = dp[num - 1][sum >> 1];
		B = 3 * B % MOD;
	}
	All = (All - A + B + MOD) % MOD;
	cout << All << "\n";
	return 0;
}

Measured memory_bytes: 211616
#include<stdio.h>
int main(){
  int a,b,i,r;
  while(scanf("%d %d",&a,&b),a||b){
    if(a<b){
      r=a;
      a=b;
      b=r;
    }
    for(i=0;b;i++){
      r=a%b;
      a=b;
      b=r;//printf("%d\n",r);
    }
    printf("%d %d\n",a,i);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s;
	int n,ind = 0,ans = 0;
	cin >> s;
	if(s[0] == '>') s = "<" + s;
	if(s.back() == '<') s += ">";
	n = s.length();
	while(ind < n){
		int a = 0,b = 0;
		while(s[ind] == '<'){
			a++; ind++;
		}
		while(ind < n && s[ind] == '>'){
			b++; ind++;
		}
		if(a > b) swap(a,b);
		ans += a * (a - 1) / 2 + b * (b + 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1412
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s[0] == 'S')
        cout << "Cloudy" << endl;
    else if(s[0] == 'C')
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np

def isBingo(isOpen):
    if np.any(np.all(isOpen==1,axis=0)==True) or \
        np.any(np.all(isOpen==1,axis=1)==True):
        return "Yes"
    cnt1=0
    cnt2=0
    for i in range(3):
        if isOpen[i][i]==1:
            cnt1+=1
        if isOpen[i][2-i]==1:
            cnt2+=1
    if cnt1==3 or cnt2==3:
        return "Yes"
    else:
        return "No"

bingo = [list(map(int, input().split())) for _ in range(3)]
n = int(input().strip())

isOpen=np.zeros([3,3],dtype=int)
for _ in range(n):
    b=int(input().strip())
    for i in range(3):
        for j in range(3):
            if b==bingo[i][j]:
                isOpen[i][j]=1
print(isBingo(isOpen))

Measured memory_bytes: 14436
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m*n/gcd(m,n);}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename Iter> ostream& out_container(ostream &os, Iter first, Iter last){
  os << "{"; auto itr = first; while(itr != last){if(itr != first) os << ","; os << *itr; ++itr;} os << "}"; return os;
}

template <typename T> ostream& operator<<(ostream &os, const vector<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const deque<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const set<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const unordered_set<T> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const unordered_map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

int diff(string &a, string &b){
  int ret = 0;
  REP(i,a.size()) if(a[i] != b[i]) ++ret;
  return ret;
}

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

  int n;
  string a,b,c;

  while(cin >> n >> a >> b >> c){
    int ans = 0;
    REP(i,n){
      if(a[i] == b[i] && b[i] == c[i]) continue;
      if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) ++ans;
      else ans += 2;
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100
#define INF 10000001
#define NIL -1
#define BLACK 1

typedef struct{
  int k;
  int v[MAX];
  int c[MAX];
}node;


int d[MAX],pi[MAX],color[MAX];
node A[MAX];

void initializeSS(int,int);
void dijkstra(int,int);


int main(){
  int i,j,n,u,sum;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&A[u].k);
    for(j=0;j<A[u].k;j++) scanf("%d%d",&A[u].v[j],&A[u].c[j]);
  }

  dijkstra(n,0);

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

void initializeSS(int n,int s){
  int v;

  for(v=0;v<n;v++){
    d[v]=INF;
    pi[v]=NIL;
  }
  d[s]=0;
}

void dijkstra(int n,int s){
  int i,u,v,mincost;
  
  initializeSS(n,s);

  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }

    if(mincost==INF) break;

    color[u]=BLACK;

    for(i=0;i<A[u].k;i++){
      v=A[u].v[i];
      if(color[v]!=BLACK && d[u]+A[u].c[i]<d[v]){
	pi[v]=u;
	d[v]=d[u]+A[u].c[i];
      }
    }
  }
}



Measured memory_bytes: 2112
#include<stdio.h>

#define N 10000
int main(){
	int i,n,m;
	int a[N];
	scanf("%d %d",&n,&m);
	for(i = 0; i < m; i++){
		scanf("%d",&a[i]);
	}
	for(i = 0; i < m; i++){
		if(a[i] <= n){
			n = n - a[i];
			if(i == m - 1){
			printf("%d",n);}}
			else{
				printf("-1");
				break;
			}
			
	}
}

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

int main() {
	int x;
	cin >> x;
	bool flag;
	int ans;
	
	for(int i=2;i<110000;i++){
		flag = true;
		for(int j=2;j<i;j++){
			if(i%j==0){
				flag = false;
				break;
			}
		}
		if(i>=x && flag){
		    ans = i;
		    cout << ans << endl;
		    return 0;
		}
		//if(flag) cout << i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N, 0);
    rep(i, Q) {
        int q;
        cin >> q;
        A[q - 1]++;
    }

    rep(i, N) {
        if (K - (Q - A[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int n;
  cin >> n;
  n++;
  ll ans = 0;
  REP(i, n) {
    if (i == 0) continue;
    REP(j, n) {
      if (j == 0) continue;
      REP(k, n) {
        if (k == 0) continue;
        ans += gcd(gcd(i, j), k);
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  
  int i;
  for(i=0;i<N;i++){
    cin >> h.at(i);
  }
  int s=0;
  for(i=0;i<N;i++){
    if(h.at(i)>=K){
      s++;
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b) {
    cout << c << endl;
  }else if(a == c) {
    cout << b << endl;
  }else{
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
	n, x = map(int, (input().strip().split()))
	l = list(map(int, input().strip().split()))
	pos = 0
	ans = 1
	for i in l:
		pos += i
		if pos > x:
			break
		ans += 1
	print(ans)

if __name__ == '__main__':
	main()


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

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

	if (abs(s[0] - s[1]) || abs(s[1] - s[2])) {
		out("Yes");
		return 0;
	}

	out("No");

	return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll n, a, b; cin >> n >> a >> b;
	if (n == 1) {
		cout << (a == b ? 1 : 0) << endl;
	} else {
		if (a <= b) {
			ll lo = a * (n - 1) + b;
			ll hi = a + b * (n - 1);
			cout << (hi - lo + 1) << endl;
		} else {
			cout << 0 << endl;
		}
	}
}


Measured memory_bytes: 256
def search(ps, id):
    if ps[id] == -1:
        return 0
    else:
        return 1 + search(ps, ps[id])


n = int(input())
tree = [[] for _ in range(n)]
ps = [-1 for _ in range(n)]
for _ in range(n):
    s = input().split()
    id = int(s[0])
    k = int(s[1])
    children = [int(x) for x in s[2:]]
    tree[id] = children
    for child in children:
        ps[child] = id

for id in range(n):
    p = ps[id]
    d = search(ps, id)
    c = tree[id]
    if p == -1:
        type = "root"
    elif len(c) == 0:
        type = "leaf"
    else:
        type = "internal node"

    print("node " + str(id) + ": parent = " + str(p) + ", depth = " + str(d) + ", " + type + ",", c)


Measured memory_bytes: 25084
import sys

input = sys.stdin.readline

def main(): 
    N = int(input())
    
    Id = {}
    
    G = [[] for i in range(N*(N-1)//2)]
    size = [0] * (N*(N-1)//2)
    
    cur = 0
    for i in range(1, N+1):
        for idx, j in enumerate(list(map(int, input().split()))):
            if i < j: a, b = i, j
            else: a, b = j, i
        
            if (a, b) not in Id:
                Id[(a, b)] = cur
                cur += 1
            k = Id[(a, b)]
        
            if idx: 
                G[par].append(k)
                size[k] += 1
            par = k
            
    g = [idx for idx, s in enumerate(size) if s == 0]
    
    ans = 0
    while g:
        ans += 1
        n_g = []
        
        for v in g:
            length = len(G[v])
            if not length: continue
            
            size[G[v][0]] -= 1
            if not size[G[v][0]]: n_g.append(G[v][0])
    
            if length == 2:
                size[G[v][1]] -= 1
                if not size[G[v][1]]: n_g.append(G[v][1])
        g = n_g
        
    for s in size:
        if s != 0:
            print(-1)
            sys.exit()
    print(ans)           

if __name__ == '__main__':
    main()



Measured memory_bytes: 154740
n=int(input())
#L=list(map(int,input().split()))
#a,b=map(int,input().split())
#A=[[0 for i in range()] for j in range()]
#l = [int(input()) for i in range(N)]
#data_list = [ list(map(int,input().split(" "))) for i in range(3)]
print(n*n*n)

Measured memory_bytes: 38256
def solve(n, x, a_list):
    
    ans = 0
    for i in range(len(a_list)-1):
        tmp = a_list[i] + a_list[i+1]
        if tmp > x:
            d = tmp - x
            ans += d
            if a_list[i+1] - d >= 0:
                a_list[i+1] = a_list[i+1] -d
            else:
                a_list[i] = a_list[i] - (d-a_list[i+1])
                a_list[i+1] = 0
    return ans

if __name__ == "__main__":
    n, x = [int(i) for i in input().split()]
    a_list = [int(i) for i in input().split()]
    print(solve(n, x, a_list))

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

ll x,y,a,b,c;
Vi p,q,r;
priority_queue<PLL> pq;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>x>>y>>a>>b>>c;
    p.resize(a);q.resize(b);r.resize(c);
    //red = 0,green = 1,other = 2;
    rep(i,a){
        cin>>p[i];
        pq.push(mp(p[i],0));
    }
    rep(i,b){
        cin>>q[i];
        pq.push(mp(q[i],1));
    }
    rep(i,c){
        cin>>r[i];
        pq.push(mp(r[i],2));
    }
    ll ans = 0;
    ll rn = 0,gn=0;
    ll tmp = 0;
    rep(i,a+b+c){
        if(tmp == x+y)break;
        PLL now = pq.top();
        pq.pop();

        if(now.second==2){
            ans += now.first;
            tmp++;
        }else if(now.second==0){
            if(rn<x){
                rn++;
                tmp++;
                ans += now.first;
            }
        }else{
            if(gn<y){
                gn++;
                tmp++;
                ans += now.first;
            }
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 12780
A,B,C,X =map(int,open(0).read().split())
c=0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if i*500+j*100+50*k == X:
        #print(i,j,k)
        c+=1
print(c)

Measured memory_bytes: 39880
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N;
char S[200010];
int Wa[200010];

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

  rep( i, N )
    Wa[i+1] += Wa[i]+(S[i]=='.');

  int ans = 1<<30;

  rep( i, N+1 )
    ans = std::min( ans, (i-Wa[i])+(Wa[N]-Wa[i]) );

  printf( "%d\n", ans );

  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)

signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int a, b, c; cin>>a>>b>>c;
    int ans = max(c-a+b, 0LL);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

def solve() :
    l, r = 1, W
    d, u = 1, H
    
    for i in range(N - 1, -1, -1) :
        if T[i] == 'L' :
            r = min(r + 1, W)
        elif T[i] == 'R' :
            l = max(l - 1, 1)
        elif T[i] == 'D' :
            u = min(u + 1, H)
        elif T[i] == 'U' :
            d = max(d - 1, 1)
            
        if S[i] == 'L' :
            l += 1
        elif S[i] == 'R' :
            r -= 1
        elif S[i] == 'D' :
            d += 1
        elif S[i] == 'U' :
            u -= 1
            
        if r < l or u < d :
            return 'NO'

    if l <= sc <= r and d <= H + 1 - sr <= u :
        return 'YES'
    else :
        return 'NO'
    
print(solve())


Measured memory_bytes: 53920
#include <stdio.h> 
int main() {
int W, H, x, y, r;
scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
if(x >= r && y >= r && (H - r) >= y && (W - r) >= x) {
printf("Yes\n");
} 
else {
printf("No\n");
}
return 0;
}


Measured memory_bytes: 1992
n, k = map(int, input().split())
*p, = map(int, input().split())
p = [v - 1 for v in p]
*c, = map(int, input().split())
minc = float('-inf')

ans = minc


def get_loop(i):
    pos = i
    cnt = 0
    cur_score = 0
    while cnt == 0 or pos != i:
        pos = p[pos]
        cur_score = cur_score + c[pos]
        cnt += 1
    return cnt, cur_score

# print(get_loop(2))

def solve(pos, k):
    score = minc
    cur_score = 0
    loop_length, loop_score = get_loop(pos)
    if k >= 2 * loop_length and loop_score > 0:
        # print("%s: %s // %s, %s, %s" % (i, k, loop_length, cur_score, max_loop_score))
        cur_score = loop_score * ((k - loop_length) // loop_length)
        score = max(cur_score, score)
        k = k % loop_length + loop_length
    else:
        k = min(k, 2 * loop_length)
    for _ in range(k):
        pos = p[pos]
        cur_score += c[pos]
        score = max(cur_score, score)
    # print("%s: %s" % (i, score))
    return score

for i in range(n):
    ans = max(ans, solve(i, k))
print(ans)



Measured memory_bytes: 69028
#include<bits/stdc++.h>
using namespace std;
const long double PI =(acos(-1));

int main(){
    int r,c;
    cin >> r >> c;
    vector<vector<int> > t(r+1, vector<int> (c+1));
    //vector<vector<int> > ans(r+1, vector<int> (c+1));
    //vector<int> tr(c);
    //vector<int> tc(r);
    int total=0;
    for(int i=0;i<r;++i){
        total=0;
        for(int j=0;j<c;++j){
            cin >> t.at(i).at(j);
            total+=t.at(i).at(j);
            t.at(r).at(j)+=t.at(i).at(j);
        }
        t.at(i).at(c)=total;
        t.at(r).at(c)+=total;
    }
    for(int i=0;i<=r;++i){
        for(int j=0;j<c;++j){
            cout << t.at(i).at(j) << " ";
        }cout << t.at(i).at(c) << endl;
    }
    /*
    for(int i=0;i<=r;++i){
        for(int j=0;j<=c;++j){
            if(i==r && j==c){
                cout << total << endl;
            }else if(i==r && j<c){
                cout << tr.at(j) << " ";
            }else if(j==c && i<r){
                cout << tc.at(i);
            }else{
                cout << t.at(i).at(j) << " ";
            }
            //if(i<=r && j<c) cout << ".";
        }if(i<r)cout << endl;
    }//cout << endl;
    */
    return 0;
}


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

int main() {
  int N,i;
  cin>>N;
  vector<int> h(N), dp(N,0);
  for (i=0;i<N;i++) cin>>h[i];
  dp[1]=abs(h[1]-h[0]);
  for (i=2;i<N;i++) {
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 3552
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {
	private static int h, w, n;
	private static boolean[] wall;
	private static int[] sx, sy;
	
	private static int[] dx = { 0, 1,  0, -1 };
	private static int[] dy = { 1, 0, -1,  0 };
	
	private static int getInt() throws Exception {
		int i = 0;
		while(true){
			int buf = System.in.read();
			if('0' > buf || buf > '9'){
				break;
			}
			i = i * 10 + buf - '0';
		}
		return i;
	}
	private static int heuristic(final int sx, final int sy, final int ex, final int ey) {
		return 0;//Math.abs(sx - ex) + Math.abs(sy - ey);
	}
	private static int search(final int sx, final int sy, final int ex, final int ey) {
		Comparator<int[]> cmp = new Comparator<int[]>() {
			@Override
			public int compare(int[] a, int[] b) {
				return Integer.compare(a[2] + heuristic(a[0], a[1], ex, ey), b[2] + heuristic(b[0], b[1], ex, ey));
			}
		};
		int[] costs = new int[h*w];
		costs[sx + sy*w] = Integer.MAX_VALUE;
		PriorityQueue<int[]> q = new PriorityQueue<>(cmp);
		q.offer(new int[]{sx, sy, 0});
		while(true){
			int[] now = q.poll();
			int newCost = now[2] + 1;
			for(int i = 0; i < 4; i++){
				int nx = now[0] + dx[i];
				int ny = now[1] + dy[i];
				int p = nx + ny*w;
				if(0 <= nx && nx < w && 0 <= ny && ny < h && !wall[p] && (costs[p] == 0 || costs[p] > newCost)){
					if(nx == ex && ey == ny) return now[2] + 1;
					costs[p] = newCost;
					q.offer(new int[]{nx, ny, newCost});
				}
			}
		}
		
	}
	public static void main(String[] args) throws Exception {
		h = getInt();
		w = getInt();
		n = getInt();
		wall = new boolean[h*w];
		sx = new int[10];
		sy = new int[10];
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++) {
				int buf = System.in.read();
				if(buf =='\n' || buf == '\r'){
					x--;
					continue;
				}
				wall[x + y*w] = buf == 'X';
				if(buf == 'S'){
					sx[0] = x;
					sy[0] = y;
				}
				if('1' <= buf && buf <= '9'){
					buf -= '0';
					sx[buf] = x;
					sy[buf] = y;
				}
			}
		}
		int a = 0;
		for(int i = 1; i <= n; i++) a += search(sx[i-1], sy[i-1], sx[i], sy[i]);
		System.out.println(a);
	}

}

Measured memory_bytes: 81348
N = int(input())
A = list(map(int, input().split()))
import math
ans = 0
for i in range(N):
  a = A[i]
  b = int(math.log2(a))+1
  for j in range(b):
    if a % 2 == 0:
      ans += 1
      a = a/2
    else:
      break
      
print(ans)
    
    

Measured memory_bytes: 4148
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = sorted(list(map(int, input().split())), reverse=True)

    MOD = int(1e9) + 7

    tmp = N - 1
    ans = 1
    for i in range(N//2):
        # print(a[2*i], a[2*i+1], tmp)
        if a[2*i] == tmp and a[2*i+1] == tmp:
            # print("ok")
            ans *= 2
            ans %= MOD
        else:
            print(0)
            return
        tmp -= 2
    
    if N&1:
        if a[N-1] != 0:
            print(0)
            return
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 13872
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;

int main() {
  int N;
  cin >> N;
  cout << (N * (N + 1)) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
//A - Frog 1
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

int n,k, a[100005];
int dp[100005];

int func(int ind){
	if (ind == n)
		return 0;
	if (dp[ind]!= -1)
		return dp[ind];
	int mini = 1e10;
	for (int i = ind+1; i <= min(n,ind+k); ++i)
	{
		mini = min(mini, abs(a[i]-a[ind])+ func(i));
	}
	return dp[ind]= mini;
}

signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>k;

	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i];
		dp[i] =-1;
	}
	memset(dp, -1, sizeof dp); 

	cout<<func(1)<<endl;
	return 0;
}


Measured memory_bytes: 9888
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>

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

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> ret;

  int n,x,cnt;
  n=-1,x=-1;
  
  while(!(n==0 && x== 0)){
    cin >> n >> x;
    cnt = 0;

    for(ii=1;ii<=n;ii++){
      for(jj=ii+1;jj<=n;jj++){
        for(kk=jj+1;kk<=n;kk++){
          if(ii!=jj && ii != kk && jj != kk
             && (ii+jj+kk) == x){
            //cout << "ii:" << ii;
            cnt ++;
          }
        }
      }
    }
    if(!(n==0 && x== 0)){
      cout << cnt << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3116
n = int(input())
S = [input() for _ in range(n)]

import hashlib
base1 = 1007
mod1 = 10**9+7
dic = {}

for s in S:
  hs = hashlib.md5(s.encode()).hexdigest()
  dic.setdefault(hs, s)

print(len(dic))

Measured memory_bytes: 56924
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int64
    let M = (float >> sqrt >> int64) N

    let ms =
        [1L..M]
        |> List.filter (fun x -> N % x = 0L)
        |> List.collect (fun x -> [x; N / x])
        |> List.map (fun x -> x - 1L)
        |> List.filter ((<>) 0L)
        |> List.distinct

    eprintfn "*%A" ms

    ms
    |> List.filter (fun m -> N / m = N % m)
    |> List.sum
    |> printfn "%i"

    0

Measured memory_bytes: 51900
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;
#define chmax(a, b) a=(((a)<(b))?(b):(a))
#define chmin(a, b) a=(((a)>(b))?(b):(a))
#define F first
#define S second
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const P<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}


signed main()
{
   int N; cin >> N;
   V<int> x(N), y(N);
   REP(i, N) {
      cin >> x[i] >> y[i];
   }

   int MIN = INF, min_i, MAX = -INF, max_i;
   int MAXMIN = INF, MINMAX = -INF;
   REP(i, N) {
      if (MIN > min(x[i], y[i])) {
         MIN = min(x[i], y[i]);
         min_i = i;
      }
      if (MAX < max(x[i], y[i])) {
         MAX = max(x[i], y[i]);
         max_i = i;
      }
      chmin(MAXMIN, max(x[i], y[i]));
      chmax(MINMAX, min(x[i], y[i]));
   }

   int ans = (MAX - MAXMIN) * (MINMAX - MIN);
   if (min_i == max_i) {
      cout << ans << endl;
      return 0;
   }

   V<P<int,int>> tmp;
   REP(i, N) {
      tmp.PB(MP(min(x[i],y[i]), max(x[i], y[i])));
   }
   SORT(tmp);
   int RMIN = tmp[0].F, RMAX = tmp[N-1].F;
   int BMIN = INF, BMAX = -INF;
   REP(i, N) {
      RMIN = (i+1 < N ? tmp[i+1].F : INF);
      chmin(BMIN, tmp[i].S);
      chmax(BMAX, tmp[i].S);
      chmin(ans, (MAX - MIN) * (max(BMAX, RMAX) - min(BMIN, RMIN)));
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 9584
#include <stdio.h>
#include <math.h>
using namespace std;
constexpr int kN = int(2E5 + 10);
int a[kN];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = k + 1; i <= n; i++) if (a[i] > a[i - k]) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 2388
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//ワーシャルフロイト法のテンプレ.graphに最短経路が格納される.
//負の重みがある場合inf + const = inf に気を付けること.
//graphは隣接行列.
void WF(vector<vector<int>> &graph){
	int n = graph.size();
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}
}

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0, temp = 0;
	rep(i,n){
		if (s[i] == 'I')
			temp++;
		else
			temp--;
		ans = max(ans, temp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n;
  cin>>n;
  vector<ll>v(n);
  rep(i,n)cin>>v[i];
  ll ans = INF;
  REP(p,1,101){
    ll tmp = 0;
    rep(i,n){
      tmp += pow(v[i]-p,2);
    }
    ans = min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

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

using namespace std;

int main(){
	int n,a,b;
	string s; cin>>n>>a>>b>>s;

	int cnt1=0,cnt2=0;
	for(char c:s){
		if(c=='a'){
			if(cnt1<a+b){
				puts("Yes");
				cnt1++;
			}
			else puts("No");
		}
		else if(c=='b'){
			if(cnt1<a+b && cnt2<b){
				puts("Yes");
				cnt1++;
			}
			else puts("No");
			cnt2++;
		}
		else puts("No");
	}

	return 0;
}


Measured memory_bytes: 896
a, b = map(int, input().split())
o1 = o2 = o3 = -1
for i in range(min(a+1, (b//10000)+1)):
    for j in range(min(a-i+1, ((b-10000*i)//5000)+1)):
        k = a-i-j
        if b == i*10000+j*5000+k*1000:
            o1 = i
            o2 = j
            o3 = k
            break
print(o1, o2, o3)


Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
	int h[20];
	int i=0;
	int n=0;
	int j=0;
	int count=0;
	int max=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		h[i]=0;
	}
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&h[i]);
	}
	
	for(i=0;i<n;i++)
	{
		max=0;
		for(j=0;j<i+1;j++)
		{
			if(max<h[j])
			{
				max=h[j];
			}
		}
		if(max==h[i])
		{
			count++;
		}
	}
	
	printf("%d",count);
			
	return 0;
}

Measured memory_bytes: 128
import sys

if __name__=="__main__":
    ab=[]
    cd=[]
    [n,m]=map(int,input().split(" "))
    for i in range(n):
        ab.append(list(map(int,input().split(" "))))
    for j in range(m):
        cd.append(list(map(int,input().split(" "))))
    for i in range(n):
        min=sys.maxsize
        index=0
        for j in range(m):
            distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
            if min > distance :
                min=distance 
                index=j
        print(index+1)

Measured memory_bytes: 39280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n, r;
    cin >> n >> r;
    cout << r + (100 * max(0, 10 - n)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
bool option(pair<int, int> a, pair<int, int> b){
	return a.second < b.second;
}
int32_t main(){ fast;
	int n,k; cin>>n>>k;
	int cnt = 0, ma = 0, mi = 200005;
	vector<int> map(200005, 0);
	rep(i, n){
		int x; cin>>x;
		mi = min(mi, x);
		ma = max(ma, x);
		if(map[x] == 0){
			cnt++;
		}
		map[x]++;
	}
	if(cnt <= k){
		cout<<0<<endl;
		return 0;
	}
	vector<int> a;
	for(int i = mi; i <= ma; i++){
		if(map[i] != 0){
			a.push_back(map[i]);
		}
	}
	int need = cnt - k;
	sort(all(a));
	int ans = 0;
	for(int i = 0; i < need; i++){
		ans += a[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2168
#入力値処理
n = int(input())
data = [int(s) for s in input().split()]

bindata = []

for value in data:
  tmp = format(value,'b').zfill(60)  
  bindata.append(tmp)

#各桁の1の個数を格納
numlist = []
for i in range(60):
  numlist.append([row[i] for row in bindata])
#print(numlist)

binnum = [0] * 60
for i in range(60):
  binnum[59-i] = numlist[i].count('1')
#print(binnum)

"""
for rowdata in bindata:
  for j in range(60):
    if rowdata[j] == '1':
      numlist[59-j] += 1
"""
ans = 0

#各桁の1の個数と0の個数の積の和を求める
for i in range(60):
  ans += binnum[i] * (n-binnum[i]) * (2 ** i)
ans = ans % (10**9 + 7)
print(ans)






"""
ans = 0

for i in range(n-1):
  for j in range(i,n):
    ans = ans +  int(bin(data[i] ^ data[j]),0)
ans = ans % (10 ** 9 + 7)

print(int(ans))
"""

Measured memory_bytes: 196268
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
#define pint pair<int,int>
#define vi(v) rep(i,v.size())cin >> v[i]
#define vc(v) rep(i,v.size())cout << v[i] << endl
#define ni(n) cin >> n
#define nc(n) cout << n << endl
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll>a(x),b(y),tmp,c(z);
  vi(a);
  vi(b);
  vi(c);
  sort(all(a));
  sort(all(b));
  sort(all(c));
  rep(i,x)rep(j,y)tmp.push_back(a[i] + b[j]);
  sort(tmp.rbegin(),tmp.rend());
  priority_queue<ll>ans;
  rep(i,min(k,x * y))rep(j,z)ans.push(tmp[i] + c[j]);
  rep(i,k){
    cout << ans.top() << endl;
    ans.pop();
  }
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 43240
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int x = sc.nextInt();

      int[] pos = new int[n+1];
      for(int i = 0; i < m; i++)
        pos[sc.nextInt()] = 1;
      int leftCost = 0;
      for(int i = x-1; i > 0; i--)
        leftCost += pos[i];
      int rightCost = 0;
      for(int i = x+1; i < n; i++)
        rightCost += pos[i];

      System.out.println(Math.min(leftCost, rightCost));
  }
}

Measured memory_bytes: 21844