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

int main() {
    ll n;
    cin>>n;
    ld a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ld dp[n+1][n+1]={},sum=0;
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++){
        dp[i][0]=dp[i-1][0]*(1-a[i-1]);
        for(int j=1;j<=n;j++){
            dp[i][j]=dp[i-1][j-1]*a[i-1]+dp[i-1][j]*(1-a[i-1]);
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    for(int i=(n/2)+1;i<=n;i++) sum+=dp[n][i];
    cout<<fixed<<setprecision(10);
    cout<<sum<<"\n";
}

Measured memory_bytes: 144388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int x,y;
	cin>>x>>y;
	if(x*2<=y&&y<=x*4&&(y-(x*2))%2==0){
		puts("Yes");
	}else{
		puts("No");
	}
}


Measured memory_bytes: 3620
#include <algorithm>
#include <chrono>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vi2;
typedef vector<vi2> vi3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vll> vll2;
typedef vector<vll2> vll3;
typedef vector<bool> vb;

#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define repeat(n) for (int i = 0; i < n; i++)
#define umap unordered_map
#define uset unordered_set
#define vec vector
#define loop(a) for (auto &x : a)
#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back

template <typename T>
void debug0(const T &value) {
    cerr << value << endl;
}

template <typename T, typename... Args>
void debug0(const T &value, const Args &... args) {
    cerr << value << ' ';
    debug0(args...);
}

#ifdef LOCAL
#define debug(...) debug0(__VA_ARGS__)
#else
#define debug(...)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int extgcd(int a, int b, int &x, int &y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = extgcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int invmod(int a, int m) {
    int x, y;
    int g = extgcd(a, m, x, y);
    if (g != 1) {
        return -1;
    } else {
        x = (x % m + m) % m;
        return x;
    }
}

const int MODULE = 1e9 + 7;

int add(int x, int y) {
    x += y;
    while (x >= MODULE) {
        x -= MODULE;
    }
    return x;
}

int mul(int x, int y) {
    return (ll)x * y % MODULE;
}

vi fnv, fac;

void prep_mod(int n) {
    fnv = vi(n + 1);
    fac = vi(n + 1);
    fnv[1] = fac[1] = 1;
    rep(i, 2, n + 1) {
        fac[i] = mul(fac[i - 1], i);
        fnv[i] = mul(fnv[i - 1], invmod(i, MODULE));
    }
}

int comb(int total, int choose) {
    if (choose == 0 || total == choose) {
        return 1;
    } else {
        return mul(fac[total], mul(fnv[choose], fnv[total - choose]));
    }
}

int power(int base, int exp) {
    if (exp == 0) {
        return 1;
    } else if (exp % 2 == 0) {
        return power(mul(base, base), exp / 2);
    } else {
        return mul(base, power(base, exp - 1));
    }
}

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

    int kk;
    string ss;
    cin >> kk;
    cin >> ss;

    prep_mod(ss.size() + kk);
    /* int ans = mul(comb(ss.size() + kk, ss.size()), power(25, kk)); */
    int ans = 0;
    rep(last, 0, kk + 1) {
        int ans1 = mul(mul(comb(ss.size() + kk - last - 1, ss.size() - 1), power(25, kk - last)), power(26, last));
        ans = add(ans, ans1);
    }
    cout << ans << el;
}


Measured memory_bytes: 20100
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

ll n;

char solve(const string& str, string& ans) {
  char ret;
  for (ll i = 1; i < n; i++) {
    string diff = (ans[i - 1] == 'S') ? "W" : "S";
    string same = (ans[i - 1] == 'S') ? "S" : "W";
    string add;
    if (ans[i] == 'S') {
      if (str[i] == 'o')
        add = same;
      else
        add = diff;
    } else {
      if (str[i] == 'o')
        add = diff;
      else
        add = same;
    }
    if (i < n - 1)
      ans += add;
    else
      ret = add[0];
  }  // i

  assert(ret == 'S' || ret == 'W');

  return ret;
}  // solve

