akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int H,W,h,w;
  cin >> H >> W >> h >> w;

  cout << (H-h) * (W-w) << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n,m;
int a[100010];

int main(){
  while(1){
    cin>>n>>m;
    if(n==0)break;
    rep(i,n)cin>>a[i];
    int res=-1;
    rep(i,n)rep(j,i){
      if(a[i]+a[j]<=m)maxch(res,a[i]+a[j]);
    }
    if(res==-1)cout<<"NONE"<<endl;
    else cout<<res<<endl;
  }
  return 0;
}



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

const int MAXN = 1000;
const int MAXV = MAXN * (MAXN-1) / 2;
vector<vector<int>> to(MAXV);

vector<int> dp(MAXV);
vector<bool> visited(MAXV, false);
vector<bool> calculated(MAXV, false);

int dfs(int v){
	//cout << "dfs" << v << dp[v] << endl;
	if(visited[v]){
		if(!calculated[v]){
			// find roop!
			return -1;
		}
		//return dp[v];
	}
	if(calculated[v]) return dp[v];
	
	visited[v] = true;
	int res = 1;
	for(int p : to[v]){
		int tmp = dfs(p);
		if(tmp == -1) return -1;
		res = max(res, tmp+1);
	}
	dp[v] = res;
	calculated[v] = true;
	return dp[v];
}

