akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <map>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    map<ll, ll> m;
    for (ll z = 0; z <= 10 * n; z++) {
        m[z * z] = z;
    }

    auto cnt = [&](int i) {
        ll ans = 0;
        for (ll x = 1; x * x <= i; x++) {
            for (ll y = 1; y * y <= i; y++) {
                if (x * x + y * y + x * y > i) break;
                ll zD = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - i);
                if (zD < 0) continue;
                if (!m.count(zD)) continue;
                zD = m[zD];
                zD -= (x + y);
                if (zD % 2 == 1) continue;
                zD /= 2;
                if (zD == 0) continue;
                ans++;
            }
        }
        return ans;
    };

    REP(i, 0, n) {
        print(cnt(i + 1));
    }
    return 0;
}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    int mp[3] = {0};
    rep(i, N) {
        if (P[i] <= A) mp[0]++;
        else if (A+1 <= P[i] and P[i] <= B) mp[1]++;
        else if (B+1 <= P[i]) mp[2]++;
    }
    int ans = mp[0];
    rep(i, 3) ans = min(ans, mp[i]);
    cout << ans << endl;
}


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

int main(){
    int N;
    cin>>N;
    int a[N],b[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }

    for(int i=0;i<N;i++){
        b[a[i]-1]=i+1;
    }

    for(int i=0;i<N;i++){
        cout<<b[i]<<endl;
    }

    return 0;

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll x = 0, y = 0, d = 0, tt = 0, ct = 0;
    ll n;
    cin >> n;
    rep(i, n)
    {
        ll t, nx, ny;
        cin >> t >> nx >> ny;
        d = abs(nx-x) + abs(ny-y);
        tt = abs(t-ct);
        if(d > tt || d%2 != tt%2) ANS("No");

        ct = t;
        x = nx, y = ny;
    }
    cout <<"Yes";
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,w;
	cin>>n>>w;
	vector<string> s(n);
	for (int i=0; n>i; i++){
		cin>>s.at(i);
	}
	for (int j=0; w+2>j;j++){
		cout<<"#";
	}
	cout<<endl;
	for (int k=0; n>k; k++){
		cout<<"#"<<s.at(k)<<"#"<<endl;
	}
	for (int j=0; w+2>j;j++){
		cout<<"#";
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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(){

	int n;
	cin >> n;
	int a[100005] = {};
	int f[100005] = {};
	int b = 1;
	rep(i,1,n+1)cin >> a[i];
    int cnt = 0;
	while(b != 2){
        if(f[b] == 0){
            f[b] = 1;
            b = a[b];
        }else{
            P(-1);
            ret 0;
        }
	
        cnt ++ ;
	}
    P(cnt);
	return  0;
}

Measured memory_bytes: 1024
#0^1^2^...^n
def rec(n)
  return 0 if n<=0
  return 1 if n==1
  return 3 if n==2
  return 0 if n==3
  return 4 if n==4
  d=1
  d*=2 while d<=n
  d/=2
  k=(n-d).odd? ? 0 : d
  k^rec(n-d)
end

a,b=gets.split.map(&:to_i)

puts rec(b)^rec(a-1)

Measured memory_bytes: 1788
import statistics
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
b = statistics.median_low(A)
c = statistics.median_high(A)
d = sum(map(lambda x:abs(x-b),A))
e = sum(map(lambda x:abs(x-c),A))
print(min(d,e))

Measured memory_bytes: 34024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
int n,m,a[N];
ll k;
bool st[N];
int main()
{
	cin>>n>>k;
	k++;
	for(int i=1;i<=n;i++) cin>>a[i];
	vector<int> ve;
	int pos=1;
	while(!st[pos])
	{
		ve.push_back(pos);
		st[pos]=1;
		pos=a[pos];
	}
//	for(int i=0;i<ve.size();i++) cout<<ve[i]<<' ';
//	cout<<endl;
	int l,xx;
	for(int i=0;i<ve.size();i++)
		if(ve[i]==pos)
		{
			l=i;
			break;
		}
	xx=ve.size()-l;
	if(k>ve.size())
	{
		k-=ve.size();
		k%=xx;
		if(k==0) cout<<ve[ve.size()-1];
		else
			cout<<ve[k+l-1];
	}
	else cout<<ve[k-1];
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	set<string> sset;

	for (int i=0; i<n; i++)
	{
		string input;
		cin >> input;
		sset.insert(input);
	}

	cout << sset.size() << endl;
}

Measured memory_bytes: 19180
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
const ll MOD = 998244353;

int main() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  vector<ll> dp(s + 1);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    vector<ll> ndp(s + 1);
    for (int j = 0; j <= s; ++j)
      ndp[j] = dp[j] * 2 % MOD;
    for (int j = 0; j <= s - a[i]; ++j) {
      ndp[j + a[i]] += dp[j];
      ndp[j + a[i]] %= MOD;
    }
    swap(dp, ndp);
  }
  cout << dp[s];
}

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

    #define ll long long

    using namespace std;

    int b, mx;

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

    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            b++;
        }
        else{
            mx = max(mx, b);
            b = 0;
        }
    }
    cout << max(mx, b);
    return 0;

    }



Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var l = readLine()!!.split(" ").map(String::toInt).sorted().reversed()

    var dropIndex = 0
    while (dropIndex < n - 2 && l[dropIndex] > l[dropIndex + 1] + l[dropIndex + 2]) {
        dropIndex++
    }
    l = l.drop(dropIndex)
    n = l.size

    var count = 0
    for (a in 0 until n - 2) {
        for (b in a + 1 until n - 1) {
            val sub = l[a] - l[b]
            for (c in b + 1 until n) {
                if (l[c] > sub) {
                    count++
                } else {
                    break
                }
            }
        }
    }


    println(count)
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll a, b, k;
  cin >> a >> b >> k;
  if (b - a + 1 >= 2 * k){
	forll(i, 0, k)
	  cout << a + i << endl;
	forllde(i, k)
	  cout << b - i + 1 << endl;
  }else{
	forll(i, a, b + 1)
	  cout << i << endl;
  }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)

	if b <= a {
		fmt.Println("delicious")
	} else if b <= (a + x) {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
n = list(input())
n = [int(i) for i in (n)]
m = len(n)
if m == 1:
    print(n[0])
else:
    flg = False
    for i in range(1,m):
        if n[i] != 9:
            flg = True
            break
    if flg:
        n[0] -= 1
        for i in range(1,m):
            n[i] = 9
    print(sum(n))

Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    vector<double> p(1005, 0);
    for (ll i = 1; i <= 1000; i++)
    {
        ll sum = i * (i + 1) / 2;
        p[i] = (double)sum / i;
    }

    ll n, k;
    cin >> n >> k;
    vector<double> v(n);
    double _max = 0;
    double sum = 0;
    for (ll i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        v[i] = p[temp];
    }

    queue<double> q;
    for (ll i = 0; i < k - 1; i++)
    {
        sum += v[i];
        q.push(v[i]);
    }

    for (ll i = k - 1; i < n; i++)
    {
        q.push(v[i]);
        sum += v[i];
        _max = max(sum, _max);
        sum -= q.front();
        q.pop();
    }

    cout << SP(10) << _max << endl;
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <math.h>
int main()
{
	int N,y,t=0;
	scanf("%d",&N);
	while(t<=floor(N/4)){
		y=N-4*t;
		if(y%7==0){
			printf("Yes\n");
			t=floor(N/4)+1;
		}else if(t==floor(N/4)){
			printf("No\n");
			t++;
		}else{
			t++;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int digsum_rec(int x){
    if(x == 0){
        //printf("reached 0\n");
        return 0;
    }else{
        //printf("when %d is divided by 10: q = %d, r = %d\n", x, x / 10, x % 10);
        return digsum_rec(x / 10) + x % 10;
    }
}

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

    int digs = digsum_rec(n);
    //printf("digitsum of %d = %d\n", n, digs);
    printf("%s\n", (n % digs == 0)? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MAXN=5e5+51;
ll cnt,sum;
ll x[MAXN],b[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	cnt=read();
	for(register int i=1;i<=cnt;i++)
	{
		b[x[i]=read()]++;
	}
	for(register int i=1;i<=cnt;i++)
	{
		sum+=b[i]*(b[i]-1)/2;
	}
	for(register int i=1;i<=cnt;i++)
	{
		printf("%lld\n",sum-b[x[i]]+1);
	}
}

Measured memory_bytes: 7296
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>

typedef long long ll;
const ll INF = 1e18 + 1;
const ll MOD = 1e9 + 7;

template <typename Head> void print(Head&& head){ std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void print(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 50 == 49) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T lsum(std::vector< T > vt) { return accumulate(vt.begin(), vt.end(), 0); }

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll money[3] = {10000, 5000, 1000};

  ll N, Y;
  std::cin >> N >> Y;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      ll k = N - i - j;
      if (i >= 0 && j >= 0 && k >= 0) {
	ll sum = money[0] * i + money[1] * j + money[2] * k;
	//print(i, j, N - i - j, sum);
	if (sum == Y) {
	  print(i, j, N - i -j);
	  return 0;
	}
      }
    }
  }

  std::cout << "-1 -1 -1" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define num 210

using namespace std;

int main(){
    int N;
    int r[num],b[num];
    for (int i=0;i<num;i++){
	r[i]=-1;
	b[i]=-1;
    }
    cin >> N;
    for (int i=0;i<N;i++){
	int a,b;
	cin >> a >> b;
	r[a]=b;
    }
    for (int i=0;i<N;i++){
	int c,d;
	cin >> c >> d;
	b[c]=d;
    }

    int ans=0;
    for (int i=1;i<num;i++){
	if (b[i] > 0){
	    int key=-1,el=-1;
	    for (int j=0;j<i;j++){
		if ((r[j] >= 0) && (key < r[j]) && (r[j] < b[i])){
		    key=r[j];
		    el=j;
		}
	    }
	    if (el >= 0){
		ans++;
		r[el]=-1;
	    }
	}
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    
    int a, b;
 
    while(1){
        
        cin >> a >> b;
        
        if(a == 0 && b == 0)break;
        
        for ( int i = 0; i < a; i++ ){
            for ( int j = 0; j < b; j++ ){
                if((i + j) % 2 == 0){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        boolean flag = false;
        if ((a + b) == c) flag = true;
        if ((a + c) == b) flag = true;
        if ((b + c) == a) flag = true;
        System.out.println(flag ? "Yes" : "No");
    }
}


Measured memory_bytes: 21716
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans1 = a * x + b * y;
    if (x > y) {
        swap(x, y);
        swap(a, b);
    }
    int ans2 = 2 * c * x + (y - x) * b;
    int ans3 = 2 * c * y;
    cout << min({ans1, ans2, ans3}) << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i).sort
b = Array.new(m)
c = Array.new(m)
m.times do |i|
  b[i], c[i] = gets.chomp.split(" ").map(&:to_i)
end
idxes = c.map.with_index { |v, i| [v, i] }.sort_by { |v, i| v }.reverse.map { |v, i| i }
i = 0
finish = false
idxes.each do |idx|
  b[idx].times do
    if a[i] < c[idx]
      a[i] = c[idx]
      i += 1
    else
      finish = true
    end
    break if i >= n || finish
  end
  break if i >= n || finish
end
puts a.inject(&:+)


Measured memory_bytes: 16872
import java.util.*;

public class Main {
    static int n;
    static long[] a;
    static long[] b;
    static long[] c;
    static long[] dpB;
    static long[] dpA;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new long[n];
        b = new long[n];
        c = new long[n];
        dpB = new long[n+1];
        dpA = new long[n+1];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }

        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);

        //Bの要素iより大きいCの要素がいくつあるかを累積和でdpB[]に格納
        int indC = 0;
        for (int i = 0; i < n; i++) {
            long count = 0;
            for (int j = indC; j < n; j++) {
                if (b[i] < c[j]) {
                    count = n - j;
                    break;
                } else {
                    indC = j;
                }
            }
            if (i==0) {
                dpB[i] = count;
            } else {
                dpB[i] = count + dpB[i-1];
            }
        }
        int indB = 0;
        //Aの要素iより大きいBの要素の値をdpC[]に格納
        for (int i = 0; i < n; i++) {
            long count = 0;
            for (int j = indB; j < n; j++) {
                if (a[i] < b[j]) {
                    if (j > 0) {
                        count = dpB[n-1] - dpB[j-1];
                    } else {
                        count = dpB[n-1];
                    }
                    break;
                } else {
                    indB = j;
                }
            }
            if (i==0) {
                dpA[i] = count;
            } else {
                dpA[i] = count + dpA[i-1];
            }
        }
        System.out.println(dpA[n-1]);
    }
}


Measured memory_bytes: 99912
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N,K;cin>>N>>K;
    vector<bool>A(N+1,false);
    vector<bool>B(N+1,false);
    REP(i,K){
        int a,b;cin>>a>>b;
        if(a==1)A[b]=true;
        if(b==1)A[a]=true;
        if(a==N)B[b]=true;
        if(b==N)B[a]=true;
    }
    bool ok=false;
    for(int i=2;i<N;i++){
        if(A[i]&&B[i])ok=true;
    }
    if(ok) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}


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

int main(){
	int n,x,a=0;
	cin >> n >> x;
	for(int i=1;i<=n;i+=2){
		a++;
	}
	
	if(a>=x) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class test{
    static void Main(){
        string[] str;
        str=Console.ReadLine().Split(' ');
        int a=int.Parse(str[0]);
        int b=int.Parse(str[1]);
        Console.WriteLine("{0} {1} {2}",a/b,a%b,W(a,b));
    }
    static string W(int x,int y){
        string str="";
        int q=x/y;
        str+=q.ToString();
        int r=x%y;
        if(r!=0){
            str+=".";
            for(int i=0;i<5;i++){
                str+=((r*10)/y).ToString();
                r=(r*10)%y;
            }
        }
        return str;
    }
}


Measured memory_bytes: 9292
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		
		int n=Integer.parseInt(scan.next());
		double[]v=new double [n];
		for (int i=0;i<n;++i) {
			v[i]=Double.parseDouble(scan.next());
		}
		Arrays.parallelSort(v);
		
		double sum=0;
		for(int i=0;i<n;++i) {
			if (i==0) {
				sum+=(v[i]+v[i+1])/2;
				
			}else if (i==1)continue;
			
			else {
				sum=(sum+v[i])/2;
			}
			
		}
		
		System.out.print(sum);
}
}
//end

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

int main() {
  map<char, string> cards;
  cin >> cards['a'] >> cards['b'] >> cards['c'];
  char turn = 'a';
  while (!cards[turn].empty()) {
    char new_turn = cards[turn][0];
    cards[turn] = cards[turn].substr(1, cards[turn].size() - 1);
    turn = new_turn;
  }
  cout << (char)toupper(turn) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,a[101010],Z,jum,las,K;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		Z+=i;
		jum+=a[i];
	}
	if(((jum%Z)!=0))
	{
		cout<<"NO\n";
		return 0;
	}
	Z=jum/Z;
	for(i=1;i<=n;i++)
	{
		las=a[i-1];
		if(i==1)
			las=a[n];
		ll X=a[i]-las;
		ll L=0,R=Z,C,H=-1;
		while(L<=R)
		{
			C=(L+R)/2;
			ll tom=C-((Z-C)*(n-1));
		//	cout<<C<<" "<<tom<<" "<<X<<"\n";
			if(tom==X)
			{
				H=C;
				break;
			}
			if(tom<X)
				L=C+1;
			else
				R=C-1;
		}
		//cout<<
	//	cout<<i<<" "<<H<<"\n";
		if(H==-1)
		{
			cout<<"NO\n";
			return 0;
		}
		else
			K+=(Z-H);
	}
	//cout<<K<<"\n";
	if(K==Z)
		cout<<"YES\n";
	else
		cout<<"NO\n";
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main(){
    int x[6]={}, y[6]={};
    for(int i=0;i<6;i++){
        cin>>x[i];
    }
     for(int i=0;i<6;i++){
        cin>>y[i];
    }
    int z[6][7]={{1,2,4,3,1,2,4},{0,3,5,2,0,3,5},{0,1,5,4,0,1,5},{0,4,5,1,0,4,5},{0,2,5,3,0,2,5},{1,3,4,2,1,3,4}};
    int a=0,b=0,c=0;
    while(1){
        if(y[0]==x[a]){
            break;
        }
        a++;
    }
     while(1){
        if(y[1]==x[b]){
            break;
        }
        b++;
    }
     while(1){
        if(z[a][c]==b){
            break;
        }
        c++;
    }
    if(x[z[a][c+1]]==y[2]&&x[z[a][c+2]]==y[4]&&x[z[a][c+3]]==y[3]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

int cou(char a,char b,char c){
	if(a!=b && b!=c && a!=c){
		return 1;
	}
	else if(a==b && b==c&& c==a){
		return 3;
	}
	else{
		return 2;
	}
}

int main(){
	int N;
	string A,B,C;
	cin>>N>>A>>B>>C;
	int count=0;
	for(int i=0;i<N;i++){
		 count+=3-cou(A.at(i),B.at(i),C.at(i));
	}
	cout <<count<<endl;
	
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int X;
cin>>X;
vector<bool> expo(X+1);
expo[1] = 1;
for(int b=2;b<=X;b++){
int v = b*b;
while(v<=X){
expo[v] = 1;
v*=b;
}
}
for(int i=X;i>=1;i--) if(expo[i]){
cout<<i<<endl;
return 0;
}
}

Measured memory_bytes: 256
#include<stdio.h>

main()
{
	char s[101],p[101];

	
	scanf("%s",s);
	scanf(" %s",p);
	
	short pcount=0;
	short scount=0;
	
	while(p[pcount]!='\0'){
		pcount++;
	}
	
	while(s[scount]!='\0'){
		scount++;
	}
	
	short i,j;
	short judge = 0;
	
	for(i=0;i<101;i++){
		if(s[i]==p[0]){
			for(j=0;j<pcount;j++){
				if(s[(i+j)%scount] != p[j]){
					break;
				}
				if(j == pcount-1){
					judge=1;
				}
			}
		}
		
		if(judge == 1){
			break;
		}
	}
	
	judge ? printf("Yes\n") : printf("No\n");
	
	return 0;
}
			

Measured memory_bytes: 524
n, a, b = gets.strip.split.map(&:to_i)

def digit_sum n
    sum = 0
    while n > 0 do
        sum += n % 10
        n /= 10
    end
    sum
end

ok = (1..n).select do |n|
  x = digit_sum(n)
  a <= x and x <= b
end

puts ok.reduce(:+)

Measured memory_bytes: 1916
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mod = 10**9+7
if (max(a) < 0 and k%2) or n == k:
  ans = 1
  for i in range(n-k,n):
    ans *= a[i]
    ans %= mod
  print(ans)
  exit()
cntn = 0
cntp = n-1
if k%2:
  ans = a[-1]
  cntp -= 1
  n -= 1
else:
  ans = 1
for i in range(k//2):
  tmp = 0
  if (cntn < n-1 and a[cntn+1] < 0) and (cntp > 0 and a[cntp-1] >= 0):
    if a[cntn]*a[cntn+1] > a[cntp-1]*a[cntp]:
      tmp = a[cntn]*a[cntn+1]
      cntn += 2
    else:
      tmp = a[cntp-1]*a[cntp]
      cntp -= 2
  elif cntn < n-1 and a[cntn+1] < 0:
    tmp = a[cntn]*a[cntn+1]
    cntn += 2
  else:
    tmp = a[cntp-1]*a[cntp]
    cntp -= 2  
  ans *= tmp
  ans %= mod
print(ans)

Measured memory_bytes: 104916
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int f(int n, int k) {
	return n == 1 ? 0 : 1 + (k - 1 + f(n - 1, k)) % (n - 1);
}

int main() {
	for (;;) {
		int n, k, m; cin >> n >> k >> m;
		if (n == 0) break;
		cout << 1 + (m - 1 + f(n, k)) % n << endl;
	}
}

Measured memory_bytes: 1472
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll fact[500005];

ll comb(ll a, ll b) {
  ll ue = fact[a];
  ll shita1=1, shita2=1;
  ll tmpshita1, tmpshita2;
  ll h, two;
  h = mod - 2;
  while(h>0) {
    tmpshita1 = fact[b];
    tmpshita2 = fact[a-b];
    two = 1;
    while(2*two<h) {
      two *= 2;
      tmpshita1 *= tmpshita1;
      tmpshita2 *= tmpshita2;
      tmpshita1 %= mod;
      tmpshita2 %= mod;
    }
    h -= two;
    shita1 *= tmpshita1;
    shita2 *= tmpshita2;
    shita1 %= mod;
    shita2 %= mod;
  }
  return ue*shita1%mod*shita2%mod;
}

int main() {
  fact[0] = 1;
  for(ll i=1;i<500005;++i) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
  }
  ll N, K;
  cin>>N>>K;
  ll ans;
  if(K>=N) {
    ans = comb(2*N-1, N);
  }
  else {
    ans = 1;
    for(int i=1;i<=K;++i) {
      ans += comb(N, i)*comb(N-1, i)%mod;
      ans %= mod;
    }
  }
  cout<<ans<<endl;
}



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

namespace Contest01_B
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            int A = Convert.ToInt32(input[0]);
            int B = Convert.ToInt32(input[1]);

            int count = 0;
            int sum = 1;

            while (sum < B)
            {
                sum = sum + A - 1;
                count = count + 1;
            }

            Console.WriteLine(count);

            Console.Read();
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());
    vector<int> b(m);
    for (int i = 0; i < m; i++)cin >> b[i];
    sort(b.begin(), b.end());

    ll ret = 1;
    int h = 0, w = 0;
    for (int i = n * m; i > 0; i--) {
        bool afound = *lower_bound(a.begin(), a.end(), i) == i;
        bool bfound = *lower_bound(b.begin(), b.end(), i) == i;

        if (afound && bfound) {
            h++, w++;
        } else if (afound) {
            ret *= w, ret %= MOD;
            h++;
        } else if (bfound) {
            ret *= h, ret %= MOD;
            w++;
        } else {
            ret *= h * w - (n * m - i), ret %= MOD;
        }
    }

    cout << ret << endl;
    return 0;
}

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

int main() {
  int n,m;
  cin >> n;
  vector<string>blue;
  vector<string>red;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    blue.push_back(s);
  }
  cin>>m;
  for(int i=0;i<m;i++){
    string s;
    cin>>s;
    red.push_back(s);
  }
  auto cal = [&](string s){
    int buff = 0;
    for(string t:blue){
      if(t==s){
        buff++;
      }
    }
    for(string t:red){
      if(t==s){
        buff--;
      }
    }
    return buff;
  };
  int ans =0;
  for(string t:blue){
    ans = max(ans,cal(t));
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string str,ans;
    int n;
    cin >> str >> n;
    int l = str.length();
    for(int i = 0;i < l;i++){
        if(i%n == 0)ans += str[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b = int(input())
print(a[b-1])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int maxn=2e3+10; 
const int inf=1e9+10;

int dp[maxn][maxn],n,a[maxn*3],f[maxn],maxval=-inf,cnt=0;
vector <pair<pair<int,int>,int> > v;

int main(){
	scanf("%d",&n);
	for(int i=0;i<3*n;i++) scanf("%d",&a[i]);
	for(int i=0;i<maxn;i++) for(int j=0;j<maxn;j++) dp[i][j]=-inf;
	for(int i=0;i<maxn;i++) f[i]=-inf;
	
	dp[a[0]][a[1]]=0; dp[a[1]][a[0]]=0; 
	f[a[0]]=0; f[a[1]]=0; maxval=0;
	for(int i=2;i+3<=3*n;i+=3){
		sort(a+i,a+i+3);
		int na=a[i],nb=a[i+1],nc=a[i+2];
		if(na==nb&&nb==nc){ cnt++; continue; }
		v.clear();
		if(na==nb) for(int j=1;j<=n;j++) v.pb(mp(mp(j,nc),dp[na][j]+1));
		else if(nb==nc) for(int j=1;j<=n;j++) v.pb(mp(mp(j,na),dp[nb][j]+1));
		v.pb(mp(mp(na,nb),dp[nc][nc]+1)); 
		v.pb(mp(mp(nb,nc),dp[na][na]+1));
		v.pb(mp(mp(na,nc),dp[nb][nb]+1)); 
		v.pb(mp(mp(na,nb),maxval)); v.pb(mp(mp(na,nc),maxval));  v.pb(mp(mp(nb,nc),maxval));
		for(int j=1;j<=n;j++) for(int k=i;k<i+3;k++) v.pb(mp(mp(j,a[k]),f[j]));
		for(int j=0;j<v.size();j++){
			int x=v[j].fst.fst,y=v[j].fst.snd,val=v[j].snd;
			checkmax(dp[x][y],val); checkmax(dp[y][x],val);
			checkmax(maxval,val); checkmax(f[x],val); checkmax(f[y],val);
		}
	}
	dp[a[n*3-1]][a[n*3-1]]++;
	int ans=0;
//	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) cout<<i<<","<<j<<","<<dp[i][j]<<endl;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) checkmax(ans,dp[i][j]);
	printf("%d\n",ans+cnt);
	return 0;
}

Measured memory_bytes: 19732
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	t, x := floatScanner(), floatScanner()
	fmt.Println(t / x)
}


Measured memory_bytes: 1772
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

struct SCC {
    int V;
    vector<vi> G, rG;
    vector<int> vs, used, cmp;
    SCC(const vector<vi>& g) : V(g.size()), G(g), rG(V), used(V), cmp(V) {
        for (int i = 0; i < V; i++) for (int u : G[i]) rG[u].push_back(i);
    }
    void dfs(int v) {
        used[v] = 1;
        for (int u : G[v]) if (!used[u]) dfs(u);
        vs.push_back(v);
    }
    void rdfs(int v, int k) {
        used[v] = 1;
        cmp[v] = k;
        for (int u : rG[v]) if (!used[u]) rdfs(u, k);
    }
    int calc() {
        fill(used.begin(), used.end(), 0);
        vs.clear();
        for (int v = 0; v < V; v++) {
            if (!used[v]) dfs(v);
        }
        fill(used.begin(), used.end(), 0);
        int k = 0;
        for (int i = vs.size()-1; i >= 0; i--) {
            if (!used[vs[i]]) rdfs(vs[i], k++);
        }
        return k;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V, E;
    cin >> V >> E;
    vector<vi> G(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }
    SCC scc(G);
    scc.calc();
    int Q;
    cin >> Q;
    while (Q--) {
        int u, v;
        cin >> u >> v;
        if (scc.cmp[u] == scc.cmp[v]) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 5120
#include <cstdlib>
#include <iostream>

int rectangle_area(int a, int b) {
    return a * b;
}

int rectangle_length(int a, int b) {
    return a + a + b + b;
}

int main() {
    int a;
    int b;

    std::cin >> a;
    std::cin >> b;

    std::cout << rectangle_area(a, b) << " " << rectangle_length(a, b) << std::endl;

    return EXIT_SUCCESS;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

int main() {
  ll N, M;
  cin >> N >> M;

  vi L(M), R(M), D(M);
  for (ll i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i] -= 1;
    R[i] -= 1;
  }

  vector<vector<pii>> G(N);
  for (ll i = 0; i < M; i++) {
    G[L[i]].push_back(make_pair(R[i], D[i]));
    G[R[i]].push_back(make_pair(L[i], -D[i]));
  }

  vi x(N);
  unordered_set<ll> visited;

  for (ll i = 0; i < N; i++) {
    if (visited.find(i) == visited.end()) {
      x[i] = 0;
      queue<ll> q;
      q.push(i);
      visited.insert(0);
      while (q.size()) {
        ll fr = q.front();
        q.pop();
        for (pii j: G[fr]) {
          ll to = j.first;
          ll d = j.second;
          if (visited.find(to) == visited.end()) {
            x[to] = x[fr] + d;
            visited.insert(to);
            q.push(to);
          } else {
            if (x[to] != x[fr] + d) {
              cout << "No" << endl;
              return 0;
            }
          }
        }
      }
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 21924
N = int(input())
L = list(map(int,input().split()))
ans = 0
i = 0
for i in range (N):
 for j in range (i+1, N):
  for k in range (j+1, N):
   if L[i]==L[j] or L[i]==L[k] or L[j]==L[k]:
    ans = ans
   elif L[i]+L[j]<=L[k] or L[i]+L[k]<=L[j] or L[j]+L[k]<=L[i]:
    ans = ans
   else:
    ans = ans + 1
print (ans)


Measured memory_bytes: 9208
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    p_lst.sort()
    minimum = 0
    
    for i in range(k):
        price = p_lst[i]
        minimum += price
        
    print(minimum)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;
import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = (int)1e9 + 7;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        int trun = 0;
        while (a > 0 && c > 0) {
            if (trun == 0) {
                c -= b;
                if (c <= 0) {
                    out.println("Yes");
                }
            } else {
                a -= d;
                if (a <= 0) {
                    out.println("No");
                }
            }
            trun ^= 1;
        }
    }



}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}

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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 5000005
#define Md 1000000007
#define inv3 333333336
int n;
int ifac[MN];
int p3[MN];
int main(){
	read(n);p3[0]=ifac[0]=ifac[1]=1;
	for(int i=1;i<=n;++i){
		p3[i]=1ll*p3[i-1]*inv3%Md;
		if(i!=1)ifac[i]=1ll*ifac[Md%i]*(Md-Md/i)%Md;
	}
	lg re=ifac[n],res=0;
	for(int i=1;i<=n;++i){
		re=re*inv3%Md;
		res=(res+re*ifac[n-i+1]%Md)%Md;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 10496
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
map<int,int>cnt;
int main(){
   // freopen("file.in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
    	int x;
		scanf("%d",&x);
		cnt[x]++;	
    }
   	while(m--){
		int x,y;
		scanf("%d%d",&y,&x);
		while(y>0){
			PII nd=*cnt.begin();
			if(nd.ff>x)
				break;
			cnt.erase(cnt.begin());
			if(nd.ss==0)
				continue;
			if(nd.ss<=y){
				cnt[x]+=nd.ss;
				y-=nd.ss;
			}
			else{
				cnt[x]+=y;cnt[nd.ff]+=nd.ss-y;
				y=0;	
			}
		}
	}
	ll ans=0;
	tr(it,cnt)
		ans+=(it->ff)*1LL*(it->ss);
	printf("%lld\n",ans);	
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int n;
  cin >> n;
  int s_t[n], total = 0;
  for (int i = 0; i < n; i++){
    cin >> s_t[i];
    total += s_t[i];
  }
  int m;
  cin >> m;
  int change[200][2];
  int p, x;
  for (int i = 0; i < m; i++){
    cin >> change[i][0] >> change[i][1];
  }
  for (int i = 0; i < m; i++){
    int temp = total-s_t[change[i][0]-1] + change[i][1];
    cout << temp << endl;
  }
  return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

char grid[22][22];
int ans = 0;
bool visited[22][22];

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

void init(){
    rep(i, 22) rep(j, 22) {grid[i][j] = '#'; visited[i][j] = false;}
}

void dfs(int px, int py, int sx, int sy){
    visited[sx][sy] = true;
    ans++;
    rep(i, 4){
        int nx = sx+dx[i];
        int ny = sy+dy[i];
        if(grid[nx][ny] == '.' && !visited[nx][ny]){
            dfs(sx, sy, nx, ny);
        }
    }
}

int main(void){
    while(true){
        ans = 0;
        init();
        int W, H; cin >> W >> H;
        if(W == 0) break;
        int sx, sy;
        rep(i, H){
            string S; cin >> S;
            rep(j, W){
                grid[i+1][j+1] = S[j];
                if(S[j] == '@'){
                    sx = i+1;
                    sy = j+1;
                }
            }
        }
        dfs(-1, -1, sx, sy);
        cout << ans << endl;
    }
    return 0;
}


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

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        private struct Pos
        {
            public int row;
            public int col;
        }
        private const long MOD = 1000000007;
        static void SolveA(string[] args)
        {
            int n = ReadAndParseInt();
            var a = ReadAndParseIntArr();
            var alist = new List<int>(a);
            alist.Sort();
            alist.Reverse();
            int alice = 0;
            for(int i=0;i<alist.Count;i+=2)
            {
                alice += alist[i];
            }
            int bob = 0;
            for(int i=1;i<alist.Count;i+=2)
            {
                bob += alist[i];
            }
            Console.WriteLine(alice - bob);
        }
    }
}

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

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

  string A, B, C;
  cin >> A;
  cin >> B;
  cin >> C;

  int count = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) != B.at(i) && A.at(i) != C.at(i) && B.at(i) != C.at(i)) count += 2;
    else if (A.at(i) != B.at(i) && A.at(i) == C.at(i)) count++;
    else if (A.at(i) != B.at(i) && B.at(i) == C.at(i)) count++;
    else if (A.at(i) == B.at(i) && A.at(i) != C.at(i)) count++;
  }

  cout << count << endl;
}

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

int selectionSort(int A[], int N) {
    int minj;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) minj = j;   
        }
        if (i != minj) {
            swap(A[i], A[minj]);
            cnt++;
        }
    }
    return cnt;
}

void trace(int A[], int N) {
    for (int k = 0; k < N; k++) {
        if (k > 0) cout << ' ';
        cout << A[k];
    }
    cout << endl;
}

int main() {
    int N, A[100], count = 0;
    cin >> N;

    for (int i = 0; i < N; i++) cin >> A[i];

    count += selectionSort(A, N);
    trace(A, N);
    cout << count << endl;

    return 0;


}


Measured memory_bytes: 3116
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	cin>>n>>m;
	vector<int> g[100010];
	for(int i=0; i<m; i++){
		int a, b; cin>>a>>b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<int> que;
	int d[100010];
	const int INF=1e9+7;
	fill(d, d+n, INF);
	int p[100010];
	que.push(0);
	d[0]=0;
	while(!que.empty()){
		int x=que.front(); que.pop();
		for(auto y:g[x]){
			if(d[y]>d[x]+1){
				p[y]=x;
				d[y]=d[x]+1;
				que.push(y);
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=1; i<n; i++){
		cout<<p[i]+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 10776