int main() {
  string str;
  cin >> n >> str;

  string ans = "SS";
  char chk_goal;
  char goal;
  if (str[0] == 'o')
    goal = 'S';
  else
    goal = 'W';
  chk_goal = solve(str, ans);
  if (chk_goal == ans[0] && goal == ans[n-1]) {
    cout << ans << endl;
    return 0;
  }

  ans = "SW";
  if (str[0] == 'o')
    goal = 'W';
  else
    goal = 'S';
  chk_goal = solve(str, ans);
  if (chk_goal == ans[0] && goal == ans[n-1]) {
    cout << ans << endl;
    return 0;
  }

  ans = "WS";
  if (str[0] == 'o')
    goal = 'W';
  else
    goal = 'S';
  chk_goal = solve(str, ans);
  if (chk_goal == ans[0] && goal == ans[n-1]) {  
    cout << ans << endl;
    return 0;
  }

  ans = "WW";
  if (str[0] == 'o')
    goal = 'S';
  else
    goal = 'W';
  chk_goal = solve(str, ans);
  if (chk_goal == ans[0] && goal == ans[n-1]) {    
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


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

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

ll n,d,a;
ll ans;
ll ans2;

int main() {
  cin >> n >> d >> a;

  vector<P> x;
  for(int i = 0; i < n; i++) {
    ll X,H;
    cin >> X >> H;
    x.push_back(P(X,H));
  }

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

  vector<ll> pos(n);
  for(int i = 0; i < n; i++) pos[i] = x[i].first;
  vector<ll> damage(n+1,0);

  int p = 0;

  while(p < n) {
    if(x[p].second > damage[p]) {
      // ll bomb = max((x[p].second - damage[p] - a)/a+1,1ll);
        ll bomb = max((x[p].second - damage[p] + a - 1),0ll) / a;
      ans += bomb;
      int tmp = upper_bound(pos.begin(),pos.end(),x[p].first + 2 * d) - pos.begin();
      damage[p] += bomb * a;
      damage[tmp] -= bomb * a;
    }
    p++;
    damage[p] += damage[p-1];
  }

  /* sort(x.begin(),x.end(),greater<P> ());
  for(int i = 0; i < n; i++) {
    pos[i] = -x[i].first;
    x[i].first = pos[i];
  }
  damage.assign(n+1,0);
 

   p = 0;

  while(p < n) {
    if(x[p].second > damage[p]) {
      ll bomb = max((x[p].second - damage[p] + a - 1),0ll) / a;
      ans2 += bomb;
      // cout << ans2 <<"   "<<x[p].first + 2 * d << endl;
      int tmp = upper_bound(pos.begin(),pos.end(),x[p].first + 2 * d) - pos.begin();
      damage[p] += bomb * a;
      damage[tmp] -= bomb * a;
    }
    p++;
    damage[p] += damage[p-1];
  }

  //  cout << ans << "    "<< ans2 << endl;
 cout << min(ans,ans2) << endl;
  */
  
  cout << ans << endl;
}
  


Measured memory_bytes: 7148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int A = s.nextInt();
        int B = s.nextInt();
        int flag=-1;
        for(int i=0;i<10;i++){
            if(A==Math.floor(((B*10)+i)*0.08)){
                flag=(B*10)+i;
                break;
            }

        }
        System.out.println(flag);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int A, B, C; cin >> A >> B >> C;
  if(A+B+C==17 && max({A, B, C})==7 && min({A, B, C})==5) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;


int main() {
  string s,t;
  map<char, int> a, b;
  cin >> s >> t;
  char pres = s[0];
  char pret = t[0];
  reps(i, s.size()-1){
    if(!((s[i] == pres && t[i] == pret) || (s[i] != pres && t[i] != pret))){
      cout << "No" << endl;
      return 0;
    }
    pres = s[i];
    pret = t[i];

  }
  rep(i, s.size()){
    a[s[i]]++;
    b[t[i]]++;
  }
  if(a.size() != b.size()){
      cout << "No" << endl;
      return 0;
  }
  vector<int> ai;
  vector<int> bi;

  for(auto vk : a){
    ai.push_back(vk.second);
  }
  for(auto vk : b){
    bi.push_back(vk.second);
  }
  sort(ai.begin(), ai.end());
  sort(bi.begin(), bi.end());
  rep(i, ai.size()){
    if(ai[i] != bi[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



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

int main(){
    int N, X, T;
    cin >> N >> X >> T;
    
    int rap;

    rap = N / X;
    if (N % X != 0) rap++;
    

    cout << rap * T << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define bj 22

int main() {
  int a,b,c,rs;
  cin >> a >> b >> c;
  rs = a+b+c;
  if(rs/bj){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define E(a) begin(a), end(a)
#define ER(a, r) begin(a), begin(a) + r
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char a[4];
	cin >> a;
	int b = ((a[0] == '1' && a[1] < '3') || (a[0] == '0' && a[1] != '0')) * 2 +
			((a[2] == '1' && a[3] < '3') || (a[2] == '0' && a[3] != '0'));
	switch(b) {
		case 0: cout << "NA\n";break;
		case 1: cout << "YYMM\n";break;
		case 2: cout << "MMYY\n";break;
		case 3: cout << "AMBIGUOUS\n";break;
	}
}


Measured memory_bytes: 256
def memorize(func):
    memo = {}
    def wrapper(*args):
        if args not in memo:
            memo[args] = func(*args)
        return memo[args]
    return wrapper
def factorize(n, factor=2, index=0):
    counter = 0
    while True:
        if n%factor==0:
            n //=factor
            counter += 1
        else:
            break
    if counter>0:
        yield (factor, counter)
    if factor**2 < n:
        yield from factorize(n, factor+1)
    elif n>2:
        yield (n, 1)
@memorize
def choose(N, M):
    if M>N:
        return 0
    if N==0 or M==0:
        return 1
    else:
        return N*choose(N-1, M-1)//M
def ans(N, M):
    val = 1
    for _, r in factorize(M):
        val *= choose(N+r-1, r)
        val %= (10**9+7)
    return val
import sys; sys.setrecursionlimit(100000)
print(ans(*map(int, input().split())))

Measured memory_bytes: 8932
# -*- coding:utf-8 -*-
c = []
for i in range(3):
	a = list(map(int, input().split()))
	c.append(a)

s = c[0][1]-c[0][0]
t = c[0][2]-c[0][0]

A = c[1][1]-c[1][0]-s
B = c[1][2]-c[1][0]-t
C = c[2][1]-c[2][0]-s
D = c[2][2]-c[2][0]-t

if (A == 0) & (B == 0) & (C == 0) & (D == 0):
	print("Yes")
else:print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
 
using namespace std;
typedef long long Int;
#define INF (1LL<<60)
#define rep(i,n) for(Int (i)=0;(i)<(n);(i)++)
Int dp[5][200000];
Int table[200000];
Int a[200000],b[200000],c[200000];
Int count2[200000];
Int count3[200000];

Int solve(int x){

}

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

	Int n;
	cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n) cin >> c[i];
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);

	rep(i,n) dp[0][i] = i+1;

	// 2段目dp
	Int start =0;
	rep(i,n){
		while(a[start]<b[i]){
			start++;
			if (start == n) break;
		}
		if(start == 0){
			dp[1][i] = 0;
			continue;
		}
		start--;
		if(i == 0){
			dp[1][i] = dp[0][start];
			continue;
		}
		dp[1][i] = dp[1][i-1] + dp[0][start];
	}

		// 3段目dp
	start =0;
	rep(i,n){
		while(b[start]<c[i]){
			start++;
			if (start == n) break;
		}
		if(start == 0){
			dp[2][i] = 0;
			continue;
		}
		start--;
		if(i == 0){
			dp[2][i] = dp[1][start];
			continue;
		}
		dp[2][i] = dp[2][i-1] + dp[1][start];
	}
	cout<<dp[2][n-1]<<endl;

	return 0;
}

Measured memory_bytes: 12544
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>
#include <iomanip>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;

using namespace std;

ll n, m, k;

int main(){
    cin >> n >>k;
    vector<ll> a(n);
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    vector<ll> pl, mn;
    for (int i=0; i<n; ++i){
        if (a[i] > 0){
            pl.push_back(a[i]);
        }else{
            mn.push_back(-a[i]);
        }
    }
    ll ret = 1;
    sort(pl.begin(), pl.end());
    reverse(pl.begin(), pl.end());
    sort(mn.begin(), mn.end());
    reverse(mn.begin(), mn.end());
    ll plctr = 0;
    ll mnctr = 0;
    bool cnd = true;
    for (int i=0; i<k; ++(++i)){
        if(i==k-1){
            if (plctr != pl.size()){
                ret *= pl[plctr];
                ret %= DENOM;
            }else{
                cnd = false;
            }
            break;
        }
        if(pl.size() < plctr +2){
            if (mn.size() < mnctr +2){
                cnd = false;
                break;
            }else{
                ret *= (mn[mnctr] * mn[mnctr+1]) % DENOM;
                ret %= DENOM;
                mnctr += 2;
            }
        }else if(mn.size() < mnctr +2){
            ret *= (pl[plctr] * pl[plctr+1]) % DENOM;
            ret %= DENOM;
            plctr += 2;
        }else{
            ll mnv = mn[mnctr] * mn[mnctr+1];
            ll plv = pl[plctr] * pl[plctr+1];
            if (plv > mnv){
                ret *= plv % DENOM;
                ret %= DENOM;
                plctr += 2;
            }else{
                ret *= mnv % DENOM;
                ret %= DENOM;
                mnctr += 2;
            }
        }
        
    }
    if (!cnd){
        ret = 1;
        plctr = 0;
        mnctr = 0;
        reverse(pl.begin(), pl.end());
        reverse(mn.begin(), mn.end());
        for (int i=0; i<k; ++i){
            if (plctr == pl.size()){
                ret *= mn[mnctr];
                ret %= DENOM;
                mnctr++;
            }else if(mnctr == mn.size()){
                ret *= pl[plctr];
                ret %= DENOM;
                plctr++;
            }else{
                ll mnv = mn[mnctr];
                ll plv = pl[plctr];
                if(plv < mnv){
                    ret *= plv;
                    ret %= DENOM;
                    ++plctr;
                }else{                    
                    ret *= mnv;
                    ret %= DENOM;
                    ++mnctr;
                }
            }
        }
        ret = -ret;
        if (ret < 0){
            ret += DENOM;
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>

using namespace std;

int main() {
	string S;
	cin >> S;
	int count=0;
	int N = (int)(S.length());

	for (int i = 1; i < N; i++) {
		if (S[i - 1] == '0' && S[i] == '0') {
			S[i] = '1';
			count++;
		}
		else if (S[i - 1] == '1' && S[i] == '1') {
			S[i] = '0';
			count++;
		}
	}

	cout << count << endl;

}



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

S = []
for _ in range(N):
    S.append(input())

def make_dic(string):
    dic = {}
    for c in "abcdefghijklmnopqrstuvwxyz":
        dic[c] = 0
    for s in string:
        dic[s] += 1
    return dic

def common_dic(dic_1, dic_2):
    dic = {}
    for c in "abcdefghijklmnopqrstuvwxyz":
        dic[c] = min(dic_1[c], dic_2[c])
    return dic

dic_c = make_dic(S[0])
for i in range(1, N):
    dic_c = common_dic(dic_c, make_dic(S[i]))

for c in "abcdefghijklmnopqrstuvwxyz":
    if dic_c[c] > 0:
        print(c * dic_c[c], end="")
print()


Measured memory_bytes: 3064
n, m = list(map(int, input().split()))
points = list(map(int, input().split()))

points.sort()

points_diff = []
for i in range(len(points)):
    if i != (len(points) - 1):
        points_diff.append(abs(points[i] - points[i+1]))

points_diff.sort()

result = []
for i in range(m - n):
    result.append(points_diff[i])
    
print(sum(result))


Measured memory_bytes: 13968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int arrayCnt = new Integer(s.nextLine()).intValue();
		int[] array = new int[arrayCnt];
		String[] tmpArray = s.nextLine().split(" ");
		for(int i=0 ; i<array.length ; i++) {
			array[i] = new Integer(tmpArray[i]).intValue();
		}

		int targetCnt = new Integer(s.nextLine()).intValue();
		int[] target = new int[targetCnt];
		String[] tmpTarget = s.nextLine().split(" ");
		for(int i=0 ; i<target.length ; i++) {
			int sum = 0;
			int cnt = -1;

			target[i] = new Integer(tmpTarget[i]).intValue();
			if(search(cnt, sum, array, target[i], arrayCnt))
				System.out.println("yes");
			else
				System.out.println("no");
		}


	}

	public static boolean search(int cnt, int sum, int[] array, int target, int stopCnt) {
		cnt++;
		if(sum == target)
			return true;
		else if(cnt == stopCnt) {
			return false;
		}

		boolean a = search(cnt, sum+array[cnt], array, target, stopCnt);
		boolean b = search(cnt, sum, array, target, stopCnt);
		if(a == true || b == true)
			return true;
		else
			return false;
	}
}

Measured memory_bytes: 19124
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> list = IntStream.range(0, n).mapToObj(i -> sc.nextInt()).collect(Collectors.toList());
        int sum = list.stream().mapToInt(i -> i).sum();
        int min =  sum % (4 * m) == 0 ? sum / (4 * m) :sum / (4 * m) + 1;
        if(list.stream().filter(f -> f >= min).count() >= m){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 29904
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    long long h,a;
    cin >> h >> a;
    long long sum=0;
    while(h>0)
    {
        h-=a;
        sum++;
    }
    cout << sum << endl;
}


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

int main(){
  string S, T;
  cin>>S>>T;
  char forecast[3],tenki[3];
  for(int i = 0; i<3; i++){
    forecast[i] = S.at(i);
    tenki[i] = T.at(i);
  }
  int match = 0;
  for(int i = 0; i<3; i++){
    if(forecast[i] == tenki[i]){
      match++;
    }
  }
  cout<<match<<"\n";
}

Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "tmp.cpp"

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> in(n, 0);
  REP(i, n - 1 + m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    in[b]++;
  }

  int root = 0;
  REP(i, n) {
    if (in[i] == 0) {
      root = i;
      break;
    }
  }

  vector<int> ans(n);
  queue<int> q;
  ans[root] = -1;
  q.push(root);
  while (!q.empty()) {
    int rt = q.front();
    q.pop();
    for (const auto v : g[rt]) {
      in[v]--;
      if (in[v] == 0) {
        ans[v] = rt;
        q.push(v);
      }
    }
  }
  REP(i, n) { cout << ans[i] + 1 << endl; }
  return 0;
}


Measured memory_bytes: 9088
N, K =map(int, input().split())
mod = 10**9 + 7
A = int(-(N+1)*(N+2)*(2*N+3)/6)%mod
B = int((N+1)*(N+1)*(N+2)/2)%mod
C = N+1
a = int(-(K-1)*K*(2*K-1)/6)%mod
b = int((N+1)*(K-1)*K/2)%mod
c = K-1
print((A+B+C-a-b-c)%mod)


Measured memory_bytes: 9128
n,m=map(int,input().split())
l=[]
for i in range(m):
    a=list(map(int,input().split()))
    a.append(i)
    l.append(a)
l.sort(key=lambda x:x[1])
l.sort(key=lambda x:x[0])
j,y=0,1
for i in range(m):
    x=l[i].pop(0)
    y=y+1 if j==x else 1
    j=x
    l[i][0]=str(x).zfill(6)+str(y).zfill(6)
l.sort(key=lambda x:x[1])
for i in l:print(i[0])

Measured memory_bytes: 38408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
 
int main(){   
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=1; i<=n; ++i){
        if(i%3 == 0) continue;
        if(i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
n=int(input())
s=input()
a = [str(c) for c in s]
ans=0
r=0
g=0
b=0
er=0
for i in range(n):
    if a[i]=='R':
        r+=1
        ans=ans+g*b
    elif a[i]=='G':
        g+=1
        ans=ans+r*b
    else:
        b+=1
        ans=ans+g*r
for i in range(n-1):
    for j in range(i+1,n):
        k=j+(j-i)
        if k<n:
            if a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i]:
                er+=1
print(ans-er)

Measured memory_bytes: 74072
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }else{
        ll k1 = (n-b)+1+(n-(a+(n-b)+1))/2;
        ll k2 = (a-1)+1+((b-1-(a-1))-1)/2;
        cout<<min(k1,k2)<<endl;



    }

return 0;
}


Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,m,k;
string s;

main(){
	cin>>n>>m;
	if(m%n==0)dump(m+n);
	else dump(m-n);
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 2e5 + 5;
int n;
struct Box {
	int vals[2], pos[2];
} b[N];
struct Ball {
	int val, box, ballID;
	bool operator<(const Ball &rhs) const { return val < rhs.val; }
};
vector<Ball> v;
int other[N << 1];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) {
		fw (j, 0, 2) {
			cin >> b[i].vals[j];
			v.pb({b[i].vals[j], i, j});
		}
	}
	sort(v.begin(), v.end());
	int curPos = 0;
	fa (i, v) {
		int boxInd = i.box;
		fw (j, 0, 2) if (i.ballID != j) {
			b[boxInd].pos[j] = curPos;
		}
		curPos++;
	}
	fw (i, 0, n) {
//		cout << b[i].pos[0] << " " << b[i].pos[1] << "\n";
		other[b[i].pos[0]] = b[i].pos[1];
		other[b[i].pos[1]] = b[i].pos[0];
	}
	//Case 1: Both min and max are assigned to the same color.
	int bestSuf = -1;
	bw (i, v.size(), 0) if (other[i] > i) {
		bestSuf = i + 1;
		break;
	}
	int ans = infll;
	fw (i, 0, v.size()) {
		if (other[i] < i) break; //Prefix is now invalid.
		bestSuf = max(bestSuf, other[i] + 1);
		if (bestSuf == v.size()) break; //Suffix is now empty. Invalid for current case.
		//If we assign everything from 0 -> i to blue, bestSuf -> sz - 1 is the largest blue suffix.
		//Pair i + 1 and bestSuf - 1 together.
//		cout << "Prefix " << v[i].val << " other = " << other[i] << " bestSuf = " << bestSuf << "\n";
		assert(i + 1 != bestSuf - 1);
		if (other[i + 1] != bestSuf - 1) {
			ans = min(ans, (v.back().val - v[0].val) * (v[bestSuf - 1].val - v[i + 1].val));
		} else {
			//Pair i + 1 with bestSuf.
			if (bestSuf != v.size() - 1) {
				ans = min(ans, (v.back().val - v[0].val) * (v[bestSuf].val - v[i + 1].val));
			}
		}
	}
	//Case 2: Min and max got different colors on 'em.
	//Have min = blue and max = red, then coloring is easy
	int mnBlue = inf, mxRed = -1, mxBlue = -1, mnRed = inf;
	fw (i, 0, n) {
		int small = inf, big = -1;
		fw (j, 0, 2) {
			small = min(small, b[i].vals[j]);
			big = max(big, b[i].vals[j]);
		}
		mxBlue = max(mxBlue, small);
		mnRed = min(mnRed, big);
		mnBlue = min(mnBlue, small);
		mxRed = max(mxRed, big);
	}
	ans = min(ans, (mxBlue - mnBlue) * (mxRed - mnRed));
	cout << ans;
	return 0;
}

Measured memory_bytes: 21224
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int n, m;
	while (scanf("%d %d", &m, &n), n)
	{
		int thick[100];
		for (int i = 0; i < n; ++i)
			scanf("%d", thick+i);

		int maxThick = 0;
		for (int i = 0; i < n; ++i)
			maxThick = max(maxThick, thick[i]);

		int ans = -1;
		for (int t = maxThick; ans == -1; ++t)
		{
			int step = 0;
			int sum = 0;
			int i;
			for (i = 0; i < n && step < m; ++i)
			{
				if (sum + thick[i] > t)
				{
					sum = 0;
					++step;
				}
				sum += thick[i];
			}
			if (i == n && step < m)
				ans = t;
		}
		printf("%d\n", ans);
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll x;
    cin>>x;
    ll a=100;
    ll ans = 0;
    while(a<x){
        a = a + (a*0.01);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL H, W, N; cin >> H >> W >> N;
	int DX[] = { 0, 0, 1, -1, 1, 1, -1, -1,0 };    int DY[] = { 1, -1, 0, 0, 1, -1, 1, -1,0 };

	map<PII, int>Map;
	FOR(i, 0, N) {
		int y, x; cin >> y >> x;
		y--, x--;
		FOR(k, 0, 9) {
			int ny = y + DY[k];
			int nx = x + DX[k];
			if (1 <= ny && ny < H - 1 && 1 <= nx && nx < W - 1) {
				Map[PII(ny, nx)]++;
			}
		}
	}
	VL ans(10, 0);
	const auto MM = Map;
	for (auto m : MM) {
		ans[m.second]++;
	}
	ans[0] = ((H - 2)*(W - 2) - accumulate(ALL(ans), 0LL));
	FOR(i, 0, 10) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 112768
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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;
  P(pow(n, 3));
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
      int n = sc.nextInt();
      int[] a = new int[n];
      
      for(int i=0;i<n;i++){
      	a[i] = sc.nextInt();
      }
      
      Arrays.sort(a);
      
    System.out.println(a[n-1] -  a[0]);
      
}
}


Measured memory_bytes: 35864
n, m = gets.chomp.split(" ").map(&:to_i)
inputs = []
ans = 0
n.times do
    inputs << gets.chomp.split(" ").map(&:to_i)
end
inputs.sort!{|a, b| a[0] <=> b[0]}
quantity = 0
inputs.each do |a, b|
    if m <= quantity + b
        ans += a * (m-quantity)
        break
    else
        ans += a*b
    end
    quantity += b
end
puts ans

Measured memory_bytes: 10488
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define taskname "A"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 5e3 + 5;
const int maxm = 1e7 + 5;

const int mod = 1e9 + 7;
int n , A , B;
int pos[maxn] , a[maxn];
int m = 0;
ll f[maxn][maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP" , "r"))
        freopen(taskname".INP","r",stdin),
        freopen(taskname".OUT","w",stdout);
    cin >> n >> A >> B;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
        pos[a[i]] = i;
    }
    memset(f,123,sizeof  f);
    f[1][0] = 0;
    ll res = 1e18;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 0 ; j < i ; ++j){
            if(pos[i] > pos[j]){
                f[i + 1][j] = min(f[i + 1][j] , f[i][j] + B);
                f[i + 1][i] = min(f[i][j] , f[i + 1][i]);
            }else{
                f[i + 1][j] = min(f[i + 1][j] , f[i][j] + A);
            }
        }
    }
    cout << *min_element(f[n+1],f[n+1]+n+1);
}