int main(){
	
	int n;
	cin >> n;
	
	vector<vector<int>> a(n, vector<int>(n-1));
	rep(i,n){
		rep(j,n-1){
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	
	// 試合組み合わせにidをつける
	vector<vector<int>> id(n, vector<int>(n));
	int matchId = 0;
	rep(i,n){
		for(int j = i+1; j < n; j++){
			id[i][j] = matchId++;
		}
	}
	
	rep(i,n){
		for(int j = 0; j < i; j++){
			id[i][j] = id[j][i];
		}
	}
	/*
	rep(i,n){
		rep(j,n){
			printf("%d%c", id[i][j], j==n-1? '\n':' ');
		}
	}
	*/
	
	rep(i,n){
		rep(j,n-1){
			int from = a[i][j];
			a[i][j] = id[i][from];
			//printf("%d%c", a[i][j], j==n-2? '\n':' ');
		}
	}
	
	rep(i,n){
		rep(j,n-2){
			to[a[i][j]].push_back(a[i][j+1]);
		}
	}
	/*
	rep(i,matchId){
		rep(j,to[i].size()){
			printf("%d:%d%c", i,to[i][j], j==to[i].size()-1? '\n':' ');
		}
	}
	*/
	
	rep(i,matchId){
		int tmp = dfs(i);
		if(tmp == -1){
			puts("-1");
			return 0;
		}
	}
	
	int res = 0;
	rep(i,dp.size()) res = max(res, dp[i]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 37632
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();// 几个500
		int B = sc.nextInt();// 几个100
		int C = sc.nextInt();// 几个50
		int X = sc.nextInt();
		int ans = 0;
		int i,j,k;
		for (i = 0; i <= A; i++) {
			for (j = 0; j <= B; j++) {
				for (k = 0; k <= C; k++) {
					if (500 * i + 100 * j + 50 * k == X)
						ans+=1;
				}
			}
		}
		System.out.println(ans);

		
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int x; cin >> x;
  int kyu = 8;
  if (x >= 1800) kyu = 1;
  else if (x >= 1600) kyu = 2;
  else if (x >= 1400) kyu = 3;
  else if (x >= 1200) kyu = 4;
  else if (x >= 1000) kyu = 5;
  else if (x >= 800) kyu = 6;
  else if (x >= 600) kyu = 7;
  cout << kyu << endl;
  return 0;
}

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

int main() {
  string s;cin>>s;
  int n=s.size()-8;
  rep(i,n)cout<<s[i];
  cout<<endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 10005 

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

int dp[ARRAY_MAX];

int main() {

	int N, W;
	cin >> N >> W;

	vector<int> v(N), w(N), m(N);
	for (int i = 0; i < N; i++)
	{
		cin >> v[i] >> w[i] >> m[i];
	}

	for (int i = 0; i < N; i++)
	{
		for (int k = 0; m[i] > 0; k++)
		{
			int key = min(m[i], (1 << k));
			m[i] -= key;

			int nv = key * v[i];
			int nw = key * w[i];

			for (int j = W; j >= nw; j--)
			{
				dp[j] = max(dp[j], dp[j - nw] + nv);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i <= W; i++)
	{
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;



}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans =-9223372036854775807;
	ans = max(a*c,b*d);
	ans = max(ans,b*c);
	ans = max(ans,a*d);
	// ans = max(ans,b*d);
	// ans = max(ans,c*d);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
int dx[]={1, 0, -1, 0};
int dy[]={0,1, 0,-1};
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	fastio;
	int n,m,k;
	cin>>n>>m>>k;
	int d[n+5][m+5];
	int x1, x2, y1,y2;
	cin>>x1>>y1>>x2>>y2;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			char c;
			cin>>c;
			if(c=='.') d[i][j]=INT_MAX;
			else d[i][j]=-1;
		}
	}
	d[x1][y1]=0;
	queue<pr<int, ii> > q;
	q.push({0, {x1, y1}});
	while(!q.empty())
	{
		int xu=q.front().se.fi, yu=q.front().se.se,dist=q.front().fi;
		q.pop();
		if(dist>d[xu][yu]) continue;
		for(int i=0; i<4; i++)
		{
			for(int j=1; j<=k; j++)
			{
				int xv=xu+dx[i]*j, yv=yu+dy[i]*j;
				if(1<=xv and xv<=n and 1<=yv and yv<=m and d[xv][yv]!=-1 and d[xv][yv]>=d[xu][yu]+1)
				{
					if(d[xv][yv] > d[xu][yu]+1) q.push({d[xu][yu]+1, {xv, yv}});
					d[xv][yv]=d[xu][yu]+1;
				}
				else break;
			}
		}
	}
	if(-1<d[x2][y2] and d[x2][y2]<INT_MAX) cout<<d[x2][y2];
	else cout<<-1;
}




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

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s.at(0)==s.at(1) && s.at(1)!=s.at(2) && s.at(2)==s.at(3)){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  cout << v[n/2]-v[n/2-1] << endl;
  return 0;
}

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

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;


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

	s[3] = '8';

	cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    string s; cin >> s;
    int ans = 0;

    irep(i,s.size()){
        if(s[i] == 'o') { ans += 100; }
    }
    cout << ans + 700 << endl;
    return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> ap(a);
	for (int i = 0; i < a; i++)cin >> ap.at(i);
	vector<int> bp(b);
	for (int i = 0; i < b; i++)cin >> bp.at(i);
	vector<vector<int>> w(m, vector<int>(3));
	for (int i = 0; i < m; i++) {
		cin >> w.at(i).at(0) >> w.at(i).at(1) >> w.at(i).at(2);
	}

	//暫定 = ap最小+bp最小
	int a_min = 100000;
	for (int i = 0; i < a; i++) a_min = min(a_min, ap.at(i));
	int b_min = 100000;
	for (int i = 0; i < b; i++)b_min = min(b_min, bp.at(i));
	int res = a_min + b_min;
	//割引券で暫定より低くなる可能性:mで検索
	for (int i = 0; i < m; i++) {
		int aw = w.at(i).at(0);
		int bw = w.at(i).at(1);
		int c = w.at(i).at(2);
		int wari = ap.at(aw-1) + bp.at(bw-1) - c;
		res = min(res, wari);
	}
	cout << res << endl;
}

Measured memory_bytes: 6528
/*
     _              ,_,                 
    / \   _ __, ___,| |__   __ _,_ __  
   / ^ \ | '_ \/ _ \| '_ \ / _` | /_/  
  /-/-\-\|-| |--| |-|-|_)-|-(_|-|-|    
 /_/   \_\_| |__| |_|_.__/ \__,_|_|    
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(a)       (a).begin(),(a).end()
#define rep(i,a,n)   for(int i=a ; i<n ; i++)
 
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<ll,ll> mii;
typedef map<char,ll> mci;
 
ll gcd(ll a, ll b){
	if(b==0)return a;
	else return gcd(b, a%b);
}

signed main(){
    ll test=1;
    // cin>>test;
    while(test--){
        ll n; cin>>n;
        string s; cin>>s;
        ll w=0, r=0, cnt=0;
        rep(i, 0, n){
        	if(s[i]=='W')w++;
        	else r++;
        }
        rep(i, 0, n){
        	if(s[i]=='R'&&i>=r)cnt++;
        }
        cout<<cnt<<endl;
    }
        
}

Measured memory_bytes: 3728
/*
氏名 : 杉谷　裕貴,学籍番号 : 190441066
概要 : 表計算を行うプログラム
*/
#include<stdio.h>

int main(void)
{
	int r, c, i, j, a[101][101] = { 0 };

	scanf("%d %d", &r, &c);

	for (i = 0; i < r; i++)/*r回繰り返す*/
	{
		for (j = 0; j < c; j++)/*c回繰り返す*/
		{
			scanf("%d", &a[i][j]);/*表の入力*/
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
		}
		a[r][c] += a[i][c];
	}

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

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int N, K; cin >> N >> K;
  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
  }
  sort(all(p));
  int ans = 0;
  rep(i, K) {
    ans += p[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
////package Educ_DP;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] l=s.nextLine().split(" ");
        int num=Integer.parseInt(l[0]);
        int cap=Integer.parseInt(l[1]);

        String[] a=s.nextLine().split(" ");
        int[] list=new int[a.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(a[i]);
        }
        boolean[] dp=new boolean[cap+1];
        for (int i=0;i<=cap;i++){
            for (int j:list){
                if (i-j>=0 && !dp[i-j]){
                    dp[i]=true;
                }
            }
        }
        if (dp[cap]){
            System.out.println("First");
        }
        else{
            System.out.println("Second");
        }
    }
}


Measured memory_bytes: 36652
/*||>>>> Praveen Ojha <<<<>>>> 22 June 2019 <<<<>>>> 17:28:18 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n;
	cin>>n;
	vpii vv;
	int x,y;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		vv.push_back({y,x});
	}
	sort(all(vv));
	debug()<< imie(vv);
	int flag=1,tot=0;
	for(int i=0;i<n;i++){
		tot+=vv[i].S;
		if(tot>vv[i].F){
			flag=0;
			break;

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

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

int main() {
    string s; cin >> s;
    for (char i = 'a'; i <= 'z'; i++) {
        if (s.find(i) == -1) {
            cout << i;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

int main(){
    int n;
    cin>>n;
    int total=0;
    // vector<int> a(n);
    string s;
    
    s=to_string(n);
    for(int i=0;i<s.size();i++){
        
        total=total+stoi(s.substr(i,1));
    }
    
    if(n%total==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;
//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
//komennto C+udekaijo

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,k;cin>>a>>b>>k;
	vector<pair<int,int> > v(100);
	rep(i,100){v[i].first=0;v[i].second=0;}

	rep(i,100){
		if(a%(i+1)==0)v[i].first=1;
		if(b%(i+1)==0)v[i].second=1;
	}
	int c=0;
	int ans=0;
	int i=99;
	while(c!=k){
		if(v[i].first&&v[i].second){
			c++;
			ans=i+1;
		}
		i--;
	}
	cout<<ans<<endl;

	


	return 0;
}


Measured memory_bytes: 256
/*

*/

#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

int main()
{
	double x1,y1,x2,y2;
	double x3,y3;
	double r;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	x3=x2;
	y3=y1;
	r=((x3-x1)*(x3-x1))+((y2-y3)*(y2-y3));
	r=sqrt(r);
	printf("%f\n", r);
	return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define x first
#define y second
ll gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<ll> nxt(1000010,0),mp(1000010,0);
        for(int i=2;i*i<=1000000;i++)
        if(!nxt[i])
        {
            nxt[i]=i;
            for(int j=i*i;j<=1000000;j+=i)
            if(!nxt[j])
            nxt[j]=i;
        }
        for(int i=2;i<=1000000;i++)
        if(!nxt[i])
        nxt[i]=i;
        vector<ll> a(n);
        for(int i=0;i<n;i++)
        cin>>a[i];
        int g=a[0];
        int flag=0;
        for(int i=0;i<n;i++)
        {
            g=gcd(g,a[i]);
            ll sp=a[i];
            while(nxt[sp])
            {
                if(mp[nxt[sp]]!=i&&mp[nxt[sp]]!=0||flag)
                {flag=1;break;}
                mp[nxt[sp]]=i;
                sp/=nxt[sp];
            }
        }
        if(flag==0)
        cout<<"pairwise coprime\n";
        else if(g==1)
        cout<<"setwise coprime\n";
        else
        cout<<"not coprime\n";
    }
    return 0;
}

Measured memory_bytes: 26688
#include <stdio.h>

int main(void) {
	int a,b,c,d,t,p;
		while(scanf("%d",&t) != EOF){
			p = 0;
			for (a = 0;a <= 9;a++){
				for (b = 0;b <= 9;b++){
					for (c = 0;c <= 9;c++){
						for (d = 0;d <= 9;d++){
							if (a + b + c + d == t){
								p = p + 1;
							}
						}
					}
				}
			}
			printf("%d\n",p);
		}
	return 0;
}
//aoj 0008

Measured memory_bytes: 596
n = int(input())
red = []
blue = []
for i in range(n):
    red.append(list(map(int,input().split())))
for i in range(n):
    blue.append(list(map(int,input().split())))
red.sort(reverse = True)
blue.sort(key=lambda x:x[1])
ans = 0
for i in range(n):
    redx,redy = red[i][0],red[i][1]
    for j in range(len(blue)):
        bluex,bluey = blue[j][0],blue[j][1]
        if redx < bluex and redy < bluey:
            ans += 1
            blue.pop(j)
            break
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>

using namespace std;

using ll = long long;
//constexpr ll N = 2e5;
//ll a[N];


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

	for (int i = 0; i < s.length(); i++)
	{
		if (((s[i] + N  -1 ) / 'Z') > 0) {
			s[i] = 'A' + s[i] + N - 'Z' - 1;
		}
		else {
			s[i] = s[i] + N;
		}
	}

	cout << s;

	
	return 0;
}

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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define trace(...)
#endif

