akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            String[] in = br.readLine().split(" ");
            int n = Integer.parseInt(in[0]);
            int m = Integer.parseInt(in[1]);
            int x = Integer.parseInt(in[2]);
            int[] c = new int[n];
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                in = br.readLine().split(" ");
                c[i] = Integer.parseInt(in[0]);
                for (int j = 0; j < m; j++) {
                    a[i][j] = Integer.parseInt(in[j + 1]);
                }
            }

            br.close();

            int ans = (int) 1e9;
            for (int bit = 0; bit < (1 << n); bit++) {
                int acc = 0;
                int[] tmp = new int[m];
                for (int i = 0; i < n; i++) {
                    if ((bit >> i & 1) == 1) {
                        acc += c[i];
                        for (int j = 0; j < m; j++) {
                            tmp[j] += a[i][j];
                        }
                    }
                }
                boolean check = true;
                for (int i = 0; i < m; i++) {
                    if (tmp[i] < x) {
                        check = false;
                    }
                }
                if (check) {
                    ans = Math.min(ans, acc);
                }
            }

            PrintWriter pw = new PrintWriter(System.out);

            pw.println((ans == (int) 1e9) ? -1 : ans);

            pw.flush();

        }
    }
}

Measured memory_bytes: 34272
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll x[60],y[60];
pair<ll,ll> lis[60];
int main(){
	int n,k;
	cin>>n>>k;
	lol(i,n){
		cin>>x[i]>>y[i];
		lis[i]=make_pair(y[i],i);
	}
	sort(lis,lis+n);
	ll ans=(ll)mod*(ll)mod*4;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ll left=lis[i].first;
			ll right=lis[j].first;
			vector<ll> v;
			for(int r=0;r<n;r++){
				if(left<=y[r]&&y[r]<=right){
					v.push_back(x[r]);
				}
			}
			sort(v.begin(),v.end());
			for(int r=k-1;r<v.size();r++){
				ans=min(ans,(v[r]-v[r-k+1])*(right-left));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    int count=0;
    for(int i=0; i<N; i++)
    {
        for(int j=0; ; j++)
        {
            if(A.at(i)%2==0)
            {
                A.at(i)=A.at(i)/2;
                count++;
            }
            else
            {
                break;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3672
D, G = map(int, input().split())
arr = []
n = 0
for i in range(D):
    arr.append([int(c) for c in input().split()])
    n += arr[i][0]

ans = 1e9

for bit in range(1 << D):
    sum = 0
    num = 0
    rest_max = -1
    for i in range(D):
        if bit & 1 << i:
            sum += 100 * (i + 1) * arr[i][0] + arr[i][1]
            num += arr[i][0]
        else:
            rest_max = i

    if sum < G:
        p = 100 * (rest_max + 1)
        need = (G - sum + p - 1) // p
        if need >= arr[rest_max][0]:
            continue
        num += need
    ans = min(ans, num)

print(ans)


Measured memory_bytes: 41456
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long a[n];
    long ans = 1;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i] == 0)ans = 0;
    }
    

    if(ans == 0)cout<<0<<endl;
    else{
        for(int i=0;i<n;i++){
            if((1000000000000000000L)/ans >= a[i])ans *= a[i];
            else{
                ans = -1;
                break;
            }
        }
        cout << ans << endl;
        
        
    }
}

Measured memory_bytes: 4404
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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


	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;

	if (s == u)cout << a - 1 << ' ' << b << endl;
	else cout << a << ' ' << b - 1 << endl;


	return 0;
}

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

long long N;
long long a, b, c, d, e, k;
int main(){
    long long v[5];
    cin >> N;
    for(int i=0; i<5; i++)
	cin >> v[i];

    long long min = v[0];

    for(int i=0; i<5; i++){
	if(min > v[i])
	    min = v[i];	
    }

    a = N / min;
    b = N % min;
    if( b > 0)
	a++;	
    
    cout << 5 + a -1 << "\n";
 }




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
    int n;
    while (cin >> n && n) {
        unordered_map<int, int> pos;
        vector<pair<int, ll>> res(4001);
        for (int i=1; i<=n; ++i) {
            int no;
            ll price, quantity;
            cin >> no >> price >> quantity;
            if ( ! pos[no]) {
                pos[no] = i;
                res[pos[no]].first = no;
            }
            res[pos[no]].second += price * quantity;
        }

        bool NA = true;
        for (int i=0; i<(int)res.size(); ++i) {
            if (res[i].second >= 1000000) {
                cout << res[i].first << endl;
                NA = false;
            }
        }
        if (NA)
            cout << "NA" << endl;
    }
    return 0;
}

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

