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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,M; cin >> N >> M;
    VI a(M), b(M,0);
    VVI c(M);
    REP(i,M){
        int B;
        cin >> a[i] >> B;
        REP(j,B){
            int C; cin >> C; C--;
            b[i] += 1<<C;
        }
    }

    int dp[M+1][1<<N]; REP(i,M+1)REP(j,1<<N) dp[i][j] = 1e9;
    dp[0][0] = 0;
    REP(i,M)REP(j,1<<N){
        chmin(dp[i+1][j], dp[i][j]);
        chmin(dp[i+1][j | b[i]], dp[i][j] + a[i]);
    }
    int ans = 1e9;
    REP(i,M) chmin(ans, dp[i+1][(1<<N)-1]);
    cout << (ans<1e9 ? ans : -1) << endl;
    return 0;
}

Measured memory_bytes: 16256
#include <stdio.h>
int main(){


  int data[10000];
  int n,i;

  scanf("%d",&n);
 for(i=0;i<n;i++){

   scanf("%d",&data[i]);
 
 }

 for(i=n-1;i>0;i--){

   printf("%d ",data[i]);
  
 }
 printf("%d",data[0]);
 printf("\n");
 return 0;
}

Measured memory_bytes: 608
package main

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

type edge struct {
	//行き先
	to int
	//コスト
	cost int
}

const white = 1
const black = 2

var n int

//edges[i] : i番目の頂点から出てる辺。可変長
var edges [][]edge
var costCache []int
var searched []bool

// index番目の都市から0番目の都市に向かうコストを計算
func getCostTo0(index int) int {
	if index == 0 { //ゴール到達
		return 0
	}
	if costCache[index] > 0 {
		return costCache[index]
	}
	goalCost := -1
	searched[index] = true
	for _, e := range edges[index] {
		if searched[e.to] {
			continue
		}
		c := getCostTo0(e.to)
		if c >= 0 {
			goalCost = e.cost + c
			break
		}
	}
	searched[index] = false
	if goalCost < 0 {
		return -1
	}
	costCache[index] = goalCost
	return goalCost
}

func solve() []int {
	var ans []int
	ans = make([]int, n)

	ans[0] = white
	for i := 1; i < n; i++ {
		if getCostTo0(i)%2 == 0 {
			ans[i] = white
		} else {
			ans[i] = black
		}
	}
	return ans
}

//
func main() {
	scanner.Split(bufio.ScanWords)
	n = scanInt()

	edges = make([][]edge, n)
	for i := 0; i < n; i++ {
		edges[i] = make([]edge, 0)
	}
	for i := 0; i < n-1; i++ {
		u := scanInt() - 1
		v := scanInt() - 1
		w := scanInt()
		edges[u] = append(edges[u], edge{v, w})
		edges[v] = append(edges[v], edge{u, w})
	}
	costCache = make([]int, n)
	searched = make([]bool, n)
	ans := solve()
	for _, a := range ans {
		if a == white {
			fmt.Println("0")
		} else {
			fmt.Println("1")
		}
	}
}

// Commen--------------------------
var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	a, _ := strconv.Atoi(scanner.Text())
	return a
}
func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

// End -------------------------------


Measured memory_bytes: 17280
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	long long X;
	cin >> X;

	long long ret;
	long long sum = 0;
	for(ret=1; sum<X; ret++)
		sum += ret;

	cout << ret-1 << endl;

	return 0;
}


Measured memory_bytes: 256
#from more_itertools import pairwise

N = int(input())
H = [int(i) for i in input().split()]
cnt = 0
max_cnt = 0
for h, r in zip(H, H[1:]):
    print()
    if r <= h:
        cnt += 1
    elif h < r and cnt:
        max_cnt = max(max_cnt, cnt)
        cnt = 0

ans = max(max_cnt, cnt)

print(ans)