Measured memory_bytes: 196096
n, p = map(int, input().split())
a = list(map(int, input().split()))

is_odd = False
for ai in a:
    if ai % 2 == 1:
        is_odd = True
        break

if is_odd:
    ans = 2 ** (n - 1)
else:
    if p == 0:
        ans = 2 ** n
    else:
        ans = 0
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
typedef long double ld;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-10;
const ll inf = 1e18;
const int maxn = 200005;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())    s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

int main(int argc, char const *argv[])
{
	ll x;
	cin >> x;
	ll ans = 0;
	ans += (x / 500) * 1000;
	ll left = x - (x / 500) * 500;
	ans += (left / 5) * 5;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T,class... Ts>
auto make_vec(size_t a,Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));
}

const int MOD = 1000000007;
void add(ll &a,ll b){
    a+=b;
    if(a>=MOD)a-=MOD;
}

int main(){
    int N;cin >> N;
    auto dp = make_vec<ll>(N+1,5,5,5);
    dp[0][0][0][0]=1;
    //0:dammy,1:A,2:C,3:G,4,T;
    //NG::AGC(132),ACG(123),GAC(312),A#GC(1#32),AG#C(13#2)
    for(int n=0;n<N;n++){
        rep(i,5){
            rep(j,5){
                rep(k,5){
                    FOR(now,1,5){
                        if(j==1&&k==3&&now==2)continue;
                        if(j==1&&k==2&&now==3)continue;
                        if(j==3&&k==1&&now==2)continue;
                        if(i==1&&k==3&&now==2)continue;
                        if(i==1&&j==3&&now==2)continue;
                        add(dp[n+1][j][k][now],dp[n][i][j][k]);
                    }
                }
            }
        }
    }

    ll res = 0;
    FOR(i,1,5)FOR(j,1,5)FOR(k,1,5)add(res,dp[N][i][j][k]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
# ABC058C - 怪文書 / Dubious Document (ARC071C)
def main():
    n = int(input())
    lst = [input().rstrip() for _ in range(n)]
    ch = sorted(set.intersection(*[set(i) for i in lst]))
    ans = ""
    for c in ch:
        cnt = float("inf")
        for i in lst:
            cnt = min(cnt, i.count(c))
        ans += c * cnt
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <utility>
#include <cmath>
#include <queue>

using namespace std;

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

#define INF 		2000000007
#define MOD			10e9+7
#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

bool S[200005];

int move(int &a,int &b){
	if(a+2!=b && S[a+2]){a += 2;return 1;}
	else if(a+1 != b && S[a+1]){a+=1;return 1;}
	return 0;
}
int slow(int &a,int &b){
	if(a+1!=b && S[a+1]){a += 1;return 1;}
	else if(a+2 != b && S[a+2]){a+=2;return 1;}
	return 0;
}

int main(){
	int N,AB[2],CD[2];cin>>N>>AB[0]>>AB[1]>>CD[0]>>CD[1];
	string str;cin>>str;
	REP(i,N)S[i]=((str[i]=='.') ? 1 : 0);

	int prime=0;
	AB[0]--;AB[1]--;CD[0]--;CD[1]--;
	if(CD[0] < CD[1])prime = 1;

	bool flag = true;

	while(flag){
		//cout << AB[prime] << " " << AB[!prime] << endl;
		while(AB[prime]<CD[prime]){
			if(!move(AB[prime],AB[!prime]))break;}
		if(AB[!prime]!=CD[!prime]){
			if(!slow(AB[!prime],AB[prime]))flag=false;
		}
		else if(AB[prime]>=CD[prime])break;
		else flag = false;
	}

	if(flag)puts("Yes");
	else puts("No");

	return 0;
}



Measured memory_bytes: 772
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$a = (int)$input[0];
$b = (int)$input[1];

if (abs($a) === abs($b)) {
	echo '0';
}elseif (($a+$b)%2 === 0) {
	echo (int)(($a+$b)/2);
}else{
	echo 'IMPOSSIBLE';
}

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B));

    return 0;
}

