akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def solve():
    N, Q = map(int, input().split())
    adjL = [[] for _ in range(N)]
    for _ in range(N-1):
        A, B = map(int, input().split())
        A, B = A-1, B-1
        adjL[A].append(B)
        adjL[B].append(A)

    anss = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p = p-1
        anss[p] += x

    useds = [False] * N
    def dfs(vNow, x):
        useds[vNow] = True
        anss[vNow] += x
        for v2 in adjL[vNow]:
            if not useds[v2]:
                dfs(v2, anss[vNow])

    dfs(0, 0)

    print(' '.join(map(str, anss)))

solve()


Measured memory_bytes: 271372
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
 
using namespace std;
 
int main(){

  	char input;
  	vector<int>words(26);
	while(cin >> input){
      	if(input >= 'A' && input <= 'Z')
          input += 0x20;
      
      	if(input < 'A')
          continue;
		
      	int num = input - 'a';
      	words.at(num)++;
    }
  
  	for(int i=0; i<26; i++){
    	char alpha = i + 'a';
      	cout << alpha << " : "  << words.at(i) << endl;
    }
  
  	
  return 0;
}


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

int main(){
  vector<int> num(3);
  for(int i =0; i < 3;i++){
    cin >> num.at(i);
  }
  sort(num.begin(), num.end());
  int d = num.at(0), e = num.at(1), f = num.at(2);
  int ans = 0;
  if((e-d)%2 == 1){
    d++;
    f++;
    ans++;
  }
  ans += (e-d)/2 + (f-e);
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<ctime>
#define N 100010
using namespace std;
int n,a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int mx=0,mn=n;
	for(int i=1;i<=n;i++)mx=max(mx,a[i]),mn=min(mn,a[i]);
	bool flag=1;
	for(int i=1;i<=n;i++)if(a[i]!=n-1)flag=0;
	if(flag){cout<<"Yes";return 0;}
	int cnt=0;
	if(mx-mn>1){cout<<"No";return 0;}
	for(int i=1;i<=n;i++)
	if(a[i]<mx)++cnt;
	if(mx<cnt||2*(mx-cnt)>n-cnt||(n>cnt&&(mx-cnt<1)))cout<<"No";
	else cout<<"Yes";
	return 0;
}

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

int main()
{   ll n;
    scanf("%lld",&n);
    ll z[n],x[n];
    for(ll i=0;i<n;i++)
    {   scanf("%lld",&z[i]);
        x[i]=0;
    }
    x[0]=0;
    x[1]=abs(z[0]-z[1]);
    for(ll i=2;i<n;i++)
        x[i]=min(x[i-1]+abs(z[i]-z[i-1]),x[i-2]+abs(z[i]-z[i-2]));
    printf("%lld",x[n-1]);
    return 0;
}


Measured memory_bytes: 1792
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        a: i32, b: i32, c: i32
    }
    let ans = if a == b {
        c
    } else if b == c {
        a
    } else {
        b
    };
    println!("{}", ans);
}


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

int main(){
  using ll = long long int ;
  ll n,k ;
  cin >> n >> k ;
  vector<ll> kake(n+1) ;
  vector<ll> invs(n+1) ;
  vector<ll> invn(n+1) ;
  ll mod = 1000000007 ;
  vector<ll> a(n) ;
  for(int i=0;i<n;i++) cin >> a.at(i) ;
  kake.at(0) = kake.at(1) = 1 ;
  for(int i=2;i<=n;i++) kake.at(i) = kake.at(i-1)*i%mod ;
  invn.at(1) = 1 ;
  for(int i=2;i<=n;i++) invn.at(i) = mod-invn.at(mod%i)*(mod/i)%mod ;
  invs.at(0) = invs.at(1) = 1 ;
  for(int i=2;i<=n;i++) invs.at(i) = invs.at(i-1)*invn.at(i)%mod ;
  sort(a.begin(),a.end()) ;
  ll ans = 0 ;
  for(int i=0;i<n-k+1;i++){
    ll sub = a.at(n-1-i)-a.at(i) ;
    ll ncr = kake.at(n-1-i)*(invs.at(k-1)*invs.at(n-i-k)%mod)%mod ;
    ans += (sub*ncr%mod+mod)%mod ;
    ans %= mod ;
  }
  cout << ans << endl ;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + (x - 1)) / x * t << endl;
}

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