const int MOD = 1000000007;

class ModInt
{
public:
    int64_t x;
    ModInt(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    ModInt operator-() const { return ModInt(-x); }
    ModInt &operator+=(const ModInt a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    ModInt &operator-=(const ModInt a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    ModInt &operator*=(const ModInt a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    ModInt operator+(const ModInt a) const { return ModInt(*this) += a; }
    ModInt operator-(const ModInt a) const { return ModInt(*this) -= a; }
    ModInt operator*(const ModInt a) const { return ModInt(*this) *= a; }
    ModInt pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        ModInt t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    ModInt inv() const { return pow(MOD - 2); }
    ModInt &operator/=(const ModInt a) { return *this *= a.inv(); }
    ModInt operator/(const ModInt a) const { return ModInt(*this) /= a; }
};
istream &operator>>(istream &is, const ModInt &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const ModInt &a) { return os << a.x; }

void solve(int N)
{
    cout << ModInt(10).pow(N) - ModInt(9).pow(N) * 2 + ModInt(8).pow(N) << endl;
}

int main()
{
    int N;
    cin >> N;
    solve(N);
    return 0;
}


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

int main(void) {
  int n;
  cin >> n;

  int pt=0,px=0,py=0;
  for (int i = 0; i < n; i++) {
    int t,x,y;
    cin >> t >> x >> y;

    int d=x-px+y-py;
    int dt=t-pt;
    if(!(d<=dt && d%2==dt%2)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array = new int[3];
		for(int i=0; i<array.length; i++){
			array[i] = sc.nextInt();
		};
		int[] SUM = new int[array[0]];
		int sumsum = 0;
		for(int i=1; i<=array[0]; i++){
			String s = String.valueOf(i);
			char[] c = s.toCharArray();
			int ss = 0;
			for(int j=0; j<c.length; j++){
				ss += Character.getNumericValue(c[j]);
			};
			if (array[1] <= ss && ss <= array[2]) {
				sumsum += i;
			}
		};
		System.out.println(sumsum);
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define inf 9e18
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
using namespace std;
int dp[100005][3];
int solve(int pos,int act,int a[][3],int &n){
    if(pos==n)
        return 0;
    if(dp[pos][act]!=-1)
        return dp[pos][act];
    int ans = a[pos][act];
    for(int i=0;i<3;i++){
        if(i==act)
            continue;
        ans = max(ans,a[pos][act] + solve(pos+1,i,a,n));
    }
    return dp[pos][act] = ans;
}
int32_t main()
{
    
    fastio
    int n;
    cin>>n;
    int a[n][3];

    
    for(int i=0;i<n;i++)
        for(int activity=0;activity<3;activity++)
            cin>>a[i][activity],dp[i][activity]=-1;

    int ans = 0;
    for(int i=0;i<3;i++)
        ans = max(ans,solve(0,i,a,n));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 14336
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<=((int)n);++i)
#define rev(i,n,j) for(int i=(n);i>=((int)j);--i)
typedef long long int ll;
#define int long long int
const ll INFL=0x3f3f3f3f3f3f3f3fLL;
const int INF=0x3f3f3f3f;
const int mod=998244353;
#define endl "\n"
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define readmat(a, n, m) int a[n + 5][m + 5] = {}; rep(i, 1, n) {rep(j, 1, m) cin >> a[i][j];}
#define printmat(a, n, m) rep (i, 1, n) {rep (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define printarr(a, n) rep(i, 1, n) cout << a[i] << " "; cout << endl;
typedef std::map< int,int> mii;
typedef std::vector< int > vi;
typedef std::vector< vi > vvi;
typedef std::pair< int,int > ii;
using namespace std;
#define cerr cout
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);}
const int N = 1e6+5, M = N;
vector <int>g[N];

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}

void solve()
{
	int n,s;
	cin>>n>>s;
	int a[n+5];
	for(int i = 1; i <=n; ++i) 
	{
		cin>>a[i];
	}

	int dp[n+5][s+5];
	mem(dp,0);
	dp[0][0]=power(2,n);

	int inv=power(2,mod-2);

	for(int i = 1; i <=n; ++i) 
	{
		for(int j =0; j <=s; ++j) 
		{
			if (j<a[i])
			{
				dp[i][j]=dp[i-1][j];
				continue;
			}
			dp[i][j]=(dp[i][j]+dp[i-1][j]+(dp[i-1][j-a[i]]*inv)%mod)%mod;
		}
	}


	cout<<dp[n][s]<<endl;
  

}



signed main()
{
  FAST;
#ifdef LOCAL
    freopen("C:\\Users\\hp\\Documents\\input.txt", "r", stdin);
    freopen("C:\\Users\\hp\\Documents\\output.txt", "w", stdout);
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
#endif

solve();

#ifdef LOCAL
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cout<<endl;
    cout << "\nElapsed Time: " << elapsed_time << "ms\n";
#endif

return 0;

}

// vector string set map first second continue break return upper_bound lower_bound length void sort
// stack queue pop size erase empty insert
// #Hala BBCF



Measured memory_bytes: 97624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
K = INT()

ans = 1
for _ in range(N):
	ans = min(ans*2, ans+K)

print(ans)

Measured memory_bytes: 5712
import sys
input = sys.stdin.readline
from bisect import *

def judge(x):
    cnt = 0
    
    for Ai in A:
        cnt += N-bisect_left(A, x-Ai)
    
    return cnt>=M

def binary_search():
    l, r = 0, 10**10+100
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            l = m+1
        else:
            r = m-1
    
    return r

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
acc = [0]

for Ai in A:
    acc.append(acc[-1]+Ai)

b = binary_search()
ans = 0
cnt = 0

for Ai in A:
    i = bisect_left(A, b+1-Ai)
    ans += (N-i)*Ai+acc[N]-acc[i]
    cnt += N-i

ans += (M-cnt)*b
print(ans)


Measured memory_bytes: 58160
import sys
from collections import defaultdict,deque
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def unite(x,y):
    x = root(x)
    y = root(y)
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

f = defaultdict(int)
par = defaultdict(int)
rank = defaultdict(int)
n = int(sys.stdin.readline())
for i in range(n):
    a,x = sys.stdin.readline().split()
    f[a] = int(x)
    par[a] = a
    rank[a] = 0

m = int(sys.stdin.readline())
for i in range(m):
    x,y = sys.stdin.readline().split()
    if root(x) != root(y):
        unite(x,y)

ans = 0
for i in f.keys():
    root(i)
    f[par[i]] = min(f[par[i]],f[i])
for i in f.keys():
    ans += f[root(i)]
print(ans)



Measured memory_bytes: 6864
from math import log2
N = int(input())
a = list(map(int, input().split()))
Maxa = max(a)
if(Maxa == 0):
  for i in range(N):
    print(0, end = " ")
else:
  J = int(log2(Maxa)) + 1
  A = [format(x, 'b').zfill(J) for x in a]
  S = [0] * J
  for j in range(J):
    for i in range(N):
      S[j] += int(A[i][j])
    S[j] %= 2

  X = [""] * N
  for i in range(N):
    for j in range(J):
      X[i] += str(int((int(A[i][j]) != S[j])))
    print(int(X[i], 2), end = " ")

Measured memory_bytes: 122872
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
using namespace std;

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


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int total = 0;
		if(a>b) {
			total+=2*a-1;
		}else if(a==b) {
			total+=2*a;
		}else {
			total+=2*b-1;
		}
		System.out.println(total);

	}
	}


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

struct edge { int to, cost; };
typedef pair<int, int> P;
const int MAX_V = 100010;
const ll INF = 1e18;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;

		for (int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	cin >> V;
	for (int i = 0; i < V - 1; i++){
		int a, b, c;
		cin >> a >> b >> c;
		G[a - 1].push_back({b - 1, c});
		G[b - 1].push_back({a - 1, c});
	}

	int Q, K;
	cin >> Q >> K;
	vector<int> x(Q), y(Q);
	for (int i = 0; i < Q; i++){
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
	}

	dijkstra(K - 1);
	for (int i = 0; i < Q; i++){
		ll res = d[x[i]] + d[y[i]];
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[55][3][3][3][3];
string f[2];
int n;
int main(){
	cin >> n; cin >> f[0] >> f[1];
	if(n==1){
		cout << 3 << endl; return 0;
	}
	rep(i,3)rep(j,3)rep(k,3)rep(l,3){
		if(f[0][0] == f[0][1] && i != k) continue;
		if(f[0][0] == f[1][0] && i != j) continue;
		if(f[1][0] == f[1][1] && j != l) continue;
		if(f[0][1] == f[1][1] && k != l) continue;
		if(f[0][0] != f[0][1] && i == k) continue;
		if(f[0][0] != f[1][0] && i == j) continue;
		if(f[1][0] != f[1][1] && j == l) continue;
		if(f[0][1] != f[1][1] && k == l) continue;
		dp[1][i][j][k][l] = 1;
	}
	for(int x=2;x<n;x++){
		rep(i,3)rep(j,3)rep(k,3)rep(l,3){
			if(dp[x-1][i][j][k][l] == 0) continue;
			rep(a,3)rep(b,3){
				if(f[0][x-1] == f[0][x] && a != k) continue;
				if(f[1][x-1] == f[1][x] && b != l) continue;
				if(f[0][x-1] != f[0][x] && a == k) continue;
				if(f[1][x-1] != f[1][x] && b == l) continue;				
				if(f[0][x] == f[1][x] && a != b) continue;
				if(f[0][x] != f[1][x] && a == b) continue;
				dp[x][k][l][a][b] = dp[x][k][l][a][b]+dp[x-1][i][j][k][l];
				dp[x][k][l][a][b]%=mod;
			}
		}
	}
	ll ret = 0;
	rep(i,3)rep(j,3)rep(k,3)rep(l,3) ret = (ret+dp[n-1][i][j][k][l])%mod;
	cout << ret << endl;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var strs = new HashSet<string>();
        var contents = new string[num];
        for(var i = 0; i < num; i++)
        {
            contents[i] = ReadLine();
        }
        var isShiritori = true;
        for(var i = 0; i < num; i++)
        {
            if (strs.Contains(contents[i])) { isShiritori = false;break; }
            if (i != 0)
            {
                if (contents[i - 1].Substring(contents[i - 1].Length - 1, 1) != contents[i].Substring(0, 1)) { isShiritori = false; break; }
            }
            strs.Add(contents[i]);
        }
        WriteLine(isShiritori ? "Yes" : "No");
    }
}



Measured memory_bytes: 13280
#include <stdio.h>

int main(void)
{
	int s[10000], t[500], u[500];
	int c = 0;
	int n, q;
	int i, j, k;
	int flag;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &t[i]);
	}

	for (i = 0; i < q; i++) {
		for (j = 0; j < n; j++) {
			if (t[i] == s[j]) {
				flag = 0;
				for (k = 0; k < c; k++) {
					if (u[k] == s[j]) {
						flag = 1;
					}
				}
				if (flag == 0) {
					u[c] = s[j];
					c++;
				}
			}
		}
	}

	printf("%d\n", c);

	return 0;
}


Measured memory_bytes: 1928
//  Author : Amit Kumar 

#include <iostream>
#include <algorithm> 
#include <string> 
#include <sstream>
#include <fstream>
#include <iomanip> 
#include <chrono> 
#include <numeric> 
#include <utility>
#include <functional>

#include <bitset>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <deque>
#include <list>


#include <climits>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdio>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace std::chrono;
//  using namespace placeholders;
using namespace __gnu_pbds;
template<typename TypeInfo>
using new_set = tree< 
/* ob.order_of_key(element) -> number of element strictly less than element
 * *ob.find_by_order(n) ->  nth element in increasing order
 */
         TypeInfo ,
         null_type ,
         less<TypeInfo> ,
         rb_tree_tag ,
         tree_order_statistics_node_update 
 > ;

void show_me() { cerr << endl; }
 
template <typename HEAD, typename... TAIL>
void show_me(HEAD H, TAIL... T) {
  cerr << " " << (H);
  show_me(T...);
}
 
#ifdef HELL_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "]:", show_me(__VA_ARGS__)
#else
#define show(...) 0
#endif
 
template<typename A, typename B>
ostream& operator<<(ostream&out, const pair<A, B>&p){
    out << p.first << ' ' << p.second ;
    return out;
}

template<typename A, typename B>
istream& operator>>(istream&in, pair<A, B>&p){
    in >> p.first >> p.second ;
    return in;
}

template<typename A> 
istream& operator>>(istream&in, vector<A>&vec){
    for(auto&itr:vec){
        in >> itr;
    }
    return in;
}

template<typename A>
ostream& operator<<(ostream&out,const vector<A>&vec){
    for(auto&itr:vec){
        out << itr <<' '; // VVV 
    }
    return out;
}

const int MAXM = (int)1e5+100;
const int MAXN = (int)1e5+100;
const int MOD  = (int)1e9+7;




signed main(void){
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    ios::sync_with_stdio(false); // FLUSH THE STREAM IF USING puts / printf / scanf/
    cin.tie(nullptr);            //
    cout.tie(nullptr);           //
#ifdef HELL_JUDGE
    auto INITIAL_TIME = high_resolution_clock::now();
#endif 

    int n; cin >> n; 
    int64_t sum{};
    vector<int64_t>v(MAXN);
    for(int x,i=0;i<n;++i){
        cin >> x; v[x]++;
        sum+=x;
    }
    int q; cin >> q; 
    while(q--){
        int64_t b,c; cin >> b >> c; 
        sum -=(v[b]*b);
        sum -=(v[c]*c);
        v[c]+=v[b];
        sum+=(v[c]*c);
        v[b]=0;
        cout << sum << '\n'; 
    }

#ifdef HELL_JUDGE
    auto FINAL_TIME = high_resolution_clock::now();
    cout << "Time : "
         << duration_cast<milliseconds>(FINAL_TIME-INITIAL_TIME).count() 
         << " ms" << '\n'; 
#endif 
    return 0;
}


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

int main(){
  int a,b;
  long int ans;
  char op;
  cin>>a>>op>>b;
   
  if(op=='+')ans=a+b;
  else if(op=='-')ans=a-b;
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3572
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
temp=[]
for i in range(n):
    for _ in range(a[i]):
        temp.append(i+1)

ans=[]
for j in range(h):
    if j%2==0:
        ans.append(list(temp[j*w:(j+1)*w]))
    else:
        ans.append(list(temp[(j+1)*(w)-1:j*w-1:-1]))
   
        

for k in ans:
    ans2=[str(v) for v in k]
    print(" ".join(ans2))

Measured memory_bytes: 9496
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var vs = new List<string>
        {
            "Sunny",
            "Cloudy",
            "Rainy"
        };

        string S = Console.ReadLine();

        int index = vs.FindIndex(s => s.Equals(S));
        Console.WriteLine(vs[(index + 1) % 3]);
	}
}


Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
typedef long long int LL;
using namespace std;
int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(A*C<=B)
        printf("%d\n",C);
    else
        printf("%d\n",(int)B/A);
    return 0;
}


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