Measured memory_bytes: 256
#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>;

const double PI = acos(-1);

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double th = double(h*60+m)/720 * 2*PI;
  double tm = double(m)/60 * 2*PI;
  double xh = a*cos(th), yh = a*sin(th);
  double xm = b*cos(tm), ym = b*sin(tm);
  double dx = xh-xm, dy = yh-ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 4104
#include <cstdio>
char str[1005][1005]; 
int main()
{
	// freopen("AGC021-C.in", "r", stdin); 
	int n, m, a, b; 
	scanf("%d%d%d%d", &n, &m, &a, &b); 
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			str[i][j] = '.'; 
	}
	if (m & 1)
	{
		for (int i = 0; i + 1 < n && b; i += 2)
		{
			str[i][m - 1] = '^'; 
			str[i + 1][m - 1] = 'v'; 
			b--; 
		}
	}
	if ((b & 1) && (n & 1) && n >= 3 && m >= 3)
	{
		str[n - 2][m - 3] = '^'; 
		str[n - 1][m - 3] = 'v'; 
		b--; 
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m && b; j++)
		{
			if (str[i][j] == '.' && str[i + 1][j] == '.')
			{
				str[i][j] = '^'; 
				str[i + 1][j] = 'v'; 
				b--; 
			}
		}
	}
	if (b)
	{
		puts("NO"); 
		return 0; 
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j + 1 < m && a; j++)
		{
			if (str[i][j] == '.' && str[i][j + 1] == '.')
			{
				str[i][j] = '<'; 
				str[i][j + 1] = '>'; 
				a--; 
			}
		}
	}
	if (a)
	{
		puts("NO"); 
		return 0; 
	}
	else
	{
		puts("YES"); 
		for (int i = 0; i < n; i++)
			puts(str[i]); 
	}
	return 0; 
}


