akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const llong MOD = 1000000007;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N;
llong T, t[200200], TL = 0, DAM = 0;

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> t[i];
		if (t[i] <= TL) TL = t[i] + T;
		else {
			DAM += t[i] - TL;
			TL = t[i] + T;
		}
	}

	cout << TL - DAM;

	


}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct Comb{
  
  vector<int> fact,infact;
  int mod;
  
  Comb(int n,int m=1e9+7):
    fact(n+1),
    infact(n+1),
    mod(m)
  {
    n++;
    fact[0] = 1;
    for( int i = 1 ; i < n ; i++ ){
	 fact[i] = fact[i-1] * i;
	 fact[i] %= mod;
    }
    for( int i = 0 ; i < n ; i++ ){
	 infact[i] = mod_pow( fact[i] , mod-2 );
    }
  }

  int mod_pow(int x,int n){
    if(n==0)return 1;
    int res=mod_pow( x*x%mod , n/2 );
    if( n & 1 )res = res*x%mod;
    return res;
  }

  int comb(int a,int b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = infact[a-b]* infact[b] % mod;
    return tmp * fact[a] % mod; 
  }

  int perm(int a,int b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    return fact[a] * infact[a-b] % mod;
  }
};


signed main(){
  int n,m,k,mod=1000000007;
  cin>>n>>m>>k;
  Comb c(n*m);
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
	 ans+=((m-j-1)*(m-j)/2%mod)*(n-i)%mod;
	 ans%=mod;
	 ans+=((j)*(j+1)/2%mod)*(n-i-1)%mod;
	 ans%=mod;
	 ans+=((n-i-1)*(n-i)/2%mod)*m%mod;
	 ans%=mod;
    }
  }
  ans*=c.comb(n*m-2,k-2);
  cout<<ans%mod<<endl;
  return 0;
}


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

int main() {
    int flag = true;
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x - r < 0 || W < x + r) {
        flag = false;
    }
    if(y - r < 0 || H < y + r) {
        flag = false;
    }
    string messages = flag ? "Yes" : "No";
    cout << messages << endl;
    return 0;
}


Measured memory_bytes: 3216
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int N, T, cost, time, ans = 1001;

	scanf("%d%d", &N, &T);
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &cost, &time);
		if (time <= T) {
			if (cost <= ans)
				ans = cost;
		}
	}

	if (ans == 1001)
		puts("TLE");
	else 
		printf("%d\n", ans);

	return 0;
}


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

int main() {
  
  string S;
  cin >> S;

  if(S.at(0) == S.at(1) && S.at(1) == S.at(2)) cout << "No" << endl;
  else cout << "Yes" << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
#define N 100005
inline bool up(int&x,const int y){return x<y?x=y,1:0;}
inline bool down(int&x,const int y){return x>y?x=y,1:0;}
int n;
typedef std::pair<int,int> pii;
pii a[N];
int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0),std::cout.tie(0);
	std::cin>>n;
	int tmp=0;
	rep(i,1,n){
		std::cin>>a[i].first>>a[i].second;
		if((a[i].first+a[i].second)&1) ++tmp;
		else --tmp;
	}
	if(abs(tmp)!=n) return std::cout<<"-1\n",0;
	int m=31+static_cast<int>(tmp<0);
	std::cout<<m<<'\n';
	rep(i,0,30) std::cout<<(1<<i)<<' ';
	if(m>31) std::cout<<"1\n";
	else std::cout<<'\n';
	rep(i,1,n){
		int x=a[i].first,y=a[i].second;
        int buf[35]={0},ty=0;
        if(tmp<0) buf[31]='R',--x;
        _rep(j,30,0){
        	if(abs(x)<abs(y)) std::swap(x,y),ty^=1;
        	if(x>0) x-=1<<j,buf[j]=ty?'U':'R';
        	else x+=1<<j,buf[j]=ty?'D':'L';
		}
		rep(i,0,m-1) std::cout.put(buf[i]);
		std::cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3680
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let (a, b) = {
		let tmp: Vec<usize> = read_vec();
		(tmp[0], tmp[1])
	};

	println!("{}", lcm(a, b));
}

fn gcd(a: usize, b: usize) -> usize {
	if a%b == 0 {
		return b;
	} else {
		return(gcd(b, a%b));
	}
}