typedef struct List {
	struct List *prev, *next;
	char color;
} list;

int main()
{
	char S[100001];
	scanf("%s", S);
	
	int i, ans = 0;
	list L[100001], *p;
	L[0].prev = NULL;
	L[0].next = NULL;
	L[0].color = S[0];
	for (i = 1; S[i] != 0; i++) {
		L[i-1].next = &(L[i]);
		L[i].prev = &(L[i-1]);
		L[i].next = NULL;
		L[i].color = S[i];
	}
	for (p = L[0].next; p != NULL; p = p->next) {
		if (p->prev != NULL && p->color != p->prev->color) {
			ans += 2;
			if (p->prev->prev != NULL) p->prev->prev->next = p->next;
			if (p->next != NULL) p->next->prev = p->prev->prev;
		}
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream> // cout, endl, cin
#include <vector> // vector
using namespace std;

int main(){
    int N,counter;
    cin>>N;
    string S;
    cin>>S;
    counter=0;
    for(int i=0;i<N-1;i++){
        while(S.at(i)==S.at(i+1)){
            counter=counter+1;
            i=i+1;
            if(i==N-1){
                break;
                }
        }
    }
    cout<<N-counter<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N;
    while (cin >> N) {
        vector<long long> A(N);
        for (int i = 0; i < N; ++i) cin >> A[i];

        long long res = 1;
        for (int i = 0; i < N; ++i) res *= 3;

        long long sub = 1;
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 == 0) sub *= 2;
            else sub *= 1;
        }
        cout << res - sub << endl;
    }
}


















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

