akhauriyash/Code-Regression huggingface dataset:
/* 
    AABRA KA DABRA.. !! 
*/
#include "bits/stdc++.h"
using namespace std;
typedef long double ld;
#define int long long
#define RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i <n; i++)
#define repv(i,k,n) for(int i=k; i<=n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define endl '\n'
#define deb(x) cout<<#x<<" = "<<x<<endl
#define gcd __gcd
#define inf LLONG_MAX
#define minf LLONG_MIN 
const int mod = (int)(1e9+7);

int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
bool is_power_2(int n)  { return log2(n)==floor(log2(n));}
bool is_prime(int n){   for(int i=2; i*i<=n; i++)   if(n%i==0)  return 0;   return 1;}

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

/*                                                                 
    ╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦ 
*/  




void solve()
{   
    int n,i,j,k,m;
    cin>>n;
    int ar[n];
    int tot = 0;
    rep(i,n)
        cin>>ar[i] , tot^=ar[i];;
    int ans[n];
    rep(i,n)
    {
        ans[i] = ar[i]^tot;
    }
    for(int x:ans)
        cout<<x<<" ";
}   
signed main()
{
    RAGE;

    int t=1;
    //  cin>>t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 6732
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr<<#x<<": "<<(x)<<'\n'
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f;
const ll nax = 2e5+5;
ll n, arr[nax];

int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;++i){
		cin >> arr[i];
	}
	ll maks=-1, ans=0;
	for(int i=0;i<n;++i){
		if(arr[i]<maks){
			ans+=maks-arr[i];
		}
		maks=max(maks, arr[i]);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5172
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <climits>
#include <set>
using namespace std;
#define repn(i,s,n) for (int i=int(s); i < int(n); i++)
#define rep(i,n) repn(i,0,n)
#define repd(i,n) for (int i=int(n)-1; i >= 0; i--)

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef VVI Graph;
typedef long long ll;



int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  VI ls(n * 2);
  rep(i, n * 2) cin >> ls[i];
  sort(ls.begin(), ls.end());
  int ans = 0;
  rep(i, n) ans += ls[i * 2];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
int main(){
  ll h,w;
  cin >>h>>w;
  ll cnt=1;
  if (!(h==1 || w==1)){
    if (h*w%2==1){
      cnt=h*w/2+1;
    }else{
      cnt=h*w/2;  
    }
  }
    cout << cnt;
}
  

Measured memory_bytes: 256
function Main(input) {
  const inputArr = input.split(" ");

  for (let i = 0; i < inputArr.length; i++) {
    if (parseInt(inputArr[i], 10) === 0) {
      console.log(i + 1);
      break;
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29588
#include <vector>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  int n, k;
  cin >> n >> k;
  vector<int> h;
  for(int i=0;i<n;i++){
    int hi;
    cin >> hi;
    h.push_back(hi);
  }
  sort(h.begin(),h.end(),greater<int>());
  long long int sum = 0;
  for(int i=k;i<n;i++){
    sum += h[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, M; cin >> N >> M;
    vector<bool> isACs(N, false);
    vector<int> WANums(N, 0);
    int penaltyNum = 0;
    for (int i = 0; i < M; ++i)
    {
        int pi; cin >> pi; --pi;
        string Si; cin >> Si;
        if (Si == "AC")
        {
            if (isACs[pi]) continue;
            penaltyNum += WANums[pi];
            isACs[pi] = true;
        }
        else
        {
            ++WANums[pi];
        }
    }
    int ACNum = count_if(isACs.begin(), isACs.end(), 
        [](const bool isAC){ return isAC; });
    cout << ACNum << ' ' << penaltyNum << '\n';
}


Measured memory_bytes: 640
use std::io::stdin;

fn main() {
    let n = {
        let mut s = String::new();
        stdin().read_line(&mut s).unwrap();
        let n: f64 = s.trim_right().parse().unwrap();
        n
    };

    let m = n.sqrt().floor() as i64;

    let mut res = 0;
    for i in (1..(m+1)).rev() {
        if (n as i64) % i == 0 {
            let j = (n as i64) / i;
            res += (i - 1);
            res += (j - 1);
            break;
        }
    }
    println!("{}", res);
}

Measured memory_bytes: 4352
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize
    };

    for a in 1..=9 {
        for b in 1..=9 {
            if a * b == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

int main () {
  string s; cin >> s;
  string a = s.substr(0, 5);
  string b = s.substr(6, 7);
  string c = s.substr(14, 5);
  cout << a << ' ' << b << ' ' << c << endl;
}


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

int main()
{
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> xs;
  vector<int> ys;
  for (auto i = 0; i < n; i++) {
    int t;
    cin >> t;
    xs.push_back(t);
  }
  for (auto j = 0; j < m; j++) {
    int t;
    cin >> t;
    ys.push_back(t);
  }
  sort(begin(xs), end(xs), greater<>());
  sort(begin(ys), end(ys));
  if (x < ys[0] && xs[0] < ys[0] && xs[0] < y && xs[0] < ys[0]) {
    cout << "No War";
  } else {
    cout << "War";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	int i,j,k,t,n,m,l,x,y,z;
	double b;
	long long a,c,d;
    while(scanf("%lld%lf",&a,&b)!=EOF){
    	d=b*100+0.1;
    	c=a*d/100;
    	printf("%lld\n",c);
	}
    return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : " ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ';
constexpr char newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    V<V<int>> a(n, V<int>(m));
    V<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }
    int res = INF;
    for (int i = 0; i < (1 << n); i++) {
        int sum = 0;
        bool f = true;
        V<int> s(m);
        for (int j = 0; j < n; j++) {
            if (kbit(i, j)) {
                for (int k = 0; k < m; k++) {
                    s[k] += a[j][k];
                }
                sum += c[j];
            }
        }
        for (int j = 0; j < m; j++) {
            if (s[j] < x) f = false;
        }
        if (f) chmin(res, sum);
    }
    cout << (res == INF ? -1 : res) << newl;
}

Measured memory_bytes: 3660
sd = input()
T = input()

if len(sd)<len(T):
    fl=False
else:
    for i in range(len(sd)-len(T),-1,-1):
    #    print(i)
        st=sd[i:len(T)+i]
    #    print(sd[i:len(T)+i])
        fl=True
        for j in range(len(T)):
            if st[j]!='?':
                if st[j]!=T[j]:
                    fl=False
        if fl:
            s=sd[:i]+T+sd[len(T)+i:]
            for k in range(len(s)):
                if s[k]=='?':
                    s=s[:k]+'a'+s[k+1:]
            break
if fl:
    print(s)
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
A, B, C, X, Y = map(int, input().split())

cost = 0

if A + B <= 2 * C:
    cost = A * X + B * Y
elif A + B > 2 * C:
    if X > Y:
        cost = C * 2 * Y
        if 2 * C < A:
            cost += 2 * C * (X - Y)
        else:
            cost += A * (X - Y)
    elif Y >= X:
        cost = C * 2 * X
        if 2 * C < B:
            cost += 2 * C * (Y - X)
        else:
            cost += B * (Y - X)
print(cost)

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

int main(){
  long long h, w; cin >> h >> w;
  vector<vector<long long>> a(h + 1, vector<long long>(w + 1, 0));
  vector<vector<long long>> b(h + 1, vector<long long>(w + 1, 0));
  vector<vector<long long>> sa(h + 1, vector<long long>(w + 1, 0));
  for(int i = 1; i < h + 1; i++){
    for(int j = 1; j < w + 1; j++){
      cin >> a.at(i).at(j);
    }
  }
  for(int i = 1; i < h + 1; i++){
    for(int j = 1; j < w + 1; j++){
      cin >> b.at(i).at(j);
      sa.at(i).at(j) = a.at(i).at(j) - b.at(i).at(j);
      if(sa.at(i).at(j) < 0) sa.at(i).at(j) *= -1;
    }
  }
  long long k = 80 * 80 * 3;
  vector<vector<vector<int>>> dp(h + 1, vector<vector<int>>(w + 1, vector<int>(k, 0)));
  for(int i = 1; i < h + 1; i++){
    for(int j = 1; j < w + 1; j++){
      for(long long l = 0; l < k - 80; l++){
        if(i == 1 & j == 1){
          dp.at(i).at(j).at(sa.at(i).at(j)) = 1;
          continue;
        }
        long long kpi, kpj, kmi, kmj;
        kpi = l + sa.at(i).at(j);
        kpj = l + sa.at(i).at(j);
        kmi = l - sa.at(i).at(j);
        kmj = l - sa.at(i).at(j);
        if(kmi < 0) kmi *= -1;
        if(kmj < 0) kmj *= -1;
        if(dp.at(i - 1).at(j).at(kpi) == 1 | dp.at(i - 1).at(j).at(kmi) == 1 | dp.at(i).at(j - 1).at(kpi) == 1 | dp.at(i).at(j - 1).at(kmi) == 1){
          dp.at(i).at(j).at(l) = 1;
        }
      }
    }
  }
  for(int i = 0; i < k; i++){
    if(dp.at(h).at(w).at(i) == 1){
      cout << i;
      return 0;
    }
  }
}

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

using namespace std;

typedef long long ll;

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];

	sort(v.begin(), v.end());

	int p = 0;
	for(int i = 0; i < k; i++)
		p = p + v[i];

	cout << p << endl;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    string S[3] = {};
    int p[3] = {};
    int current = 0;
    for(int i = 0; i < 3; i++)cin >> S[i];
    while(true){
        if(p[current] == S[current].length()){
            printf("%c", 'A' + current);
            return 0;
        }else{
            p[current]++;
            current = S[current][p[current]-1]-'a';
        }
    }
}


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

int main(void)
{
    int H;
  	int N;
  	int count=0;
  	int i=0;
    // 整数の入力
    scanf("%d %d\n",&H,&N);
  	int A[N];
  	for(i=0;i<N;i++){
      	scanf("%d\n",&A[i]);
    }
   	for(i=0;i<N;i++){
    	H=H-A[i];
    }
  	if(H>0)
      printf("No\n");
	else if(H<=0)
      printf("Yes\n");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
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;
}
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
ll n;
string s;
mint dp[3300][3300];
mint dp_sum[3300][3300];
int main(){
    cin>>n>>s;
    dp[0][0]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<=i-1;j++){
            dp_sum[i-1][j]=dp[i-1][j];
            if(j-1>=0)dp_sum[i-1][j]+=dp_sum[i-1][j-1];
        }
        for(int j=0;j<=i;j++){
            if(s[i-1]=='<'){
                if(j-1>=0)dp[i][j]+=dp_sum[i-1][j-1];
            }
            else{
                dp[i][j]=dp_sum[i-1][i-1];
                if(j-1>=0)dp[i][j]-=dp_sum[i-1][j-1];
            }
        }
    }
    mint ans=0;
    rep(i,n)ans+=dp[n-1][i];
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 173744
if __name__ == "__main__":
    n = int(input())
    b = list(map(int, input().split(" ")))

    a = []

    for i in range(n):
        if i == 0:
            a.append(b[i])

        elif i < n - 1:
            a.append(min(b[i - 1], b[i]))

        else:
            a.append(b[n - 2])
    print(sum(a))


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    // https://atcoder.jp/contests/abc082/tasks/abc082_a
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        double a = scan.nextDouble();
        double b = scan.nextDouble();

        double x = (a + b) / 2;

        // System.out.println(x);

        int answer = (int) Math.ceil(x);

        System.out.println(answer);

        scan.close();
    }

}


Measured memory_bytes: 22612
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modpow(ll x,ll n,ll mod){ll res=1;for(ll i=0;i<n;i++){res=res*x%mod;}return res;}
ll MODpow(ll x,ll n){ll res=1;for(ll i=0;i<n;i++){res=res*x%MOD;}return res;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {

    vvl a(3,vl(3));
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }

    ll n; cin >> n;
    vl b(n);
    rep(i,n){
        cin >> b[i];
        rep(j,3){
            rep(k,3){
                if(b[i] == a[j][k]) a[j][k] = -1;
            }
        }
    }

    //横
    rep(i,3){
        if(a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    //縦
    rep(i,3){
        if(a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    //斜め
    if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1){
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}



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

void Main()
{
  int A,B,C,K; cin >> A >> B >> C >> K;
  if (K <= A+B) {cout << min(K,A) << endl; return;}
  cout << A - (K-A-B) << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3652
// AOJ GRL_6_B Minimum Cost Flow
// 2018.4.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 1000
typedef struct { int t, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x10101010
#define MAX 110
typedef struct { int to, rev; int cap, cost; } EDGE;
EDGE edge[MAX][MAX]; int hi[MAX];
int V;				// 頂点数
int potential[MAX], dist[MAX], prevv[MAX], preve[MAX];

void add_edge(int from, int to, int cap, int cost)
{
	int f, t;
	EDGE *ep;

	f = hi[from]++, t = hi[to]++;
	ep = &edge[from][f], ep->to = to, ep->cap = cap, ep->cost = cost, ep->rev = t; 
	ep = &edge[to][t], ep->to = from, ep->cap = 0, ep->cost = -cost, ep->rev = f;
}

int minCostFlow(int S, int T, int F)
{
	int i, v, nv, t, nt, ret;
	EDGE *ep;

	ret = 0;
	memset(potential, 0, V << 2);
  
	while (F > 0) {
		memset(dist, INF, V << 2);
		qsize = 0;
		enq(S, 0), dist[S] = 0;
		while (qsize) {
			v = que[0].s, t = que[0].t, deq();
			if (dist[v] < t) continue;
			for (i = 0; i < hi[v]; i++) {
				ep = &edge[v][i];
				if (ep->cap <= 0) continue;
				nv = ep->to;
				nt = t + ep->cost - potential[nv] + potential[v];
				if(dist[nv] > nt) {
					dist[nv] = nt;
					prevv[nv] = v, preve[nv] = i;
					enq(nv, nt);
				}
			}
		}
		if (dist[T] == INF) return -1;
		for (v = 0; v < V; v++) potential[v] += dist[v];

		t = F;
		for (v = T; v != S; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			if (t > ep->cap) t = ep->cap;
		}
		F -= t;

		ret += t * potential[T];
		for (v = T; v != S; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			ep->cap -= t;
			edge[v][ep->rev].cap += t;
		}
	}
	return ret;
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

typedef struct { int id, ab; char f; } T;
T block[2002]; int sz;
int a[1002], b[1002];

int cmp(T *a, T *b) { return a->ab - b->ab; }

int main()
{
	int E, F, u, v, c, d;
	int source, sink;

	V = in(), E = in(), F = in();
	source = 0, sink = V-1;
	while (E--) {
		u = in(), v = in(), c = in(), d = in();
		add_edge(u, v, c, d);
	}
	printf("%d\n", minCostFlow(source, sink, F));
	return 0;
}


Measured memory_bytes: 2100
import sys

def input():
  return sys.stdin.readline()

N=int(input())
A=list(map(int,input().split()))
B=[0]*(10**5)
for a in A:
  B[a-1]+=1
s=sum(A)
Q=int(input())
for i in range(Q):
  b,c=map(int,input().split())
  bb,bc=B[b-1],B[c-1]
  B[c-1]+=bb
  B[b-1]=0
  s+=bb*c-bb*b
  print(s)

Measured memory_bytes: 85500
def main():
  ans = func(input())
  print(ans)
  
  
def func(sentence):
  unique_list = set(sentence)
  for s in unique_list:
    if sentence.count(s) % 2 != 0:
      return('No')
      break
  return('Yes')

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
string yes="Yes",no="No";
int main()
{
  int N;
  cin>>N;
  vector<int> t(N+1), x(N+1), y(N+1);
  t[0]=x[0]=y[0]=0;
  for(int i=1;i<=N;i++){
    cin>>t[i]>>x[i]>>y[i];
  }
  bool can=true;
  for(int i=0;i<N;i++){
    if(!can) break;
    int T=t[i+1]-t[i];
    int X=abs(x[i+1]-x[i]);
    int Y=abs(y[i+1]-y[i]);
    if (X+Y>T) {
      can=false;
      break;
    }
    if((X+Y)%2!=T%2){
      can=false;
      break;
    }
    
  }
  
  cout<<((can)? yes:no);
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {

	int i = 0;
	int j = 0;
	int n;
	int b,f,r,v;
	int a1[3][10];
	int a2[3][10];
	int a3[3][10];
	int a4[3][10];
	int **p;
	
	for(i=0;i<3;i++){
		for(j=0;j<10;j++){
			a1[i][j]=0;
			a2[i][j]=0;
			a3[i][j]=0;
			a4[i][j]=0;
		}
	}
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		f--;
		r--;
		switch(b){
			case 1:
				if((v > 0) && (v + a1[f][r] < 10)){
					a1[f][r] += v;	
				}else if((v < 0) && (v + a1[f][r] >= 0)){
					a1[f][r] += v;
				}
				break;
			case 2:
				if((v > 0) && (v + a2[f][r] < 10)){
					a2[f][r] += v;	
				}else if((v < 0) && (v + a2[f][r] >= 0)){
					a2[f][r] += v;
				}
				break;
			case 3:
				if((v > 0) && (v + a3[f][r] < 10)){
					a3[f][r] += v;	
				}else if((v < 0) && (v + a3[f][r] >= 0)){
					a3[f][r] += v;
				}
				break;
			case 4:
				if((v > 0) && (v + a4[f][r] < 10)){
					a4[f][r] += v;	
				}else if((v < 0) && (v + a4[f][r] >= 0)){
					a4[f][r] += v;
				}
				break;
		}
	}
	for(i=0;i<3;i++){
		for(j=0;j<10;j++){
			printf(" %d",a1[i][j]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(i=0;i<3;i++){
		for(j=0;j<10;j++){
			printf(" %d",a2[i][j]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(i=0;i<3;i++){
		for(j=0;j<10;j++){
			printf(" %d",a3[i][j]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(i=0;i<3;i++){
		for(j=0;j<10;j++){
			printf(" %d",a4[i][j]);
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2044
#include<iostream>
using namespace std;
int main(){
  while(1){
    int n,m,a,b,d=10,e=10,f=0,map[21][21]={};
    char c;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      map[a][b]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>c>>a;
      if(c=='N'){
	for(int j=0;j<a;j++){
	  e++;
	  if(map[d][e]==1){
	    f++;
	    map[d][e]=0;
	  }
	}
      }
      if(c=='S'){
	for(int j=0;j<a;j++){
	  e--;
	  if(map[d][e]==1){
	    f++;
	    map[d][e]=0;
	  }
	}
      }
      if(c=='E'){
	for(int j=0;j<a;j++){
	  d++;
	  if(map[d][e]==1){
	    f++;
	    map[d][e]=0;
	  }
	}
      }
      if(c=='W'){
	for(int j=0;j<a;j++){
	  d--;
	  if(map[d][e]==1){
	    f++;
	    map[d][e]=0;
	  }
	}
      }
    }
    if(f==n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;
const int MAX = 1e5;

long long h[MAX+1];

bool enough(long long t, long long cnt, long long n, long long maxh, long long a, long long b) {
    long long b_damage = t * b, r = 0, ext_d = a - b;
    for(int i=0; i<n; ++i) {
        if (b_damage >= h[i]) {
            continue;
        } else {
            long long ext_h = h[i] - b_damage;
            r += ext_h / ext_d + (ext_h % ext_d != 0 ? 1 : 0);
        }
    }
    return (r <= t);

}

void solve() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long maxh = 0, hi;
    long long cnt = 0;
    for (long long i=0; i < n; ++i) {
        cin >> hi;
        h[i] = hi;
        if (hi > maxh) {
            maxh = hi;
            cnt = 1;
        }else if (hi == maxh) {
            ++cnt;
        }
    }
    long long ans, all_h, minh;
    long long l, r;
    //cout << maxh << " " << cnt << endl;
    l = 1; r = maxh / b + 1;
    while (l < r) {
        long long mid = (l+r) / 2;
        if (enough(mid, cnt, n, maxh, a, b)) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    cout << r;
}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 3960
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")

# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define FILE

using namespace std;

const int N = 2e5 + 7;

string s;

int main()
{
    /// Author: Dilshod--Imomov
    speed;
    #ifdef FILEx
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // FILE
    cin >> s;
    string ans;
    if ( s == "Sunny" ) ans = "Cloudy";
    if ( s == "Cloudy" ) ans = "Rainy";
    if ( s == "Rainy" ) ans = "Sunny";
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>

int main(void) {
  std::string s1;
  std::string s2;

  std::getline(std::cin, s1);
  std::getline(std::cin, s2);
  
  bool compared = true;
  
  for (int i = 0; i < s1.size(); i++) {
    compared = true;
    
    for (int j = 0; j < s2.size(); j++) {
      int k = (i + j) % s1.size();

      if (s1[k] != s2[j]) {
	compared = false;
	
	break;
      }
    }

    if (compared) {
      break;
    }
  }

  if (compared) {
    std::cout << "Yes";
  } else {
    std::cout << "No";
  }

  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 1176
# include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  for(int i=0;i<K;i++){
    if(A>=B){
      B*=2;
    }else if(B>=C){
      C*=2;
    }
    else{
      cout << "Yes";
      return 0;
    }
  }
  if(A<B && B<C) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const ll MOD = 1e9 + 7; 
ll pow(ll x,ll y);

int main() {
    IOS;
    ll a,b;
    cin >> a >> b;
    cout << a*b;
    return 0;
}

ll pow(ll x, ll y) 
{ 
    ll result = 1; 
    while (y) { 
        if (y & 1) 
            result = result * x % MOD; 
        y = y / 2; 
        x = x * x % MOD; 
    } 
    return result; 
} 
;


Measured memory_bytes: 3640
#define N 100001 
long p[N],r[N],n,m,i,b[N],a[N][2],c,d;int f(int x){if(p[x]==x)return x;return f(p[x]);}int u(int x,int y){x=f(x);y=f(y);if(r[x]<r[y])p[x]=y;else p[y]=x;r[y]+=r[x];r[x]=r[y];}int main(){scanf("%ld%ld",&n,&m);for(i=0;i<m;i++)scanf("%d%d",a[i],&a[i][1]);b[m]=n*(n-1)/2;for(i=0;i<N;i++){p[i]=i;r[i]=1;};for(i=m-1;i>=0;i--){c=a[i][0],d=a[i][1];if(f(c)==f(d))b[i]=b[i+1];else{b[i]=b[i+1]-r[f(c)]*r[f(d)];u(c,d);}}for(i=1;i<=m;i++)printf("%ld\n",b[i]);}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

ll N, T;
vecll t;

int main(void) {
    cin >> N >> T;
    ll ans = 0;
    ll last_t = 0;
    rep(i, N) {
        ll t;
        cin >> t;
        ans += min(T, t - last_t);
        last_t = t;
    }
    ans += T;

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

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	int N, M;
	cin>>N>>M;
	vector<int> cnt(N, 0);
	REP(i, M) {
		int a, b;
		cin>>a>>b;
		--a;
		--b;
		cnt[a]++;
		cnt[b]++;
	}
	REP(i, N) {
		cout<<cnt[i]<<endl;
	}
}

Measured memory_bytes: 256
K, N = map(int, input().split())
An = list(map(int, input().split()))

dist = []
for i in range(N - 1):
    dist.append(An[i + 1] - An[i])

result = 0
matagi = K - An[N - 1] + An[0]
if max(dist) >= matagi:
    result = sum(dist) + matagi - max(dist)
else:
    result = sum(dist)

print(result)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  int MOD = 1000000007;
  int n;
  cin >> n;
  string s;
  cin >> s;
  set<char> c_set;
  REP(i,n) c_set.insert(s[i]);
  sort(ALL(s));
  ll res = 1;
  for(auto c: c_set){
    auto lowp = lower_bound(ALL(s),c);
    auto uppp = upper_bound(ALL(s),c);
    res *= ((uppp - lowp) + 1) % MOD;
    res = res % MOD;
  }
  cout << res - 1 << endl;
  return 0;
}


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

int main(){

  int a,b;
  int i;
  string s,s1,s2;
  cin >> a >> b;
  cin >> s;
  for(i=0;i<a;i++){
    if(strncmp("-",&s[i],1)==0){
      cout << "No" << endl;
    return 0;
    }
  }
  for(i=a+1;i<a+b;i++){
    if(strncmp("-",&s[i],1)==0){
      cout << "No" << endl;
    return 0;
    }
  }
  
  if(strncmp("-",&s[a],1)==0){
    
    s1=s.substr(0,a);
    s2=s.substr(a+1,b);

    if(s1.size() == a && s2.size() == b){
      
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<b)
using namespace std;

int main(){
	int t,N;
	int dx[6]={1,1,0,-1,-1,0};
	int dy[6]={0,1,1,0,-1,-1};
	while(cin>>t>>N && (t!=0||N!=0)){
		bool obs[121][121]={false};
		int visited[121][121]={0};
		int tx,ty,ans=0;
		queue<pair<int,int>> q;
		REP(i,0,N){
			cin>>tx>>ty;
			obs[ty+60][tx+60]=true;
		}
		int sx,sy;
		cin>>sx>>sy;
		q.push({sx+60,sy+60});
		visited[sy+60][sx+60]=1;
		while(!q.empty()){
			int nowx=q.front().first,nowy=q.front().second;
			q.pop();
			REP(k,0,6){
				int nextx=nowx+dx[k],nexty=nowy+dy[k];
				if(obs[nexty][nextx]||visited[nexty][nextx]!=0) continue;
				visited[nexty][nextx]=visited[nowy][nowx]+1;
				if(visited[nexty][nextx]<=t)		q.push({nextx,nexty});
			}
		}
		REP(i,0,121)	REP(j,0,121)	if(visited[i][j]!=0)	ans++;

		p(ans);
	}
	return 0;
}

Measured memory_bytes: 3228
# -*- coding: utf-8 -*-

def main():

    W, a, b = map(int, input().split())

    if a + W < b:
        ans = b - (a + W)

    elif b + W < a:
        ans = a - (b + W)
    
    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9108
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N = II()
    A = LI()

    four = 0
    two = 0
    for a in A:
        if a % 4 == 0:
            four += 1
        elif a % 2 == 0:
            two += 1
    # print(four, two)

    j = four + two // 2
    # print(j)
    if N // 2 <= j:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14480
n, m = map(int, input().split())
a = [[i for i in input()] for j in range(n)]
b = [[i for i in input()] for j in range(m)]

def match(y,x):
    result = True
    for i in range(m):
        for j in range(m):
            if a[y+i][x+j] != b[i][j]:
                result = False
    return result

flg = False
for i in range(n-m+1):
    for j in range(n-m+1):
        if match(i,j):
            flg = True

print('Yes' if flg else 'No')

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

int main() {
	long N; cin >> N;
	for(long h=min((long) 3500, 2+N*3/4); 4*h>=N; --h){
	    for(long i=min((long) 3500, 2+2*N*h/(4*h-N)); i*(4*h-N)>=N*h; --i){
	        if(4*h*i>N*(h+i) && (N*h*i)%(4*h*i-N*(h+i))==0){
	            long j=(N*h*i)/(4*h*i-N*(h+i));
	            cout << h << ' ' << i << ' ' << j << endl;
	            return 0;
	        }
	    }
	}
	return 0;
}


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

int main() {
  int H, N, A = 0, X;
  cin >> H >> N;
  
  for (int i = 0; i<N; ++i) {
    cin >> X;
  	A += X;
  }
  
  if (A >= H)
  cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
// gcd lcm
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll n;
  cin>>n;
  ll ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int z=1;z<=n;z++){
        ans+=gcd(i,gcd(j,z));
      }
    }
  }
  COUT(ans);
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 3500;
const int MOD = 3511;

int qpow(LL a, int b) {
	LL ans = 1;
	for (; b; a = (a * a) % MOD, b >>= 1)
		if (b & 1) ans = (ans * a) % MOD;
	return ans % MOD;
}
int inv[MAXN + 3];

int main(int argc, char const *argv[]) {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	LL _1 = 2132, _2 = 3315, _3 = 2652;
	LL N;
	scanf("%lld", &N);
	// cout << (_1 * _2 * _3 * 4) << " " << N * (_2 * _3 + _1 * _2 + _1 * _3) << endl;
	int invN = qpow(N, MOD - 2);
	for (int i = 0; i <= MAXN; i++) inv[i] = qpow(i, MOD - 2);
	for (int h = 1; h <= MAXN; h++)
		for (int invn = 1; invn < MAXN; invn++) {
			int invw = ((4 * invN - inv[h] - invn) % MOD + MOD) % MOD;
			if (!invw) continue;
			int n = inv[invn], w = inv[invw];
			if ((LL)N * h * (n + w) == (LL)n * w * (4 * h - N)) {
				printf("%d %d %d\n", h, n, w);
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
import sys
n=int(input())
lst=[]
for i in range(n):
  a,b=map(int,input().split())
  lst.append([a,b])
lst.sort(key=lambda x:x[1])
time=0
for i in range(n):
  if time+lst[i][0]<=lst[i][1]:
    time+=lst[i][0]
  else:
    print('No')
    sys.exit()
print('Yes')
  
  

Measured memory_bytes: 84568
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        if(((A>B)&&(B!=1))||((A==1)&&(B!=1))){
            System.out.println("Alice");
        }
        if(A==B){
            System.out.println("Draw");
        }
        if(((A<B)&&(A!=1))||((B==1)&&(A!=1))){
            System.out.println("Bob");
        }
}
        
        
    }


Measured memory_bytes: 21460
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, K;
int x[100], y[100];

bool check(int top, int bottom, int right, int left) {
  int cnt = 0;
  rep(k, 0, N) {
    int cx = x[k];
    int cy = y[k];
    if (left <= cx && cx <= right && bottom <= cy && cy <= top) {
      ++cnt;
    }
  }

  return cnt >= K;
}

int dummy[1000000];

int main() {
  cin >> N >> K;
  rep(i, 0, N) { cin >> x[i] >> y[i]; }

  for (ll i = 0; i <= 2000000000; ++i) {
    dummy[i % 1000000] = i;
  }

  ll ans = numeric_limits<ll>::max();
  rep(i, 0, N) {
    rep(j, i, N) {
      rep(k, j, N) {
        rep(l, k, N) {
          ll top = max(y[i], max(y[j], max(y[k], y[l])));
          ll bottom = min(y[i], min(y[j], min(y[k], y[l])));
          ll left = min(x[i], min(x[j], min(x[k], x[l])));
          ll right = max(x[i], max(x[j], max(x[k], x[l])));

          if (check(top, bottom, right, left)) {
            chmin(ans, (top - bottom) * (right - left));
          }
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 7544
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

ll N, A, B;
ll h[100001] = {};
ll k[100001] = {};

bool clear(ll m) {
	rep(i, 0, N) {
		k[i] = h[i];
	}
	rep(i, 0, N) {
		k[i] -= m * B;
	}

	ll c = A - B;
	ll cnt = 0;
	rep(i, 0, N) {
		if (k[i] > 0)
		{
			cnt += k[i] / c;
			if (k[i] % c != 0) {
				cnt++;
			}
		}
	}

	return cnt <= m;
}

int main() {
	cin >> N >> A >> B;
	rep(i, 0, N) {
		cin >> h[i];
	}

	ll lb = -1, ub = 1000000001;
	ll m = 0;
	rep(i, 0, 1000) {
		m = (lb + ub) / 2;
		if (clear(m)) {
			ub = m;
		}
		else {
			lb = m;
		}
	}

	cout << ub << endl;
}

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

using namespace std;

int main()
{
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans = 0;
    for(int i=0;i<=3000;i++) {
        for(int j=0;j<=3000;j++) {
            int temp = i*r+j*g;
            if(temp<=n && (n-temp)%b==0) ans++;
        }
    }
   cout<<ans;
   return 0;
}

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

int main(){
	int m, f, r;
	int ans=0;

	while(cin >> m >> f >> r) {
		if(m==-1 && f==-1 && r==-1) break;

		ans = m+f;
		if(m==-1 || f==-1) {
			cout << "F" << endl;
		}else if(ans >= 80) {
			cout << "A" << endl;
		}else if(ans >= 65) {
			cout << "B" << endl;
		}else if(ans >= 50 || r >= 50) {
			cout << "C" << endl;
		}else if(ans >= 30) {
			cout << "D" << endl;
		}else{
			cout << "F" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3084
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,m,q;
vector<int> g[100005];
pair<int,pi> eve[100005];

int col[100005],rad[100005];
int main(){
  cin>>n>>m;
  REP(i,m){
    int a,b;scanf("%d%d",&a,&b);--a;--b;
    g[a].pb(b);
    g[b].pb(a);
  }
  cin>>q;
  REP(i,q){
    int v,d,c;scanf("%d%d%d",&v,&d,&c);
    --v;
    eve[i]={v,{d,c}};
  }
  memset(rad,-1,sizeof(rad));
  memset(col,-1,sizeof(col));
  for(int i=q-1;i>=0;--i){
    int v=eve[i].fr,d=eve[i].sc.fr,c=eve[i].sc.sc;
    if(rad[v]>=d) continue;
    rad[v]=d;
    if(col[v]==-1) col[v]=c;
    queue<int> que;
    que.push(v);
    while(!que.empty()){
      int cur=que.front();que.pop();
      if(rad[cur]) for(auto to:g[cur]){
        if(rad[to]<rad[cur]-1){
          if(col[to]==-1) col[to]=c;
          rad[to]=rad[cur]-1;
          que.push(to);
        }
      }
    }
  }
  REP(i,n) if(col[i]==-1) col[i]=0;
  REP(i,n) printf("%d\n",col[i]);
  return 0;
}





Measured memory_bytes: 8824
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 1e7 + 10, mod = 998244353;
int fac[N], inv[N], n, ans, m;
int qpow(int a, int b) {
    int c = 1;
    while(b) {
        if(b & 1) c = 1ll * c * a % mod;
        a = 1ll * a * a % mod;
        b >>= 1;
    } return c;
}
int C(int x, int y) {
    if(x < y) return 0;
    return 1ll * fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int main() {
    scanf("%d %d", &n, &m);
    if(n > m) swap(n, m);
    fac[0] = 1;
    for(int i = 1; i <= m; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
    inv[m] = qpow(fac[m], mod - 2);
    for(int i = m; i >= 1; --i) inv[i - 1] = 1ll * inv[i] * i % mod;
    for(int i = 0, o = 1; i <= n; ++i, o = mod - o)
        ans += 1ll * C(n, i) * C(m, i) % mod * fac[i] % mod * qpow(m + 1, n - i) % mod * qpow(n + 1, m - i) % mod * o % mod,
        ans %= mod;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 7720
num = list(map(int, input().split()))
num = sorted(num)
count = 0
while True:
    if (num[2] - num[0]) > 1:
        num[0] += 2
        count += 1
    elif (num[2] - num[1]) > 1:
        num[1] += 2
        count += 1
    elif (num[2] - num[0]) == 1 and (num[2] - num[1]) == 1:
        count += 1
        break
    elif (num[2] - num[0]) == 0 and (num[2] - num[1]) == 0:
        break
    else:
        count += 2
        break
print(count)


Measured memory_bytes: 3064
N = int(input())
A = [int(a) for a in input().split()]
Q = int(input())
M = [int(m) for m in input().split()]

dp = [[None] * 2000 for _ in range(N + 1)]

def solve(i, m):
    if dp[i][m] != None:
        return dp[i][m]
    if m == 0:
        dp[i][m] = True
    elif N <= i:
        dp[i][m] = False
    elif solve(i + 1, m):
        dp[i][m] = True
    elif solve(i + 1, m - A[i]):
        dp[i][m] = True
    else:
        dp[i][m] = False
    return dp[i][m]

for m in M:
    print('yes' if solve(0, m) else 'no')


Measured memory_bytes: 5956