main(){
    string str;
    cin >> str;
    int mx, mn, n = str.size();
    mn = n;
    str =  '*' + str;
    for(int i = 1; i < n; ++i){
        if(str[i] == str[i+1]) continue;
        mx = max(i, n-i);
        mn = min(mn, mx);
    }
    if(n == 1) mn = 1;
    cout << mn << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];

    }
    bool bp = false;
    int ans = 1300000;
    for(int tmp = 0; tmp < (1 << 13); tmp++){
        bitset<13> s(tmp);
        vector<int> y(m,0);
        int sum = 0;
        rep(i,n){
            if(s.test(i)) sum += c[i];
            rep(j,m){
                if(s.test(i)) y[j] += a[i][j];
        }

        }
        bool check = true;
        rep(i,m){
            if(!(y[i] >= x)) check = false;
        
        }
        if(check){
            bp = true;
        ans = min(ans,sum);
        }
        

    }

    if(bp)cout << ans << endl;
    else cout << -1 << endl;
    
}



Measured memory_bytes: 3548
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll a, b, c;
	cin >> a >> b >> c;

	ll res = 0;
	if (a % 2 == 0 && a == b && a == c)
	{
		res = -1;
	}
	else
	{
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
		{
			res++;

			ll a0 = a;
			ll b0 = b;
			ll c0 = c;

			a = b0 / 2 + c0 / 2;;
			b = a0 / 2 + c0 / 2;;
			c = b0 / 2 + a0 / 2;;


		}
	}
	println(res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define LI long int
#define INF 100010001000
using namespace std;
int ma[105][105],a[105],x,y,n,sum,xo,yo,no;


int main(){
    fill(ma[0],ma[104],1);
    cin >> x >> y >> n;

    for(int i=0;i<n;i++){
        cin >> xo >> yo >> no;
        if(no==1){
            for(int j=0;j<y;j++){
                for(int k=0;k<xo;k++){
                    ma[k][j]=0;
                }
            }
        }else if(no==2){
            for(int j=0;j<y;j++){
                for(int k=xo;k<x;k++){
                    ma[k][j]=0;
                }
            }
        }else if(no==3){
            for(int j=0;j<yo;j++){
                for(int k=0;k<x;k++){
                    ma[k][j]=0;
                }
            }
        }else{
            for(int j=yo;j<y;j++){
                for(int k=0;k<x;k++){
                    ma[k][j]=0;
                }
            }
        }

    }

    for(int i=0;i<y;i++){
        for(int j=0;j<x;j++){
            sum+=ma[j][i];
        }
    }

    cout << sum << endl;

return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
bc = sorted([list(map(int, input().split())) for i in range(m)], key=lambda x:x[1], reverse=True)
ans = 0
x, y = 0, 0
for i in range(n):
    if y == m or a[x] > bc[y][1]:
        ans += a[x]
        x += 1
    else:
        ans += bc[y][1]
        bc[y][0] -= 1
        if bc[y][0] == 0:
            y += 1
print(ans)

Measured memory_bytes: 101996
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a=0;
    char c;
    
    cin >> n;
    
    while(n--){
        cin >> c;
        if(c == 'Y') {
            a=1;
            break;
        }
        cin.ignore();
    }
    
    printf("%s\n",a?"Four":"Three");
}

Measured memory_bytes: 256
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;
typedef pair < ll, ll > pl;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)1e5 + 5;
const int mod = (int)1e9 + 7;