using namespace std;

int main(void) {
	int n;
	int p;
	int q = 0;
	cin >> n;
	p = n;
	for (int i = 1; i <= p; i++) {
		q += i;
	}
	cout << q << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

var infty = 1000000 * 2

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := nextInt()
	a := make([]int, n)
	for i := range a {
		a[i], _ = nextInt()
	}

	aMin := infty
	aMax := -infty
	aSum := 0
	for i := range a {
		if a[i] < aMin {
			aMin = a[i]
		}
		if a[i] > aMax {
			aMax = a[i]
		}
		aSum += a[i]
	}
	fmt.Println(aMin, aMax, aSum)
}



Measured memory_bytes: 1260
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        _n: usize, a: usize1, b: usize1, c: usize1, d: usize1,
        s: chars
    }

    println!("{}", if calc(&s, a, b, c, d) {"Yes"} else {"No"});
}

fn calc(s: &[char], a: usize, b: usize, c: usize, d: usize) -> bool {
    if !can_reach(s, b, d) {
        return false;
    }
    if d < c {
        let mut sm = s.to_vec();
        let mut is_modified = false;
        for i in b-1..d {
            if i+2 < s.len() && sm[i] == '.' && sm[i+1] == '.' && sm[i+2] == '.' {
                sm[i+1] = '#';
                is_modified = true;
                break;
            }
        }
        if !is_modified {
            return false;
        }
        can_reach(&sm, a, c)
    } else {
        can_reach(s, a, c)
    }
}