fn lcm(a: usize, b: usize) -> usize {
	return a * b / gcd(a, b);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//const int mod=1e9+7;
const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

int a[110];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll n,k;
    cin>>n>>k;
    n%=k;
    cout<<min(n,k-n);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll= long long;
int main(){
    string s,t;
    int a,b;
    cin >> a >> b;
    int i;
    for(i=0;i<b;i++){
        string sk;
        sk=to_string(a);
        s+=sk;
    }
    for(i=0;i<a;i++){
        string tk;
        tk = to_string(b);
        t+=tk;
    }
    //cout << s << " " << t << endl;
    if(a<=b)cout << s <<endl;
    else cout << t << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read();
int n, s, t;
int hd[400005], nx[1000006], to[1000006], c[1000006], cnt;
void add(int f, int t, int cap) {
    nx[++cnt] = hd[f], hd[f] = cnt, to[cnt] = t, c[cnt] = cap;
}
void fadd(int f, int t, int c) { add(f, t, c), add(t, f, 0); }

int dep[400005];
queue<int> q;
bool bfs() {
    for (int i = 1; i <= t; ++i) dep[i] = 0;
    dep[s] = 1, q.push(s);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = hd[u], v; i; i = nx[i]) {
            if (!c[i] || dep[v = to[i]]) continue;
            dep[v] = dep[u] + 1, q.push(v);
        }
    }
    return dep[t];
}

int iter[400005];
int dfs(int u, int dist) {
    if (u == t) return dist;
    for (int &i = iter[u], v, d; i; i = nx[i]) {
        if (!c[i] || dep[v = to[i]] != dep[u] + 1) continue;
        if (d = dfs(v, min(dist, c[i]))) return c[i] -= d, c[i ^ 1] += d, d;
    }
    return 0;
}
int Dinic() {
    int rt = 0, d;
    while (bfs()) {
        for (int i = 1; i <= t; ++i) iter[i] = hd[i];
        while (d = dfs(s, 10000000)) rt += d;
    }
    return rt;
}

vector<int> e[400005];
int p[400005];
struct Res {
    int u, v;
} res[400005];
bool get_res() {
    for (int u = 1; u < n; ++u) {
        for (int i = hd[u]; i; i = nx[i])
            if (to[i] != s && c[i] == 0) p[u] = to[i] - n + 1;
        cerr << "#" << u << ' ' << p[u] << endl;
    }

    int sum = 0;
    q.push(n);
    while (!q.empty()) {
        int u = q.front();
        ++sum, q.pop();
        for (int i = 0, v; i < e[u].size(); ++i)
            if (p[v = e[u][i]]) res[v] = (Res){u, p[v]}, q.push(p[v]), p[v] = 0;
    }
    return sum == n;
}

