akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/agc030/tasks/agc030_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main(){
    LL A,B,C;
    cin>>A>>B>>C;
    cout<<B+min(A+B+1,C)<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
A = deque(input())
B = deque(input())
C = deque(input())

p = A.popleft()
while True:
    if p == 'a':
        if len(A) == 0:
            print("A")
            exit()
        p = A.popleft()
    elif p == 'b':
        if len(B) == 0:
            print("B")
            exit()
        p = B.popleft()
    elif p == 'c':
        if len(C) == 0:
            print("C")
            exit()
        p = C.popleft()

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

long long N, X[200009], E[200009], G;

vector<long long> solve() {
	G = X[0];
	for (int i = 1; i < N; i++) {
		if (G <= X[i]) { G = X[i]; E[i] = 0; }
		else {
			if (X[i - 1] >= X[i]) {
				for (int j = 0; j < 16; j++) {
					if (X[i - 1] <= (1LL << (2 * j))*X[i]) { E[i] = E[i - 1] + j; break; }
				}
			}
			else {
				for (int j = 0; j < 16; j++) {
					if ((1LL << (2 * j)) * X[i - 1] > X[i]) { E[i] = E[i - 1] - (j - 1); break; }
				}
			}
			G = X[i];
			for (int j = 0; j < E[i]; j++) {
				G *= 4; if (G >= (1LL << 60)) { G = (1LL << 60); break; }
			}
		}
	}

	long long sum = 0, ret = 0, retsum = 0, pos = 0; for (int i = 0; i < N; i++) sum += E[i];
	vector<long long>res; res.push_back(sum * 2);

	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			long long JURAI = E[j]; if (j > pos) JURAI -= retsum;

			if (j == i + 1) {
				E[i + 1] = 0; G = X[i + 1];
			}
			else {
				if (G <= X[j]) { G = X[j]; E[j] = 0; }
				else {
					if (X[j - 1] >= X[j]) {
						for (int k = 0; k < 36; k++) {
							if (X[j - 1] <= (1LL << (2 * k))*X[j]) { E[j] = E[j - 1] + k; break; }
						}
					}
					else {
						for (int k = 0; k < 16; k++) {
							if ((1LL << (2 * k)) * X[j - 1] > X[j]) { E[j] = E[j - 1] - (k - 1); break; }
						}
					}
				}
			}
			G = X[j];
			for (int k = 0; k < E[j]; k++) {
				G *= 4; if (G >= (1LL << 60)) { G = (1LL << 60); break; }
			}
			sum -= (JURAI - E[j]);
			if (E[j] >= 15 || j == N - 1 || JURAI - E[j] == 0) {
				ret = JURAI - E[j]; retsum += ret; pos = max(pos, 1LL * j); sum -= ret * (N - pos - 1);
				res.push_back(sum * 2);
				break;
			}
		}
	}
	res.push_back(0);
	return res;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i];

	vector<long long> v1 = solve(); reverse(X, X + N);
	vector<long long> v2 = solve();
	reverse(v2.begin(), v2.end());
	long long minx = (1LL << 60);
	for (int i = 0; i <= N; i++) minx = min(minx, v1[i] + v2[i] + i);
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 8048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  ll a,b,n;cin>>a>>b>>n;
  ll q=n%b;
  ll p=n/b;
  if(p==0){
    cout<<(a*q)/b<<endl;
  }else{
    cout<<(a*(b-1))/b<<endl;
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 200005;

vi G[N], s;
int ans[N], a[N];

void dfs(int u, int p = -1) {
	if(s.empty() || a[u] > s.back()) {
		s.PB(a[u]);
		ans[u] = s.size();
		for(int v:G[u]) if(v != p)
			dfs(v, u);
		s.pop_back();
	} else {
		int pos = lower_bound(ALL(s), a[u]) - s.begin();
		int tt = s[pos];
		s[pos] = a[u];
		ans[u] = s.size();
		for(int v:G[u]) if(v != p)
			dfs(v, u);
		s[pos] = tt;
	}
}

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		G[u].PB(v);
		G[v].PB(u);
	}
	dfs(1);
	for(int i = 1; i <= n; i++)
		cout << ans[i] << endl;
}