fn can_reach(s: &[char], start: usize, goal: usize) -> bool {
    for i in start..goal {
        if s[i] == '#' && s[i+1] == '#' {
            return false;
        }
    }
    true
}


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

int main() {
    int     N;
    cin >> N;
    
    while ( 1 ) {
        N = N - 1000;
        if ( N <= 0 ) {
            N = -N;
            break;
        }
    }
    
    cout << N << endl;
    
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N);
  long count = 0, ans = 0, minnum = 100000000000;
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
    if(data.at(i) < 0){
      count++;
      data.at(i) *= -1;
    }
    ans += data.at(i);
    minnum = min(minnum, data.at(i));
  }
  if(count % 2 == 1)ans -= minnum * 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
class Edge
  attr_reader :s, :e, :z

  def initialize(s, e, z)
    @s = s
    @e = e
    @z = z
  end
end

class Graph
  def initialize(n,edges)
    @city = n
    @dist = Array.new(n).map{Array.new(n,Float::INFINITY)}
    edges.each do |edge|
      @dist[edge.s][edge.e] = @dist[edge.e][edge.s] = [@dist[edge.e][edge.s], edge.z].min
    end
  end

  def warshall_floyd
    @city.times{|i| @dist[i][i] = 0}
    @city.times do |k|
      @city.times do |i|
        @city.times do |j|
          @dist[i][j] = [@dist[i][j], @dist[i][k] + @dist[j][k]].min if(@dist[i][j] > @dist[i][k] + @dist[k][j])
        end
      end
    end
    @dist
  end