ll a[10];

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    for (int i = 0; i < 7; i++)
        cin >> a[i];
    
    ll res = 0ll + a[1] + a[0] / 2 * 2 + a[3] / 2 * 2 + a[4] / 2 * 2;
    if (a[0] % 2 == 1 && a[3] % 2 == 1 && a[4] % 2 == 1)
        res += 3;
    
    ll res2 = a[1];
    if (a[0] > 0 && a[3] > 0 && a[4] > 0) {
        res2 += 3;
        a[0]--, a[3]--, a[4]--;
    }
    
    res2 += 0ll + a[0] / 2 * 2 + a[3] / 2 * 2 + a[4] / 2 * 2;
    
    cout << max(res, res2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,W;
  cin >> H >>W;
  int N;
  cin >> N;
  int a[N];
  rep(i,N) cin >> a[i];
  int ans[H][W];
  int x=0;
  int y=0;
  rep(i,N){
    while(a[i]>0){
      //      cout << x << " " << y << " "<<i+1 << endl;
      ans[y][x]=i+1;
      a[i]--;
      if(y%2==0){
	if(x!=W-1) x++;
	else y++;
      }
      else if(y%2==1){
	if(x!=0) x--;
	else y++;
      }
    }
  }
  rep(i,H){
    rep(j,W) cout << ans[i][j] << " ";
    cout << ""<<endl;
  }
    
  return 0;
    

}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		scan.close();
		
		for(int i = 0; i < 3; i++) {
			if(n%10 == 7) {
				System.out.println("Yes");
				return;
			}else {
				n /= 10;
			}
		}
		
		System.out.println("No");
	}

}