Measured memory_bytes: 27648
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        long sum = 0;
        int n = Integer.parseInt(f.readLine());
        for(int i = 1; i <= n; i++){
            if(i % 3 != 0 && i % 5 != 0) sum+=i;
        }
        out.println(sum);
        out.close();
    }
}


Measured memory_bytes: 32864
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int N;
    int X[100];
    int sum = 0;
    int i;
    int avg;

    scanf("%d", &N);
    for(i=0;i<N;i++)
    {
        scanf("%d", &X[i]);
        sum += X[i];
    }

    avg = sum / N;
    avg = ((sum % N) < N - (sum % N)) ? avg : avg + 1;
    
    sum = 0;
    for (i = 0; i < N; i++)
    {
        sum += (X[i]-avg)*(X[i]-avg);   
    }

    printf("%d", sum);

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    static public void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        scan.close();

        if (a * b % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }

    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

#define first start 
#define second goal 

using namespace std;

const int NONE = -1;
const int MAX = 1000000000;

struct sector {
	int length, id;	
	sector(int id_, int length_): id(id_), length(length_) {}
};

vector<sector> sys;
int pos;


void read(int pos) {
	int idx = 0;
	//rep(i, sys.size()) { cout << sys[i].id << "," << sys[i].length << " ";} cout << endl;
	rep(i, sys.size()) {
		idx += sys[i].length;
		if(idx > pos) {
			cout << sys[i].id << endl;	
			return;
		}
	}
	cout << -1 << endl;
}

void write(int id, int size) {

	if(sys.size() == 0) {
		sys.push_back(sector(id, size));	
		return;
	}

	int n = sys.size();
	rep(i, n) {
		if(sys[i].id != -1) continue;
		
		vector<sector>::iterator it = sys.begin()+i;
		if(sys[i].length == size) {
			sys[i].id = id;	
			return;
		}
		else if(sys[i].length - size > 0){
			sys.insert(it+1, sector(-1, sys[i].length - size));
			sys[i].id = id;
			sys[i].length = size;
			return;
		}
		else if(sys[i].length - size < 0) {
			sys[i].id = id;
			size -= sys[i].length;
		}
		if(size <= 0) return;
	}
	sys.push_back(sector(id, size));

	return;
}

void del(int id) {
	rep(i, sys.size()) {
		if(sys[i].id == id) sys[i].id = -1;	
	}
}