end


n, m, r = gets.chomp.split(" ").map(&:to_i)
input = gets.chomp.split(" ").map{|i| i.to_i.pred}
query = input.permutation(r)

edges = []

m.times do
  s, e, z = gets.chomp.split(" ").map(&:to_i)
  edges << Edge.new(s.pred, e.pred, z)
end

graph = Graph.new(n,edges)
dist = graph.warshall_floyd

score = []
query.each do |route|
  score << route.each_cons(2).map{|a,b| dist[a][b]}.inject(&:+)
end
p score.min

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int n ;
  cin >> n ;
  vector<ll> luc(n+1) ;
  luc.at(0) = 2 ;
  luc.at(1) = 1 ;
  REP(i,n-1){
    luc.at(i+2) = luc.at(i+1) + luc.at(i) ;
  }
  
  cout << luc.at(n) <<endl;

  return 0 ;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  char X, Y; cin >> X >> Y;
  if (X < Y) cout << '<' << endl;
  else if (X == Y) cout << '=' << endl;
  else cout << '>' << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int a, b, c,ans;
    scanf("%d%d%d", &a, &b, &c);
    if (a + b >= c) {
        ans = b + c;
    } else {
        if (c - 1 <= b) {
            ans = b + c;
        } else {
            ans = a + b + 1 + b;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

bool Free[200];
string s;

int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
        if(Free[s[i]]==false)
            Free[s[i]]=true;
        else
        {
            cout<<"no";
            return 0;
        }
    cout<<"yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int A, B;
  rd(A);
  rd(B);
  if(A==1){
    A = 14;
  }
  if(B==1){
    B = 14;
  }
  if(A>B){
    wt_L("Alice");
    wt_L('\n');
  }
  else if(A<B){
    wt_L("Bob");
    wt_L('\n');
  }
  else{
    wt_L("Draw");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int A, B;
//   rd(A, B);
//   if(A==1) A = 14;
//   if(B==1) B = 14;
//   wt( if[A>B, "Alice", A<B, "Bob", "Draw"] );
// }


Measured memory_bytes: 256
import heapq
import sys

N = int(input())
a = [[] for i in range(N)]
for i in range(N - 1):
	u, v, w = map(int, input().split())
	a[u - 1].append([v - 1, w])
	a[v - 1].append([u - 1, w])
b = [[0, 0]]
c = [False] * N
d = [sys.maxsize] * N
d[0] = 0
while len(b):
	e = heapq.heappop(b)
	c[e[1]] = True
	for i in a[e[1]]:
		if c[i[0]]:
			continue
		if d[e[1]] + i[1] < d[i[0]]:
			d[i[0]] = d[e[1]] + i[1]
			heapq.heappush(b, [d[i[0]], i[0]])
for i in d:
	print(i % 2)

Measured memory_bytes: 49984
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  int cnt = 0;
  rep(i, 4)
  {
    char c;
    cin >> c;
    cnt += (c == '2');
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    while(k and b<=a)
    {
    	k--;
    	b *= 2;
    }
    if(b<=a) cout<<"No";
    else
    {
    	while(k and c<=b)
    	{
    		k--;
    		c *= 2;
    	}

    	if(c<=b) cout<<"No";
    	else cout<<"Yes";
    }
}

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


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

#define ARRAY_MAX 100005

const ll INF = 1 << 30;
const ll MOD = 1000000007;


int main() {

	ll n;
	cin >> n;

	vector<pll> A(n);
	for (int i = 0; i < n; i++)
	{
		cin >> A[i].first >> A[i].second;
	}

	sort(A.begin(), A.end());
	   	  
	vector<ll> sum(n + 10, 0);

	for (int i = 1; i <= n; i++)
	{
		sum[i] = sum[i - 1] + A[i - 1].second;
	}

	ll maxi = 0;
	ll m = 0;

	for (int i = 1; i <= n; i++)
	{
		m = max(m,A[i - 1].first - sum[i - 1]);
		maxi = max(maxi,sum[i] - A[i - 1].first + m);
	}

	cout << maxi << endl;

	return 0;
}



Measured memory_bytes: 14448
#include<stdio.h>
 
int main(void)
{
 int i=0, n=0, m=0;
 char s[100000];
  
 scanf("%s",s);

 while(s[i]=='0' || s[i]=='1') {
    if(s[i]==s[i+1]){
       if     (s[i+1]=='1') s[i+1]='0';
       else if(s[i+1]=='0') s[i+1]='1';
       n++;
    }
    i++;
 }
  
  printf("%d\n", n);
 
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main() 
{long long a,b,x,y;
 cin>>a>>b;
 long long start=1;
 while(1)
 {x=(start*8)/100,y=(start*10)/100;
  if(x==a && y==b){cout<<start;break;}
 else if(x>a || y>b){cout<<-1;break;}
 start++;
 }
 return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
    long long k,a,b;
    bool ans = false;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++) {
        if(i % k == 0 ) ans = true;
        else continue;
    }   
    if(ans) cout << "OK" << endl;
    else cout << "NG" << endl;
}


Measured memory_bytes: 3620
n = int(input())
i = 1
ans = ['']
while True :
    x = i
    if x > n :
        break
    if x % 3 == 0 :
        ans.append(i)
    else :
        while x != 0 :
            if x % 10 == 3 :
                ans.append(i)
                break
            else :
                x = x // 10 
    i += 1
print(*ans)


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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+100000000
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}


vector<ll> A[300005];
set<pair<ll, ll> > g;


void solve() {
           
           g.clear();
           
           ll H, W;
           cin >> H >> W;
           
           ll M;
           cin >> M;
           
           for(ll i = 1; i <= W; i++) {
                    A[i].clear();
           }
           
           
           ll row[H + 1] = {0};
           ll column[W + 1] = {0};
           
           for(ll i = 1; i <= M; i++) {
                    ll a, b;
                    cin >> a >> b;
                    row[a]++;
                    column[b]++;
                    A[b].pb(a);
           }
           
           for(ll i = 1; i <= H; i++) {
                g.insert({row[i], i});
           }
           
           ll ma = 0LL;
           
           for(ll i = 1; i <= W; i++) {
                    ll ma1 = 0LL;
                    for(auto it : A[i]) {
                            ma1 = max(ma1, row[it]);
                    }
                    
                    if(A[i].size() >= 1) {
                            ma = max(ma, column[i] + ma1 - 1);
                    }
                    for(auto it : A[i]) {
                            g.erase({row[it], it});
                    }
                   
                    
                    if(g.size() >= 1) {
                            auto it = g.end();
                            it--;
                            ma = max(ma, column[i] + (*it).first);
                    }
                    
                    for(auto it : A[i]) {
                            g.insert({row[it], it});
                    }
               
           }
           
           cout << ma << endl;
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 43472
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

signed main(void) {

	int n, m,s,t;
	cin >> n >> m;
	vector<vector<Edge>> g(n);
	REP(i, m) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back({ u,v,1 });
	}
	cin >> s >> t;
	s--, t--;

	priority_queue<pair<int, pii>, vector<pair<int,pii>> , greater<pair<int,pii>>> pq;
	vector<array<int, 3>> dist(n, array<int, 3>{-1,-1,-1});
	pq.push({ 0, {s,2} });

	while (pq.size()) {

		auto cur = pq.top();
		pq.pop();

		if (dist[cur.second.first][cur.second.second] != -1) {
			continue;
		}

		dist[cur.second.first][cur.second.second] = cur.first;

		for (auto itr : g[cur.second.first]) {

			pq.push({ cur.first + (cur.second.second == 1), {itr.to, (cur.second.second + 1)%3} });

		}

	}

	printf("%d\n", dist[t][2]);
	
return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <string>
using namespace std;
int N,M,K;
typedef long long ll;

int main(){

    map<string,ll> a;

    cin >> N;
    for(int i=0;i<N;i++){
        string tmp;
        cin >> tmp;
        sort(tmp.begin(),tmp.end());
        a[tmp] += 1 ;
        
    }
    ll ans=0;
    for(auto e:a){
        ll tmp = e.second*(e.second-1)/2; 
        ans += tmp;
    }
        cout << ans << endl;
    
}

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

int main(void) {
  int n;
  int sum1 = 0, sum2 = 0;
  char card1[101], card2[101];
  int i;
  int d;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) {
    scanf("%s", card1);
    scanf("%s", card2);
    d = strcmp(card1, card2);
    if (d == 0) {
      sum1++;
      sum2++;
    }
    else if (d > 0)
      sum1 = sum1 + 3;
    else if (d < 0)
      sum2 = sum2 + 3;
  }

  printf("%d %d\n", sum1, sum2);
  
  return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



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

	int m = 9999999,a,b;
	for (int i = 0; i < n; i++) {
		a = 0; b = 0;
		for (int j = 0; j < n; j++) {
			if (j <= i) a += w[j];
			else b += w[j];
		}
		a = abs(a-b);
		m = min(m,a);
	}
	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256