Measured memory_bytes: 35720
N,M,X=map(int,input().split())
l=[list(map(int,input().split())) for i in range(N)]


cmin=12*10**5+1
for bit in range(2**N):
    A=[0]*M
    c=0
    for j in range(N):
        if (bit>>j)&1:
            c+=l[j][0]
            A=[x+y for (x,y) in zip(A, l[j][1:])]
    if min(A) >= X:
        cmin=min(cmin,c)

if cmin!=12*10**5+1:
    print(cmin)
else:
    print(-1)

Measured memory_bytes: 68716
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void swap_int(int *x, int *y) {int temp;temp = *x;*x = *y;*y = temp;}
void swap_char(char *x, char *y) {char temp;temp = *x;*x = *y;*y = temp;}
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x > y ? y : x; }

int main(){
    int a,b;

    scanf("%d %d",&a,&b);
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b){
        printf("Alice\n");
    }else if(a==b){
        printf("Draw\n");
    }else{
        printf("Bob\n");
    }
    return 0;
}

Measured memory_bytes: 128
from sys import stdin
N = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
sum = 0
wh = s.count('.')
cnt = 0
for itr in range(N):
    if s[itr] == '#':
        cnt += 1
        continue
    if cnt > 0:
        sum += 1
        cnt -= 1
print(sum)