int N,a; vector<int> sol,v;

void Input(){
	cin>>N;
	for(int i=1; i<=N; i++){
		cin>>a;
		v.push_back(a);
	}
}

void Solve(){
	bool solution=true;
	for(int j=0; j<N; j++){
		bool pos=false;
		for(int i=v.size()-1; i>=0; i--){
			if(v[i]==i+1){
				sol.push_back(v[i]);
				v.erase(v.begin()+i);
				pos=true;
				break;
			}
		}
		solution=solution&pos;
	}
	if(solution){
		for(int i=sol.size()-1; i>=0; i--){
			cout<<sol[i]<<'\n';
		}
	}else{
		cout<<-1<<'\n';
	}
}

int main(){
	Input();
	Solve();
}

Measured memory_bytes: 3644
#include <stdio.h>
#include<string.h>
 
int main()
{
    int n,i,T=0,H=0,f;
    char t[101],h[101];
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s%s",t,h);
        f=strcmp(t,h);
        if(f==0){T+=1;H+=1;}
        else if(f>0)T+=3;
        else H+=3;
    }
    printf("%d %d\n",T,H);
    return 0;
}


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

int main() {
  int w, h, n, i, wl = 0, hl = 0;
  cin >> w >> h >> n;
  
  vector<int> x(n);
  vector<int> y(n);
  vector<int> a(n);
  for(i = 0; i < n; i++){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  
  for(i = 0; i < n; i++){
    if(a.at(i) == 1){
      wl = max(wl, x.at(i));
    }
    else if(a.at(i) == 2){
      w = min(w, x.at(i));
    }
    else if(a.at(i) == 3){
      hl = max(hl, y.at(i));
    }
    else{
      h = min(h, y.at(i));
    }
  }
  
  if(w < wl || h < hl){
    cout << 0 << endl;
  }
  else{
    cout << (w - wl) * (h - hl) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
const int N = 5 * 100000 + 100;

const int oo = 1e9;
int n ;
double v[N], t[N],tp = 0.0,L;

deque< pdd > q;

int main() {
	cin >> n >> L;
	for (int i = 0; i < n; ++i) {
		scanf("%lf%lf", &t[i], &v[i]);
	}
	for (int i = 0; i < n; ++i) {
		double rem = v[i];
		while (q.size() && rem > 0) {
			pdd g = q.front();
			double d = min(g.x, rem);
			rem -= d;			
			tp -= d*g.y;
			q.pop_front();
			if (g.x - d> 0)q.push_front(mp(g.x-d, g.y));
		}
		while(q.size() && q.back().y > t[i]){
			pdd src = q.back();q.pop_back();
			t[i] = (t[i]*v[i]+src.x*src.y)/(src.x+v[i]);
			v[i] = (v[i]+src.x);
			tp -= src.x*src.y;
		}
		tp += v[i]*t[i];
		q.pb(mp(v[i],t[i]));
		printf("%.9lf\n", tp/L);
	}
	return 0;
}

Measured memory_bytes: 26000
n=input()
b=list(map(int,input().split()))
a=[]
while b:
  c=0
  for i,j in enumerate(b,1):
    if i==j:c=i
  if c==0:
    print(-1)
    exit()
  a+=[b.pop(c-1)]
print(*a[::-1],sep='\n')

Measured memory_bytes: 64080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t H, W;
  cin >> H >> W;
  
  int64_t all_masu = H * W;
  if( H == 1 || W == 1) {
     cout << 1 << endl; 
  }
  else if ( all_masu % 2 == 0) {
    cout << all_masu /2 << endl;
  }
  else {
    cout << all_masu / 2 + 1 << endl;  
  } 
  
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
const int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
const int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
char c[8][9];
int place(int x, int y, char t, bool m) {
	int ret = 0;
	for (int i = 0; i < 8; i++) {
		int px = x + dx[i], py = y + dy[i];
		bool flag = false;
		while (0 <= px && px < 8 && 0 <= py && py < 8) {
			if (c[py][px] == '.') break;
			if (c[py][px] == t) {
				flag = true; break;
			}
			px += dx[i];
			py += dy[i];
		}
		if (flag) {
			int qx = x, qy = y, q = 0;
			while (qx != px || qy != py) {
				if(m) c[qy][qx] = t;
				qx += dx[i];
				qy += dy[i];
				if (q++ > 0) ret++;
			}
		}
	}
	return ret;
}
int main() {
	for (int i = 0; i < 8; i++) scanf("%s", &c[i]);
	int t = 0, v = 0;
	while (true) {
		int x = -1, y = -1, r = 0;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (c[i][j] == '.') {
					int p = place(j, i, t % 2 == 0 ? 'o' : 'x', false);
					if (p >= r && p >= 1 && t % 2 == 1) { x = j; y = i; r = p; }
					else if (p > r && p >= 1) { x = j; y = i; r = p; }
				}
			}
		}
		if (r == 0) {
			if (v == 0) { v = 1; t++; continue; }
			break;
		}
		else { place(x, y, t++ % 2 == 0 ? 'o' : 'x', true); v = 0; }
	}
	for (int i = 0; i < 8; i++) printf("%s\n", c[i]);
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
/*
 * Be careful of overflow
 * Array bounds
 * Assert a!=0 when performing x/a
 * Check base condition for recursion
 * Iterator -> O(1), Element -> O(log n) while using erase
 * 1LL<<x when x>32
 * Be sure of what you are going to code (exception dp)
 * Don't try fancy tricks during contest
 * You can always make a bad round to a good enough round
 */ 

void solve()
{
	int d,t,s;
	cin>>d>>t>>s;
	if((d+s-1)/s <= t) cout<<"Yes\n";
	else cout<<"No\n";
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3644
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		boolean[] dp=new boolean[10010];

		//初期条件
		dp[0]=true;

		//現在最大どこまで入っているか記録するための変数
		//毎回10000回近くまわすのは無駄。
		int imax=0;

		for (int i = 0; i < N; i++) {

			int buf=sc.nextInt();

			//重複がないように後ろから更新していく。
			for (int j = imax; j>=0; j--) {

				if(dp[j]==true) {
					dp[j+buf]=true;
				}

			}

			imax+=buf;
		}

		for (int j = imax; j > 0; j--) {

			if(dp[j]==true && (j%10!=0)) {
				System.out.println(j);
				return;
			}

		}

		System.out.println(0);

	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 23764
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t=0;
		int nn = 31;
		while(true){
			if(isPrime(nn)){
				t++;
				System.out.print(nn+ " ");
				if(t==n){
					break;
				}
			}
			nn++;
		}
		
	}
	private static boolean isPrime(int n){
		
		for(int i=2;i<=Math.sqrt(n);i++){
			if(n%i==0 || n%5!=1){
				return false;
			}
		}
		return true;
	}
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int n;
    cin>>n;
    int ans=0;
    rep(i,1,(n+1)/2){
        if(i+(n-i)==n)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
N,M = map(int,input().split())

if N==1 and M==1:
    print("0")
else:
    N = N*(N-1)
    M = M*(M-1)
    ans = (M+N)//2
    print(ans)














Measured memory_bytes: 3060
N,W = map(int,input().split())
wv = [[0,0]]
dp = [[0]*(W+1) for _ in range(N+1)]
for _ in range(N):
    w,v = map(int,input().split())
    wv.append([w,v])

for weight in range(1,W+1):
    for good in range(1,N+1):
        if weight-wv[good][0] >= 0:
            dp[good][weight] = max(dp[good-1][weight-wv[good][0]]+wv[good][1], dp[good-1][weight])
        else:
            dp[good][weight] = dp[good-1][weight]

print(dp[N][W])

Measured memory_bytes: 120300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll f = A[0];
   // cout << 0 << endl;
    rep2(i, 1, N)
    {
        if(A[i] >= f)
        {
            f = A[i];
            //cout << 0 << endl;
            continue;
        } 
        int x = A[i-1]-A[i];
        //cout << x << endl;
        ans += A[i-1]-A[i];
        A[i] = A[i-1];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n,m;cin>>n>>m;
  map<int,int> ac,wa;
  int a=0,w=0;
  rep(i,m){
    int p;string s;cin>>p>>s;
    if(s=="WA")wa[p]++;
    else {
      if(ac[p]==0){
        ac[p]++;
        a++;
        w+=wa[p];
      }
    }
  }
    cout<<a<<" "<<w<<endl;
}

Measured memory_bytes: 12972
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
//const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1001001001001;

int main(){
    int n,k;
    cin>>n>>k;
    vi a(n);
    int sum = 0;
    rep(i,n){
        cin>>a[i];
        sum += a[i];
    }
    vi candidates;
    for(int i=1; i*i<=sum; i++){
        if(sum%i)continue;
        candidates.push_back(i);
        candidates.push_back(sum/i);
    }
    int ans = 0;
    for(int c: candidates){
        vi mod(n);
        rep(i,n){
            mod[i] = (a[i]%c);
        }
        sort(mod.begin(), mod.end());
        ll tot = 0;
        bool ok = true;
        rep(i,n){
            if(ok && tot + mod[i]<=k){
                tot += mod[i];
            }else{
                tot -= c-mod[i];
                ok = false;
            }
        }
        if(tot>=0)ans = max(ans, c);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3644
instr = input().split()

n = int(instr[0])
a = int(instr[1])
b = int(instr[2])

bigger = a
smaller = b
if a < b:
    bigger = b
    smaller = a

max = smaller
min = 0
if (n - bigger) < smaller:
    min = smaller - (n - bigger)

print(str(max)+' '+str(min))



Measured memory_bytes: 3060
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
k = inp()
res = 1
for i in range(n):
    res = min(res+k, res*2)
print(res)

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

int main(){
  long long a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(v<=w)
    cout << "NO" << endl;
  else if((v-w)*t >= abs(b-a))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << ((a - 1) / d >= (c - 1) / b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int INF = 0x3f3f3f3f;
const int MAXN = 15;
int a[MAXN][MAXN];
int b[MAXN];

int main() {
    int n, m, x;
    scanf("%d%d%d", &n, &m, &x);// don't forget &
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            scanf("%d", &a[i][j]);// don't forget &
        }
    }
    int ans = INF;
    for (int i = 0; i < (1 << n); i++) {
        memset(b, 0, sizeof b);
        int cur = 0;
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {
                cur += a[j + 1][0];
                for (int k = 1; k <= m; k++) {
                    b[k] += a[j + 1][k];
                }
            }
        }
        for (int j = 1; j <= m; j++) {
            if (b[j] < x) {
                cur = INF;
                break;
            }
        }
        ans = min(ans, cur);
    }
    printf("%d", ans == INF ? -1 : ans);
    
    return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>

int main (){

    int a, b;

    scanf("%d %d", &a, &b);

    if (a+b>16){
        printf(":(\n");
    }
    else if (a>8 || b>8){
        printf(":(\n");
    }
    else {
            printf("Yay!\n");
    }
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
// #include <string>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >>k;
  int n[] = {a,b,c};
  SORT(n, 3);
  cout << n[2] * pow(2, k) + n[0] + n[1] <<endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		char c = scan.next().toCharArray()[0];

		List<Character> lists = new ArrayList<Character>(Arrays.asList('a', 'i', 'u', 'e', 'o'));

		if (lists.contains(c)) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

typedef pair<int, int> pii;
const int N = 1e5 + 100;
const pii BAD = pii(-1, -1);

int n;
struct tree {
	int par[N];
	bool dead[N];
	queue<pii> q;
	vector<int> nei[N], comp[N];
	map<pii, vector<pii>> edges;
	tree() {
		for (int i = 0; i < N; i++)
			comp[par[i] = i].push_back(i);
	}
	pii ask() {
		if (q.empty())
			return BAD;
		pii p = q.front();
		q.pop();
		return p;
	}
	pii f(pii p, pii q) {
		for (pii x: {p, q})
			if (edges[x].size())
				return edges[x].back();
		return BAD;
	}
	void normalize(pii p) {
		int U = p.first, V = p.second;
		while (edges[p].size()) {
			pii e = edges[p].back();
			int u = par[e.first], v = par[e.second];
			if ((U == u && V == v) || (U == v && V == u))
				break;
			//cerr << U << ' ' << V << ' ' << e.first << ' ' << e.second << ' ' << u << ' ' << v << '\n';
			edges[p].pop_back();
		}
	}
	void read() {
		for (int i = 0; i < n - 1; i++) {
			int u, v;
			cin >> u >> v;
			nei[--u].push_back(--v);
			nei[v].push_back(u);
			edges[pii(u, v)].push_back(pii(u, v));
			q.push(pii(u, v));
		}
	}
	void merge(int u, int v) {
		//abort();
		if (comp[u].size() >= comp[v].size())
			swap(u, v);
		//cerr << "merge " << u << ' ' << v << '\n';
		edges[pii(u, v)].clear();
		edges[pii(v, u)].clear();
		while (comp[u].size()) {
			int me = comp[u].back();
			comp[u].pop_back();
			comp[par[me] = v].push_back(me);

			for (int she: nei[me]) {
				int a = u, b = par[she];
				if (a != b && b != v) {
					pii A = pii(v, b);
					q.push(A);
					for (pii B: {pii(u, b), pii(b, u)}) {
						while (edges[B].size()) {
							edges[A].push_back(edges[B].back());
							edges[B].pop_back();
						}
					}
				}
			}
		}
		dead[u] = true;
	}
} blue, red;

void input() {
	cin >> n;
	blue.read();
	red.read();
}

bool can(pii p) {
	//cerr << "try " << p.first << ' ' << p.second << '\n';
	pii q = pii(p.second, p.first);
	for (pii x: {p, q}) {
		blue.normalize(x);
		red.normalize(x);
	}
	pii A = blue.f(p, q), B = red.f(p, q);
	if (min(A.first, B.first) == -1)
		return false;
	int u = blue.par[A.first], v = blue.par[A.second];
	blue.merge(u, v);
	red.merge(u, v);
	return true;
}

bool ok() {
	int want = n - 1;
	while (want) {
		pii p = blue.ask();
		if (p == BAD)
			p = red.ask();
		if (p == BAD)
			return false;
		if (can(p))
			want--;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	input();
	cout << (ok()? "YES\n": "NO\n");
}


Measured memory_bytes: 143692
#include <bits/stdc++.h>
 
//#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << endl; 
#define TIME (ld)clock()/CLOCKS_PER_SEC
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 300 + 7, mod = 998244353, MAXN = 1e6 + 7;
const double eps = 1e-9;
const ll INF = 1e18, inf = 1e9;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
string s;
int k; 
int dp[maxn][maxn][maxn];

void ADD(int &a, int b) {
    a += b; 
    if (a >= mod) a -= mod; 
}

int pref[maxn];
 
void solve() {
    cin >> s >> k; 
    s.pb('0'); 
    int n = s.size(); 
    vector<int> null; 
    for (int i = 0; i < n; ++i) if (s[i] == '0') null.pb(i); 
    for (int i = 0; i < n; ++i) pref[i + 1] = pref[i] + s[i] - '0'; 
    dp[0][0][0] = 1; 
    for (int i = 0; i < null.size(); ++i) {
        for (int len = 0; len <= n; ++len) {
            for (int cnt = 0; cnt <= n; ++cnt) {
                if (!dp[i][len][cnt]) continue;                 
                for (int add = 0; add <= pref[n] - len; ++add) {
                    if (add + len < pref[null[i] + 1]) continue; 
                    int new_cnt = cnt + max(0, add - pref[null[i] + 1] + pref[(i == 0 ? 0 : null[i - 1])]); 
                    if (new_cnt >= maxn) continue; 
                    ADD(dp[i + 1][len + add][new_cnt], dp[i][len][cnt]); 
                }
            }            
        }
    }
    int ans = 0; 
    for (int cnt = 0; cnt <= min(n, k); ++cnt) {
        ADD(ans, dp[null.size()][pref[n]][cnt]); 
    }
    cout << ans; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 30644
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n,k;
    cin>>n>>k; 
    ll a[n];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll prod = 1;
    for(ll i=0; i<k; i++)
    {
        prod *= a[i];
    }
    // cout<<prod<<'\n';
    for(ll i=k; i<n; i++)
    {
        // ll temp = prod;
        // prod /= a[i-k];
        // prod *= a[i];
        if(a[i] > a[i-k])
        {
            cout<<"Yes"<<'\n';
        }
        else
        {
            cout<<"No"<<'\n';
        }
        
    }
}

Measured memory_bytes: 5168
fun main(args: Array<String>) {
    val (N, M, C) = readLine()!!.split(" ").map(String::toInt)
    val B = readLine()!!.split(" ").map(String::toInt)
    val ans = (1..N).count {
        val A = readLine()!!.split(" ").map(String::toInt)
        A.zip(B).map { it.first * it.second }.sum() + C > 0
    }
    println(ans)
}

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

using namespace std;

int main(){
    cin.exceptions(cin.failbit);
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    int grid[3][3];
    for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) cin >> grid[i][j];
    int n;
    cin >> n;
    int ans[3][3];
    memset(ans, 0, sizeof ans);
    for (int i = 0; i < n; ++i){
        int a;
        cin >> a;
        for (int i = 0 ; i < 3; ++i){
            for (int j = 0; j < 3; ++j){
                if (grid[i][j] == a)ans[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < 3; ++i){
        int linha = 1, coluna = 1;
        for (int j = 0; j < 3; ++j){
            linha = linha and ans[i][j];
            coluna = coluna and ans[j][i];
        }   
        if(linha or coluna) {
            cout << "Yes\n";
            return 0;
        }
    }
    if (ans[0][0] and ans[1][1] and ans[2][2] or ans[0][2] and ans[1][1] and ans[2][0])
        cout << "Yes\n";
    else 
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
// Author : Chi
// created : 2020-05-24 Sunday

//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb          push_back
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         1000000007
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define pdp(d,i)    fixed<<setprecision(i)<<d
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//namespaces
using    namespace __gnu_pbds;
using    namespace std;

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
long double c[3000];
int n;
long double dp[3000][3000];
long double rec(int x,int i){
    if(x==0)
        return 1;
    if(i==0)
        return 0;
    if(dp[x][i] >= -0.9)
        return dp[x][i];
    long double ans=c[i]*rec(x-1,i-1)+(1-c[i])*rec(x,i-1);
    return dp[x][i]=ans;
}
void solve(){
    cin>>n;
    r1n(i,n)
        cin>>c[i];
    memset(dp,-1,sizeof dp);
    cout<<pdp(rec((n+1)/2,n),10);
}
// Driver Code
int main(){
    TEST1
    return 0;
}
/*
adsfasdfas
adfasdfsadgnf
afdsafda
*/


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 998244353;
using mint = Fp<MOD>;

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> L(K), R(K); REP(i, K) cin >> L[i] >> R[i];
  vector<mint> dp(N + 1, 0); dp[1] = 1;
  vector<mint> sum(N + 1, 0); sum[1] = 1;
  for(int i = 2; i <= N; ++i) {
    REP(k, K) {
      // L[i]〜R[i]
      int li = i - R[k];
      int ri = i - L[k];
      li = max(li, 1);
      if(ri < 0) continue;
      dp[i] += sum[ri] - sum[li - 1];
    }
    sum[i] += sum[i - 1] + dp[i];
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 6388
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26188
unittest
{
	assert( [ "2" ].parse.expand.solve == "1 2 2" );
//	assert( [ "3485" ].parse.expand.solve == "872 1012974 1539173474040" );
//	assert( [ "4664" ].parse.expand.solve == "3498 3498 3498" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	for( auto x = 1L; x <= 3500; x++ )
	{
		for( auto y = x; y <= 3500; y++ )
		{
			auto z = ( n * x * y ) / ( 4.0L * x * y - n * x - n * y );
			if( z % 1 == 0 && 0 < z ) return format( "%s %s %s", x, y, cast( long ) z );
		}
	}
	assert( false );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  int count = 0;
  int tmp;
  REP(i, n){
    cin >> tmp;
    if(tmp != i + 1){
      count ++;
    }
    if(count > 2){
      cout << "NO"<< endl;
      return 0;
    }
  }
  if(count == 0 || count == 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define debug(x) cerr<<#x<<' '<<x<<'\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,a;
    cin>>n>>a;
    int ans=n/a;
    if(n%a) ans++;
    cout<<ans<<'\n';
    return 0;
}



Measured memory_bytes: 256
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
sm=0
xb=x[0]
for i in range(1,n):
  d=x[i]-xb
  if d*a<=b:
    sm+=a*d
  else:
    sm+=b
  xb=x[i]
print(sm)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

int main()
{
  int h,w;
  cin >> h >> w;
  vector<string> grid(h);
  vector<vector<int>> ver(h,vector<int>(w,0)),hor(h,vector<int>(w,0));

  for(int i=0; i<h; i++){
    string s;
    cin >> s;
    grid[i] = s;
  }
  for(int i=0; i<h; i++){
    int cnt = 0;
    for(int j=0; j<w; j++){
      if(grid[i][j] == '#'){
        cnt = 0;
      }else{
        cnt++;
      }
      ver[i][j] = cnt;
    }
    int tmp = ver[i][w-1];
    for(int j=w-1; j>=0; j--){
      if(ver[i][j] == 0){
        tmp = 0;
      } else if(ver[i][j] > 0 && tmp == 0){
        tmp = ver[i][j];
      }
      ver[i][j] = tmp;
    }
  }

  for(int i=0; i<w; i++){
    int cnt = 0;
    for(int j=0; j<h; j++){
      if(grid[j][i] == '#'){
        cnt = 0;
      }else{
        cnt++;
      }
      hor[j][i] = cnt;
    }
    int tmp = hor[h-1][i];
    for(int j=h-1; j>=0; j--){
      if(hor[j][i] == 0){
        tmp = 0;
      } else if(hor[j][i] > 0 && tmp == 0){
        tmp = hor[j][i];
      }
      hor[j][i] = tmp;
    }
  }

  int ans = 0;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(grid[i][j] == '.'){
        ans = max(ans,ver[i][j]+hor[i][j]-1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35712
#include <cstdio>
#include <set>
#define MOD 1000000007
#define MOD2 998244353
using namespace std;
char s[5005];
int n;
bool check(int len)
{
 set<long long> se,se2;
 for(int i=1;i+len-1<=n;i++)
 {
  long long sum=0,sum2=0;
  if(i-len>0)
  {
   for(int j=i-len;j<i;j++)
    sum=(sum*26+s[j]-'a')%MOD,sum2=(sum2*26+s[j]-'a')%MOD2;
   se.insert(sum),se2.insert(sum2);
  }
  sum=0,sum2=0;
  for(int j=i;j<=i+len-1;j++)
   sum=(sum*26+s[j]-'a')%MOD,sum2=(sum2*26+s[j]-'a')%MOD2;
  if(se.count(sum)&&se2.count(sum2))return true;
 }
 return false;
}
int main()
{
 scanf("%d",&n);
 scanf("%s",s+1);
 int l=0,r=n/2;
 while(l<r)
 {
  int mid=(l+r+1)>>1;
  if(check(mid))l=mid;
  else r=mid-1;
 }
 printf("%d\n",l);
 return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,Y,M,D;
  cin>>S;
  for(int i=0;i<4;i++){
    Y=Y+S.at(i);
  }
  for(int i=5;i<7;i++){
    M=M+S.at(i);
  }
  for(int i=8;i<10;i++){
    D=D+S.at(i);
  }
  int y=stoi(Y);
  int m=stoi(M);
  int d=stoi(D);
  bool flag=true;
  if(y>=2020){
    flag=false;
  }
  else if(y==2019&&m>=5){
    flag=false;
  }
  if(flag==false){
    cout<<"TBD"<<endl;
  }
  else{
    cout<<"Heisei"<<endl;
  }
}


Measured memory_bytes: 256
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))
#define MAX_A 1000000 + 1

int sum_array(vi &C, int start, int end, int step){
	int c = 0;
	rpd(i, start, end, step) c += C[i];
	return c;
}

bool is_pairwise(vi &C){
	if(sum_array(C, 2, MAX_A, 2) > 1) return false;
	rpd(i, 3, MAX_A, 2) if(sum_array(C, i, MAX_A, i) > 1) return false;
	return true;
}

int main(){
	int N; cin>>N;
	vi C(MAX_A, 0);
	int g = 0;
	rpd(i, 0, N, 1){
		int a; cin>>a;
		C[a]++;
		g = gcd(g, a);
	}
	int t = 2;
	if(is_pairwise(C)) t = 0;
	else if(g == 1) t = 1;
	cout<< vector<string>{"pairwise","setwise","not"}[t] <<" coprime\n";
}


Measured memory_bytes: 7224
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    a,b=MI()
    if a+b==15:
        print("+")
    elif a*b==15:
        print("*")
    else:
        print("x")
    

        
        
        
        
    
if __name__=="__main__":
    main()



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

using namespace std;

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

    int n,k;
    cin>>n>>k;

    int x;
    vector<int> nums(n);
    for(int i=0;i<n;i++){
        cin>>nums[i];
    }    

    vector<int> dp(k+1);
    dp[0]=0;
    for(int i=1;i<k+1;i++){
        for(int j=0;j<n;j++){
            if(i-nums[j] >=0 && (dp[i-nums[j]]==0)){
                dp[i]=1;
                break;
            }
        }
    }


    /*
    * Not so nice approach -> O(n^2) *

    for(int i=1;i<k+1;i++){
        for(int j=i-1;j>=0;j--){
            if(dp[j]==0 && cnt.count(i-j)){
                dp[i]=1;
                break;
            }
        }
    }

    */

    if(dp[k]){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
}

Measured memory_bytes: 3712
var
	n,i,cnt,a,b:Longint;
	v:array[1..100000]of array of Longint;
	c,d1,d2:array[1..100000]of Longint;
procedure dfs1(u,d:Longint);
var i:Longint;
begin
	d1[u]:=d;
	for i:=0 to c[u]-1 do if d1[v[u][i]]=0 then dfs1(v[u][i],d+1);
end;
procedure dfs2(u,d:Longint);
var i:Longint;
begin
	d2[u]:=d;
	for i:=0 to c[u]-1 do if d2[v[u][i]]=0 then dfs2(v[u][i],d+1);
end;
begin
	read(n);
	for i:=2 to n do begin
		read(a,b);
		inc(c[a]);
		inc(c[b]);
		setLength(v[a],c[a]);
		setLength(v[b],c[b]);
		v[a][c[a]-1]:=b;
		v[b][c[b]-1]:=a;
	end;
	dfs1(1,1);
	dfs2(n,1);
	for i:=1 to n do if d1[i]<=d2[i] then inc(cnt);
	if cnt*2>n then writeln('Fennec')else writeln('Snuke');
end.


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,x=0,y=0,i,j,k,aa,bb,z;
    cin>>n;
    long long a[n+5];
    long long c[n+5];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        c[i]=a[i];
    }
    long long b[n+5];
    for(i=0;i<n;i++)
    {
        if(i==0)
        {
            b[i]=a[i];
        }
        else
        {
            b[i]=b[i-1]+a[i];
        }
    }
    z=b[n-1];
    for(i=0;i<n;i++)
    {
        x=x+a[i];
        z=z-a[i];
        if(x==z && x!=0 && z!=0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    //cout<<-1<<endl;
    long long z1=b[n-1];
    x=0;
    long long zz=1e18;
    //cout<<z<<endl;
    for(i=0;i<n-1;i++)
    {
        x=x+c[i];
        z=z1-x;
        //cout<<x<<" "<<z<<endl;
        zz=min(zz,abs(z-x));
    }
    cout<<zz<<endl;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = LLONG_MAX;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int x[N];
int arr[N];
int pre[N];
void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int x= 0;
	
	int ans = 0;
	for(int i =0;i<n;i++){
		if(s[i] == 'I') x++;
		else x--;
		ans =max(ans,x);
	}
	cout<<ans<<endl;
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main (){
  int X,Y;
  cin>>X>>Y;
  int ans=0;
  for(int i=0;i<=X;i++){
    if((i*2+(X-i)*4)==Y)ans=1;
  }
  if(ans==0){
    cout<<"No";
  }
  else{
    cout<<"Yes";
  }
}


Measured memory_bytes: 3612