Measured memory_bytes: 2176
ab = input().split(' ')
st = input().split(' ')
st = [int(x) for x in st]
k = int(ab[1])
max1 =0
pl = sum(st)
for i in range(int(ab[0])-k):
    pl -= min(st)
    del st[st.index(min(st))]


        
print(pl)  

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

int main(int argc, char** argv) {
  string S;
  cin >> S;
  int K;
  cin >> K;
  int N = S.size();

  // Run Length Encoding
  // e.g. issii -> i1s2i2
  vector< pair<char, ll> > cnts;
  rep(i, N) {
    ll cnt = 1;
    while (i < N - 1 && S[i] == S[i+1]) {
      ++cnt;
      ++i;
    }
    cnts.emplace_back(S[i], cnt);
  }

  // For Debug
  // for (auto x : cnts) {
  //   cout << x.first << x.second;
  // }
  // cout << endl;

  if (cnts.size() == 1) {
    cout << cnts[0].second * K / 2 << endl;
  } else {
    if (cnts[0].first == cnts[cnts.size()-1].first) { // The chars of pre and suf are the same
      ll ans = 0;
      ans += cnts[0].second / 2;
      ans += cnts[cnts.size()-1].second / 2;
      ans += (cnts[0].second + cnts[cnts.size()-1].second) / 2 * (K-1);
      for (int i = 1; i < cnts.size() - 1; ++i) {
        ans += cnts[i].second / 2 * K;
      }
      cout << ans << endl;
    } else {
      ll ans = 0;
      for (auto x : cnts) {
        if (x.second > 1) {
          ans += x.second / 2;
        }
      }
      ans *= K;
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 256
// #undef _GLIBCXX_DEBUG

#include <atcoder/dsu>

#include <bits/stdc++.h>
using namespace std;
 
#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif
 
#define ARG4(_1,_2,_3,_4,...) _4
 
#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)
 
#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)
 
#define forv(i,v) for (auto i = v.begin(); i != v.end(); ++i)
#define forr(i,v) for (auto i = v.end(); i != v.begin() && (--i, 1); )
#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;
 
const ld pi = 3.1415926535897932384626433832795l;
 
template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T> inline T abs (T x) {return x > T() ? x : -x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}
 
int main () {
	std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	atcoder::dsu d(n);
	forn(i, q) {
		int tp, u, v;
		cin >> tp >> u >> v;
		if (tp == 0) {
			d.merge(u, v);
		} else {
			bool res = d.same(u, v);
			if (res) {
				cout << 1 << "\n";
			} else {
				cout << 0 << "\n";
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3956