Measured memory_bytes: 3500
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int n, dp[200010];
int main() {
  scanf("%d", &n);
  dp[0] = 0;
  for (int i = 0; i <= 9; i++) {
    dp[i] = i;
  }
  for (int i = 10; i <= 99; i++) {
    int x = i / 10, y = i % 10;
    dp[i] = dp[i - 1];
    if (y == 0)
      ;
    else if (x == y) {
      dp[i] += 3;
    } else if (x > y) {
      dp[i] += 2;
    }
  }
  for (int i = 100; i <= 999; i++) {
    int x = i / 100, y = i % 10;
    dp[i] = dp[i - 1];
    if (y == 0)
      ;
    else if (x == y) {
      dp[i] += 4;
      int z = i / 10 - 10 * x;
      dp[i] += 2 * z + 1;
    } else if (x > y) {
      dp[i] += 2;
      dp[i] += 20;
    } else if (x < y) {
      dp[i] += 2;
    }
  }
  for (int i = 1000; i <= 9999; i++) {
    int x = i / 1000, y = i % 10;
    dp[i] = dp[i - 1];
    if (y == 0)
      ;
    else if (x == y) {
      dp[i] += 24;
      int z = i / 10 - 100 * x;
      dp[i] += 2 * z + 1;
    } else if (x > y) {
      dp[i] += 22;
      dp[i] += 200;
    } else if (x < y) {
      dp[i] += 22;
    }
  }
  for (int i = 10000; i <= 99999; i++) {
    int x = i / 10000, y = i % 10;
    dp[i] = dp[i - 1];
    if (y == 0)
      ;
    else if (x == y) {
      dp[i] += 224;
      int z = i / 10 - 1000 * x;
      dp[i] += 2 * z + 1;
    } else if (x > y) {
      dp[i] += 2222;
    } else if (x < y) {
      dp[i] += 222;
    }
  }
  for (int i = 100000; i <= 200000; i++) {
    int x = i / 100000, y = i % 10;
    dp[i] = dp[i - 1];
    if (y == 0)
      ;
    else if (x == y) {
      dp[i] += 2224;
      int z = i / 10 - 10000 * x;
      dp[i] += 2 * z + 1;
    } else if (x > y) {
      dp[i] += 22222;
    } else if (x < y) {
      dp[i] += 2222;
    }
  }
  printf("%d\n", dp[n]);
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;

int main(void) {
    ll n; cin >> n;
    vvll g(n);
    rep(i, n-1) {
        ll u, v; cin >> u >> v; u--, v--;
        g[u].pb(v), g[v].pb(u);
    }

    vll d(n);
    function<ll(ll, ll)> f = [&](ll v, ll p) {
        for (auto u : g[v]) if (u != p) chmax(d[v], f(u, v));
        return d[v] + 1;
    };
    f(0, -1);

    vll ret(n);
    // dpar[v][p] = p???v???????????¨?????¨????????§?????§???d
    function<void(ll, ll, ll)> ff = [&](ll v, ll p, ll dpar) {
        vector<P> children = {P(0, -1)};
        for (auto u : g[v]) children.emplace_back(u == p ? dpar + 1 : d[u] + 1, u);
        sort(all(children)); reverse(all(children));

        ret[v] = children[0].fi;

        for (auto u : g[v]) if (u != p) ff(u, v, children[children[0].se==u].fi);
    };
    ff(0, -1, 0);

    rep(i, n) cout << 2 * (n - 1) - ret[i] << endl;


    return 0;
}

Measured memory_bytes: 31480
#include <cstdio>
using namespace std;

int main (void)
{
	int i, n, x;

	scanf("%d", &n);

	for (i=1; i<=n; i++){
		x = i;
		if (x % 3 == 0)
			printf(" %d", i);
		else{
			do{
				if (x % 10 == 3){
					printf(" %d", i);
					break;
				}
				x /= 10;
			}while (x);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)
#define size size()

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






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

def warshall_floyd(d, V): 
    for k in range(V):
        for i in range(V):
            for j in range(V):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    return d #d[i][j]に頂点i, j間の最短距離を格納

def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):
    min_cost = warshall_floyd(c,10)
    answer = 0

    for h in range(H):
        for w in range(W):
            if A[h][w] == -1:
                continue

            answer += min_cost[A[h][w]][1]
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    c = [[int(next(tokens)) for _ in range(9 - 0 + 1)] for _ in range(9 - 0 + 1)]  # type: "List[List[int]]"
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, c, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40796
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=5001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 

int main()
{
  int n;
  cin>>n;
  int a[n],cnt=0;
  fo(i,0,n)
   cin>>a[i];
  fo(i,1,n-1)
  {
    if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]>a[i+1]&&a[i]<a[i-1])) cnt++;

  }
  cout<<cnt<<endl;
}

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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if