Measured memory_bytes: 14252
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    a, v = map(int, readline().split())
    b, w = map(int, readline().split())
    t = int(readline())
    b -= a
    b = abs(b)
    print('YES' if t * v >= t * w + b else 'NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9252
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(int i = 0; i < x; i++)
using namespace std;
typedef long long ll;
ll MOD = (ll)1e9 + 7;
const ll N = 2e5+5, inf = 1e18+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

struct Node {
    ll val, lazy;
    void add(ll x) {
        val += x;
        lazy += x;
    }
};
vector<Node> st(4*N, {0, 0});

void add(int node, int l, int r, int ql, int qr, ll x) {
    if (l > qr || r < ql) return;
    if (ql <= l && r <= qr) {
        st[node].add(x);
    } else {
        st[node*2].add(st[node].lazy);
        st[node*2+1].add(st[node].lazy);
        st[node].lazy = 0;

        add(node*2, l, (l+r)/2, ql, qr, x);
        add(node*2+1, (l+r)/2+1, r, ql, qr, x);
        st[node].val = max(st[node*2].val, st[node*2+1].val);
    }
}

ll query(int node, int l, int r, int ql, int qr) {
    if (l > qr || r < ql) return -inf;
    if (ql <= l && r <= qr) {
        return st[node].val;
    } else {
        st[node*2].add(st[node].lazy);
        st[node*2+1].add(st[node].lazy);
        st[node].lazy = 0;

        ll q1 = query(node*2, l, (l+r)/2, ql, qr);
        ll q2 = query(node*2+1, (l+r)/2+1, r, ql, qr);
        return max(q1, q2);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n, m; cin >> n >> m;
    vector<ll> l(m), r(m), a(m), dp(n+1, -inf);
    vector<vector<ll>> starting(n+1, vector<ll>()), ending(n+1, vector<ll>());
    rep (i, m) {
        cin >> l[i] >> r[i] >> a[i];
        starting[l[i]].push_back(i);
        ending[r[i]].push_back(i);
    }

    dp[0] = 0;
    /*
    for (int k = 0; k < m; ++k) if (l[k] == 0) dp[0] += a[k];
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            ll sum = 0;
            for (int k = 0; k < m; ++k)
                if (j < l[k] && l[k] <= i && i <= r[k])
                    sum += a[k];
            dp[i] = max(dp[i], dp[j]+sum);
        }
    }
    */
    for (int i = 1; i <= n; ++i) {
        for (ll x : starting[i]) add(1, 0, n, 0, i-1, a[x]);
        dp[i] = query(1, 0, n, 0, i-1);
        for (ll x : ending[i]) add(1, 0, n, 0, l[x]-1, -a[x]);
        add(1, 0, n, i, i, dp[i]);
    }
    cout << *max_element(begin(dp), end(dp)) << endl;
}

Measured memory_bytes: 40960
#include<stdio.h>

int main(void) {
	int N, L, S = 0, i;
	scanf("%d %d", &N, &L);
	if (L + N - 1 < 0) {
		for (i = 1; i <= N - 1; i++) {
			S = S + L + i - 1;
		}
		printf("%d\n", S);
	}else {
		if (L < 1) {
			for ( i = 1; i <= N ; i++) {
				S = S + L + i - 1;
			}
			printf("%d\n", S);
		}else{
			for (i = 2; i <= N; i++) {
				S = S + L + i - 1;
			}
			printf("%d\n", S);
		}
	}
	return 0;
}

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

int main(void) {
  char c;
  cin >> c;
  if (c == 'A') cout << 'T';
  else if (c == 'T') cout << 'A';
  else if (c == 'C') cout << 'G';
  else cout << 'C';
}

Measured memory_bytes: 256
N, W, H = [int(x) for x in input().split()]

map_x = [0] * W
map_y = [0] * H

for _ in range(N):
    x, y, w = [int(x) for x in input().split()]
    map_x[max(0, x - w)] = max(map_x[max(0, x - w)], x + w - max(0, x - w))
    map_y[max(0, y - w)] = max(map_y[max(0, y - w)], y + w - max(0, y - w))


def check_wifi(wifi):
    m = 0
    end = len(wifi)

    for i, x in enumerate(wifi):
        if x and i + x > m:
            m = i + x

        if m >= end:
            return True

        if i < m:
            continue

        return False

    return False


print('Yes' if check_wifi(map_x) or check_wifi(map_y) else 'No')

Measured memory_bytes: 11476
main = do
  k <- readLn :: IO Int
  let xs = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  print $ xs !! (k-1)


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

#define vi vector<int>
#define pb push_back

int main(){
        string sa, sb, sc;
        int ia, ib, ic;
        cin >> sa >> sb >> sc;
        ia = ib = ic = 0;
        char c = sa[ia];
        char last = 'A';
        ia++;
        while(true) {
                switch(c) {
                case 'a':
                        c = sa[ia];
                        last = 'A';
                        ia++;
                        break;
                case 'b':
                        c = sb[ib];
                        last = 'B';
                        ib++;
                        break;
                case 'c':
                        c = sc[ic];
                        last = 'C';
                        ic++;
                        break;
                case '\0':
                        cout << last << endl;
                        return 0;
                        break;
                }
        }
        return 0;
}


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

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

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int solve(int n) {
  int cnt = 0;
  while (true) {
    if (n % 2 == 0) {
      n /= 2;
      cnt++;
    } else {
      break;
    }
  }
  return cnt;
}

int main() {
  int N;
  cin >> N;
  vi a(N);
  rep(i, N) cin >> a[i];

  int res = 0;
  rep(i, N) {
    for (int j = i + 1; j < N; j++) {
      res = max(res, abs(a[j] - a[i]));
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mxn=2005;
string s[3];bool used[9][mxn];
int len[3];
int ans=114514;
inline void go(int d,string a,string b){
	for(int i=0;i<a.size();++i)for(int j=0;i+j<a.size() and j<b.size();++j)if(a[i+j]!='?' and b[j]!='?' and a[i+j]!=b[j]){
		used[d][i]=1;
		break;
	}
}
inline bool check(int i,int j,int a,int b){
	b-=a;
	if(b<0){
		swap(i,j);
		b=-b;
	}
	return b>=len[i] or not used[i*3+j][b];
}
inline bool ok(int j,int k){return check(0,1,0,j) and check(0,2,0,k) and check(1,2,j,k);}
int main(){
	for(int i=0;i<3;++i)cin>>s[i],len[i]=s[i].size();
	for(int i=0;i<3;++i)for(int j=0;j<3;++j)if(i!=j)go(i*3+j,s[i],s[j]);
	for(int i=-len[2]-len[1];i<=len[0]+len[2];++i)
		for(int j=-len[2]-len[1];j<=len[0]+len[1];++j)
			if(ok(i,j))
				ans=min(ans,max(len[0],max(len[1]+i,len[2]+j))-min(0,min(i,j)));
	cout<<ans<<'\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    REP(i,N-K){
        cout << (A[i] < A[K+i] ? "Yes" : "No") << "\n";
    }
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i=1;i<n;++i){
        ans += v[i] - v[i-1];
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

const long long NS = (long long)1e5 + 4;
long long N;
long long arr[NS];
vector < long long > sum1[NS], sum2[NS];

int main(){
    scanf("%lld", &N);
    for(long long i = 1; i <= N; ++i) scanf("%lld", arr + i);
    for(long long i = 1; i <= N; ++i){
        long long pos = N - N / i * i, sum = 0;
        if(!pos) pos += i;
        while(pos <= N){
            sum += arr[pos]; sum1[i].push_back(sum);
            pos += i;
        }
        pos = 1, sum = 0;
        while(pos <= N){
            sum += arr[pos]; pos += i;
        }
        pos = 1;
        while(pos <= N){
            sum2[i].push_back(sum), sum -= arr[pos], pos += i;
        }
    }
    long long ans = -(long long)1e18;
    for(long long i = 1; i <= N; ++i){
        for(long long j = 1; i - j > 0 && j * j <= N - i; ++j){
            if((N - i - 1) % j == 0 && (i % j != 0 || i / j >= (N - i - 1) / j + 1)){
                long long A = i, B = i - j;
                long long gap1 = sum1[j][(long long)sum1[j].size() - 1];
                if((long long)sum1[j].size() - (N - A - 1) / j - 1){
                    gap1 -= sum1[j][(long long)sum1[j].size() - (N - A - 1) / j - 2];
                }
                long long gap2 = sum2[j][0];
                if((N - A - 1) / j + 1 < (long long)sum2[j].size()){
                    gap2 -= sum2[j][(N - A - 1) / j + 1];
                }
                ans = max(ans, gap1 + gap2);
            }
            if((N - i - 1) % j == 0 && (N - i - 1) / j != 0){
                long long jj = j; j = (N - i - 1) / j;
                if((N - i - 1) % j == 0 && (i % j != 0 || i / j >= (N - i - 1) / j + 1)){
                    long long A = i, B = i - j;
                    long long gap1 = sum1[j][(long long)sum1[j].size() - 1];
                    if((long long)sum1[j].size() - (N - A - 1) / j - 1){
                        gap1 -= sum1[j][(long long)sum1[j].size() - (N - A - 1) / j - 2];
                    }
                    long long gap2 = sum2[j][0];
                    if((N - A - 1) / j + 1 < (long long)sum2[j].size()){
                        gap2 -= sum2[j][(N - A - 1) / j + 1];
                    }
                    ans = max(ans, gap1 + gap2);
                }
                j = jj;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 37872
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k;
	vector<P> vec;
	cin >> n >> k;
	ll sum = 0;
	for(int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		vec.push_back(P(a, b));
	}
	sort(vec.begin(), vec.end());
	for(int i = 0; i < n - 1; i++)
	{
		vec[i + 1].second += vec[i].second;
	}
	for(int i = 0; i < n; i++)
	{
		if(vec[i].second >= k)
		{
			cout << vec[i].first << endl;
			return 0;
		}
	}
	return 0;
}


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

int main() {
    string S,T; cin >> S >> T;
    int ma = 0;
    int num = S.size() - T.size() + 1;

    for (int i = 0; i < num; i++) {
        int cnt = 0;
        for (int j = 0; j < T.size(); j++) {
            if (S[j+i] == T[j]) cnt++;
        }
        ma = max(ma, cnt);
    }
    cout << T.size() - ma << endl;
}

Measured memory_bytes: 3632
# 解説

def main():
    N = int(input())
    s = input()

    dp = [[0] * N for _ in range(N)]
    ans = 0
    for i in reversed(range(N)):
        for j in reversed(range(i, N)):
            if s[i] == s[j]:
                if i + 1 < N and j + 1 < N:
                    dp[i][j] = min(dp[i + 1][j + 1] + 1, j - i)
                    ans = max(ans, dp[i][j])
                else:
                    dp[i][j] = 1
            else:
                dp[i][j] = 0
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int a,b;
void solve(){
	cin >> a >> b;
	
	if(b%2 || a*4 < b || a*2 > b){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

int main(){
  long ans = 0;
  long tmp;
  rep(i, 3){
    cin >> tmp;
    ans += tmp;
  }

  if(ans <= 21) cout << "win" << endl;
  else cout << "bust" << endl;
  
  return 0;
}

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

using namespace std;
using ll = long long;
const int N = 200005;

string n;
int k;

ll dp[111][4][2];
ll f(int i, int j, int less) {
	if(j > k) return 0;
	if(i == (int)n.size()) return j == k;
	ll &ans = dp[i][j][less];
	if(~ans) return ans;
	ans = 0;
	if(less) {
		return ans = f(i + 1, j, less) + f(i + 1, j + 1, less) * 9;
	}
	else {
		int dig = int(n[i] - '0');
		for(int d = 0; d <= dig; d++) {
			ans += f(i + 1, j + !!d, d < dig);
		}
	}
	return ans;
}

int main() {
	memset(dp, -1, sizeof dp);

	cin >> n >> k;
	cout << f(0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int K; cin>>K;
      int A,B; cin>>A>>B;
    bool ans = false;
    for(int i=A; i<=B; i++){
        if(i%K==0){
          ans = true;
        }
    }
  if(ans){
    cout<<"OK"<<endl;
  }
  else{
    cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3652
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

A, B, K = MI()

a = max(0, A - K)

if A - K >= 0:
    b = B
else:
    b = max(0, B + (A - K))

print("{0} {1}".format(a, b))


Measured memory_bytes: 43376
n = int(input())
a = [int(i) for i in input().split()]
m,ans = 10**9,0
for i in range(n-1):
    m = min(m,abs(a[i]))
    if a[i] < 0:
        a[i]*=(-1)
        a[i+1]*=(-1)
if a[-1] >= 0:
    print(sum(a))
else:
    a[-1] *= (-1)
    m = min(m,abs(a[i+1]))
    print(sum(a)-m*2)


Measured memory_bytes: 14224
#include<stdio.h>

int card[4][13] = {};

void CARD_INPUT(char symbol, int rank){

  if (symbol == 'S') {
    card[0][rank-1] = 1;
  } else if (symbol == 'H') {
    card[1][rank-1] = 1;
  } else if (symbol == 'C') {
    card[2][rank-1] = 1;
  } else {
    card[3][rank-1] = 1;
  }
}

void PRINTF_LACK(int symbol, int rank) {
  if (symbol == 0) {
    printf("S %d\n", rank + 1);
  } else if (symbol == 1) {
    printf("H %d\n", rank + 1);
  } else if (symbol == 2) {
    printf("C %d\n", rank + 1);
  } else {
    printf("D %d\n", rank + 1);
  }
}

int main() {
  int n, i, j, rank;
  char symbol;
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%c", &symbol);
    scanf("%c %d", &symbol, &rank);
    CARD_INPUT(symbol, rank);
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (card[i][j] == 0) PRINTF_LACK(i, j);
    }
  }

  return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
	char W[10], str[1000];
	int i, count=0;
	scanf("%s", W);
	while(1){
		scanf("%s", str);
		if(strcmp(str, "END_OF_TEXT")==0){
			break;
		}
		for(i=0; i<1000; i++){
			str[i]=tolower(str[i]);
		}
		if(strcmp(str, W)==0){
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 552
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c = sc.nextInt();

		int total = c * 800;
		int discount = c / 15 * 200;
		System.out.println(total - discount);
		sc.close();
	}

}

Measured memory_bytes: 22996
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    long K = scanner.nextLong();
    NumCount[] nums = new NumCount[N];
    for (int i = 0; i < N; i++) {
      nums[i] = new NumCount(scanner.nextInt(), scanner.nextInt());
    }
    Arrays.sort(nums);

    long c = 0;
    for (NumCount n : nums) {
      c += n.count;
      if (c >= K) {
        System.out.println(n.num);
        return;
      }
    }
  }

  private static class NumCount implements Comparable<NumCount> {
    final int num;
    final int count;

    private NumCount(int num, int count) {
      this.num = num;
      this.count = count;
    }

    @Override public int compareTo(NumCount o) {
      return this.num - o.num;
    }
  }
}


Measured memory_bytes: 87880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

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

            TextReader input = Console.In;

            string str = "";

            while ((str = input.ReadLine()) != null) {
                // スペースで区切る
                string[] s = str.Split(' ');
                // 2 個でない場合
                if (s.Length != 2) {
                    continue;
                }
                int one = 0;
                int two = 0;
                if (!int.TryParse(s[0], out one)) {
                    continue;
                }
                if (!int.TryParse(s[1], out two)) {
                    continue;
                }
                Console.WriteLine((one + two).ToString().Length);
            }
        }
    }
}

Measured memory_bytes: 19920
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i=1; i<10; i++){
    int comp = i*100 + i*10 + i;
    if(N <= comp){
      ans = comp;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a,b,c,d;

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>a>>b>>c>>d;
int dem=1;
while (a>0&&c>0){
    if (dem==1) {
            c-=b;
            dem=2;

    }
    else {
            a-=d;
            dem=1;
    }
}

if (a>0) cout<<"Yes";
else cout<<"No";
}


Measured memory_bytes: 3608
#include <stdio.h>
int main(){
  long n,k,r;
  scanf("%ld%ld",&n,&k);
  for(int i=0;i<n;i++){
    if(i==0)r=k;
    else r*=k-1;
  }
  printf("%ld",r);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int n,h,w,cnt=0;
  cin >> n >> h >> w;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i+h<=n&&j+w<=n)cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int dp[10][5];//dp[i][1]dp[i][1]dp[i][1]dp[i][1]
char an[20];
int bn[30];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%s",an);
        bn[(int )an[0]-'A']++;
    }
    for(int i=n/k;i>=0;i--){
        int cnt=0;
        for(int j=0;j<=26;j++){
            if(bn[j]>i){
                cnt+=i;
            }
            else cnt+=bn[j];
        }
        if(cnt>=i*k) {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


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

int H,W,N;
long long counts[10];
map<pair<int,int>,int> cells;

vector<pair<int,int> > nei(int a, int b)
{
    vector<pair<int,int> > ans;
    for(int i = -1; i <= 1; i++)
    {
        for(int j = -1; j <= 1; j++)
        {
            if(a+i > 1 && a+i < H && b+j > 1 && b+j < W)
            {
                ans.push_back(make_pair(a+i,b+j));
            }
        }
    }
    return ans;
}

int main()
{
    scanf("%d%d%d", &H, &W, &N);
    for(int i = 0; i < N; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        for(auto p:nei(a,b))
        {
            if(cells.count(p))
            {
                cells[p]++;
            }
            else
            {
                cells[p] = 1LL;
            }
        }
    }
    counts[0] = (1LL*H-2LL) * (1LL*W-2LL);
    for(auto kv:cells)
    {
        counts[0]--;
        counts[kv.second]++;
    }
    for(auto c:counts)
    {
        printf("%lld\n", c);
    }
    return 0;
}


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

int main(){
    int n,w; cin >> n >> w;
    int wv[n][2];
    rep(i,n) cin >> wv[i][0] >> wv[i][1];
    int v[(n*1000)+1];
    rep(i,(n*1000)+1) v[i]=-1;
    v[0]=0;
    rep(i,n){
        for(int j=1000*n; j>=wv[i][1]; j--){
            if(v[j-wv[i][1]]==-1) continue;
            if(v[j-wv[i][1]]+wv[i][0]>w) continue;
            if(v[j]==-1) v[j]=v[j-wv[i][1]]+wv[i][0];
            else v[j]=min(v[j],v[j-wv[i][1]]+wv[i][0]);
        }
    }
    int ans=0;
    for(int i=1000*n; i>=0; i--){
        if(v[i]!=-1){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    }
    else if(r < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

K, S = LI()

count = 0
for x in range(K+1):
    for y in range(K+1):
        if (x+y <= S) and (x+y >= S-K):
            count += 1

print(count)

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


int main(){
        std::string s, t;
        std::cin >> s >> t;

        bool cant = false;
        std::vector<int> sr(26, 0), tr(26, 0);
        for(int i=0; i<s.size(); i++){
                int x = s[i]-'a', y = t[i]-'a';
                if(x!=y)
                        if(sr[x]!=0 && sr[x]!=t[i] or tr[y]!=0 && tr[y]!=s[i]) cant = true;
                sr[x] = t[i];
                tr[y] = s[i];
        }

        if(cant) puts("No");
        else puts("Yes");
        return 0;
}

Measured memory_bytes: 776
#include <cstdio>
#include <algorithm>

static const int maxm = 1e6 + 10;

int cnt[maxm];
int n,m,x,y;

int main(){
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i++) scanf("%d%d",&x,&y),cnt[x]++,cnt[y]++;

	for(int i = 1;i <= n;i++){
		if(cnt[i] & 1) return puts("NO"),0;
	}

	puts("YES");
	
	return 0;
}


Measured memory_bytes: 512
def is_possible(N, M, m):
    if M >= 2 * m:
        r = M - 2 * m
        t = r // 2
        if N + t >= m:
            return True
    return False


def solve(N, M):
    a = 0
    b = 10 ** 20
    while b - a > 1:
        m = (a + b) // 2
        if is_possible(N, M, m):
            a = m
        else:
            b = m
    return a

N, M = map(int, input().split())
res = solve(N, M)
print(res)


Measured memory_bytes: 3064
def main():
    n, m = map(int,input().split())

    lst = [0 for i in range(n)]
    for i in range(n):
        lst[i] = list(map(int,input().split()))[1:]


    tmp = [i for i in range(1,m+1)]
    for i in lst:
        tmp = set(tmp) & set(i)

    print(len(tmp))


if __name__ == "__main__":
        main()


Measured memory_bytes: 3060
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int P = sc.nextInt();
	        int ocnt=0;
	        int ecnt=0;
	        
	        int h=50;
	        long[][] ncr=new long[h][h];
	        ncr[0][0]=1;
	        for(int i=1;i<h;i++) {
	        	ncr[i][0]=1;
	        	for(int j=1;j<i;j++) {
	        		ncr[i][j]=ncr[i-1][j-1]+ncr[i-1][j];
	        	}
	        	ncr[i][i]=1;
	        }
	        
	        
	        for(int i=0;i<N;i++) {
	        	int tmp=sc.nextInt();
	        	if(tmp%2==0) {
	        		ecnt++;
	        	} else {
	        		ocnt++;
	        	}
	        }
	        long ec=(long) Math.pow(2, ecnt);
	        long ans=0;
	        for(int i=0;i<=ocnt;i++) {
	        	if(i%2==P) {
	        		if(i==0) {
	        			ans=ans+ec;
	        		} else {
	        			ans=ans+ncr[ocnt][i]*ec;
	        		}
	        	}
	        }
	        System.out.println(ans);
  	        	        
	 }

}

Measured memory_bytes: 21844
$fact = Array.new(2*10**6,0)
$fact[0] = 1
for i in 1..2*10**6-1
  $fact[i] = $fact[i-1]*(i+1)%(10**9+7)
end
$fact << 1
def exp(a,b)
  if b == 0
    1
  elsif b%2 == 0
    (exp(a,b/2)**2)%(10**9+7)
  else
    (a*exp(a,b-1))%(10**9+7)
  end
end
def combi(n,r)
  $fact[n-1]*exp($fact[n-r-1],10**9+5)*exp($fact[r-1],10**9+5)%(10**9+7)
end
h,w,a,b = gets.chomp.split(" ").map(&:to_i)
ans = 0
if a > h/2
  for i in 0..h-a-1
    ans += combi(i+b-1,b-1)*combi(h+w-i-b-2,w-b-1)
  end
else
  ans += combi(h+w-2,h-1)
  for i in 0..a-1
    ans -= combi(h-a+i+b-1,b-1)*combi(a-i+w-b-2,w-b-1)
  end
end
puts ans%(10**9+7)

Measured memory_bytes: 17404
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    int k;
    int tmp_a;
    int ans=0;
    vector<int> a(200010, 0);
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a[tmp_a]++;
    }

    sort(a.begin(),a.end(),greater<int>());
    for(int i=k; i<a.size(); i++){
        ans+=a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
ll d[10], v[10];

ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> d[i] >> v[i];
      ll g = gcd(d[i], v[i]);
    }
    ll A = 1;
    for (int i = 0; i < n; i++) {
      A = lcm(A, d[i]);
    }
    ll B = A / d[0] * v[0];
    for (int i = 0; i < n; i++) {
      B = gcd(B, A / d[i] * v[i]);
    }
    for (int i = 0; i < n; i++) {
      cout << A / d[i] * v[i] / B << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

constexpr int ARRAY_SIZE = 2000 + 10;

bool a[ARRAY_SIZE];
int seq[20];

void search(int, int);

int main()
{
	for(int i = 0; i < ARRAY_SIZE; ++i)
	{
		a[i] = false;
	}
	a[0] = true;

	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		int in = 0;
		cin >> in;
		seq[i] = in;
	}

	search(n - 1, 0);

	int q;
	cin >> q;
	for(int i = 0; i < q; ++i)
	{
		int m = 0;
		cin >> m;
		cout << (a[m] ? "yes" : "no") << endl;
	}
	
	return 0;
}

void search(int index, int sum)
{
	if(index < 0)
	{
		a[sum] = true;
		return;
	}
	search(index - 1, sum);
	search(index - 1, sum + seq[index]);
}





Measured memory_bytes: 3096
#include<stdio.h>
main(){
  int c[3],sum,i,k;
  while(scanf("%d %d %d",&c[0],&c[1],&c[2])!=EOF){
    k=0;
    sum=20;
    sum-=c[0]+c[1];
    for(i=1;i<=10;i++){
      if(i!=c[0] && i!=c[1] && i!=c[2]){
	if(sum>=i){
	  k++;
	}
      }
    }
    if(k>=4){
      puts("YES");
    }
    else{
      puts("NO");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;
#define int long long int
int power(int a,int b)
{
	int x=pow(a,b);
	return x;
}
int32_t main()
{
	int n;
	cin>>n;
	int value=0;
	int arr[n+1];
	int j;
	for(j=1;j<=n;j++)
	{
		cin>>arr[j];
		value^=arr[j];
	}
	int answer[n+1];
	answer[n]=value^arr[n];
	for(j=n-1;j>=1;j--)
	{
		answer[j]=(answer[j+1]^arr[j]^arr[j+1]);
	}
	for(j=1;j<=n;j++)
	{
		cout<<answer[j]<<" ";
	}
	cout<<endl;
}


Measured memory_bytes: 6724
#include <bits/stdc++.h>
#define pb push_back
//#define int long long
using namespace std;
//const int inf = 1e18 + 7;
const int N = 1e5 + 1;
const int md = 1e9 + 7;
//dist[0] - takahashi, dist[1] - aoki
std::vector<vector<int>> dist(2, vector<int>(N, 0));
vector<int> g[N];
void dfs(int from, int l, int par, int q) {
  dist[q][from] = l;
  for(int to : g[from]) {
    if(to == par) 
      continue;
    dfs(to, l + 1, from, q);
  }
}
void sol() {
  int n, T, A, u, v;
  int ans = 0;
  cin >> n >> T >> A;
  for(int i=0; i<n; i++) {
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);  
  }
  dfs(T, 0, T, 0);
  dfs(A, 0, A, 1);
  for(int i=1; i<=n; i++) {
    if(dist[0][i] < dist[1][i]) {
      ans = max(ans, dist[1][i]);
    }
  }
  ans--;
  cout << ans;
}

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


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

int main() {
    int N,M;
    cin >> N >> M ;
    vector<int>V(N);
    for (int i=0 ; i<N ; i++)
        cin >> V.at(i);
    sort(V.begin(),V.end(),greater<int>());
    int S=0;
    for (int i=0 ; i<N ; i++)
        S+=V.at(i);
    if (V.at(M-1) * 4 * M <S)
    cout << "No" << endl;
    else 
    cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
int main(){
      int n;
      int k;
      cin>>n>>k;
      while(k--){
            int x,y;
            cin>>x>>y;
            if(y>n/2)y=(n+1)-y;
            if(x>n/2)x=(n+1)-x;
            if(x>y)x=y;
            if(x%3==0)cout<<"3"<<endl;
            else cout<<x%3<<endl;
      }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define var auto
#define MOD 1000000007


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    int t1 , t2, a1, a2; cin>>t1>>t2>>a1>>a2;
    while(t1>0 && t2>0 && a1>0 && a2>0){
        a1 -= t2;
        if(a1<=0) return cout<<"Yes", 0;
        t1 -= a2;
        if(t1<=0)return cout<<"No", 0;
    }
	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main()
{
  int i = 0;
  char S[101];
  scanf("%s",&S);
  while (S[i])
    i++;
  //printf("%d\n",i);
  int len = i;
  //printf("i:%d\n",i);
  int k = 0;
  int counter = 0;
  //printf("len/2:%d\n",len/2);
  i -= 1;
  while (k != len / 2)
  {
    if (S[i] != S[k])
    {
      //printf("S[%d]=%c:S[%d]=%c\n",i,S[i],k,S[k]);
      S[i] = S[k];
      counter++;
    }
    i--;
    k++;
  }
  printf("%d",counter);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,x[200010],y[200010];
    cin>>n;
    rep(i,n){
        cin>>x[i]>>y[i];
        int a=x[i]+y[i],b=x[i]-y[i];
        x[i]=a,y[i]=b;
    }
    cout<<max(*max_element(x,x+n)-*min_element(x,x+n),*max_element(y,y+n)-*min_element(y,y+n))<<endl;
    return 0;
}

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

int main(){
	long long f[50];
	f[0]=1;
	f[1]=1;
	
	for(int i=2; i<45; ++i) f[i]=f[i-1]+f[i-2];
	
	int n;
	scanf(" %d", &n);
	cout << f[n] << endl;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    ll x, y, z, ans, tmp;
    cin >> x >> y >> z;
    
    tmp = x % y;
    ans = x / y;
    while(!(tmp >= z * (ans + 1))){
        x -= y;
        ans--;
        tmp += y;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

 
struct Unionfind{
    vector<int> parents;
    int n;
    Unionfind(int n):n(n),parents(n,-1){ }

    int find(int x){
        if(parents[x] < 0) return x;
        else return parents[x] = find(parents[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x==y) return;
        if(parents[x] > parents[y]) swap(x,y);
        parents[x] += parents[y];
        parents[y] = x;
    }  

   int size(int x){
       return -parents[find(x)];
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }

   vector<int> members(int x){
       int root = find(x);
       vector<int> member;
       for(int i=0;i<n;i++){
           if(find(i)==root ){
               member.push_back(i);
           }
       }
      return member;
  }

  int group_cnt(){
      int c = 0;
      rep(i,n){
          if(parents[i] < 0) ++c;
      }
      return c;
  }
};

int main(){
    int n,m;
    cin >> n >> m;
    Unionfind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        uf.unite(a,b);
    }
    int ans = 0;
    rep(i,n){
        ans = max(ans,uf.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
L = 10
table = [a = [[0, 0], [0, -1], [1, 0], [0, 1], [-1, 0]],
         b = a + [[1, -1], [1, 1], [-1, 1], [-1, -1]],
         b + [[0, -2], [2, 0], [0, 2], [-2, 0]]]
field = Array.new(L) {Array.new(L, 0)}

set = ->(x, y) {
  return if x < 0 or x >= L or y < 0 or y >= L
  field[y][x] += 1
}

$<.readlines.map {|l| l.split(",").map(&:to_i)}.each do |x, y, s|
  table[s - 1].each {|dx, dy| set.(x + dx, y + dy)}
end
f = field.flatten
puts f.count(0)
puts f.max


Measured memory_bytes: 6860
use std::io;
use std::cmp;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N: usize = iter.next().unwrap().parse().unwrap();
    
    let mut A: Vec<Vec<i32>> = Vec::new();

    for i in 0..2 {
        let mut vec: Vec<i32> = Vec::new();

        let mut buf2 = String::new();
        std::io::stdin().read_line(&mut buf2).unwrap();
        let mut iter2 = buf2.split_whitespace();
        for j in 0..N {
            let a: i32 = iter2.next().unwrap().parse().unwrap();
            vec.push(a);
        }
        A.push(vec);
    }

    let mut cumsum: Vec<Vec<i32>> = Vec::new();

    for i in 0..2 {
        let mut c: Vec<i32> = Vec::new();
        for &e in A[i].iter() {
            let last = if c.len()>0 { *c.last().unwrap() } else {0};
            c.push(last + e);
        }
        cumsum.push(c);
    }

    let mut res: i32 = 0;
    for j in 0..N {
        let row0: i32 = cumsum[0][j];
        let row1: i32 = (cumsum[1].last().unwrap()) - (if j - 1 >= 0 && j-1<N { cumsum[1][j - 1] } else { 0 });
        res = cmp::max(res, row0 + row1);
    }
    println!("{}", res);
}


Measured memory_bytes: 4352