int main() {
    n = read(), s = 2 * n - 1, t = 2 * n, cnt = 1;
    for (int i = 1; i < n; ++i) fadd(i + n - 1, t, 1);
    for (int i = 1, c, u; i < n; ++i) {
        c = read(), fadd(s, i, 1);
        while (c--) {
            if ((u = read()) != n) fadd(i, u + n - 1, 1);
            e[u].push_back(i);
        }
    }
    if (Dinic() < n - 1) return puts("-1"), 0;
    if (!get_res()) return puts("-1"), 0;

    for (int i = 1; i < n; ++i) printf("%d %d\n", res[i].u, res[i].v);

    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

Measured memory_bytes: 36096
/****************************************

			LostMartian

****************************************/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) {
	cout << arg1 << " ";
	pn(args...);
}
template <typename Arg1>
void ps(Arg1&& arg1) {
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) {
	cout << arg1 << " ";
	ps(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
	cin >> arg1;
	read(args...);
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define umap unordered_map<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.rbegin(), x.rend()
#define test ll t; cin>>t; while(t--)
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define iAmSpeed ios_base::sync_with_stdio(false); cin.tie(NULL);
void LOCAL();
int main()
{
	clock_t z = clock();
	//LOCAL();
	iAmSpeed
	set<pi > sst;
	ll h, w, m;
	cin >> h >> w >> m;
	vpi row(h + 1), col(w + 1);
	rep(i, 0, h + 1) {
		row[i].se = i;
	}
	rep(i, 0, w + 1) {
		col[i].se = i;
	}
	rep(i, 0, m) {
		ll x, y;
		cin >> x >> y;
		row[x].fi += 1, col[y].fi += 1;
		sst.emplace(x, y);
	}
	sort(all(row));
	sort(all(col));
	ll xx=row[0].fi, yy=col[0].fi;
	for (ll r = 0; row[r].fi == xx; r++) {
		for (ll c = 0; col[c].fi == yy; c++) {
			if (!sst.count(make_pair(row[r].se, col[c].se))) {
				ll ans = row[r].fi + col[c].fi;
				pn(ans);
				return 0;
			}
		}
	}
	ll ans=row[0].fi+col[0].fi-1;
	pn(max((ll)0, ans));












	debug("Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}
void LOCAL() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


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

int main() {
  int n; cin >> n;
  priority_queue<P, vector<P>, greater<P>> pq;
  string ans = "Yes";
  rep(i,n) {
    int a, b; cin >> a >> b;
    pq.push(make_pair(b,a));
  }
  ll t = 0;
  while(!pq.empty()) {
    auto p = pq.top(); pq.pop();
    int shimekiri = p.first;
    int work = p.second;
    t += work;
    if (t > shimekiri) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int n;
  cin >> n;
  vector<vector<int> > open(n, vector<int>(10));  // 営業しているかどうか
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> open[i][j];
    }
  }
  vector<vector<ll> > ri(n, vector<ll>(11, 0));  // 利益
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> ri[i][j];
    }
  }
  ll ans = -INF;
  for (int i = 1; i < (1 << 10); i++) {
    ll res = 0;
    for (int j = 0; j < n; j++) {  // 全ての店舗回繰り返す
      int kazu = 0;
      for (int k = 0; k < 10; k++) {       // 営業の時間帯の重なりを数える
        if (i & (1 << k) && open[j][k]) {  // 両方共開いている
          kazu++;
        }
      }
      res += ri[j][kazu];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
let rec solve (ac, wa, tle, re) list = 
  match list with
  | "AC"::xx -> solve (ac + 1, wa, tle, re) xx
  | "WA"::xx -> solve (ac, wa + 1, tle, re) xx
  | "TLE"::xx -> solve (ac, wa, tle + 1, re) xx
  | "RE"::xx  -> solve (ac, wa, tle, re + 1) xx
  | _::xx -> solve (ac, wa, tle, re) xx
  | [] -> (ac, wa, tle, re)
let numOfAns = stdin.ReadLine() |> int
[for _ in 1 .. numOfAns -> stdin.ReadLine()] 
  |> solve (0, 0, 0, 0)
  |> fun (ac, wa, tle, re) -> 
    printfn "AC x %d\nWA x %d\nTLE x %d\nRE x %d" ac wa tle re

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

using namespace std;

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

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,k;
int a[125252];
ll psum[125252];
ll asum[125252];
ll dp[125252];

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)psum[i+1]=psum[i]+a[i];
  REP(i,n)asum[i+1]=asum[i]+max(0,a[i]);
  ll ans = -1e14;
  REP(i,n-k+1){
    // [i,i+k)
    ll tmp = asum[i] + (asum[n]-asum[i+k]) + max(0ll,psum[i+k]-psum[i]);
    CHMAX(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2176
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
int D[200001];
int M;
int T[200001];

signed main(){
    cin >> N;
    rep(i, N) cin >> D[i];
    sort(D, D+N);
    cin >> M;
    rep(i, M) cin >> T[i];
    sort(T, T+M);

    int i = 0;
    rep(j, M){
        int idx = lower_bound(D+i, D+N, T[j]) - D;
        if(idx == N || D[idx] != T[j]){
            cout << "NO" << endl;
            return 0;
        }
        i = idx+1;
    }
    cout << "YES" << endl;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int n  = Integer.parseInt(strArr[0]) - 1;
            int k = Integer.parseInt(strArr[1]) - 1;
            strArr = br.readLine().split(" ");
            int ans = n / k;
            if (n % k != 0) {
                ans++;
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


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

last = ""
all_set = set()
result = True
for i in range(N):
    w = input()
    if i > 0:
        if w[0] != last[-1] or w in all_set:
            result = False
    all_set.add(w)
    last = w
if result:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

ll n,p;
ll ans=1;


void input(){
	cin>>n>>p;
	return;
}

void solve(){
	if(n==1){
		cout<<p<<endl;
		return;
	}
	for(ll i=2;i<=sqrtl(p)+1;i++){
		int cnt=0;
		ll m=p;
		while(true){
			if(m%i!=0)break;
			cnt++;
			m/=i;
		}
		if(cnt>=n)ans=max(ans,i);
	}
	cout<<ans<<endl;	
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 1e5+12;
//indexed_set s;

double a,b,c;

int main() {

    cin >> a >> b >> c;
    double t = a/c;
    if (t <= b) cout << "Yes";
    else cout << "No";
return 0;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){

  while(1){
    int n,m,p;
    cin >> n >> m >> p;
    if(n==0) break;
    int x[1000],sum=0;
    rep(i,n){
      cin >> x[i];
      sum += x[i]*100;
    }
    sum = sum - sum * p /100;
    int ans = 0;
    if(x[m-1] != 0) ans =  sum / x[m-1];
    cout << ans << endl;
  }

}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  int i;
  int sizeS=0;
  int flag=0;
  int temp=3;
  if(N==2){
    printf("No");
    return 0;
  }
  if(N==1){
    printf("Yes\n");
    printf("2\n");
    printf("1 1\n");
    printf("1 1\n");
    return 0;
  }
  if(N==3){
    sizeS=3;
    flag=1;
  }
  if(N>3){
    for(i=3;i<500;i++){
      temp=temp+i;
      if(temp==N){
        sizeS=i+1;
        flag=1;
      }
    }
  }
  if(flag==0){
    printf("No");
    return 0;
  }
  int j;
  int S[sizeS+1][sizeS+1];
  S[1][1]=1;
  S[2][1]=1;
  int K=1;
  for(i=2;i<sizeS;i++){
    for(j=1;j<=i;j++){
      S[j][i]=K+j;
    }
    for(j=1;j<=i;j++){
      S[i+1][j]=K+j;
    }
    K=K+i;
  }

  printf("Yes");
  printf("\n");
  printf("%d\n",sizeS);
  for(i=1;i<=sizeS;i++){
    printf("%d ",sizeS-1);
    for(j=1;j<=sizeS-1;j++){
      printf("%d ",S[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a,b;
set<int> st;
vector<int> vec;

int main(){
	cin >> n;
	REP(i,2,200001){
		bool f=true;
		for(int j=2;j*j<=i;j++) if(!(i%j)) f=false;
		if(f) st.insert(i);
	}
	for(auto s:st) if(st.count(2*s-1)) vec.push_back(2*s-1);
	
	REP(i,0,n){
		cin >> a >> b;
		cout << upper_bound(vec.begin(), vec.end(), b)-lower_bound(vec.begin(), vec.end(), a-1) << endl;
	}
	return 0;
}


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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    string ans;
    for (int i = 0; i < dy; ++i) ans += "U";
    for (int i = 0; i < dx; ++i) ans += "R";
    for (int i = 0; i < dy; ++i) ans += "D";
    for (int i = 0; i < dx; ++i) ans += "L";
    ans += "L";
    for (int i = 0; i < dy + 1; ++i) ans += "U";
    for (int i = 0; i < dx + 1; ++i) ans += "R";
    ans += "D";
    ans += "R";
    for (int i = 0; i < dy + 1; ++i) ans += "D";
    for (int i = 0; i < dx + 1; ++i) ans += "L";
    ans += "U";
    cout << ans << endl;
}

Measured memory_bytes: 256
//         Jai Saraswati Maa       Om Namah Shivaay        Jai Bhawani
// You have to work hard and keep coding till you get correct output never quit! :-)
// May the force be with you
// Ganpatai Bappa Morya! Mangal Murti Morya!
#include<bits/stdc++.h>
#define sc(x) scanf("%d",&x);
#define scc(x,y) scanf("%d %d",&x,&y);
#define sccc(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define sl(x) scanf("%lld",&x);
#define sll(x,y) scanf("%lld %lld",&x,&y);
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z);
#define pf(x) printf("%d",x);
#define pfn(x) printf("%d\n",x);
#define pl(x) printf("%lld",x);
#define pln(x) printf("%lld\n",x);
#define st(s) scanf("%s",s);
using namespace std;
bool isPerfectSquare(int n)
{
    // sum is sum of all odd numbers. i is
    // used one by one hold odd numbers
    for (int sum=0,i=1; sum<n; i+=2)
    {
        sum += i;
        if (sum == n)
            return true;
    }
    return false;
}
int main()
{
   char s[100],a[100];
   st(s)
   st(a)
    if(s[0]==a[2]&&s[1]==a[1]&&s[2]==a[0])
        printf("YES\n");
    else
        printf("NO\n");
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const ll inf = 1e12 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
int main()
{   

    flash;
    ll n, m ;
    double s=0;
    cin >> n >> m;
    ll a[n];
    rep(i,0,n)cin >> a[i];
    rep(i,0,n)s+=a[i];

    double r=s/(4*m);
    ll c=0;
    rep(i,0,n){
      if(a[i]>=r)c++;
    }
    if(c>=m)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll N;
vector<vector<pair<ll, ll>>> G;
vll colors;

void dfs(ll node, ll pre) {
    for (auto elem : G[node]) {
        ll next_node = elem.first;
        ll weight = elem.second;

        if (next_node == pre) continue;

        if (weight % 2) colors[next_node] = !colors[node];
        else colors[next_node] = colors[node];

        dfs(next_node, node);
    }
}

int main()
{
    cin >> N;
    G.resize(N);
    colors.resize(N);
    rep(i, N - 1) {
        ll src, dst, weight; cin >> src >> dst >> weight; src--, dst--;
        G[src].push_back({dst, weight});
        G[dst].push_back({src, weight});
    }

    dfs(0, -1);

    for (auto elem : colors) {
        cout << elem << endl;
    }
    return 0;
}

Measured memory_bytes: 9984
import java.util.Scanner;

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

	if(a < b) System.out.println("a < b");
	else if(a > b) System.out.println("a > b");
	else System.out.println("a == b");
    }
}



Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
long long ans(long long n, long long x){
	return n/x + 1LL; //0 is also divisible
}
int main() {
	// your code goes here
	long long a,b,x;
	cin>>a>>b>>x;
	a = min(a,b); b = max(a,b);
	long long res = ans(b,x);
	if(a>0) res-=ans(a-1,x);
	printf("%lld\n", res);
	
	// critical input : 0 0 x
	return 0;
}

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

using namespace std;

const int N = 1e5 + 100, inF = 2e9;

int n, k, h[N], dp[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		dp[i] = (i > 0) * inF;
		cin >> h[i];
		for (int j = 1; j <= min(i, k); j++)
			dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
	}
	cout << dp[n - 1];
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

Measured memory_bytes: 21788
h,w,k = map(int,input().split())
c = [0]*h
for i in range(h):
    c[i] = list(input())
lis = []
for i in range(h):
    for j in range(w):
        if c[i][j] == "#":
            lis.append([i,j])
ans = 0
for i in range(2**(w+h)):
    num = 0
    lis_w = []
    lis_h = []
    for j in range(w+h):
        if (i >> j)&1:
            if j >= w:
                lis_h.append(j-w)
            else:
                lis_w.append(j)
    for I,J in lis:
        sw = 1
        if I in lis_h:
            sw = 0
        if J in lis_w:
            sw = 0
        if sw == 1:
            num += 1
    if num == k:
        ans += 1
print(ans)

Measured memory_bytes: 9244
using System;
using System.Collections.Generic;

namespace AtCoder
{
	public class Program
	{
		// ABC109-B
		static void Main(string[] args)
		{
			string result = "Yes";
			HashSet<string> dic = new HashSet<string>();
			char lastChar = ' ';
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++) {
				string word = Console.ReadLine();
				if (i == 0 || (!dic.Contains(word) && word[0] == lastChar)) {
					dic.Add(word);
					lastChar = word[word.Length - 1];
				} else {
					result = "No";
					break;
				}
			}
			Console.WriteLine(result);
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9

#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;


void solve()
{
    int n,k;
    cin>>n>>k;
    LL arr[n+1];
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    LL dp[n+1];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=1e12;
        for(int j=1;j<=k;j++)
        {
            if(i-j<1)
                break;
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    cout<<dp[n]<<nl;
}
int main()
{   fast;
        solve();
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] people = new int[N];
		int d = Q-K;
      
		if(K<=Q){
         	for(int i=0; i<Q; i++){
             	int A = sc.nextInt();
             	people[A-1]++;
			}
			
			for(int i=0; i<N; i++){
				if(people[i]<=d){
					System.out.println("No");
				}else{
					System.out.println("Yes");
				}
			}
		}else{
			for(int i=0; i<N; i++){
				System.out.println("Yes");
			}
		}
	}
}

Measured memory_bytes: 50164
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long 
using namespace std;

ll dp[300050];
ll h[300050];
int n;

ll solve(int l, int c){
  if(l == n)
    return 0;
  
  if(dp[l*3+c] != -1)
    return dp[l*3+c];
  
  ll res = 0;
  for(int i = 0; i < 3; i++){
    if(i == c)
      continue;

    res = max(res, h[l*3+i] + solve(l+1, i));
  }

  return dp[l*3+c] = res;
}

int main()
{
    cin >> n;

    memset(dp, -1, sizeof dp);

    for(int i = 0; i < n * 3; i++)
      cin >> h[i];

    ll res = 0;
    for(int i = 0; i < 3; i++){
      res = max(res, h[i] + solve(1, i));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 16052
#include <stdio.h>

int main(void)
{
	char str[1024], com[16], p[1024];
	int a, b, n, i, t;

	scanf("%s", str);
	scanf("%d", &n);
	while (n--) {
		scanf("%s", com);
		switch (com[2]) {
		case 'i': // PRINT
			scanf("%d %d", &a, &b);
			for (i = a; i <= b; i++) {
				printf("%c", str[i]);
			}
			puts("");
			break;
		case 'v': // REVERSE
			scanf("%d %d", &a, &b);
			for (i = 0; i < (b - a + 1) / 2; i++) {
				t = str[a + i];
				str[a + i] = str[b - i];
				str[b - i] = t;
			}
			break;
		case 'p': //REPLACE
			scanf("%d %d %s", &a, &b, p);
			for (i = 0; i < b - a + 1; i++) {
				str[a + i] = p[i];
			}
			break;
		}
	}
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const int MAX_N = (int)1e5 + 5;
int A[MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int d;
        cin>>d;
        A[d]++;
    }
    int ans = 0, cnt = 0;
    for(int i=0;i<MAX_N;i++){
        if(cnt==N/2) ans++;
        cnt += A[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cctype>
#include <ctime>
#include <cassert>
#include <cwchar>
#include <cstdarg>
#include <cwctype>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <functional>
#include <iomanip>
#include <sstream>

#include <tr1/unordered_map>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#define foreach BOOST_FOREACH

using namespace std;
using namespace tr1;
using namespace boost;


typedef long long int lli;
int plen,cnum,width,cspace;
string String(int Number,string Character){
	string ret="";
	for(int i=0;i<Number;i++)ret+=Character;
	return ret;
}

int main() {
	for(;;){
		string t;
		getline(cin,t);
		plen=boost::lexical_cast<int>(t);
		if(!plen)break;
		getline(cin,t);
		cnum=boost::lexical_cast<int>(t);
		getline(cin,t);
		width=boost::lexical_cast<int>(t);
		getline(cin,t);
		cspace=boost::lexical_cast<int>(t);
		deque<string> in;
		while(1){
			getline(cin,t);
			if(t=="?")break;
			in.push_back(t);
		}
		deque<string> str;
		foreach(string t,in){
			for(int i=0;i<(int)t.size();i+=width){
				str.push_back(t.substr(i,min(width,(int)t.size()-i)));
			}
			if(t=="")str.push_back("");
		}
		for(;;){
			if((str.size()%(plen*cnum))==0)break;
			str.push_back("");
		}
		for(int i=0;i<(int)str.size();i++){
			str[i]+=String(width-str[i].size(),".");
		}
		vector<string> p(plen);

		while(!str.empty()){
			for(int i=0;i<plen;i++){
				p[i]="";
			}
			for(int i=0;i<cnum;i++){
				for(int j=0;j<plen;j++){
					if(i)p[j]+=String(cspace,".");
					p[j]+=str.front();
					str.pop_front();
				}
			}
			for(int i=0;i<plen;i++){
				cout<<p[i]<<endl;
			}
			cout<<"#"<<endl;
		}
		cout<<"?"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;

int main() {
	ll a, b; cin >> a >> b;
	cout << ((b % a == 0) ? a + b : b - a) << endl;
	return 0;
}

Measured memory_bytes: 256
h , w = input().split()
h , w = int(h) , int(w)

mp = [ '' for j in range(w * h)]
j = 0

for i in range (h) :
    tmp1 = list(input())
    for j in range (w) :
        mp[w * i + j] = tmp1[j]

def bfs (k) :
    used = [False for i in range(h * w)]
    q = [k]
    used[k] = True
    depth = [0 for i in range (h * w)]

    while len(q) > 0 :
        tmp = q.pop(0)
        if tmp > w - 1 and mp[tmp - w] == '.' and used[tmp - w] == False:
            q.append (tmp - w)
            used[tmp - w] = True
            depth [tmp - w] = depth[tmp] + 1

        if tmp < (h - 1) * w and mp[tmp + w] == '.' and used[tmp + w] == False :
            q.append (tmp + w)
            used[tmp + w] = True
            depth [tmp + w] = depth[tmp] + 1

        if tmp % w != 0 and mp[tmp - 1] == '.' and used[tmp - 1] == False :
            q.append (tmp - 1)
            used[tmp - 1] = True
            depth [tmp - 1] = depth[tmp] + 1

        if (tmp + 1) % w != 0 and mp[tmp + 1] == '.'and used[tmp + 1] == False :
            q.append (tmp + 1)
            used[tmp + 1] = True
            depth [tmp + 1] = depth[tmp] + 1
    
    mx = max(depth)

    return mx

ans = 0 

for i in range (h * w) :
    if mp[i] == '.' :
        ans = max(ans , bfs(i))

print (ans)

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

int main() {
    int h, w;
    while(true) {
        cin >> h >> w;
        if(h == 0 && w == 0) break;

        for(int i = 1; i <= h; i++) {
            for(int j = 1; j <= w; j++) {
                if(i % 2 == 1) {
                    if(j % 2 == 1) {
                        cout << '#';
                    } else {
                        cout << '.';
                    }
                } else {
                    if(j % 2 == 1) {
                        cout << '.';
                    } else {
                        cout << '#';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3060
// In the name of Allah //
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 10;
int n , x , t;
int main()
{
    cin >> n >> x >> t;
    if (n % x == 0)
        cout << (n / x) * t;
    else
    {
        cout << ((n / x) + 1) * t;
    }
}



Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#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 >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-9;

void solve() {
    ll h, w, n;
    cin >> h >> w >> n;
    map<pll, ll> m;
    for(ll i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        for(ll j = -1; j <= 1; j++) {
            for(ll k = -1; k <= 1; k++) {
                if(a + j < 2 || a + j > h - 1) continue;
                if(b + k < 2 || b + k > w - 1) continue;
                m[make_pair(a + j, b + k)]++;
            }
        }
    }
    vll ans(10);
    for(auto i = m.begin(); i != m.end(); i++) {
        ans[i->second]++;
    }
    ans[0] = (h - 2) * (w - 2);
    for(ll i = 1; i <= 9; i++) {
        ans[0] -= ans[i];
    }
    for(ll &i : ans) {
        cout << i << endl;
    }
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 56576
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  int n;
  cin>>n;
  n++;
  V<ll> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  if(n==1&&a[0]==1){
    cout<<1<<"\n";
    return 0;
  }
  if(a[0]!=0){
    cout<<-1<<"\n";
    return 0;
  }
  V<ll> sum(n);
  ll now=1,ans=0;
  for(int i=0;i<n;i++)sum[i]=a[i]+(i>0?sum[i-1]:0);
  for(int i=0;i<n;i++){
    if(now-a[i]<0){
      cout<<-1<<"\n";
      return 0;
    }
    ans+=now;
    now-=a[i];
    if(now>sum[n-1]-sum[i]){
      cout<<-1<<"\n";
      return 0;
    }
    now=min(now*2,sum[n-1]-sum[i]);
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 4780
/*
AOJ - ITP1_5_A
Date: 20180914
Author: Mikoron
 */

#include<stdio.h>

int main(void) {

        int H, W;
        int i, j;

        while(1) {
                scanf("%d %d", &H, &W);
                if(H == 0 && W == 0) break;
                for(i = 0; i < H; i++) {
                        for(j = 0; j < W; j++) {
                                printf("#");
                        }
                        printf("\n");
                }
                printf("\n");
        }

}



Measured memory_bytes: 2048
N = int(input())
A = list(map(int, input().split()))
B = [0] * len(A)

for i in range(len(A)):
  B[A[i]-1] = i+1

for i in range(len(B)):
  print(str(B[i]), end="")
  if i == len(B)-1:
    break
  print(" ", end = "")
print()

Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	int a,b;
	char mise[4]={'B','C','D','E'};
	while(cin>>a>>b){
		vector<pair<int,char> > data;
		if(a==0&&b==0)break;
		data.push_back(make_pair(a+b,'A'));
		for(int i=0;i<4;i++){
			cin>>a>>b;
			data.push_back(make_pair(a+b,mise[i]));
		}
		sort(data.begin(),data.end());
		cout<<data[4].second<<" "<<data[4].first<<endl;
	}
			
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main()
{
std::ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);

double n;
cin>>n;
if((int)n%1000==0)cout<<0<<endl;
else
{
    long m=ceil(n/1000);
    cout<<(1000*m)-n<<endl;

}












return 0;
}


Measured memory_bytes: 3920
fn main() {
    let nm = read_vec::<usize>();
    let mut a_vec = read_vec::<i32>();
    let n: usize = nm[0];
    let m: usize = nm[1];
    let mut sum: i32 = 0;

    a_vec.sort();
    a_vec.reverse();

    for number in 0..n {
        sum = sum + a_vec[number];
    }
    if m > n {
        println!("No");
    } else {
        if a_vec[m - 1] as f32 >= sum as f32/ (4.0 * m as f32) {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  map<string, int> maf;
  for (int i = 0; i < n; ++i){
    string s; cin >> s;
    maf[s]++;
  }
  cout << "AC x " << maf["AC"] << "\n";
  cout << "WA x " << maf["WA"] << "\n";
  cout << "TLE x " << maf["TLE"] << "\n";
  cout << "RE x " << maf["RE"] << "\n";
  return 0;
}

Measured memory_bytes: 3652
### main

while true
  s1, s2 = gets.strip.split(' ').map{|s| s.to_i}
  break if s1 == 0 && s2 == 0

  shops = [[s1 + s2, 'A']]

  for sn in ('B'..'E')
    s1, s2 = gets.strip.split(' ').map{|s| s.to_i}
    shops << [s1 + s2, sn]
  end

  shm = shops.max{|a, b| a[0] <=> b[0]}
  puts "#{shm[1]} #{shm[0]}"
end

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

template <typename T> class tRMQ {
  vector<T> data;
  T unit;

public:
  int n;
  function<T(const T &, const T &)> f;

  tRMQ(int _, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < _) {
      n <<= 1;
    }
    data.resize(n * 4);
    for (int i = 0; i < n * 4; i++)
      data[i] = unit;
  }

  tRMQ(vector<T> &v, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < v.size())
      n <<= 1;
    data.resize(n * 2 + 1);
    for (int i = 0; i < n + 1; i++) {
      if (i < v.size())
        data[i + n] = v[i];
      else
        data[i + n] = u;
    }
    for (int i = n - 1; i >= 0; i--) {
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  void update(int index, T val) {
    int i = index + n - 1;
    data[i] = val;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)
  T query(int a, int b, int k, int l, int r) {
    if (a < 0 || r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return data[k];
    else
      return f(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (r + l) / 2, r));
  }

  T query(int a, int b) { return query(a, b, 0, 0, n); }
};

int DAY = 86400;
int MOR = 10800;

int main() {
  int n;
  cin >> n;
  int base = 0;
  vector<ll> d(DAY);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    d[(base + a) % DAY] += 1;
    base += a + b;
    base %= DAY;
  }
  tRMQ<ll> q(d, 0ll, [](const ll &l, const ll &r) { return l + r; });
  ll ans = 0;
  for (int i = 0; i < DAY; i++) {
    ll b = q.query(max(-DAY + i, 0), max(-DAY + i + MOR + 1, 0)) +
           q.query(min(i, DAY), min(i + MOR + 1, DAY));
    ans = max(ans, b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int x;
    cin >> x;
    ll ans = 0;
    for(ll a = 1; a <= 100; a++){
        for(ll b = 2; b < 10; b++){
            ll tmp = ll(pow(a, b));
            if (tmp <= x) ans = max(tmp, ans);
        }
    }

    cout << ans << endl;

    return 0;
}

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<vector<int>> b(k, vector<int>(k, 0));
  for (int i = 0; i < n; i++) {
    int x, y; cin >> x >> y;
    char c; cin >> c;
    if (c == 'W') x += k;
    x %= 2 * k; y %= 2 * k;
    if (x < k and y < k) b[x][y]++;
    else if (x >= k and y >= k) b[x - k][y - k]++;
    else if (x < k) b[x][y - k]--;
    else b[x - k][y]--;
  }
  vector<vector<int>> c(k + 1, vector<int>(k + 1, 0));
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      c[i][j] = c[i][j - 1] + b[i - 1][j - 1];
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      c[i][j] += c[i - 1][j];
    }
  }
  int res = -1e9, res2 = 1e9;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int tmp = c[k][k] - 2 * (c[i][k] + c[k][j]) + 4 * c[i][j];
      res = max(res, tmp);
      res2 = min(res2, tmp);
    }
  }
  res = max(res, -res2);
  cout << (n + res) / 2 << '\n';
  return 0; 
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
ll a[N], b[N], c[N];
ll dp[N][3];
int n;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 1; i <= n; i ++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <math.h>
using namespace std;

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

Measured memory_bytes: 256