int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  int a[4];
  rep(i,4)cin>>a[i];
  sort(a,a+4);
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
  return 0;
  
}


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

using namespace std;

typedef long long ll;

#define INF 2000000000
#define SIZE 1000000
#define pb push_back
#define showint(x) cerr<<#x<<" is "<<x<<endl;
#define showarr(x,n) for(int I=0;I<n;I++) {cerr<<#x<<"["<<I<<"]"<<" is "<<x[I]<<endl;}
//#define fin cin

int main()
{
  ifstream fin("input.txt",ios::in);
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
  cout<<setprecision(10);
  cout<<fixed;
  int n;
  cin>>n;
  int d[n];
  int a,b;
  cin>>a>>b;
  for(int i=0;i<n;i++) cin>>d[i];
  int k1=0;
  int k2=0;
  for(int i=0;i<n;i++)
  {
    if(d[i]<=a) k1++;
    else if(d[i]<=b) k2++;
  }
  cout<<min(n-k1-k2,min(k1,k2));
}


Measured memory_bytes: 256
// 2012/07/13 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int p_max = -1;
		int d_max = -1;

		for(int i=0; i<n; i++){
			int p, d1, d2;
			cin >> p >> d1 >> d2;

			if(d1+d2>d_max){
				p_max = p;
				d_max = d1+d2;
			}
		}

		cout << p_max << ' ' << d_max << endl;
	}

	return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;

void _main() {
    cin >> N;
    FOR (i, 1, N + 1) {
        int a = (int)(i * 1.08);
        if (a == N) {
            cout << i << endl;
            return;
        }
    }
    cout << ":(" << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
#define ll long long
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; } 
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 
inline void writeln(ll x){ write(x);   puts("");   }
const ll N=400010;
ll mark[N],gg[N],head[N],nxt[N],vet[N],m,n,tot;
int main(){
	n=read();	m=read();	mark[1]=1;
	For(i,1,m){
		ll x=read(),y=read();
		if (x==1)	mark[y]=1;
		if (y==n)	gg[x]=1;
		if (y==n&&mark[x])	return puts("POSSIBLE"),0;
		if (x==1&&gg[y])	return puts("POSSIBLE"),0;
	}puts("IMPOSSIBLE");
}

Measured memory_bytes: 6400
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Map as MP
import qualified Data.Sequence as SQ
import Data.Tuple
import Data.List
import Control.Monad

type Distance = VUM.IOVector Int
type Table = VUM.IOVector Int
type Deque = SQ.Seq Int

bfs :: Distance -> MP.Map Int [Int] -> Deque -> IO Distance
bfs distance graph dq = 
  case SQ.viewl dq of
    SQ.EmptyL -> return distance
    x SQ.:< dq' -> do
      VUM.read distance x >>= \rx -> do
        let Just ys = MP.lookup x graph
        ys' <- flip filterM ys $ \y -> do
          VUM.read distance y >>= \ry ->
            if (ry /= 10^9)
               then return False
               else (VUM.write distance y $ rx+1) >> return True
        let dq'' = foldl (SQ.|>) dq' ys'
        bfs distance graph dq''