int main() {
	int n, m;
	while(cin >> n, n) {
		
		sys.clear();

		char cmd;
		rep(i, n) {
			cin >> cmd;	
			if(cmd == 'W') {
				int id, size;
				cin >> id >> size;
				write(id, size);
			}
			else if(cmd == 'D') {
				int id;
				cin >> id;
				del(id);
			}
			else if(cmd == 'R') {
				int pos;
				cin >> pos;
				read(pos);
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1304
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int N,M,X,Y;
    while (cin >> N >> M >> X >> Y) {
        VI A(N), B(M);
        FOR(i,0,N)
            cin >> A[i];
        FOR(i,0,M)
            cin >> B[i];
        string ans = "War";
        FOR(z,-200,200) if (X < z && z <= Y) {
            bool good = true;
            FOR(i,0,N)
                good &= A[i] < z;
            FOR(i,0,M)
                good &= B[i] >= z;
            if (good) {
                ans = "No War";
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll N,M,A[3000],B[3000],C=0;
vector<vector<ll>> TEN(57);
ll touri[57];

void kentou(ll a,ll b,ll t){
  t++;
  touri[a]=1;
  if(a==b){
    C++;
    return;
  }
  rep(i,TEN[a].size()){
    if(touri[TEN[a][i]]==0 && (t!=1 || TEN[a][i]!=b)){
      kentou(TEN[a][i],b,t);
    }
  }
}

int main(){
  cin >> N >> M;
  rep(i,M){
    cin >> A[i] >> B[i];
    TEN[A[i]].push_back(B[i]);
    TEN[B[i]].push_back(A[i]);
  }
  rep(i,M){
    kentou(A[i],B[i],0);
    rep(j,57){
      touri[j]=0;
    }
  }
  cout << M-C <<  endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll used[1000005];
bool mark[1005][1005];

int main()
{
	// start_routine();
	fastio;
	

    ll n,m;cin>>n>>m;
    ll a[n],b[m];
    bool mr[n]={0},mc[m]={0};
    set<ll> r,c;
    
    for(ll i=0;i<n;i++)
    {
    	cin>>a[i];
    	r.insert(a[i]);
    }
    for(ll i=0;i<m;i++)
    {
    	cin>>b[i];
    	c.insert(b[i]);
    }
    if(r.size()<n || c.size()<m)
    	return cout<<0,0;

    for(ll i=0;i<n;i++)
    {
    	for(ll j=0;j<m;j++)
    	{
    		if(a[i]==b[j])
    		{
    			mr[i]=1;mc[j]=1;
    			mark[i][j]=1;
    			used[a[i]]++;
    		}
    	}
    }

    ll mat[n][m];
    vll v;
    ll ans=1;
    for(ll i=0;i<n;i++)
    {
    	for(ll j=0;j<m;j++)
    	{
    		mat[i][j]=(min(a[i],b[j]));
    	}
    }

    for(ll i=0;i<n;i++)
    {
    	ll cnt=0;
    	if(mr[i])
    		continue;

    	cnt=0;
    	for(ll j=0;j<m;j++)
    	{
    		if(mat[i][j]==a[i])
    			cnt++;
    	}
    	ans=(ans*cnt)%mod;
    	cnt=1;
    	for(ll j=0;j<m;j++)
    	{
    		if(mat[i][j]==a[i] && cnt==1)
    		{
    			used[a[i]]++;
    			mark[i][j]=1;
    			break;
    		}
    	}
    }

    for(ll j=0;j<m;j++)
    {
    	ll cnt;
    	if(mc[j])
    		continue;

    	cnt=0;
    	for(ll i=0;i<n;i++)
    	{
    		if(mat[i][j]==b[j])
    			cnt++;
    	}
    	ans=(ans*cnt)%mod;
    	cnt=1;
    	for(ll i=0;i<n;i++)
    	{
    		if(mat[i][j]==b[j] && cnt==1)
    		{
    			used[b[j]]++;
    			mark[i][j]=1;
    			break;
    		}
    	}
    }
    for(ll i=1;i<=1000000;i++)
    	used[i]+=used[i-1];

    for(ll i=0;i<n;i++)
    	for(ll j=0;j<m;j++)
    		if(!mark[i][j])
    			v.pb(mat[i][j]);

    sort(v.begin(), v.end());
    ll tot=0;
    for(ll i=0;i<v.size();i++)
    {
    	// cout<<v[i]<<endl;
    	if(v[i]<used[v[i]]+tot)
    	{
    		ans=0;
    		break;
    	}

    	ans=(ans*(v[i]-used[v[i]]-tot))%mod;
    	tot++;
    }
    cout<<ans;


	// end_routine();
}

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

bool is_integer(double x){
    return std::floor(x) == x;
}

int main(){
    ll pay = 0;
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    q *= 4; h *= 2;
    if(n % 2 == 1){
        pay = min({q, h, s});
        n--;
    }

    if(n == 0){
        cout << pay << endl;
        return 0;
    }

    q *= 2; h *= 2; s *= 2;
    pay += min({q, h, s, d}) * (n / 2);

    cout << pay << endl;
 }

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> rgb(3);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            rgb[0].push_back(i);
        } else if (s[i] == 'G') {
            rgb[1].push_back(i);
        } else {
            rgb[2].push_back(i);
        }
    }

    Int ans = 0;
    vector<int> t{0, 1, 2};
    do {
        for (auto e : rgb[t[0]]) {
            auto gitr = upper_bound(rgb[t[1]].begin(), rgb[t[1]].end(), e);
            for (; gitr != rgb[t[1]].end(); ++gitr) {
                auto bitr = upper_bound(rgb[t[2]].begin(), rgb[t[2]].end(), *gitr);
                while (bitr != rgb[t[2]].end()) {
                    if (*gitr - e != *bitr - *gitr) {
                        ans++;
                    }

                    ++bitr;
                }
            }
        }

    } while (next_permutation(t.begin(), t.end()));

    cout << ans << endl;

    return 0;
}

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

char S[105];

int main() {

	int N;

	scanf("%d",&N);

	scanf("%s",S);

	int len=strlen(S);

	int i,j;

	int ans=0;

	for(i=0;i<len;i++){
		int history[2][26]={0};
		for(j=0;j<=i;j++){
		history[0][S[j]-'a']++;
		}
		for(j=i+1;j<len;j++){
		history[1][S[j]-'a']++;
		}
		int cnt=0;

		for(j=0;j<26;j++){
			if(history[0][j]>0&&history[1][j]>0){cnt++;}
		}

		if(ans<cnt){ans=cnt;}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

/* 前処理 O(n) */
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

/* 計算 O(1) */
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  mint sum[(int)2e+5 + 1];
  sum[0] = 0;
  repp(i, 1, (int)2e+5) {
    sum[i] = sum[i - 1] + i;
  }

  mint ans = 0;
  rep(i, N) {
    rep(j, M) {
      int a = N - i;
      int b = M - j;
      ans += sum[a - 1] * b;
      ans += sum[b - 1] * a;

      int c = N - 1 - i;
      int d = j;
      ans += sum[c] * d;
      ans += sum[d] * c;
    }
  }

  COMinit();
  ans *= COM(N * M - 2, K - 2);
  cout << ans.x << endl;
}

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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    string s; int w; cin >> s >> w;

    for (int i = 0; i < s.size(); i += w) cout << s[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
while 1:
    t = int(input())
    if t == 0:
        break
    n = int(input())
    T = 0
    for i in range(n):
        s,f = map(int,input().split())
        T += f - s

    if T >= t:
        print("OK")
    else:
        print(t-T)



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

int main() {
  ll n, k;
  cin >> n >> k;

  ll div = n/k;
  n -= k * div;
  
  ll ans = min(n, abs(n - k));

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int Maxn = 2 * 100000 + 100;
int N, root;
LL A[Maxn];
int deg[Maxn];
int Begin[Maxn], To[Maxn], Next[Maxn], e;
int fa[Maxn];

inline void add_edge (int x, int y)
{
	To[++e] = y;
	Next[e] = Begin[x];
	Begin[x] = e;
}

inline void dfs (int x)
{
	int fl = 0;
	for (int i = Begin[x]; i; i = Next[i])
	{
		int y = To[i];
		if (y == fa[x]) continue;
		fl = 1;
		fa[y] = x;
		dfs(y);
	}
	if (!fl) return ;
	LL Max = -0x3f3f3f3f3f3f3f, Sum = 0ll;
	for (int i = Begin[x]; i; i = Next[i])
	{
		int y = To[i];
		if (y == fa[x]) continue;
		Sum += A[y];
		Max = max (Max, A[y]);
	}
	if (A[x] > Sum || (Sum - A[x] > min(Sum / 2, Sum - Max)))
	{
		puts("NO");
		exit(0);
	}
	A[x] -= (Sum - A[x]);
}

int main()
{
#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
	for (int i = 1; i < N; ++i)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		add_edge(x, y);
		add_edge(y, x);
		deg[y] ++, deg[x] ++;
	}
	if (N == 2)
	{
		if (A[1] == A[2]) puts("YES");
		else puts("NO");
		return 0;
	}
	for (int i = 1; i <= N; ++i) if (deg[i] > 1){root = i; break;}
	dfs(root);
	if (!A[root]) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 6528
def LIS(l):
    from bisect import bisect_right
    dp = [l[0]+1]
    for i in range(len(l)):
        if l[i] >= dp[-1]:
            dp.append(l[i])
        else:
            dp[bisect_right(dp, l[i])] = l[i]
    return len(dp)
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    print(LIS(a[::-1]))
main()

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

int main() {
  char A;
  cin >> A;

  if(A=='a'||A=='b'||A=='c'||A=='d'||A=='e'||A=='f'||A=='g'||A=='h'||A=='i'||A=='j'||A=='k'||A=='l'||A=='m'||A=='n'||A=='o'||A=='p'||A=='q'||A=='r'||A=='s'||A=='t'||A=='u'||A=='v'||A=='w'||A=='x'||A=='y'||A=='z'){
    cout << 'a' << endl;
  }
  else{
    cout << 'A' << endl;
  }

return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main (int argc, const char * argv[]) {
	int d;
	int i;
	int sum;
	
	while (scanf("%d", &d) != EOF) {
		i = 0;
		sum = 0;
		while (i != 600) {
			sum = sum + d*i*i;
			i = i + d;
		}
		printf("%d\n", sum);
	}
	
    return 0;
}

Measured memory_bytes: 0
ans' :: Int -> Int -> [String]
ans' 0 _ = []
ans' 1 y = [ replicate y '#' ]
ans' x y = ( ( ('#':replicate (y-2) '.') ++ "#"):ans' (x-1) y )

ans :: [Int] -> [String]
ans (x:y:xs) = 
  (replicate y '#' : ans' (x-1) y )

printRec :: [[String]] -> IO()
printRec [] = return ()
printRec (s:sx) = do
  mapM_ putStrLn s
  putStrLn ""
  printRec sx

main = do
  c <- getContents
  let t = map (map read) $ map words $ lines c :: [[Int]]
      i = takeWhile (/= [0,0]) t
      o = map ans i
  printRec o

Measured memory_bytes: 4268
#include <stdio.h>

int main()
{
    int n,k,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;++i)
    {
        int x;
        scanf("%d",&x);
        if(x>=k)ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

int main() {
  int N;
  cin >> N;
  vector<pair<ll, ll>> x(N);

  rep(i, N) {
    ll X, L;
    cin >> X >> L;
    x[i].first = X + L;
    x[i].second = max(0LL, X - L);
  }

  sort(all(x));
  

  int ans = 0;
  ll t = -1;
  rep(i, N) {
    if (t <= x[i].second) {
      ans++;
      t = x[i].first;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import numpy as np

n = ni()
a = np.array(na())

ans = 0

while max(a) >= n:
	for i in range(n):
		if a[i] >= n:
			b = a[i]//n
			a[i] = a[i]-b*n-b
			a+=b
			ans+=b

print(ans)

Measured memory_bytes: 12512
#include<stdio.h>
int main(){
int a,b;
   scanf("%d %d",&a,&b);

   if(a>=b){
      for(int i=0;i<a;i++){
         printf("%d",b);
      }
   }else{
 for(int i=0;i<b;i++){
         printf("%d",a);
      }
   }
  return 0;
}


Measured memory_bytes: 1696
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	printf("square1001\n");

	return 0;
}



Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 67280421310721;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////

int n;string s;deque<char> d;
signed main(){
  cin>>n>>s;
  rep(i,n){
    if(d.empty() || s[i] == '(' || d.back() == ')')d.push_back(s[i]);
    else d.pop_back();
  }
  int a = 0, b = 0;
  rep(i,d.size()){
    if(d[i] == ')')a++;
    else b++;
  }
  rep(i,a)s = '('+s;
  rep(i,b)s += ')';
  cout << s << endl;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);++i)
#define allof(a) (a).begin(),(a).end()
#define size_of(a) (int)(a).size()
#define minit(a,b) memset(a,b,sizeof(a))

template< typename FLOW >
class Dinic {
private:
	struct Edge { int id, to; FLOW cost; int rev; };
	
	int N;
	vector< vector< Edge > > edges;
	vector< int > level, iter;
	
public:
	Dinic(int n) : N(n), edges(n), level(n, -1), iter(n, 0) {}
	
	void addEdge(int id, int from, int to) {
		edges[from].push_back(Edge{id, to, 1, size_of(edges[to])});
		edges[to].push_back(Edge{0, from, FLOW(), size_of(edges[from]) - 1});
	}
	
	void bfs(int s) {
		fill(allof(level), -1);
		queue< int > que; que.push(s);
		level[s] = 0;
		
		while (!que.empty()) {
			int v = que.front(); que.pop();
			
			for (auto& e : edges[v]) {
				if (e.cost > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	
	FLOW dfs(int v, int t, FLOW f) {
		if (v == t) return f;
		
		int enums = size_of(edges[v]);
		
		for (int& i = iter[v]; i < enums; ++i) {
			Edge& e = edges[v][i];
			
			if (e.cost > 0 && level[v] < level[e.to]) {
				FLOW d = dfs(e.to, t, min(f, e.cost));
				
				if (d > 0) {
					e.cost -= d;
					edges[e.to][e.rev].cost += d;
					return d;
				}
			}
		}
		
		return FLOW(-1);
	}
	
	FLOW maxFlow(int s, int t) {
		FLOW f = FLOW();
		
		while (1) {
			bfs(s);
			
			if (level[t] < 0) return f;
			
			fill(allof(iter), 0);
			FLOW fl;
			while ((fl = dfs(s, t, FLOW(1e9))) > 0) f += fl;
		};
	}
	
	void printAnswer() {
		vector< int > ans;
		
		for_(v,0,N) {
			for (auto& e : edges[v]) {
				if (e.cost == 0 && e.id < 0) ans.push_back(-e.id);
			}
		}
		
		sort(allof(ans));
		int m = size_of(ans);
		cout << m << endl;
		for_(i,0,m) cout << ans[i] << endl;
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	
	Dinic< int > dinic(N);
	
	for_(i,0,M) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		dinic.addEdge(i + 1, u, v);
		dinic.addEdge(-(i + 1), v, u);
	}
	
	int S, T;
	cin >> S >> T;
	--S; --T;
	
	cout << dinic.maxFlow(S, T) << endl;
	dinic.printAnswer();
}

Measured memory_bytes: 1344
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day2/problems/B>
問題文============================================================

 非負整数xを2進数表記したときの各桁の和をf(x)とする。
 正整数Nが与えられるのでf(0),f(1),...,f(N)の中で最大のものを出力せよ。
 関数f(5)の計算の例:
 5を2進数表記すると101で各桁の和は1+0+1=2
 よってf(5)=2となる。
 
=================================================================

解説=============================================================

 1を極力建てたい
     => 2^n - 1 は 0..n の全てのbitがたつ
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = __builtin_popcount(N);
    int x = 1;
    while(x <= N) x<<=1;
    ans = max(ans,__builtin_popcount(min(x-1,N)));
    x>>=1;
    ans = max(ans,__builtin_popcount(x-1));
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3220
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a,b,x;
    cin >> a >> b >> x;
    double pi = M_PI;
    double c = x/(a*a);
    if(c*2.0>b){
        c = b-c;
        double y = c*2.0;
        double ret = atan(y/a);
        ret = ret*180.0 / pi;
        
        printf("%.7f\n", ret);
    }else{
        double y = 2.0*a*c/b;
        double ret = atan(b/y);
        ret = ret*180.0 / pi;
        printf("%.7f\n", ret);
    }

    return 0;
}

Measured memory_bytes: 384
fn main() {
    let (h1, w1) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut ws = line.split_whitespace();
        let h: i32 = ws.next().unwrap().parse().unwrap();
        let w: i32 = ws.next().unwrap().parse().unwrap();
        (h, w)
    };
    let (h2, w2) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut ws = line.split_whitespace();
        let h: i32 = ws.next().unwrap().parse().unwrap();
        let w: i32 = ws.next().unwrap().parse().unwrap();
        (h, w)
    };
    let ans = h1 * w1 - h2 * w1 - h1 * w2 + h2 * w2;
    println!("{}", ans);
}

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

using namespace std;

typedef long long ll;
#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define YESNO(ans) cout << (ans?"YES":"NO") << endl;
#define pqueue priority_queue
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'

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

    int a, b;cin>>a>>b;
    int n;cin>>n;

    int ans = 0;
    while(n > 0){
        ans++;
        n -= max(a, b);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int MXN = 110;
const int MXK = 100005;
int n, k;
int v[MXN], w[MXN];
ll dp[MXN][MXK];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    // for(int i = n - 1; i >= 0; i--) {
    //     for(int j = k; j >= 0; j--) {
    //         dp[i][j] = dp[i + 1][j];
    //         if(j + w[i] <= k) {
    //             dp[i][j] = max(dp[i][j], dp[i + 1][j + w[i]] + v[i]);
    //         }
    //     }
    // }
    // cout << dp[0][0] << endl;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= k; j++) {
            dp[i][j] = dp[i - 1][j];
            if(j - w[i] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][k] << endl;
    return 0;
}

Measured memory_bytes: 81704
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    int n;cin >> n;
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a,b;cin >> a >> b;
        if(a == b){
            cnt++;
            chmax(ans, cnt);
        }
        else{
            chmax(ans, cnt);
            cnt = 0;
        }
    }
    if(ans >=3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
long long n,a[100002],z,zs;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	  cin>>a[i];
	sort(a+1,a+n+1);
	z=1;
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1])z++,z%=2;
		else zs+=z,z=1;
	}
	if(z%2)zs++;
    cout<<zs<<endl;
	return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
    var (
        a int
        b int
        c int
        d int
        max int
    )
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Scan(&c)
    fmt.Scan(&d)

    max = a * c

    if a * d > max {
        max = a * d
    }
    if b * c > max {
        max = b * c
    }
    if b * d > max {
        max = b * d
    }
    fmt.Print(max)
}

Measured memory_bytes: 1768
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        a: usize,
        b: usize,
    }
    println!("{}", a*b);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX;
const long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll P = 1e9 + 7;
	//const ll P = 998244353;

	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll cnt = 0;
	while (a >= b) {
		b *= 2;
		cnt++;
	}
	while (b >= c) {
		c *= 2;
		cnt++;
	}
	if (cnt <= k) Yes();
	else No();
}

Measured memory_bytes: 3648
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut ans = get!(String);
    let v: Vec<char> = ans.chars().collect();
    let mut hiraki = 0;
    let mut toji = 0;
    for i in 0..n {
        if v[i] == '(' {
            hiraki += 1;
        } else {
            if hiraki == 0 {
                toji += 1;
            } else {
                hiraki -= 1;
            }
        }
    }
    //eprintln!("hiraki: {}, toji: {}", hiraki, toji);
    for _ in 0..hiraki {
        ans += ")";
    }
    for _ in 0..toji {
        ans = "(".to_string() + &ans;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void)
{
  int n;
  int a[1000]={0};
  int i;
  
  scanf("%d",&n);
  for (i=0; i<n; i++) {
    scanf("%d",&a[i]);
  }

  
  for (i=n-1; i>=0; i--) {
    printf("%d",a[i]);
    if (i!=0) printf(" ");
  }
  
  printf("\n");

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
 
int n, m;
string s, t;
int dp[3030][3030];
bool vis[3030][3030];

int solve(int a, int b) {
    if (a == n || b == m) return 0;
    if (vis[a][b]) return dp[a][b];
    vis[a][b] = true;
    int ans1=0, ans2=0;
    if(s[a] == t[b]) ans1 = 1+ solve(a+1, b+1);
    else ans2= max(solve(a+1,b), solve(a, b+1) );
    // int ans = max(solve(a+1, b), solve(a, b+1));
    // if (s[a] == t[b]) ans = max(ans, 1 + solve(a+1, b+1));
    return dp[a][b] = max(ans1, ans2);
}
 
int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    cin >> s >> t;
    n = int(s.size());//4
    m = int(t.size());//5
    int u = solve(0, 0);//3
    int a = 0, b = 0;
    string ans;
    while (u) {// u ==3;
        if (a < n && solve(a + 1, b) == u) {// a < 4 && solve() ==3
            a++;
            continue;
        }
        if (b < m && solve(a, b + 1) == u) {
            b++;
            continue;
        }
        ans += s[a];
        u--; a++; b++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 48312
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};
using Graph = vector<vector<int>> ;

int main(){
  int n,m;
  cin>>n>>m;
  Graph G(n);
  vector<int> dist(n,-1);
  rep(i,m){//無向グラフ
    int a,b;
    cin>>a>>b;
    a--;b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<int> miti(n);
  queue<int> que;//観測済みかつ未訪問
  int start = 0; //0からスタート
  dist.at(start)=0;
  que.push(start);
  
  while(que.size()>0){
    int v = que.front();
    que.pop();
    for(int next_v : G.at(v)){
      if(dist.at(next_v)!=-1) continue;
      que.push(next_v);
      miti.at(next_v)=v+1;
      dist.at(next_v)=dist.at(v)+1;
    }
  }
  //rep(i,n)
    //cout<<i<<":"<<dist.at(i)<<endl;
  Yes;
  rep(i,n-1){
    //cout<<i+2<<":";
    cout<<miti.at(i+1)<<endl;
  }
}

Measured memory_bytes: 10612
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
c = Array.new

for i in 0...n do
  c[i] = a[i] - (i + 1)
end

c.sort!

b = (n % 2 == 0)? c[n/2 -1]: c[(n-1)/2]

ans = 0

for i in 0...n do
  ans += (c[i] - b).abs
end

puts "#{ans}\n"


Measured memory_bytes: 21580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

const int N = 1e5 + 2;
int a[N], n;
int dp[N][3];
int go(int ind, bool invert)
{
    if (ind == n - 1)
    {
        if (invert)
            return -a[n - 1];
        else
            return a[n - 1];
    }
    if (dp[ind][invert] != -1)
        return dp[ind][invert];

    //means i have inverted the prev element
    if (invert)
        return dp[ind][invert] = max(go(ind + 1, 0) - a[ind], go(ind + 1, 1) + a[ind]);

    return dp[ind][invert] = max(go(ind + 1, 0) + a[ind], go(ind + 1, 1) - a[ind]);
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << go(0, 0);
    return 0;
}

Measured memory_bytes: 12892
S =  input()

diff1 = 0
diff2 = 0

for i,s in enumerate(S):
    #print(i)
    if i%2==0:
        #print("hogw")
        if s!="0":
            diff1 +=1
    else:
        #print("fuga")
        if s!="1":
            diff1 +=1


i=0
for i,s in enumerate(S):
    if i%2==0:
        if s!="1":
            diff2 +=1
    else:
        if s!="0":
            diff2 +=1

print(min(diff1, diff2))
#print(diff1)
#print(diff2)


Measured memory_bytes: 3188
import math

A, B = map(int, input().split())

ans_A = A * (100 / 8)
ans_B = B * 10

for x in range(1251):
    if math.floor(x * 0.08) == A and math.floor(x * 0.1) == B:
        print(x)
        exit()

print(-1)

Measured memory_bytes: 3060
import sys
input = lambda: sys.stdin.readline().rstrip()
 
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    if a[i] == 1:
        break
left = len(a[:i])
right = len(a[i + 1:])

ans = left // (k - 1) + right//(k - 1) + (left%(k-1) + right%(k-1))//(k-1) + int((left%(k-1) + right%(k-1))%(k - 1) != 0)

print(ans)


Measured memory_bytes: 14324
#include <iostream>
#include <map>
using namespace std;
map <int, bool> hi;
int main() {
    int n, m, temp, ans = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        hi[a[i]] = 1;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> temp;
        if (hi[temp]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10516
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ceilDiv(x, d int) int {
	if x%d == 0 {
		return x / d
	}
	return (x / d) + 1
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a, b, x := nextInt(), nextInt(), nextInt()

	fmt.Println((b / x) - ceilDiv(a, x) + 1)
}


Measured memory_bytes: 640
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

h, n = na()
a, b = [], []
for _ in range(n):
    ai, bi = na()
    a.append(ai)
    b.append(bi)
inf = 10**9
dp = [[inf]* (10**4+1) for _ in range(n+1)]
for i in range(n):
    for j in range(1, 10**4+1):
        if j < a[i]:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i])
        else:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i], dp[i+1][j - a[i]] + b[i])
print(dp[n][h])



Measured memory_bytes: 119772