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

int main()
{
  long double W, H, x, y;
  cin >> W >> H >> x >> y;
  long double ans = max(min(x * H, ((W - x) * H)), min((H - y) * W, W * y));
  if (W == H or (x == 0 && y == 0) or (x == W && y == 0) or (x == W && y == H) or (x == 0 or y == H))
  {
    bool can = false;
    ans = W * H / 2;
    if (x == W / 2 && y == H / 2)
      can = true;
    cout << setprecision(20) << ans << " ";
    if (can)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
  else
  {
    bool can = false;
    if (x == W / 2 && y == H / 2)
      can = true;
    cout << setprecision(20) << ans << " ";
    if (can)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 8*1e6;

signed
main(){
		int m,n;
		while(cin >> m >> n && !(m==0 && n==0))
		{
				if(n < m){
						cout << m+n << endl;
						continue;
				}

				vector<bool> done(MAX,false);
				int cnt = 0;
				for(int num=m;num<=MAX;num++)
				{
						if(cnt == n) break;

						if(done[num]==false)
						{
								cnt++;
								for(int i=num;i<=MAX;i+=num)
								{
										done[i] = true;
								}

						}
				}

				for(int num=m;num<=MAX;num++)
				{
						if(done[num]==false)
						{
								cout << num << endl;
								break;
						}
				}

		}
}


Measured memory_bytes: 4044
#include<stdio.h>
int main(void)
{
  int x;
  scanf("%d",&x);
  x = x % 10;
  switch(x)
    {
    case 2: ;
    case 4: ;
    case 5: ;
    case 7: ;
    case 9:
      printf("hon\n");
      break;
    case 0: ;
    case 1: ;
    case 6: ;
    case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
      break;
    default:
      printf("error\n");
    }
  return 0;
}


Measured memory_bytes: 1660
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> buka(n, 0);
    FOR(i, 1, n){
        int a;
        cin >> a;
        a--;
        buka[a]++;
    }

    REP(i, n)
        cout << buka[i] << endl;
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int cnt[26];
int main(){
	string s;
	cin>>s;
	int N=s.size();
		if((s[0]==s[N-1])^(N%2==0)) puts("Second");
		else puts("First");
}


Measured memory_bytes: 512
N=int(input())

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[] for i in range(N)]
for i in range(N):
    tmp=input()
    for j in range(len(tmp)):
        S[i].append(tmp[j])
    S[i].sort()

T=S[0]
for i in range(N):
    if len(T)>len(S[i]):
        T=S[i]


D=[]
for i in range(len(T)):
    tmp=T[0]
    flag=True
    for j in range(N):
        if tmp in S[j]:
            S[j].remove(tmp)
        else:
            flag=False
    if flag==True:
        D.append(tmp)

Z=[str(a) for a in D]
Z="".join(Z)
print(Z)


Measured memory_bytes: 3064
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

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

int main() {
  IN(int, N);
  vector<vector<pair<int, int> > > xy(N, vector<pair<int, int> >());
  REP(i, N) {
    IN(int, A);
    REP(j, A) {
      IN(int, x);
      IN(int, y);
      xy.at(i).push_back(make_pair(--x, y));
    }
  }

  int bit_max = (int)pow(2, N);
  int max = 0;
  REP(bnum, bit_max) {
    bool ok_flag = true;
    bitset<15> bit(bnum);
    REP(i, N) {
      if(bit[i]) {
        REP(j, xy.at(i).size()) {
          if (bit[xy.at(i).at(j).first] != xy.at(i).at(j).second) {
            ok_flag = false;
            break;
          }
        }
      }
      if (!ok_flag) break;
    }
    if (ok_flag) {
      int num = (int)bit.count();
      chmax(max, num);
    }
  }
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 4068
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

struct BIT{
    int N;
    vector<int> dat;
    BIT() {}
    BIT(int n) {
        N = n;
        dat.resize(N + 1);
    }
    // update k th element (0-index)
    void add(int k, int x){
        k++;
        while(k <= N){
            dat[k] += x;
            k += k&-k;
        }
    }
    // sum [0, k) (0-index)
    int sum(int k){
        int s = 0;
        while(k > 0){
            s += dat[k];
            k -= k&-k;
        }
        return s;
    }
    // sum [a, b) (0-index)
    int query(int a, int b){
        if(a >= b) return 0;
        return sum(b) - sum(a);
    }
};

int n, limit;
vector<int> a;
int b[100010];

bool calc(int mid){
    rep(i, 0, n){
        if(a[i] >= mid) b[i] = 1;
        else b[i] = -1;
    }
    BIT bit(2 * n + 10);
    int now = n, cnt = 0;
    bit.add(now, 1);
    rep(i, 0, n){
        now += b[i];        
        cnt += bit.query(0, now + 1);
        bit.add(now, 1);
    }
    return cnt >= limit;
}

int solve(){
    if(n == 1) return a[0];
    int res = 0;
    int ng = 0, ok = 1e9 + 7;
    limit = (n * (n + 1) / 2 + 1) / 2;
    while(ok - ng > 1){
        int mid = (ok + ng) / 2;
        if(calc(mid)) ng = mid;
        else ok = mid;
    }
    res = ng;
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    int ans = solve();
    cout << ans << endl;
}

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

int main() {
  const ll M = 998244353;
  ll N, ans = 1;
  cin >> N;
  vector<ll> d;
  vector<ll> cnt(N, 0);
  for (ll i = 0; i < N; i++) {
    ll x;
    cin >> x;
    if (i == 0) {
      if (x != 0) ans = 0;
    } else {
      d.push_back(x);
    }
    cnt[x]++;
  }
  for (auto x : d) {
    if (x > 0) ans *= cnt[x-1];
    else ans = 0;
    ans %= M;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
n = int(input())
ai = [0]*n
for i in range(n):
  ai[i] = int(input())
bi = ai[:]
bi.sort()
num1 = bi[-1]
num2 = bi[-2]
for i in ai:
  if i == num1:
    print(num2)
  else:
    print(num1)


Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if (abs(x-a)< abs(x-b))
    {cout << "A";}else{cout<<"B";}
    return 0;
    
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] a = new long[N+1];
		long[] ans = new long[N+1];
		for( int i=1; i<=N; i++ ){
			a[i] = sc.nextLong();
		}
		int b = 1;
		int c = 1;
		if( N%2!=0 ){
			for( int i=N; i>=1; i-=2 ){
				ans[b] = a[i];
				System.out.print(ans[b]+" ");              
				b++;
			}
			for( int i=2; i<=N-1; i+=2 ){
				ans[b] = a[i];
				System.out.print(ans[b]+" ");              
				b++;
			}
		}
		if( N%2==0 ){
			for( int i=N; i>=2; i-=2 ){
				ans[c] = a[i];
				System.out.print(ans[c]+" ");              
				c++;
			}
			for( int i=1; i<=N-1; i+=2 ){
				ans[c] = a[i];
				System.out.print(ans[c]+" ");              
				c++;
			}
		}
	}
}


Measured memory_bytes: 97788
S = str(input())
if S in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']:
    print("A")
else:
    print("a")

Measured memory_bytes: 61644
def main():
    d_num = int(input())
    for i in range(d_num):
        a, b = map(str, input().split(" "))
        print(NtoS(StoN(a) + StoN(b)))

def StoN(mcxi):
    slist = list(mcxi)
    for i in range(len(slist)):
        if slist[i] == 'm': slist[i] = 1000
        elif slist[i] == 'c': slist[i] = 100
        elif slist[i] == 'x': slist[i] = 10
        elif slist[i] == 'i': slist[i] = 1
        else: slist[i] = int(slist[i])
        
    num = 1
    summ = 0
    for item in slist:
        if item == 1000 or item == 100 or item == 10 or item == 1:
            summ += num * item
        else:
            num = item
            continue
        num = 1

    return summ

def NtoS(num):
    mcxi = ""
    n1000 = num // 1000
    n100 = (num - n1000 * 1000) // 100
    n10 = (num - n1000 * 1000 - n100 * 100) // 10
    n1 = (num - n1000 * 1000 - n100 * 100 - n10 * 10)
    
    if n1000 != 0:
        if n1000 == 1: mcxi = mcxi + "m"
        else: mcxi = mcxi + str(n1000) + "m"
    if n100 != 0:
        if n100 == 1: mcxi = mcxi + "c"
        else: mcxi = mcxi + str(n100) + "c"
    if n10 != 0:
        if n10 == 1: mcxi = mcxi + "x"
        else: mcxi = mcxi + str(n10) + "x"
    if n1 != 0:
        if n1 == 1: mcxi = mcxi + "i"
        else: mcxi = mcxi + str(n1) + "i"
    return mcxi
main()



Measured memory_bytes: 5620
N, L = map(int, input().split())

apples = [L+i-1 for i in range(1, N+1)]
abs_apples = [abs(L+i-1) for i in range(1, N+1)]
try:
    apples.remove(min(abs_apples))
except ValueError:
    apples.remove(-1 * min(abs_apples))

result = sum(apples)
print(result)


Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
using namespace std;

typedef long long ll;

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - b - a;
	if (d > 0 && d * d > 4 * a *b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
//C++ template-------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//define-------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++) //指定回数ループマクロ
#define reps(i, n) for (int i = 1; i < (int)(n); i++) //1-origin
#define rrep(i, n) for (int i = ((int)(n)-1); i>=0; i--) //逆順
#define rreps(i, n) for (int i= ((int)(n)); i>0; i--) //逆順1-origin
#define all(x) (x).begin(), (x).end() //先頭と末尾のイテレータを渡す
#define sz(x) ((int)(x).size()) //size()のunsignedを回避
#define pb push_back
#define mp make_pair
#define sqrt(x) sqrt(abs(x)) //sqrtの絶対値の記入の省略
//typedef------------------------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

//main---------------------------------------------------------
int main() {
    string s; //使う数の型を決めておくぜ
    cin >> s; //入力
    int n = s.size();
    int ans = 0; //何個あるのかのカウント
    rep(i, n) { 
        ans = (ans + s[i] - '0') % 9;
    }
    if (ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl; //カウントを出力
    return 0; //終了
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int dp[3003][3003];
string s,t;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>s>>t;
	s=" "+s;t=" "+t;
	dp[0][0]=dp[0][1]=dp[1][0]=0;
	for(int i=1;i<=s.size();i++){
		for(int j=1;j<=t.size();j++){
			dp[i][j]=max(dp[i-1][j],max(dp[i][j-1],dp[i-1][j-1]+(s[i]==t[j])));
		}
	}
	int x=s.size()-1,y=t.size()-1;
	string ans="";
	while(x&&y){
		if(s[x]==t[y]&&dp[x][y]==dp[x-1][y-1]+(s[x]==t[y])){
			ans.push_back(s[x]);
			x--;y--;
		}else if(x&&dp[x][y]==dp[x-1][y]){
			x--;
		}else{
			y--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>

int main() {
  char c;
  unsigned long long s_count = 0;
  unsigned long long ret = 0;
  while (!std::cin.eof()) {
    std::cin.get(c);
    if (c == 'S') {
      s_count++;
      ret++;
    } else if (c == 'T') {
      if (s_count > 0) {
        s_count--;
        ret--;
      } else {
        ret++;
      }
    }
  }
  std::cout << ret;
  return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	string S; cin >> S;
	int N = S.length();

	int red = 0;
	int blue = 0;

	REP(i,N){
		if(S[i] == '0') red++;
		else blue++;
	}

	int ans = min(red, blue)*2;
	cout << ans << endl;
	


	return 0;

}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    VI a(3); REP(i,3) cin >> a[i];
    out(SUM(a,0LL)-MAX(a));

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)1000000007
// Big two primes 
#define X 1011001110001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int int
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vii vector<pi>
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
bool compare(const pair<int, int> &a, const pair<int, int> &b)
{
  return (a.second < b.second);
}
int main()
{
    fio;
 
    ll n,m;
    ll sum = 0;
    cin>>n>>m;

    vi a(m);

    for0(i, m)
     cin>>a[i];

    for0(i, m)
    {
      sum += a[i];
    } 

    ll d = (n-sum);

    if(d >= 0)
    cout<<d<<endl;

    else 
    cout<<"-1"<<endl;
    rr;
}

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

// ll fact[nax], invfact[nax];

// void pre()
// {
// 	fact[0] = 1;
// 	forn(i, 1, nax)
// 	{
// 		fact[i] = mult(fact[i - 1], i);
// 	}

// 	invfact[nax - 1] = mypow(fact[nax - 1], mod - 2);

// 	ford(i, nax, 1)
// 	{
// 		invfact[i - 1] = mult(invfact[i], i);
// 	}
// }

// ll ncr(ll n, ll r)
// {
// 	if (r > n)
// 		return 0;

// 	ll ans = mult(fact[n], mult(invfact[n - r], invfact[r]));

// 	return ans;
// }

ll ncr(ll n,ll r)
{
	ll res = 1;

	if(r>n-r)
	{
		r = n-r;
	}

	for (int i = 0; i < r; ++i)  
   {  
      res = mult(res,(n - i));  
      res = mult(res,mypow(i + 1,mod-2));  
   }  
  	
  	return res;
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll n,a,b;
		cin>>n>>a>>b;

		ll ans = mypow(2,n);
		ll x = ncr(n,a);
		ll y = ncr(n,b);
		//cout<<x<<" "<<y<<endl;
		ans = sub(ans,x);
		ans = sub(ans,y);
		ans = sub(ans,1);
		cout<<ans;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <vector>
#include <iomanip>
#include <iostream>
#include <stack>
#include <queue>
#include <list>
#include <utility>
#include <typeinfo>
 
#include <string>
#include <cstring>
 
#include <cstdio>
#include <cassert>
 
// M_PI for pi
#define _USE_MATH_DEFINES
#include <cmath>
 
using namespace std;
 
static const int MAX_N = 52;
static const int MAX_A = 52;

int N;
int A;

int MAX_X = 0;

int x[MAX_N];
long long dp[MAX_N][MAX_N][MAX_N * MAX_A];


void slove() {

    for (int i = 0; i < MAX_N; ++i) {
        for (int j = 0; j < MAX_N; ++j) {
            for (int k = 0; k < MAX_N * MAX_A; ++k) {
                dp[i][j][k] = 0;
            }
        }
    }

    for (int i = 0; i < N; ++i) {

        for (int j = 0; j < N; ++j) {
            if (j == 0) {
                dp[i][0][x[i]] += 1;
            }
            for (int k = 0; k < MAX_N * MAX_X; ++k) {
                if (i - 1 >= 0 && j - 1 >= 0 && k - x[i] >= 0) {
                    dp[i][j][k] += dp[i-1][j-1][k-x[i]];
                }

                if (i - 1 >= 0) {
                    dp[i][j][k] += dp[i-1][j][k];
                }
            }
        }
    }

    //for (int i = 0; i < N; ++i) {
    //    for (int k = 0; k < N * MAX_X; ++k) {
    //        printf("%2d ", k);
    //    }
    //    cout << endl;
    //    for (int k = 0; k < N * MAX_X; ++k) {
    //        printf("---");
    //    }
    //    cout << endl;
    //    for (int j = 0; j < N; ++j) {
    //        for (int k = 0; k < N * MAX_X; ++k) {
    //            printf("%2d ", dp[i][j][k]);
    //        }
    //        cout << endl;
    //    }
    //    cout << endl;
    //}

    long long ans = 0;

    for (int j = 0; j < N; ++j) {
        ans += dp[N-1][j][A*(j + 1)];
    }

    cout << ans << endl;

}
 
int main(int argc, char* argv[]) {
    
    cin >> N >> A;

    for (int i = 0; i < N; ++i) {
        cin >> x[i];
        MAX_X = MAX_X > x[i] ? MAX_X : x[i];
    }

    MAX_X += 1;

    slove();

    return 0;
}


Measured memory_bytes: 57344
#include <iostream>

using namespace std;

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

    int x[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }

    long long int ans = 0;
    for (int i = 1; i <= n - 1; i++) {

        if ((x[i + 1] - x[i]) * a < b) {
            ans += (x[i + 1] - x[i]) * a;
        } else {
            ans += b;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
string s;
int a[30];
int main(){
  string ans = "Yes";
  cin >> s;
  REP(i,s.size()){
    a[s[i]-'a'] ++;
  }
  REP(i,30){
    if(a[i]%2!=0) ans = "No";
  }
  cout << ans << endl;
  return 0;
}


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

class Page
{
public:
    string name;
    int button;
    vector<int> sx, sy, ex, ey;
    vector<string> link;
};

int main()
{
    for(;;){
        int n, w, h, m;
        cin >> n;
        if(n == 0)
            break;
        cin >> w >> h;

        vector<Page> page(n);
        for(int i=0; i<n; ++i){
            cin >> page[i].name >> page[i].button;
            page[i].sx.resize(page[i].button);
            page[i].sy.resize(page[i].button);
            page[i].ex.resize(page[i].button);
            page[i].ey.resize(page[i].button);
            page[i].link.resize(page[i].button);
            for(int j=0; j<page[i].button; ++j){
                cin >> page[i].sx[j] >> page[i].sy[j];
                cin >> page[i].ex[j] >> page[i].ey[j];
                cin >> page[i].link[j];
            }
        }

        cin >> m;
        vector<int> history(1, 0);
        int curr = 0;
        for(int i=0; i<m; ++i){
            string ope;
            cin >> ope;
            if(ope == "click"){
                int x, y;
                cin >> x >> y;
                int k = history[curr];
                string tmp;
                for(int j=0; j<page[k].button; ++j){
                    if(page[k].sx[j] <= x && x <= page[k].ex[j] && page[k].sy[j] <= y && y <= page[k].ey[j]){
                        tmp = page[k].link[j];
                        break;
                    }
                }
                if(tmp == "")
                    continue;
                int j;
                for(j=0; j<n; ++j){
                    if(tmp == page[j].name)
                        break;
                }
                history.resize(curr+1);
                history.push_back(j);
                ++ curr;
            }else if(ope == "back"){
                if(curr > 0)
                    -- curr;
            }else if(ope == "forward"){
                if(curr < history.size() - 1)
                    ++ curr;
            }else{
                cout << page[history[curr]].name << endl;
            }
        }
    }

    return 0;
}

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

using namespace std;

#define pb push_back
#define ll unsigned long long
#define pii pair<int,int>
#define uu first
#define vv second
#define INF 1000000000
#define V 38

bool used[100000001];
vector<int>v;

int pow10(int n)
{
    int prod = 1;
    while(n--)prod*=10;
    return prod;
}

void rec(int koto,int konta,int hmm)
{
    if(koto==0)
    {
        v.pb(hmm);
        return ;
    }
    if(konta==10)return;
    //for(int i=konta;i<=9;i++)
    rec(koto-1,konta+1,hmm+(konta)*pow10(koto-1));
}
bool is(int n)
{
    int y = sqrt(n);
    for(int i=1;i<=y;i++)
    {
        if(n%i==0 and used[i])
        {
            int  r = n/i;
            if(r!=i and used[r])return 1;
        }
    }
    return 0;
}

int main()
{
    //cout<<num(122345678)<<endl;
    int n;
    cin>>n;
    int arr[n];
    //int mx = -1;
    for(int i=0;i<n;i++){cin>>arr[i];used[arr[i]]=1;}

    for(int i=1;i<=8;i++)
    {
        for(int j=10-i;j>=1;j--)rec(i,j,0);
    }

    int sz = v.size();
sort(v.begin(),v.end());
   // for(int i=sz-1;i>=0;i--)
  //     cout<<v[i]<<endl;


    for(int i=sz-1;i>=0;i--)
    {
        if(is(v[i]))
        {
            cout<<v[i]<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[1000];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      if(abs(a[i]-a[j])%(n-1)==0){
	cout<<a[i]<<" "<<a[j]<<endl;
	return 0;
      }
  
}



Measured memory_bytes: 3092
N, M = map(int, input().split())
max_id, min_id = N, 1
for _ in range(M):
    l, r = map(int, input().split())
    if (max_id < l) or (min_id > r):
        max_id, min_id = 0, 1
        break
    max_id = min(max_id, r)
    min_id = max(min_id, l)
print(max_id - min_id + 1)

Measured memory_bytes: 3060
n=int(input())
l=[]
for _ in [0]*n:
    a,b=map(int,input().split())
    l.extend([(a,1),(b+1,-1)])
l.sort()
c = 0
a = 0
for _,v in l:
    c+=v
    a=max(a,c)
print(a)


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

using namespace std;

using ll = long long;

int n;
vector<int> arr;
vector<vector<ll>> dp;

ll solve(int x, int y){
    if(x > y) return 0;
    if(x == y) return arr[x];
    if(dp[x][y] != -1) return dp[x][y];
    ll u = solve(x+1, y);
    ll v = solve(x, y-1);
    return dp[x][y] = max(arr[x] - u, arr[y] - v);
}

int main(){
    cin>>n;
    arr.resize(n);
    dp.resize(n, vector<ll>(n, -1));
    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }
    ll res = solve(0, n-1);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;	
    while(t--){
    	ll n;cin>>n;
    	ll m = (n+1000-1)/1000;
    	m *= 1000;
    	cout<<m-n;
    }
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;


int main() {
	int *a = new int[200000];
	int *b = new int[200000];
	int num;

	int p, m;

	scanf("%d",&num);

	for (int i = 0; i < num; ++i) {
		scanf("%d",&a[i]);
	}
	if (num % 2 == 0) {
		m = num / 2; p = m - 1;
	}
	else {
		p = num / 2; m = p + 1;
	}
	for (int i = 0; i < num; ++i) {
		if (i % 2 == 0)
			b[p--] = a[i];
		else
			b[m++] = a[i];
	}

	if (num % 2 == 1) {
		printf("%d", b[0]);;
		for (int i = 1; i < num; ++i) {
			printf(" %d", b[i]);;
		}
		printf("\n");
	}
	else {
		printf("%d", b[num - 1]);
		for (int i = num - 2; i >= 0; --i)
			printf(" %d", b[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  ll a, b, c;
  scanf("%lld %lld %lld", &a, &b, &c);
  if(a%2 == 0 || b%2 == 0 || c%2 == 0) {
    printf("0\n");
  }
  else {
    printf("%lld\n", min(a*b, min(a*c, b*c)));
  }
}


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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define rep(i, n) FOR(i, 0, n)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
const double PI = 3.141592653589793;
//const ll MOD = 998244353;

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

	double y;
	if(a*a*b >= 2*x){
		y = (double)a*b*b/2/x;
	}else{
		y = (double)2*(a*a*b-x)/(a*a*a);
	}

	cout << setprecision(10);
	co(atan(y)*180/PI);

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

int main(void){
  int a,e,k,i;

  scanf("%d", &a);
  scanf("%d", &i);
  scanf("%d", &i);
  scanf("%d", &i);
  scanf("%d", &e);
  scanf("%d", &k);
  
  if(e-a<=k)
  	printf("Yay!\n");
  else
  	printf(":(\n");
    
  fflush(stdout);

  return 0;
}



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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll i,j,k;
	ll sum=0;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			for(k=1;k<=n;k++)
				sum+=__gcd(i,__gcd(j,k));

			//sum+=i;
		cout<<sum;
	return 0;
} 

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;


int N,M;
vector<int> G[100005];
vector<int> Gr[100005];

int v_in[100005];
int depth[100005];


int main(){
    cin>>N>>M;
    rep(i,N+M-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        Gr[b].push_back(a);
        v_in[b]++;
    }
    int root = 0;
    rep(i,N){
        if(v_in[i]==0){
            root = i;
            break;}}
    queue<int> que;
    que.push(root);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto nv : G[v]){
            v_in[nv]--;
            if(v_in[nv]==0){
                depth[nv]=depth[v]+1;
                que.push(nv);
            }
        }
    }
    rep(i,N){
        int ans = 0;
        if(i == root){
            cout<<0<<endl;
            continue;
        }
        for(auto v : Gr[i]){
            if(depth[i]==depth[v]+1){
                cout<<v+1<<endl;
                break;
            }
        }
    }
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF 1e16
#define MAX_N 10000000001


int main(){
    cin.sync_with_stdio(false);
    ll n, x;
    cin >> n >> x;
    ll a[n], mini[n];
    rep(i, n) {
        cin >> a[i];
        mini[i] = INF;
    }

    ll ans = INF;
    rep(i, n) {
        ll sum = 0;
        rep(j, n) {
            minch(mini[j], a[(j - i + n) % n]);
            sum += mini[j];
        }
        minch(ans, sum + i * x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
x1=int(a//0.08)+1
x2=int((a+1)//0.08)

y1=int(b//0.1)+1
y2=int((b+1)//0.1)

xx=[i for i in range(x1,x2)]
for z in xx:
    if z>=y1 and z<=y2:
        print(z)
        exit()
    
print(-1)


Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#define mod 1000000007
using namespace std; 

int main(){
	int a,b,c,d; cin >> a >> b >> c >> d;
	while (true){
		c=c-b;
		if (c<=0){
			cout << "Yes" << "\n";
			return 0;
		}
		a=a-d;
		if (a<=0){
			cout << "No" << "\n";
			return 0;
		}
	}	
}


Measured memory_bytes: 3620
i = 0
arr = list()
for i in range(10):
  arr.append(int(raw_input()))

fst = sec = thr = -1

for i in range(10):
  if fst < arr[i]:
    thr = sec
    sec = fst
    fst = arr[i]
  elif sec < arr[i]:
    thr = sec
    sec = arr[i]
  elif thr < arr[i]:
    thr = arr[i]

print fst
print sec
print thr



Measured memory_bytes: 4648
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
  int x,y;
  cin >> x >> y;
  int gx = 0;
  int gy = 0;
  if(x == 2) gx = 1;
  if(y == 2) gy = 1;
  if(x == 4 || x == 6 || x == 9 || x == 11) gx = 2;
  if(y == 4 || y == 6 || y == 9 || y == 11) gy = 2;

  if(gx == gy) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	vector<int> ballCount(n, 1);
	vector<bool> box(n, false);
	box[0] = true;
	rep(i, m)
	{
		int x, y; cin >> x >> y;
		--x, --y;
		--ballCount[x];
		++ballCount[y];
		if (box[x])box[y] = true;
		if (ballCount[x] == 0)box[x] = false;
	}
	int res = 0;
	rep(i, n)if (box[i])++res;
	cout << res << endl;
}

Measured memory_bytes: 640
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();
    int m = input<int>();
    int k = input<int>();

    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= m; ++j)
            if (k == (n * m - (i * j) - (n - i) * (m - j))) {
                cout << "Yes\n";
                return 0;
            }
    cout << "No\n";
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[a[i]] == i) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 640
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();

    let mut it = buf.trim().split_whitespace();

    let mut a: u64 = it.next().unwrap().parse().unwrap();
    let mut b: u64 = it.next().unwrap().parse().unwrap();
    let mut k: u64 = it.next().unwrap().parse().unwrap();

    if a <= k {
        k -= a;
        a = 0;
    } else {
        a -= k;
        k = 0;
    }

    if b <= k {
        b = 0;
    } else {
        b -= k;
    }

    println!("{} {}", a, b);

}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(3000)

import numpy as np

h,w = map(int,input().split())
s = []

for i in range(h):
    s.append(list(input()))

from collections import deque

def bfs(i,j,dist):
    lis = [[i-1,j],[i,j-1],[i+1,j],[i,j+1]]
    for place in lis:
        if place[0]<0 or place[0]>=h or place[1]<0 or place[1]>=w:
            continue
        if seen[place[0]][place[1]] != -1 or s[place[0]][place[1]]=="#":
            continue
        seen[place[0]][place[1]] = dist+1
        que.append([place[0],place[1],dist+1])
    if len(que):
        new = que.popleft()
        bfs(new[0],new[1],new[2])
    else:
        return


mx = 0
for i in range(h):
    for  j in range(w):
        if s[i][j]=="#":
            continue
        seen = [[-1 for _ in range(w)]for _ in range(h)]
        que = deque()
        seen[i][j] = 0
        bfs(i,j,0)
        ast = np.array(seen)
        tmp = np.amax(ast)
        mx = max(mx,tmp)
        #print(seen)
            #print(*seen,sep="\n")
print(mx)


Measured memory_bytes: 27292
n, t_max = gets.chomp.split.map(&:to_i)

a = []
n.times do
  c, t = gets.chomp.split.map(&:to_i)
  a.push [c, t]
end

a.select!{|c, t| t <= t_max }

if a.empty?
  puts 'TLE'
else
  puts a.map{|c, t| c}.min
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    vint a(m);
    rep(i, m) cin >> a[i];
    int ans = n;
    rep(i, m)
    {
        ans -= a[i];
    }
    if (ans < 0)
    {
        cout << -1 << endl;
    }
    else
    {

        cout << ans << endl;
    }

    return 0;
}

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


#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)

using namespace std;

int main()
{

  int a,b;
  cin >> a>>b;
  if(a<1 || 9<a || b<1|| 9<b)
  {
    cout <<"-1";
  }
  else
  {
    cout << a*b;
  }
	return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arr[105] ;

int main()
{
    ll n, ans = 0 ;
    cin >> n ;
    for (int i = 0; i < n; i++) {
        cin >> arr[i] ;
    }
    sort(arr, arr + n) ;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (arr[i] != arr[j] and arr[j] != arr[k] and arr[i] != arr[k]) {
                    if (arr[i] + arr[j] > arr[k] and arr[j] + arr[k] > arr[i] and arr[i] + arr[k] > arr[j]) {
                        ans++ ;
                    }
                }
            }
        }
    }
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
double f(double x){
    if (x<0)
        return -x;
    else
        return x;
}
int main () {
    double N, T, A, ans=0, cnt=987654321;
    cin >> N >> T >> A;
    for (int i=1;i<=N;i++){
        double a;
        cin >> a;
        if (f(T-A-a*6/1000)<cnt){
            cnt=f(T-A-a*6/1000);
            ans=i;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N, W = map(int, input().split())
dp = np.full(N*10**3+1, W+1)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
print(np.where(dp<=W)[0][-1])

Measured memory_bytes: 14908