main = do
  [n,a,b] <- map read . words <$> getLine :: IO [Int]
  let vs = let xs = zip [1..n] [2..n] in [(a,b),(b,a)] ++ (map swap xs) ++ xs :: [(Int, Int)]
  let graph = foldl (\m k -> MP.insert k [] m) MP.empty [1..n]
  let graph' = foldl (\m (f,t) -> MP.adjust (t:) f m) graph vs
  
  table <- VUM.replicate (n+1) 0 :: IO Table

  forM_ [1..n] $ \i -> do
    distance <- VUM.replicate (n+1) (10^9) :: IO Distance
    VUM.write distance i 0    
    bfs distance graph' (SQ.singleton i)
    distance' <- VU.tail . VU.zip (VU.fromList [0..n]) <$> VU.unsafeFreeze distance

    VU.forM_ distance' $ \(j,d) -> do
      when (j > i) $ do
        VUM.modify table (+1) d

  table' <- VU.tail . VU.init <$> VU.unsafeFreeze table    
  VU.mapM_ print table'

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

int main() {
	int a, b;
	cin >> a >> b;

	int ans = 0;
	for (int i = 0; i < 2; i++) {
		if (a < b) {
			ans += b;
			b--;
		} else {
			ans += a;
			a--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

struct asumikana {
	int idx, value;
};

int cmp(const void* x, const void* y) {
	int a = ((const struct asumikana*)x)->value;
	int b = ((const struct asumikana*)y)->value;
	return a < b ? -1 : a > b;
}

int N;
int A[114514];

int recCount;
int rec[114514];
struct asumikana tomatu[114514];

int main(void) {
	int i;
	int answer = 0, current;
	int pos;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	recCount = 1;
	rec[0] = 0;
	tomatu[0].idx = 0;
	tomatu[0].value = 0;
	for (i = 0; i < N; i++) {
		if (A[i] != rec[recCount - 1]) {
			rec[recCount] = A[i];
			tomatu[recCount].idx = recCount;
			tomatu[recCount].value = A[i];
			recCount++;
		}
	}
	if (rec[recCount - 1] != 0) {
		rec[recCount] = 0;
		tomatu[recCount].idx = recCount;
		tomatu[recCount].value = 0;
		recCount++;
	}
	qsort(tomatu, recCount, sizeof(*tomatu), cmp);
	current = recCount > 1 ? 1 : 0;
	pos = 0;
	while (pos < recCount && tomatu[pos].value == 0) {
		if (tomatu[pos].idx != 0 && tomatu[pos].idx != recCount - 1) current++;
		pos++;
	}
	answer = current;
	for (i = pos; i < recCount; ) {
		int sumipe = tomatu[i].value;
		while (i < recCount && tomatu[i].value == sumipe) {
			
			if (rec[tomatu[i].idx - 1] > sumipe && sumipe < rec[tomatu[i].idx + 1]) current++;
			else if (rec[tomatu[i].idx - 1] < sumipe && sumipe > rec[tomatu[i].idx + 1]) current--;
			i++;
		}
		if (current > answer) answer = current;
	}
	printf("%d\n", answer);
	return 0;
}



Measured memory_bytes: 3828
#include<stdio.h>
int main(){
  int n;
  char s;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%c",&s);
    if(s=='Y'){
      printf("Four");
      return 0;
    }
  }
  printf("Three");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 100005
#define db double
#define mod 998244353
using namespace std;
void solve()
{
	string str;
	cin >> str;
	ll n= str.size();
	string temp;
	for(ll i=0;i<n/2;i++)
	{
		temp += str[i];
		if(str[i]!=str[n-i-1])
		{
			cout << "No";
			return;
		}
	}
	string s = temp;
	reverse(temp.begin(),temp.end());
	for(ll i=0;i<s.size();i++)
		if(temp[i]!=s[i])
		{
			cout << "No";
			return;
		}
	reverse(str.begin(),str.end());
	temp="";
	s="";
	for(ll i=0;i<n/2;i++)
	{
		temp += str[i];
	}
	s = temp;
	reverse(temp.begin(),temp.end());
	for(ll i=0;i<s.size();i++)
		if(temp[i]!=s[i])
		{
			cout << "No";
			return;
		}
	cout << "Yes";
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(10);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

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

int main(){
	long long N, T, A, RT=1, RA=1;
	cin >> N;
	for(long long i=0;i<N;i++){
		cin >> T >> A;
		
		long long r=max((RT-1)/T+1, (RA-1)/A+1);
		RT = r*T;
		RA = r*A;
	}
	
	cout << RT+RA << endl;
	
    return 0;
}


Measured memory_bytes: 256