akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}
fn main() {
    input! {
        a: usize,
        b: usize,
    }
    if b == 1 {
        println!("{}", 0);
        return ;
    }
    let mut sum =a;
    if sum >= b {
        println!("{}", 1);
        return;
    }
    for i in 2..40 {
        sum = sum - 1 + a;
        if sum >= b {
            println!("{}", i);
            return;
        }
    }
}

Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
S = [0 for i in range(60)]
for i in range(N):
    a = A[i]
    for j in range(60):
        if (a>>j)&1:
            S[j] += 1
mod = 10**9 + 7
ans = 0
for i in range(60):
    s = S[i]
    t = N - s
    r = (s*t*(2**i))%mod
    ans = (ans + r)%mod
print(ans)

Measured memory_bytes: 125624
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int a[200005];

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1, x; i < n; ++i)
    read(x), ++a[x];
  for (RI i = 1; i <= n; ++i)
    printf("%d\n", a[i]);

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 5412
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	int a = 0, b = 0, c = 0;

	cin >> a >> b >> c;

	if (a < b && b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1116
def parse(str):
    strs = []
    s = ""
    code = ""
    isStr = False
    for c in str:
        if c == "\"":
            if isStr:
                strs.append(s)
                s = ""
            else:
                code = code + c
            isStr = not isStr
        elif isStr:
            s = s + c
        else:
            code = code + c
    return [strs, code]

def is_close(l1, l2):
    strs1 = parse(l1)
    strs2 = parse(l2)   
    if strs1[1] != strs2[1]:
        return False
    strs1 = strs1[0]
    strs2 = strs2[0]
    reach = False
    for i in range(min(len(strs1), len(strs2))):
        if strs1[i] != strs2[i]:
            if reach:
                return False
            else:
                reach = not reach
    if len(strs1) != len(strs2):
        return False
    else:
        return reach

while True:
    l1 = input()
    if l1 == '.':
        break
    l2 = input()
    if l1 == l2:
        print("IDENTICAL")
    elif is_close(l1, l2):
        print("CLOSE")
    else:
        print("DIFFERENT")


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
//↓,→,↑,←


#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/
struct Timer {
    int64_t start;
    const int64_t CYCLES_PER_SEC = 2800000000;
    Timer() { reset(); }
    void reset() { start = getCycle(); }
    inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
    inline int64_t getCycle() {
        uint32_t low, high;
        __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
        return ((int64_t)low) | ((int64_t)high << 32);
    }
};


bool multicase = false;

ll n, m, k, w, num, a, b, c, d, e, h, q, ans, sum, l;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
string s, t;

void solve() {
    cin >> a >> b >> c;
    ll ans = c * ((a + b - 1) / b);
    p(ans);
    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}



Measured memory_bytes: 3640
#include<iostream>

#define MAX(X, Y) (((X) > (Y))? (X): (Y))

using namespace std;

int main(void)
{
    int K, N, i, max = 0;
    long S;
    cin >> K >> N;
    int A[N], D[N];
    for(i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    S = 0;
    for(i = 0; i < N; i++)
    {
        D[i] = (K + A[(i + 1)%N] - A[i])%K;
        S += D[i];
        max = MAX(max, D[i]); 
    }
    S -= max;
    cout << S << endl;
    /*
    cerr << K <<" "<< N <<endl;
    for(i = 0; i < N; i++)
    {
        cerr << A[i] << " ";
    }
    cerr << endl;
    for(i = 0; i < N; i++)
    {
        cerr << D[i] << " ";
    }
    cerr << endl;
    */
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  if((n/1000 == n%1000/100 && n%1000/100 == n%1000%100/10)
     || (n%1000/100 == n%1000%100/10 && n%1000%100/10 == n%1000%100%10)) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	VE vec(n);
	double ans = 0;
	REP(i,n) {
		double tmp1 = log2(k / (double(i) + 1));
		vec[i] = ceil(tmp1) < 0? 0:ceil(tmp1);// 繰り上げの問題がある
		double tmp = pow(0.5, vec[i]);
		ans +=  tmp/ n;
	}
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

// import java.util.ArrayList;
// import java.util.List;
// import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String p = scan.nextLine();
		char[] sC = s.toCharArray();
		char[] pC = p.toCharArray();
		for (int i = 0; i < sC.length; i++) {
			if (pC[0] == sC[i]) {
				int cnt = 0;
				for (int j = 0; j < p.length(); j++) {
					if(pC[j] == sC[(i + j) % s.length()]){
					cnt ++;
					}else{
					break;
					}
					if(p.length() == cnt){
					System.out.println("Yes");
					return;
					}
				}

			}
		}
		System.out.println("No");
	}

}



Measured memory_bytes: 26280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int N;

int main(void) {

	cin >> N;

	long long int ans = 0;

	for (long long int i = 1; i <= N; i++) {
		if (i % 15 == 0) {}
		else if (i % 3 == 0) {}
		else if (i % 5 == 0) {}
		else { ans += i; }
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b;
	cin >> a >> b;
	int c = a + b;
	if (c == 3) {
		cout << 3 << endl;
	}
	if (c == 4) {
		cout << 2 << endl;
	}
	if (c == 5) {
		cout << 1 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll K, N;
    cin >> K >> N;
    ll max_=0;
    ll tmp=0;
    ll fi=0;
    for(int i=0; i<N; i++){
        ll a;
        cin >> a;
        if(i==0){
            fi=a;
        }
        max_=max(max_,a-tmp);
        tmp=a;
    }
    max_=max(max_,K-tmp+fi);
    cout << K-max_ << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char s[19];
	char s1[5], s2[7], s3[5];
	int i;
	
	scanf("%s", s);
	
	for (i = 0; i < 19; i++){
		if (i != 5 && i != 13) printf("%c", s[i]);
		else printf(" ");
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long n = Long.parseLong(in.readLine());
    long a = 1;
    
    for(int i=1; i<=Math.sqrt(n); i++){
      if(n%i==0)
        a = n/i;
    }
    
    System.out.println(String.valueOf(a).length());
  }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;

  if(S == U) A--;
  if(T == U) B--;

  cout << A << " " << B << endl;
  
  return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 220000;

int n, a, b;
ll x[MAXN];
ll y[MAXN];
set<tuple<ll, ll, int> >  ssx;
set<tuple<ll, ll, int> >  ssy;
vector<pair<ll, ll> > vvx;
vector<pair<ll, ll> > vvy;
int was[MAXN];

int main() {
	scanf("%d%d%d", &n, &a, &b);
	--a, --b;
	for (int i = 0; i < n; ++i)
		scanf("%lld%lld", x + i, y + i);
	for (int i = 0; i < n; ++i) {
		ll nx = x[i] - y[i];
		ll ny = x[i] + y[i];
		x[i] = nx;
		y[i] = ny;
	}
	ll d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
	was[a] = 1;
	was[b] = 1;
	queue<int> qu;
	qu.push(a);
	qu.push(b);
	for (int i = 0; i < n; ++i)
		if (!was[i]) {
			ssx.insert(make_tuple(x[i], y[i], i));
			ssy.insert(make_tuple(y[i], x[i], i));
		}
	while (!qu.empty()) {
		int a = qu.front();
		qu.pop();
		ll xl = x[a] - d;
		ll xr = x[a] + d;
		ll yl = y[a] - d;
		ll yr = y[a] + d;
		auto it = ssx.lower_bound(make_tuple(xl, yl, 0));
		while (it != ssx.end() && get<0>(*it) == xl && get<1>(*it) <= yr) {
			int b = get<2>(*it);
			ssy.erase(make_tuple(y[b], x[b], b));
			was[b] = 1;
			qu.push(b);
			ssx.erase(it++);
		}
		it = ssx.lower_bound(make_tuple(xr, yl, 0));
		while (it != ssx.end() && get<0>(*it) == xr && get<1>(*it) <= yr) {
			int b = get<2>(*it);
			ssy.erase(make_tuple(y[b], x[b], b));
			was[b] = 1;
			qu.push(b);
			ssx.erase(it++);
		}
		it = ssy.lower_bound(make_tuple(yl, xl, 0));
		while (it != ssy.end() && get<0>(*it) == yl && get<1>(*it) <= xr) {
			int b = get<2>(*it);
			ssx.erase(make_tuple(x[b], y[b], b));
			was[b] = 1;
			qu.push(b);
			ssy.erase(it++);
		}
		it = ssy.lower_bound(make_tuple(yr, xl, 0));
		while (it != ssy.end() && get<0>(*it) == yr && get<1>(*it) <= xr) {
			int b = get<2>(*it);
			ssx.erase(make_tuple(x[b], y[b], b));
			was[b] = 1;
			qu.push(b);
			ssy.erase(it++);
		}
	}
	for (int i = 0; i < n; ++i)
		vvx.push_back(make_pair(x[i], y[i]));
	for (int i = 0; i < n; ++i)
		vvy.push_back(make_pair(y[i], x[i]));
	sort(vvx.begin(), vvx.end());
	sort(vvy.begin(), vvy.end());
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		if (!was[i])
			continue;
		ll xl = x[i] - d;
		ll xr = x[i] + d;
		ll yl = y[i] - d;
		ll yr = y[i] + d;
		ans += lower_bound(vvx.begin(), vvx.end(), make_pair(xl, yr)) - upper_bound(vvx.begin(), vvx.end(), make_pair(xl, yl));
		ans += lower_bound(vvx.begin(), vvx.end(), make_pair(xr, yr)) - upper_bound(vvx.begin(), vvx.end(), make_pair(xr, yl));
		ans += upper_bound(vvy.begin(), vvy.end(), make_pair(yl, xr)) - lower_bound(vvy.begin(), vvy.end(), make_pair(yl, xl));
		ans += upper_bound(vvy.begin(), vvy.end(), make_pair(yr, xr)) - lower_bound(vvy.begin(), vvy.end(), make_pair(yr, xl));
	}
	assert(ans % 2 == 0);
	cout << ans / 2 << "\n";
	return 0;
}




Measured memory_bytes: 19312
def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = 0

    while True:
        for i in range(N):
            if A[i]%2==1:
                return count
            else:
                A[i] = A[i]/2
        count += 1

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

int main() {
	while(1) {
		int w, h;
		cin>>w>>h;
		if(w == 0 && h== 0) break;
		int yoko[h][w - 1];
		int tate[h - 1][w];
		REP(i, 2 * h - 1) {
			if(i % 2 == 0) {
				REP(j, w - 1) cin>>yoko[i / 2][j];
			} else {
				REP(j, w) cin>>tate[i / 2][j];
			}
		}
		int d[h][w];
		REP(i, h) {
			REP(j, w) d[i][j] = INF;
		}
		d[0][0] = 0;
		queue<P> q;
		q.push(P(0, 0));
		while(!q.empty()) {
			P p = q.front();
			q.pop();
			if(p.first - 1 >= 0 && tate[p.first - 1][p.second] == 0 && d[p.first - 1][p.second] == INF) {
				d[p.first - 1][p.second] = d[p.first][p.second] + 1;
				q.push(P(p.first - 1, p.second));
			}
			if(p.first + 1 < h && tate[p.first][p.second] == 0 && d[p.first + 1][p.second] == INF) {
				d[p.first + 1][p.second] = d[p.first][p.second] + 1;
				q.push(P(p.first + 1, p.second));
			}
			if(p.second - 1 >= 0 && yoko[p.first][p.second - 1] == 0 && d[p.first][p.second - 1] == INF) {
				d[p.first][p.second - 1] = d[p.first][p.second] + 1;
				q.push(P(p.first, p.second - 1));
			}
			if(p.second + 1 < w && yoko[p.first][p.second] == 0 && d[p.first][p.second + 1] == INF) {
				d[p.first][p.second + 1] = d[p.first][p.second] + 1;
				q.push(P(p.first, p.second + 1));
			}
		}
		if(d[h - 1][w - 1] == INF) cout<<0<<endl;
		else cout<<d[h - 1][w - 1] + 1<<endl;
	}
}

Measured memory_bytes: 3004
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;




int main(int argc, char *args[]) {
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


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

int n, m, q, a[50], b[50], c[50], d[50], tmp[11];
int ans = 0;

void dfs(int i) {
	if (i > n) {
		int sum = 0;
		for (int j = 0; j < q; j++) {
			if (tmp[b[j]] - tmp[a[j]] == c[j]) sum += d[j];
		}
		ans = std::max(ans, sum);
		return;
	}
	// 最後の値
	int last = tmp[i - 1];
	for (int j = last; j <= m; j++) {
		tmp[i] = j;

		dfs(i + 1);
	}
}

int main() {
	// 入力を読む
	std::cin >> n >> m >> q;
	for (int i = 0; i < q; i++) {
		std::cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	tmp[0] = 1;
	dfs(1);
	std::cout << ans << std::endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int at = 1, h1, s1, h2, s2;
    cin >> h1 >> s1 >> h2 >> s2;
    while (h1 > 0 && h2 > 0)
    {
        if (at & 1)
        {
            h2 -= s1;
        }
        else
        {
            h1 -= s2;
        }
        at++;
    }
    if (h2 <= 0)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3688
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    val a = Array(N) { sc.nextInt() }
    a.sortDescending()
    println(a.mapIndexed { i, v -> pow(-1, i) * v }.sum())
}

fun pow(a: Int, b: Int): Int {
    var result = 1
    repeat(b) {
        result *= a
    }
    return result
}


Measured memory_bytes: 36168
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for(int i=0; i<H; i++) cin >> S[i];

	vector<vector<ll>> adj(H*W, vector<ll>(H*W, 1e9));

	for(int x=0; x<H; x++) for(int y=0; y<W; y++){
		int dx[] = {0, 1};
		int dy[] = {1, 0};
		for(int i=0; i<2; i++){
			if(x+dx[i]<H&&y+dy[i]<W&&S[x][y]=='.' && S[x+dx[i]][y+dy[i]]=='.'){
				adj[x*W+y][(x+dx[i])*W+y+dy[i]]=1;
				adj[(x+dx[i])*W+y+dy[i]][x*W+y]=1;
			}
		}
	}

	for(int i=0; i<H*W; i++) debugv(adj[i]);

	vector<vector<ll>> dist(adj);

	for(int k=0; k<H*W; k++) for(int i=0; i<H*W; i++) for(int j=0; j<H*W; j++){
		dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
		if(i==0 && dist[i][j]==dist[i][k]+dist[k][j]) debug(i, j, k, dist[i][j], dist[i][k], dist[k][j]);
	}

	ll ans = 0;
	for(int i=0; i<H*W; i++) for(int j=0; j<H*W; j++){
		if(i==j || dist[i][j] >= 1e9) continue;
		debug(i, j, dist[i][j]);
		ans = max(ans, dist[i][j]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int K, S, cou;
	cou = 0;
	cin >> K >> S;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			if (i + j <= S&&S-j-i<=K)cou++;
		}
	}
	cout << cou << endl;
}

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

using namespace std;

int main() {
    int N, M;

    int sum = 0;
    cin >> N >> M;
    vector<int> A(M);

    for (int i = 0; i < M; i++) {
        cin >> A[i];
        sum += A[i];
    }

    if (sum <= N) {
        cout << N - sum << endl;
    } else {
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define printjudge(cond) {if(cond) printf("Yes\n"); else printf("No\n");}
#define printans(ans) {printf("%d\n",(ans));}
#define Ntimes(N) for(int i=0; i<N; i++)
typedef int* intarray;
typedef char* string;

int main(){
    int N, T, A;
    scanf("%d%d%d", &N, &T, &A);
    int* H = new int[N];
    Ntimes(N) scanf("%d", &H[i]);
    int ans_i;
    float temp, min_temp = 1000;
    Ntimes(N){
        temp = fabsf(A-(T-H[i]*0.006));
        if(temp<min_temp){
            ans_i = i;
            min_temp = temp;
        }
    }
    printans(ans_i+1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int dp[45][405][405];
int main(){
    int n, ma, mb; cin >> n >> ma >> mb;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    rep(i,45){
        rep(j,405){
            rep(k,405){
                dp[i][j][k] = 1e9;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 400; j++){
            for(int k = 0; k <= 400; k++){
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    int ans = 1e9;
    for(int j = 0; j <= 400; j++){
        for(int k = 0; k <= 400; k++){
            if(j == 0 && k == 0) continue;
            if(j*mb == k*ma && dp[n][j][k] != 1e9) ans = min(ans, dp[n][j][k]);
        }
    }
    if(ans == 1e9) cout << "-1" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 29056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

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

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            int count = Integer.parseInt(Arrays.asList(br.readLine().split(" ")).get(0));
            String[] strList = new String[count];
            for (int i = 0; i < count; i++) {
                strList[i] = br.readLine();
            }

            Arrays.sort(strList);
            for (int i = 0; i < count; i++) {
                if (i == count - 1) {
                    System.out.println(strList[i]);
                } else {
                    System.out.print(strList[i]);
                }
            }
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

long long int dp[5][4001];

int main(void) {

  for(int i=0; i<=1000; i++) dp[1][i] = 1;
  for(int i=2; i<5; i++){
    for(int j=0; j<=1000*i; j++){
      for(int k=0; k<=1000; k++){
        if( j + k > 4000 ) continue;
        dp[i][j+k] += dp[i-1][j];
      }
    }
  }

  int n;
  while(cin >> n){
    cout << dp[4][n] << endl;
  }


  return 0;
}

// EOF

Measured memory_bytes: 3196
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,m,a[100100],l[100100],r[100100],w[100100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%d",&m,&n),r[0]=m;
    repu(i,1,n)
    {
        int t=(a[i]=getint())-a[i-1];
        if (!(i&1))
            if (l[i-1]+w[i-1]+t>m)
                l[i]=r[i]=m,w[i]=0;
            else
                l[i]=l[i-1],r[i]=min(r[i-1],m-w[i-1]-t),w[i]=w[i-1]+t;
        else
            if (r[i-1]+w[i-1]-t>=0)
                l[i]=max(l[i-1],t-w[i-1]),r[i]=r[i-1],w[i]=w[i-1]-t;
    }
    for (int q=getint(),i=0; q--;)
    {
        int t=getint(),x=getint();
        for (; i<n && a[i+1]<=t; ++i);
        int ans=max(min(x+w[i],r[i]+w[i]),l[i]+w[i]);
        if (i&1)
            ans=min(m,ans+t-a[i]);
        else
            ans=max(0,ans+a[i]-t);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstring>
#include <cstdio>

#define Maxn 200010

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int k, n, a[Maxn];

int main() {
    k = read(); n = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    int ans = k; a[0] = a[n] - k;
    for(int i = 1; i <= n; ++i) ans = min(ans, k - (a[i] - a[i - 1]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
rain = [0] * N


rain[0] = sum(A[::2]) - sum(A[1::2])
for i in range(1, N):
    rain[i] = 2*A[i-1] - rain[i-1]
print(*rain)


Measured memory_bytes: 23068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String s ="";
		long m=0,a=0,r=0,c=0,h=0;
		for(int i=0;i<n;i++) {
			s=sc.next();
			s = String.valueOf(s.charAt(0));
			if(s.equals("M")) {
				m++;
			}
			if(s.equals("A"))
				a++;
			if(s.equals("R"))
				r++;
			if(s.equals("C"))
				c++;
			if(s.equals("H"))
				h++;

		}
		long kekka = m*(a*(r+c+h)+r*(c+h)+c*h)+a*(r*(c+h)+c*h)+r*c*h;
		System.out.print(kekka);

	}

}


Measured memory_bytes: 43680
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 1000

int N;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i],w=match[u];
    if( w<0 || (!used[w]&&dfs(w)) ){
      match[u]=v;
      match[v]=u;
      return true;
    }
  }
  return false;
}
 
int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<N;v++){
    if(match[v]<0){
      memset(used,false,sizeof(used));
      if(dfs(v))res++;
    }
  }
  return res;
}
 
int main(){
  scanf("%d",&N);
  N--;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      int a;
      scanf("%d",&a);
      if(a==1)G[j].push_back(N+i);
    }
  }

  for(int i=0;i<N;i++)sort(G[i].begin(),G[i].end());
  int f=bipartite_matching();
  if(f!=N){
    printf("no\n");
  }else{
    printf("yes\n");
    for(int i=0;i<N;i++){
      match[ match[i] ]=-1;
      match[i]=-1;
      memset(used,false,sizeof(used));
      dfs(i);
      G[i].clear();
      G[i].push_back( match[i] );
    }
    
    for(int i=0;i<N;i++)
      printf("%d\n",match[i]-N+1);
    
  }
  return 0;
}

Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define getcx getchar_unlocked
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int main() {

	LL n,i, arr[2*MAX], ans = 0, mxht = -1, mxpos = 0;

	cin>>n;
	for(i = 0; i < n ;i++) {
		cin>>arr[i];

		if(arr[i] > mxht) {
			mxht = arr[i];
			mxpos = i;
		}
	}

	for(i = 1 ; i < n; i++) {
	
		if(arr[i] == mxht) continue;

		if(i < mxpos) {

			if(arr[i] < arr[i-1]) {
				ans += (arr[i-1] - arr[i]);
				arr[i] = arr[i-1];
			}
		} else {
			ans += (mxht - arr[i]);
			arr[i] = mxht;
		}
	}

	cout<<ans<<endl;

	return 0;
}

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

#define ll long long

using namespace std;
long long power(ll  x, ll n){
    if(n==0)return 1;
    ll temp=power(x,n/2);
    if(n%2==0)return temp*temp;
    else return x*temp*temp;

}
ll max(ll a,ll b){
    return a>b?a:b;

}

ll max(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll min(ll x,ll  y){
    return x+y-max(x,y);
}
ll min(ll x,ll y,ll z){
    return min(min(x,y),z);

}



void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

bool f(ll x,ll y){
    return x>y;


}






int main(){


    ll test;
    cin>>test;

    ll a,b;
    cin>>a>>b;
    cout<<min(a*test,b);
    return 0;
}






































Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
s = a.sum
h = Hash.new
a.each do |i|
  if h[i]
    h[i] += 1
  else
    h[i] = 1
  end
end

q.times do
  b,c = gets.split.map(&:to_i)
  s -= (b-c)*(h[b]) if h[b] != nil
  puts s
  if h[c]
    h[c] += h[b] if h[b] != nil
  else
    h[c] = h[b]
  end
  h[b] = 0
end

Measured memory_bytes: 25920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define getchar_unlocked getchar
char input[3000000];
char *p = input;
int ri() {
	int r=0, s=0;
	for(;;){if(*p=='-'){s=1;break;}if(*p<='9'&&*p>='0'){r=*p-'0';break;}p++;}p++;
	for(;;){if(*p<'0'||*p>'9')break;r=r*10+*p-'0';p++;}
	if(s)r=-r;
	return r;
}
char buf[3000000];
char *ptr = buf;
void wi(int n) {
	static char tmp[12];
	char *cur = tmp + 11;
	if (n) {
		while (n) {
			*--cur = n % 10 + '0';
			n /= 10;
		}
	} else *--cur = '0';
	while (*cur) *ptr++ = *cur++;
	*ptr++ = ' ';
}

int main() {
	fread(input, 1, 3000000, stdin);
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int max = 0, x = 0;
	for (int i = 0; i < n; i++) if (max < a[i]) max = a[i], x = 1; else if (max == a[i]) x++;
	int max2 = 0;
	for (int i = 0; i < n; i++) if (a[i] != max && max2 < a[i]) max2 = a[i];
	for (int i = 0; i < n; i++) {
		if (x == 1 && a[i] == max) wi(max2);
		else wi(max);
	}
	fwrite(buf, 1, ptr - buf, stdout);
	return 0;
}


Measured memory_bytes: 5888
n = int(input())
A = [int(input()) for _ in range(n)]

#%%
idx = 0
visited = set()
count = 0
flag = False

for i in range(n):
    next_idx = A[idx]
    next_idx -= 1
    visited.add(idx)

    if idx == 1:
        flag = True
        break
    elif next_idx in visited:
        break
    count += 1
    idx = next_idx

if flag:
    print(count)
else:
    print(-1)


Measured memory_bytes: 21448
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;

ll sqrt(ll x){
    ll MIN=1;
    ll MAX=x;
    while(MAX>MIN+1){
        ll MID=(MAX+MIN)/2;
        if(MID*MID>x) MAX=MID;
        else MIN=MID;
    }
    return MIN;
}

ll d[100001], r[400];

void add(int i, ll x){
    d[i]+=x;
    r[i/300]+=x;
}

ll getsum(int i,int j){
    ll ans=0;
    int a=i/300, b=j/300;
    if(b-a<=1) {
        for(int k=i;k<=j;k++) ans+=d[k];
    }

    else {
        for(int k=i;k<(a+1)*300;k++) ans+=d[k];
        for(int k=b*300;k<=j;k++) ans+=d[k];
        for(int k=a+1;k<b;k++) ans+=r[k];
    }

    return ans;

}

int main(){
    int N,Q; cin>>N>>Q;
    vector<ll> ans;
    for(int i=0;i<Q;i++){
        int c,a,b; cin>>c>>a>>b;
        if(c==0) add(a,b);
        else ans.push_back(getsum(a,b));
    }
    for(int i=0;i<ans.size();i++) cout<<ans.at(i)<<endl;
}


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


int main(){
  long long n,i;
  cin >> n;
  vector<long long> a(n);
  map<long long,long long> mp;
  for(i=0;i<n;++i){
    cin >> a[i];
    mp[a[i]]++;
  }
  bool ans=true;
  for(auto p : mp){
    if(p.second>=2){
      ans=false;
    }
  }
  if(ans==true){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int h = 100, w = 100;
    vector<vector<int>> grid(h, vector<int>(w, 0));
    for (int i = 0; i < h / 2; i++) {
        for (int j = 0; j < w; j++) {
            grid[i][j] = 1;
        }
    }

    for (int i = 0, cnt = 0; i < h && cnt < a - 1; i += 2) {
        for (int j = 0; j < w && cnt < a - 1; j += 2) {
            grid[i][j] = 0;
            cnt++;
        }
    }

    for (int i = h - 1, cnt = 0; i >= 0 && cnt < b - 1; i -= 2) {
        for (int j = w - 1; j >= 0 && cnt < b - 1; j -= 2) {
            grid[i][j] = 1;
            cnt++;
        }
    }

    cout << h << " " << w << endl;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << (grid[i][j] == 0 ? "." : "#");
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#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 REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;
const ll MAX_DIGIT = 12;

ll K = 0;
ll t;
ll ret = 0;
ll table[10][MAX_DIGIT];
// ll acc[10][MAX_DIGIT];


void input() {
  IN(K);
}

void solve() {
  REP(i, 10) {
    table[i][0] = 1;
    // acc[i][0] = i;
  }
  ll sum = 0;
  FOR(j, 1, MAX_DIGIT) {
    REP(i, 10) {
      if (i == 0) {
        table[0][j] = table[0][j-1] + table[1][j-1];
        // acc[0][j] = acc[9][j-1];
      } else if (i == 9) {
        table[9][j] = table[8][j-1] + table[9][j-1];
        // acc[9][j] = acc[8][j] + table[9][j];
      } else {
        table[i][j] = table[i-1][j-1] + table[i][j-1] + table[i+1][j-1];
        // acc[i][j] = acc[i-1][j] + table[i][j];
      }
      sum += table[i][j];
    }
    if (sum > 100050) break;
  }
  // REP(j, MAX_DIGIT) {
  //   REP(i, 10) {
  //     DEBUG(table[i][j]);
  //   }
  //   LN();
  // }

  ll k = 1, l = 0;
  ll remain = K;
  while(l >= 0) {
    while(table[k][l] < remain) {
      remain -= table[k][l];
      if (k==9) l++;
      k = (k % 9) + 1;
    }
    // DEBUG(l);
    // DEBUG(":");
    // DEBUG(k);
    // DEBUG("=>");
    // DEBUG(remain);
    cout << k;
    if (k != 0) k -= 1;
    l -= 1;
  }
  cout << endl;
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <iostream>

int f(int n) {
    int res = 1;
    while (res <= n) {
        res <<= 1;
    }
    return res >> 1;
}

int main() {

    int n;
    std::cin >> n;

    int res = f(n);
    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int m1 = sc.nextInt();
    int d1 = sc.nextInt();
    int m2 = sc.nextInt();
    int d2 = sc.nextInt();
    if(d2 != 1){
      System.out.println(0);
    }else{
      System.out.println(1);
    }
  }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> score;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    score.push_back(tmp);
  }
  for(int i=0;i<n-k+1;i++){
    int j=i+k;
    if(i!=0){ 
      if(score.at(i-1)<score.at(k+i-1))cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4316
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

struct edge {
    int to, cost;
};

ll A, B, M, N, D, K, L, Q, W, H, T, X, Y, S;

vector<edge> es[100001];
ll ds[100001];

void dfs(ll current, ll prev, ll cost)
{
    ds[current] = cost;
    for (auto e : es[current]) {
        if (e.to == prev) continue;
        dfs(e.to, current, cost + e.cost);
    }
}

int main()
{
    cin >> N;
    for (int i = 0; i < N-1; ++i) {
        int from, to, cost;
        cin >> from >> to >> cost;
        edge e; e.to = to-1; e.cost = cost;
        es[from-1].push_back(e);
        e.to = from-1;
        es[to-1].push_back(e);
    }
    cin >> Q >> K;
    vector< pair<int, int> > qs(Q);
    for (auto& q : qs)
        cin >> q.first >> q.second;
    
    dfs(K-1, -1, 0);

    for (auto q : qs) {
        cout << ds[q.first-1] + ds[q.second-1] << endl;
    }

    return 0;
}

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

int N;

int main(void){

    cin >> N;

    int ans = 0; 

    if (N >= 400 && N < 600){
        ans = 8;
    } else if (N >= 600 && N < 800){
        ans = 7;
    } else if (N >= 800 && N < 1000){
        ans = 6;
    } else if (N >= 1000 && N < 1200){
        ans = 5;
    } else if (N >= 1200 && N < 1400){
        ans = 4;
    } else if (N >= 1400 && N < 1600){
        ans = 3;
    } else if (N >= 1600 && N < 1800){
        ans = 2;
    } else {
        ans = 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL A, B;
  cin >> A >> B;
  cout << max({A + A - 1, B + B - 1, A + B}) << endl;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  cout << SUM(a) - n << endl;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int,input().split()))
a = []

if n == 2:
  a.append(b[0])
  a.append(b[0])
else:
  for i in range(n-1):
    if i == 0:
      if b[0] >= b[1]:
        a.append(b[0])
        a.append(b[1])
      else:
        a.append(b[0])
        a.append(b[0])
    elif i == n-2:
      a.append(b[i])
    else:
      if b[i] >= b[i+1]:
        a.append(b[i+1])
      else:
        a.append(b[i])

print(sum(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int n, m;
char l[110][110];
pp S, T;

void in(){
	read(n, m);
	for(int i=1; i<=n; ++i){
		scanf("%s", l[i]+1);
		for(int j=1; j<=m; ++j){
			if(l[i][j]=='S') S=pp{i, j};
			if(l[i][j]=='T') T=pp{i, j};
		}
	}
}

struct E {
	int to, cap, rev;
};

vector<E> edge[20010];

int f(int x, int y){
	return (x-1)*m + y;
}

void P(int x){
	printf("[%d] ", x);
	++x;
	int b=x&1; x/=2;
	printf("%d,%d %s", (x-1)/m+1, (x-1)%m+1, b?"out":"in");
}

int sp, tp;

void AE(int f, int t, int c){
	//printf("Edge: "); P(f); printf("->"); P(t); putchar(10);
	edge[f].pb({t, c, int(edge[t].size())});
	edge[t].pb({f, 0, int(edge[f].size())-1});
}

const int inf=1e9;

void dg(){
	for(int i=1; i<=n; ++i){
		vector<int> ps;
		for(int j=1; j<=m; ++j) if(l[i][j]!='.') ps.pb(f(i, j));
		for(int x:ps) for(int y:ps) if(x!=y) AE(x*2, y*2-1, inf);
		for(int x:ps) AE(2*x-1, 2*x, 1);
	}
	for(int j=1; j<=m; ++j){
		vector<int> ps;
		for(int i=1; i<=n; ++i) if(l[i][j]!='.') ps.pb(f(i, j));
		for(int x:ps) for(int y:ps) if(x!=y) AE(x*2, y*2-1, inf);
	}
}

int dst[20010];
int V;
int pi[20010];
bool bfs(){
	for(int i=1; i<=V; ++i) dst[i]=inf;
	fill(pi+1, pi+V+1, 0);
	dst[sp]=0;
	queue<int> q; q.push(sp);
	while(q.size()){
		int x=q.front(); q.pop();
		for(E e:edge[x]) if(e.cap > 0){
			int y=e.to;
			if(dst[y]>dst[x]+1){
				dst[y]=dst[x]+1; q.push(y);
			}
		}
	}
	return dst[tp] != inf;
}

int dfs(int x, int f){
	if(x == tp){
		//printf("Path: "); P(x);
		return f;
	}
	for(;pi[x] < int(edge[x].size()); ++pi[x]){
		auto& e=edge[x][pi[x]];
		//printf("Read edge: "); P(x); printf("->"); P(e.to); putchar(10);
		int y=e.to;
		if(e.cap > 0 && dst[y] == dst[x]+1){
			int r=dfs(y, min(f, e.cap));
			if(r){
				/*printf(" <- ");
				P(x);*/
				e.cap -= r;
				edge[y][e.rev].cap += r;
				return r;
			}
		}
	}
	return 0;
}

int main()
{
	in(); dg(); V = 2*n*m; sp=f(S.x, S.y)*2; tp=f(T.x, T.y)*2-1;
	if(S.x == T.x || S.y == T.y){
		puts("-1"); return 0;
	}
	ll ans=0;
	while(bfs()){
		int r;
		while((r=dfs(sp, inf))){
			ans+=r;
			//putchar(10);
		}
	}
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 61696
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main(){
    int n;
    int maxp, maxv;
    int p, d1, d2;
    while (~scanf("%d", &n)) {
        maxv = INT_MIN;
        REP(i, n) {
            scanf("%d%d%d", &p, &d1, &d2);
            if (d1 + d2 > maxv) {
                maxv = d1 + d2;
                maxp = p;
            }
        }
        if (n) printf("%d %d\n", maxp, maxv);
    }

    return 0;
}




Measured memory_bytes: 3096
struct BIT
	n::Int
	bit::Array{Int}
	BIT(n)=new(n,zeros(Int,n))
end
function sum(bit::BIT,i::Int)
	ans=0
	while i>0
		ans+=bit.bit[i]
		i-=i&-i
	end
	ans
end
function add(bit::BIT,i::Int,a::Int)
	while i<=bit.n
		bit.bit[i]+=a
		i+=i&-i
	end
end
function lower_bound(bit::BIT,k::Int)#k<=sum(ret)
	if k<=0
		return 0
	end
	ret=0
	i=1
	while i*2<=bit.n
		i*=2
	end
	while i>0
		if ret+i<=bit.n&&bit.bit[ret+i]<k
			k-=bit.bit[ret+i]
			ret+=i
		end
		i>>=1
	end
	ret+1
end
function toi(x)
	parse(Int,x)
end
function ps(s)
	map(toi,split(s))
end
function main()
	N,Q=ps(readline())
	C=ps(readline())
	id=zeros(Int,N)
	P=BIT(N)
	Qs=[Pair{Int,Int}[] for _=1:N]
	i=0
	for s=readlines()
		i+=1
		l,r=ps(s)
		push!(Qs[r],l=>i)
	end
	ans=zeros(Int,Q)
	cnt=0
	for r=1:N
		c=C[r]
		if id[c]>0
			add(P,id[c],-1)
			cnt-=1
		end
		id[c]=r
		add(P,id[c],1)
		cnt+=1
		for (l,i)=Qs[r]
			ans[i]=cnt-sum(P,l-1)
		end
	end
	println.(ans)
end
main()

Measured memory_bytes: 388708