akhauriyash/Code-Regression huggingface dataset:
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

void rectangle(int h, int w) {
  for (int i = 0; i < h; ++i) {
    if (i == 0 || i == h - 1) {
      for (int j = 0; j < w; ++j) {
        cout << '#';
      }
      cout << '\n';
    } else {
      cout << '#';
      for (int j = 0; j < w - 2; ++j) {
        cout << '.';
      }
      cout << '#';
      cout << '\n';
    }
  }
}

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

  while (1) {
    int h, w; cin >> h >> w;
    if (h == 0 && w == 0) {
      break;
    }
    rectangle(h, w);
    cout << '\n';
  }

  return 0;
}


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

int main()
{
  int n;
  int debt = 100000;

  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    debt *= 1.05;
    if (debt % 1000 != 0){
      debt = (debt / 1000 + 1) * 1000;
    }
  }
  printf("%d\n", debt);

  return (0);
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxN = 1e5 + 13;
int q, ans[maxN];
bool mark[maxN];
int32_t main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> q;
    mark[1] = 1;
    for (int i = 2; i < maxN; i++) {
	if (!mark[i]) {
	    for (int j = i * i; j < maxN; j += i)
		mark[j] = 1;
	    if (!mark[i] && !mark[(i + 1) / 2])
		ans[i] = 1;
	}
	ans[i] += ans[i - 1];
    }
    while (q--) {
	int l, r;
	cin >> l >> r;
	cout << ans[r] - ans[l - 1] << '\n';;
    }
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	int A[2][100];
	for(int i=0; i<N; i++) cin >> A[0][i];
	for(int i=0; i<N; i++) cin >> A[1][i];

	int ans = 0;
	for(int i=0; i<N; i++){
		int tmp = 0;
		for(int j=0; j<=i; j++) tmp += A[0][j];
		for(int j=i; j<N; j++) tmp += A[1][j];
		ans = max(ans, tmp);
		//cout << tmp << endl;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#
# 6b
#

def main():
    n = int(input())
    c = []
    for i in range(n):
        m, r = input().split()
        r = int(r)
        c.append([m, r])
    for M in ["S", "H", "C", "D"]:
        for R in range(1, 14):
            for i in range(n):
                if c[i] == [M, R]:
                    break
            else:
                print(*[M, R])


if __name__ == '__main__':
    main()


Measured memory_bytes: 5596
#include <cstdio>


typedef long long int ll;


ll power5(ll a){
    ll ans=a;
    for(int i=1;i<=4;i++) ans*=a;
    return ans;
}

ll root(ll s){
    ll i=0;
    if (s>=0){
        while(power5(i)<s) i++;
        return i;
    }else{
        while(power5(i)>s) i--;
        return i;
    }
}

int main(){
    ll X;
    scanf("%lld",&X);

    for(ll i=0;true;i++){
        ll temp=power5(i);
        ll positive=root(X+temp);
        ll negative=root(X-temp);
        // printf("temp=%lld pos=%lld %negative=%lld\n",temp,positive,negative);
        if (power5(positive)-temp==X){
            printf("%lld %lld\n",positive,i);
            return 0;
        }else if (power5(negative)+temp==X){
            printf("%lld %lld\n",negative,-i);
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1728
#include<stdio.h>
#include<stdlib.h>

int main(){
    int n,w[100],a=0,b=0;
    scanf("%d",&n);
    int j=0,k=n-1;
    for(int i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
    while(j<=k){
        if(a<=b){
            a+=w[j];
            j++;
        }
        else{
            b+=w[k];
            k--;
        }
    }
    printf("%d\n",abs(a-b));
    return 0;
}


Measured memory_bytes: 128
<?php
$arr = explode(" ", trim(fgets(STDIN)));
$n = $arr[0];
$m = $arr[1];
$flg = true;

$no = array();
for($i = 1; $i <= $n; $i++){
	$no[$i] = -1;
}

$sc = array();
for($i = 0; $i < $m; $i++){
	$sc = explode(" ", trim(fgets(STDIN)));
	$s = $sc[0];
	$c = $sc[1];
	if($s > $n){
		$flg = false;
		break;
	}elseif($s == 1 && $c == 0 && $n > 1){
		$flg = false;
		break;
	}elseif($no[$s] == -1){
		$no[$s] = $c;
	}elseif($no[$s] != $c){
		$flg = false;
		break;
	}
}
if($flg){
	if($n == 1 && $no[1] == -1){
		echo 0;
		exit;
	}elseif($n == 1){
		echo $no[1];
		exit;
	}
	for($i = 1; $i <= $n; $i++){
		if($i == 1){
			if($no[$i] == -1){
				$no[$i] = 1;
			}
		}else{
			if($no[$i] == -1){
				$no[$i] = 0;
			}
		}
		echo $no[$i];
	}
}else{
	echo -1;
}
?>


Measured memory_bytes: 4604
A=[]
while True:	
	a=input().split('"')
	if a[0]==".":
		break
	b=input().split('"')
	
	cnt=0

	if len(a)!=len(b):
		A.append(-1)
	else:
		for i in range(len(a)):
			if(a[i]==b[i]):
				pass
			else:
				if i%2==1:
					cnt+=1
				else:
					cnt+=2
		if cnt>=2:
			A.append(-1)
		if cnt==1:
			A.append(0)
		if cnt==0:
			A.append(1)

A.reverse()
#print(A)
for i in range(len(A)):
	tmp=A.pop()
	if tmp==-1:
		print("DIFFERENT")
	elif tmp==0:
		print("CLOSE")
	else:
		print("IDENTICAL")


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

#define BUF_SIZE 20
#define STR_MAX 100002
int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, queries;
  sscanf(line, "%d %d", &num, &queries);

  char str[STR_MAX];
  int cum[STR_MAX] = {0};
  if(!fgets(str, STR_MAX, fp)) return 0;

  int flag = 0;
  int i, j;
  int len = strlen(str);
  // ACACTACG
  // cum[8] = 0; // initial value
  for(i = len-1; i >= 0; i--) {
    switch(str[i]) {
      case 'C':
        flag = 1;
        break;
      case 'A':
        if(flag) cum[i] = 1;
        flag = 0;
        break;
      default:
        flag = 0;
    }
  }
  for(i = len-1; i >= 0; i--) {
    cum[i] = cum[i+1] + cum[i];
  }

  int *ans = malloc(sizeof(int)*queries);
  int pos = 0;
  for(i = 0; i < queries; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    int start, end;
    sscanf(line, "%d %d", &start, &end);
    start--; end--;
    ans[pos++] = cum[start] - cum[end];
  }

  for(i = 0; i < pos; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

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


int main()
{
    string s;
    cin >> s;
    int count,nedan = 0;
    
    for(int i = 0;i<3;i++){
        if(s[i]=='o'){
            count=count + 1;
        }
    }
    
    nedan = 700 + count*100;
    cout << nedan << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String nl = sc.next();
    long sum = 0;

    for (int i = 0; i < nl.length(); i++) {
      sum += Integer.parseInt(nl.substring(i, i+1));
    }
    if (sum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

#define int ll

#define pb push_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int32_t main() {
	string s;
	cin >> s;
	if(s == "ARC")
		cout << "ABC";
	else
		cout << "ARC";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string n;
	int c=0;
	cin>>n;
	for(int i=0;i<n.size();i++)
	if (n[i]=='7')
	{
	c=1; 
	}
	if (c==1)
	cout<<"Yes\n";
	else cout<<"No\n";
	
}

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

int main() {
  int n,d;
  cin >> n >> d;
  int x,y,count = 0;
  for (int i  = 0; i < n; ++i) {
    cin >> x >> y;
    if (sqrt((1.0*x)*x + (1.0*y)*y) <= d) ++count;
  }
  
  cout << count;
}

Measured memory_bytes: 3636
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;

 int main()
 {
   int a,b,c,d,e,f;
   while(cin>>a>>b>>c>>d>>e>>f)
   {
     double y=1.0*(c*d-f*a)/(b*d-a*e);
     double x=1.0*(c*e-f*b)/(a*e-d*b);
     if(x==0.0) x=0.0;
     if(y==0.0) y=0.0;
     printf("%.3lf %.3lf\n",x,y);            
   }
   //while(1);      
   return 0;    
 }
 
 
 
 

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back
#define inf 1000000000000000000

							
									//nestedcode
									
ll binpow(ll a, ll b) {
    a %= M;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % M;
        a = (a * a)% M;
        b >>= 1;
    }
    return res;
}




int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,d;
    cin>>n;
    d = n + n*n + n*n*n;
    cout<<d;
    
    
}

Measured memory_bytes: 3660
// best coder in the world do not mess with me!!
#include <bits/stdc++.h>
#define REP(ii,nn) for(int ii=0; ii<nn ;ii++)
#define FOR(ii, aa, bb) for (int ii = (aa); ii < (bb); ii++)
#define FORD(ii, aa, bb) for(int ii = (aa); ii > (bb); ii--)
#define pb(aa) push_back(aa)
#define fastaff ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lld long long double
#define mp(aa,bb) make_pair(aa,bb)
#define v(a,b) vector<long long> a(b)
typedef long long int ll;
using namespace std;
bool sol()
{
	string str;cin>>str;
	int x = str.size();int l = (x-1)/2;string str2 = str;reverse(str2.begin(),str2.end());
	if(str2!=str)
		return false;
	string str1 = str.substr(0,l);string str3 = str2.substr(0,l);string str4 = str1;reverse(str4.begin(),str4.end());
	if(str4!=str1)
		return false;
	str4 = str3;reverse(str4.begin(),str4.end());
	if(str4!=str3)
		return false;
	return true;
}
int main()
{
	int t = 1;

	while(t--)
	{
		if(sol()==1)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
use std::collections::HashMap;
fn main() {
    let n: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut sum: Vec<i64> = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i] + a[i];
    }
    let mut ans: i64 = 0;
    let mut mp: HashMap<i64, i64> = HashMap::new();
    for i in 0..n {
        let _a = sum[i + 1];
        if _a == 0 {
            ans += 1;
        }
        if mp.contains_key(&_a) {
            let k = mp[&_a];
            mp.insert(_a, k + 1);
        } else {
            mp.insert(_a, 1);
        }
    }
    for (key, value) in &mp {
        ans += value * (value - 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 11720
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int w = scn.nextInt();
      	int h = scn.nextInt();
      	int n = scn.nextInt();
		int[] x = new int[n];
      	int[] y = new int[n];
      	int[] a = new int[n];
		for(int i=0; i<n; i++){
			x[i] = scn.nextInt();
          	y[i] = scn.nextInt();
          	a[i] = scn.nextInt();
		}
      	//白の面積を求める
      	int x0 = 0;//xの下限値
      	int y0 = 0;//yの下限値
      	int x1 = w;//xの上限値
      	int y1 = h;//yの上限値
      	for(int i=0; i<n; i++){
          if(a[i]==1 && x0 < x[i]) x0 = x[i];//a=1でかつx0<x[i]なら下限値更新
          if(a[i]==2 && x1 > x[i]) x1 = x[i];//a=2でかつx1>x[i]なら上限値更新
          if(a[i]==3 && y0 < y[i]) y0 = y[i];//a=3でかつx0<x[i]なら下限値更新
          if(a[i]==4 && y1 > y[i]) y1 = y[i];//a=4でかつx0>x[i]なら上限値更新
        }
      	int ans = (x1-x0)*(y1-y0);
      	if(x0>=x1 || y0>=y1) ans = 0;//下限値が上限値を上回っていた場合は面積０
      	System.out.println(ans);
	}
}


Measured memory_bytes: 35860
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}


// ----------------------------------------------------------------------------
int main(){
  int N;
  cin >> N;
  int taro=0,hanako=0;
  for(int i=0; i<N; i++){
    string t,h;
    cin >> t >> h;
    int win = t.compare(h);
    if(win > 0){
      taro += 3;
    }else if(win < 0){
      hanako += 3;
    }else{
      taro++;
      hanako++;
    }
  }
  cout << taro << " " << hanako << endl;
  return 0;
}



Measured memory_bytes: 3172
a, b, c = map(int, input().split())
k = int(input())

if a<b and b<c:
  print("Yes")

else:
  while k != 0:
    if a >= b:
      b *= 2
      k -= 1
    else:
      c *= 2
      k -= 1
  
  if a<b and b<c:
    print("Yes")
  else:
    print("No")
    

Measured memory_bytes: 9180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_121
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] dataArr1 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] dataArr2 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int h = dataArr1[0] - dataArr2[0];
            int w = dataArr1[1] - dataArr2[1];

            Console.WriteLine(h * w);

        }
    }
}



Measured memory_bytes: 11220
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;

int main(){
	int N; scanf("%d", &N);
	multiset<int> s;
	for (int i = 0; i < 3 * N; i++){
		int x; scanf("%d", &x);
		s.insert(x);
	}

	long long ans = 0;
	while (!s.empty()){
		ans += *next(s.rbegin());
		s.erase(s.begin());
		s.erase(prev(s.end()));
		s.erase(prev(s.end()));
	}

	printf("%lld\n", ans);
}

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

int n, k;
vector<vector<int>> g;
vector<int> a, high;

int solve();
int dfs(int now, int par);

int main() {
  cin >> n >> k;
  a.resize(n);
  for (auto& p : a) {
    cin >> p;
    --p;
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  high.assign(n, 0);
  g.resize(n);
  for (int i = 1; i < n; ++i) g[a[i]].push_back(i);
  return dfs(0, -1) + (a[0] != 0);
}

int dfs(int now, int par) {
  int res = 0;
  for (auto to : g[now])
    if (to != par) {
      res += dfs(to, now);
      high[now] = max(high[now], high[to] + 1);
    }
  if (high[now] == k - 1) {
    res += (par != 0 && now != 0);
    high[now] = -1;
  }
  return res;
}

Measured memory_bytes: 17128
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)

int main() {
  string s; cin >> s;
  int ans = 0;
  int N = s.size();
  for (int i = 0; i < N / 2; i++) {
      bool ng = false;
      if (s[i] == 'i' && s[N - i - 1] != 'i') ng = true;
      if (s[i] == 'w' && s[N - i - 1] != 'w') ng = true;
      if (s[i] == '(' && s[N - i - 1] != ')') ng = true;
      if (s[i] == ')' && s[N - i - 1] != '(') ng = true;
      ans += ng;
  }
  if (N % 2) {
      if (s[N / 2] == '(' || s[N / 2] == ')')
          ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	int i,N=9,c[1000],a[1000],n[1000],s[100]={0};
	char S[100][100];
	for(i=0;i<N;i++){
		scanf("%s %d %d",S[i],&a[i],&n[i]);
				s[i]=a[i]+n[i];
				c[i]=a[i]*200+n[i]*300;
		}
	for(i=0;i<N;i++){
	printf("%s %d %d\n",S[i],s[i],c[i]);
	}
	return 0;
}

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

int main() {
	long a,b;
	int k;
	cin >> a >> b >> k;
	for (int i=0; i<k; i++) {
		if (i%2==0) {
			if (a%2==1) a--;
			b+=a/2;	a=a/2; 
		}
		if (i%2==1) {
			if (b%2==1) b--;
			a+=b/2; b=b/2; 
		}
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int saidai(int a) {
	int count = 0;
	while (a % 2 == 0) {
		a /= 2;
		count++;
	}
	return count;
}
int main() {
	int n, a[100000],count=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		count += saidai(a[i]);
	}
	cout << count << endl;
	getchar();
	getchar();
	return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  ll h,w;
  cin>>h>>w;
  if(h==1||w==1){
    cout<<1<<endl;
    return 0;
  }
  if(h*w%2==0){
    cout<<h*w/2<<endl;
  }else{
    cout<<(h*w+1)/2<<endl;
  }

}


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

int W, a, b;

int main(){
std::cin >> W >> a >> b;
  if(a+W < b){
    std::cout << b-(a+W) << std::endl;
  }
  else if(a-W <= b && b <= a+W){
    std::cout << 0 << std::endl;
  }
  else{
    std::cout << a-(b+W) << std::endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int binarysearch(int N, int Q, int n[], int q[]){
	int i, mid, first, last;
	int count = 0;
	for(i = 0; i < Q; i++){
		first = 0;last = N;
		while(first < last){
			mid = (first + last) / 2;
			if(q[i] == n[mid]){
				count++;
				break;
			}
			else if(q[i] < n[mid]){
				last = mid;
			}
			else{
				first = mid + 1;
			}
		}
	}
	return count;
}

int main(void){
	int N, Q, i;
	int n[100000], q[50000];
	
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &n[i]);
	}
	scanf("%d", &Q);
	for(i = 0; i < Q; i++){
		scanf("%d", &q[i]);
	}
	printf("%d\n", binarysearch(N, Q, n, q));
	return 0;
}


Measured memory_bytes: 2356
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int h,n,sum;
  cin>>h>>n;
  vector<int>a(n);
  for(auto& i : a){
    cin>>i;
    sum+=i;
  }
  if(h<=sum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007

int i,j,k,l;

int main(){
  char S[4];
  gets(S);
  if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) puts("Bad");
  	else puts("Good");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, b) for (int i = 0; i < (b); i++ )

typedef pair<int,int> P;
typedef long long ll;

const int INF = 100000000;
const double PI=acos(-1);

bool comp(P p1, P p2){
    if (p1.first != p2.first) {
        return p1.first < p2.first;
    }
    else if (p1.second != p2.second) {
        return p1.second > p2.second;
    }
    else {
        return true;
    }
}

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

    if (N>=3 && M>=3) {
        ans = (N-2)*(M-2);
    }
    else if (N==2 || M==2) {
        ans = 0;
    }
    else if (N==1 && M==1) {
        ans = 1;
    }
    else if (N==1) {
        ans = max(M-2,(ll)0);
    }
    else if (M==1) {
        ans = max(N-2,(ll)0);
    }

    cout << ans << endl;
}


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

double dp[301][301][301];
double sushi(int n,int one,int two,int three)
{
	if(one<0 || two<0 || three<0)
		return 0;
	if(one==0  && two==0 && three==0)
		return 0;
	if(dp[one][two][three]>0)
		return dp[one][two][three];

	double a1=n+(one*sushi(n,one-1,two,three))+
				   (two*sushi(n,one+1,two-1,three))
				   +(three*sushi(n,one,two+1,three-1));
	
	dp[one][two][three]=a1/(one+two+three);
	return dp[one][two][three];
}

int main()
{
	memset(dp,-1,sizeof(dp));
	int n;
	cin>>n;
	int one=0,two=0,three=0;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		// cout<<x<<endl;
		if(x==1)
			one++;
		else if(x==2)
			two++;
		else if(x==3)
			three++;
	}
	// cout<<one<<two<<three<<endl;
	cout<<fixed<<setprecision(10)<<sushi(n,one,two,three);

}

Measured memory_bytes: 216864
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
#define gc pa==pb&&(pb=(pa=buf)+fread(buf,1,1000000,stdin),pa==pb)?EOF:*pa++
static char buf[1000000],*pa(buf),*pb(buf);
inline int readint() {
	int x=0;char c=gc;
	while(c<'0'||c>'9')c=gc;
	for(;c>='0'&&c<='9';c=gc)x=x*10+(c&15);
	return x;
}
const int N=5e5+5;
struct edge{
	int to,nxt,w;
}e[N*2];
struct E{
	int u,v;LL w;
	inline bool operator<(const E&rhs)const{return w<rhs.w;}
}G[N*2];
int cnt,head[N],w[N],id[N],tot;LL dis[N],ans,n;
void dfs(int now,int pre){
	id[now]=now;
	for(int i=head[now];i;i=e[i].nxt)if(e[i].to!=pre){
		dfs(e[i].to,now);
		if(dis[now]>dis[e[i].to]+e[i].w)dis[now]=dis[e[i].to]+e[i].w,id[now]=id[e[i].to];
	}
}
void dfs2(int now,int pre){
	for(int i=head[now];i;i=e[i].nxt)if(e[i].to!=pre){
		if(dis[e[i].to]>dis[now]+e[i].w)dis[e[i].to]=dis[now]+e[i].w,id[e[i].to]=id[now];
		dfs2(e[i].to,now);
		G[++tot]=(E){id[now],id[e[i].to],dis[now]+dis[e[i].to]+e[i].w};
	}
	G[++tot]=(E){id[now],now,dis[now]+w[now]};
}
#define fa head
#define sz w
inline int find(int x){while(x!=fa[x])x=fa[x]=fa[fa[x]];return x;}
int main(){
	n=readint();
	for(int i=1;i<=n;++i)dis[i]=w[i]=readint();
	for(int i=1;i<n;++i){
		int u=readint(),v=readint(),w=readint();
		e[++cnt]=(edge){v,head[u],w},head[u]=cnt;
		e[++cnt]=(edge){u,head[v],w},head[v]=cnt;
	}
	dfs(1,0),dfs2(1,0),sort(G+1,G+tot+1);
	for(int i=1;i<=n;++i)sz[fa[i]=i]=1;
	cnt=0;
	for(int i=1;i<=tot&&cnt!=n-1;++i){
		int x=find(G[i].u),y=find(G[i].v);
		if(x!=y){
			if(sz[x]<sz[y])swap(x,y);
			sz[x]+=sz[y],fa[y]=x,id[++cnt]=i,ans+=G[i].w;
		}
	}
	printf("%lld\n",ans);
//	for(int i=1;i<n;++i)printf("%d %d\n",G[id[i]].u,G[id[i]].v);
	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define pll pair<ll,ll>
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"
const ll mod=1e9+7;
inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){return (a%b==0)?(a/b):(a/b+1);}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    for(auto v : V) os << v <<"  ";
    return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") ";
    return os<<"}";
}
struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        return p1.first<p2.first;
    }
};


int main(){
	fio;	
	ll n;cin>>n;
	vector<pair<ll,ll>> a(n);
	f(n){
		ll x,y;cin>>x>>y;
		a[i].first=x;
		a[i].second=y;
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		if(a[i].first==a[i].second){
			ans++;
		}else{
			ans=0;
		}
		if(ans>=3){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int dp[16][16], a, b, n;

int main() {

	while (1) {
		memset(dp, 0, sizeof(dp));
		cin >> a >> b;
		if (a == 0 && b == 0) break;

		cin >> n;

		REP(i, n) {
			int x, y;
			cin >> x >> y;
			dp[y-1][x-1] = -1;
		}

		dp[0][0] = 1;
		REP(i, b) {
			REP(j, a) {
				if (i == 0 && j == 0) continue;

				if (dp[i][j] == -1) dp[i][j] = 0;
				else if (i - 1 < 0) dp[i][j] = dp[i][j-1];
				else if (j - 1 < 0) dp[i][j] = dp[i-1][j];
				else dp[i][j] = dp[i-1][j] + dp[i][j-1];
			}
		}
		cout << dp[b-1][a-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1e9
#define MOD 1e9+7
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;


int main() {
    ll x;
    cin >> x;
    
    ll m = 100;
    double l;

    int i;
    for (i = 0; m < x; i++) {
        l = m * (101.0/100.0);
        ll k = l;
        m = k;
    }    

    cout << i << endl;
    return 0;
}

Measured memory_bytes: 3636
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

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

int main() {
	int n=read(); ll x=read(),y=read();
	for (int i=2;i<=n;++i) {
		int a=read(),b=read();
		ll d=max(x/a+(x%a!=0),y/b+(y%b!=0));
		x=a*d,y=b*d;
	}
	printf("%lld\n",x+y);
	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end();
#define rall(x) x.rbegin(),x.rend();
#define ld long double
#define pll pair < long long , long long >
#define endl "\n"
using namespace std;
ll t[2000500];
int len;
string s;
void built( ll v, ll tl, ll tr)
{
    if(tl==tr)
    {
        t[v] = 0|(1<<(s[tl-1]-'a'));
        return;
    }
    ll nv = v << 1;
    ll tm = (tl+tr) >> 1;
    built(nv,tl,tm);
    built(nv+1,tm+1,tr);
    t[v] = t[nv]|t[nv+1];
}
ll get_x( ll v, ll tl, ll tr, ll l, ll r)
{
    if(l>r)
    {
        return 0;
    }
    if(tl==l && tr==r)
    {
        return t[v];
    }
    ll nv = v << 1;
    ll tm = (tl+tr) >> 1;
    return get_x(nv,tl,tm,l,min(r,tm))|get_x(nv+1,tm+1,tr,max(tm+1,l),r);
}
void upd( ll v, ll tl, ll tr, ll pos, char val)
{
    if(tl==tr)
    {
        t[v] = 0|(1<<(val-'a'));
        return;
    }
    ll nv = v << 1;
    ll tm = (tl+tr) >> 1;
    if(pos<=tm)
    {
        upd(nv,tl,tm,pos,val);
    }
    else
    {
        upd(nv+1,tm+1,tr,pos,val);
    }
    t[v] = t[nv]|t[nv+1];
}
int main()
{
    cin >> len >> s;
    int n;
    cin >> n;
    built(1,1,len);
    while(n--)
    {
        int type;
        cin >> type;
        if(type==1)
        {
            int pos;
            char c;
            cin >> pos >> c;
            upd(1,1,len,pos,c);
        }
        else
        {
            int l , r;
            cin >> l >> r;
            ll answ = get_x(1,1,len,l,r);
            ll ch = 0;
            while(answ)
            {
                ch+=(answ&1);
                answ>>=1;
            }
            cout << ch << endl;
        }
    }
}


Measured memory_bytes: 11140
#include<stdio.h>
int main()
{
    int a,b,c=0,d,e,n;
    scanf("%d %d",&a,&n);
    while(n--)
    {
        scanf("%d",&b);
        c=c+b;
    }
    if(c>a)
    {
        printf("-1");
    }
    else
    {
        printf("%d",a-c);
    }
}


Measured memory_bytes: 1732
N,A,B = map(int, input().split())
if A == 0 or A + B == 0:
    print(0)
else:
    ans = (N // (A + B)) * A  + min(A, (N % (A+B)))
    #print(N // (A+B))
    #print(min(B, (N%(A+B))))
    print(ans)



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vpll ab(n);
  rep(i,n){
    ll a,b; cin>>a>>b;
    ab[i]={a,b};
  }
  vsort(ab);
  ll ans=0;
  rep(i,n){
    ll a,b; tie(a,b)=ab[i];
    ll cnt=min(b,m);
    ans+=a*cnt;
    m-=cnt;
    if(cnt<=0) break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
int p[10], p1[10], p2[10];

void init(int n){
    for(int i=0;i<=n;i++) p[i] = i;
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    */
    
    int T,n;
    while(scanf("%d",&n)==1){
        init(n);
        for(int i=1;i<=n;i++) scanf("%d",&p1[i]); 
        for(int i=1;i<=n;i++) scanf("%d",&p2[i]);

        int lexorder = 0,a = -1,b = -1;    
        do{
            lexorder++;
            // printf("%d\n", lexorder);
            // for(int i=1;i<=n;i++) printf("%d ", p[i]);
            // printf("\n");    
            int i;
            if(a == -1){
                for(i=1;i<=n;i++) if(p1[i]!=p[i]) break;
                if(i==n+1) a = lexorder;
            }

            if(b == -1){
                for(i=1;i<=n;i++) if(p2[i]!=p[i]) break;
                if(i==n+1) b = lexorder;
            }    
        }while(next_permutation(p+1, p+n+1) and (a==-1 or b==-1));   

        //printf("%d %d\n", a,b); 
        printf("%d\n", abs(b-a)); 
    }   
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <stack>
using namespace std;

struct info
{
    int Team;
    int solved;
    int penalty;
    int mis[10];
    info(int x, int y, int z)
    {
        Team = x;
        solved = y;
        penalty = z;
        for (int i = 1; i <= 10; i++)
        {
            mis[i - 1] = 0;
        }
    }
};

bool asc(info const &left, info const &right)
{
    if (left.solved != right.solved)
        return left.solved > right.solved;
    else if (left.penalty != right.penalty)
        return left.penalty < right.penalty;
    else
        return left.Team < right.Team;
}

int main()
{
    while (true)
    {
        int t = 0, p = 0, r = 0;
        cin >> t >> p >> r;
        if (t == 0 && p == 0 && r == 0)
            break;

        vector<info> InfoList;
        for (int i = 1; i <= t; i++)
        {
            info x = info(i, 0, 0);
            InfoList.push_back(x);
        }
        // cout << "Before" << endl;
        // for (int i = 1; i <= t; i++)
        // {
        //     cout << InfoList[i - 1].Team << " " << InfoList[i - 1].solved << " " << InfoList[i - 1].penalty << endl;
        // }

        for (int i = 0; i < r; i++)
        {
            int tID, pID, t;
            string m;
            cin >> tID >> pID >> t >> m;

            if (m == "CORRECT")
            {
                InfoList[tID - 1].solved++;
                InfoList[tID - 1].penalty += InfoList[tID - 1].mis[pID - 1] * 1200 + t;
            }
            if (m == "WRONG")
            {
                InfoList[tID - 1].mis[pID - 1] += 1;
            }
        }

        sort(InfoList.begin(), InfoList.end(), asc);

        // cout << "after" << endl;
        for (int i = 1; i <= t; i++)
        {
            cout << InfoList[i - 1].Team << " " << InfoList[i - 1].solved << " " << InfoList[i - 1].penalty << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define inf 9223372036854775807LL
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int maxv = 0;

int main() { _
  ll n, w; cin >> n >> w;
  vector<ll> weights(n, 0);
  vector<ll> values(n, 0);
  for (ll i = 0; i < n; i++) {
    cin >> weights[i] >> values[i];
    maxv += values[i];
  }
  vector<vector<ll> > dp(n+1, vector<ll>(maxv+1, w+1));
  dp[0][0] = 0;
  
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= maxv; j++) {
      dp[i][j] = min(dp[i-1][j], j >= values[i-1] ? dp[i-1][j-values[i-1]] + weights[i-1] : inf);
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= maxv; i++) {
    if (dp[n][i] <= w)
      ans = max(ans, i);
  }
  cout << ans << endl;
  return 0;
}

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

using ll = long long;

int main(){
  long long int N,M;
  cin >> N >> M;
  //vector<int> H(N+1,0);
  long long int H[N+1];
  rep(i,N){cin >> H[i+1];}
  

  vector<int> highest(N+1,1);
  rep(i,N+1){highest[i]=1;}
  highest[0]=0;

  long long int a,b;
  rep(i,M){
    cin >> a >> b;
    if(H[a] >= H[b]){highest[b]=0;}
    if(H[a] <= H[b]){highest[a]=0;}
  }

  long long int ans=0;
  rep(i,N+1){
    if(highest[i]==1)ans++;
  };



  cout << ans << endl;
}


/*
N^2 = 10^10 なのでTLE
 //vector< vector<bool> > Road(N+1, vector<bool>(N+1,false) );
  bool Road[N+1][N+1];
  //rep(a,N+1)rep(b,N+1){Road[a][b]=false;}
  int a,b;
  rep(i,M){
    cin >> a >> b;
    Road[a][b]=true;
    Road[b][a]=true;
    }

  for(int i=1;i<=N;i++){
    highest = true;
    for(int j=1;j<=N;j++){
      if( (Road[i][j]) && (H[i]<=H[j]) ){
        //cout << i << "," << j << endl;
        highest = false;
        }
    }
    //cout << highest <<endl;
    if(highest)ans++;
  }
*/

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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;

using namespace std;

int main(void) {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	string ans;
	int H = ty - sy, W = tx - sx;

	cout << string(H, 'U') << string(W, 'R');
	cout << string(H, 'D') << string(W, 'L');
	cout << 'L' << string(H + 1, 'U') << string(W + 1, 'R');
	cout << 'D' << 'R';
	cout << string(H + 1, 'D') << string(W + 1, 'L');
	cout << 'U';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(container) (continer).begin(), (container).end()
#define sz(container)  (int) (container).size();
#define rall(container) (container).rbegin(), (container).rend()
using ll = long long;
#ifdef LOCAL_DEFINE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    #include "../../library/DEBUG.hpp"
#else
    #define debug(...) 0
#endif

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int val[3], n;
  cin >> n >> val[0] >> val[1] >> val[2];
  vector<string> q(n);
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  bool ok = true;
  string ans = "";
  auto get = [&](int pos) {
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        if (q[pos][i] == q[pos + 1][j]) {
          return i;
        }
      }
    }
    return -1;
  };
  for (int i = 0; i < (int) q.size(); i++) {
    if (!val[q[i][0] - 'A'] && !val[q[i][1] - 'A']) {
      ok = false;
      break;
    } else if (val[q[i][0] - 'A'] == 1 && val[q[i][1] - 'A'] == 1) {
      if (i < (int) q.size() - 1 && q[i + 1] != q[i]) {
        int pos = get(i);
        assert(pos != -1);
        ans += q[i][pos];
        val[q[i][pos] - 'A']++;
        --val[q[i][(pos + 1) % 2] - 'A'];
      } else {
        ans += q[i][0];
        ++val[q[i][0] - 'A'];
        --val[q[i][1] - 'A'];
      }
    } else {
      if (val[q[i][0] - 'A'] > val[q[i][1] - 'A']) {
        --val[q[i][0] - 'A'], ++val[q[i][1] - 'A'];
        ans += q[i][1];
      } else {
        --val[q[i][1] - 'A'], ++val[q[i][0] - 'A'];
        ans += q[i][0];
      }
    }
  }
  if (!ok) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
    for (int i = 0; i < (int) ans.size(); i++) {
      cout << ans[i] << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 6680
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""
# 最大公約数 と 最小公倍数
"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""

def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7

def main():
  n = int(input())
  LIST = readInts()
  MAX_ = [0] * (10**5 + 10) # 始めに確保しておく
  for a in LIST:
    for i in range(3):
      MAX_[a+i]+=1 # -1,0,1のように、0,1,2で被るものを考える。
  print(max(MAX_))
if __name__ == '__main__':
  main()

Measured memory_bytes: 14092
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
  ll K, A, B;
  while (cin >> K >> A >> B) {
    ll res;
    if (B - A <= 2) {
      res = K + 1;
    } else {
      ll T = min(K, A - 1);
      ll cur = 1 + T;
      K -= T;
      cur += (B - A) * (K / 2);
      cur += K % 2;
      res = cur;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
a, b, c ,k = map(int, input().split())

ak = min(a, k)
k -= ak
if k == 0:
    ans = ak
    print (ans)
else:
    bk = min(b, k)
    k -= bk
    if k == 0:
        ans = ak
        print (ans)
    else:
        ck = k
        ans = ak- ck
        print (ans)

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

int main(){
    string s;
    cin >> s;
    if(s=="SUN") cout << 7 << endl;
    if(s=="MON") cout << 6 << endl;
    if(s=="TUE") cout << 5 << endl;
    if(s=="WED") cout << 4 << endl;
    if(s=="THU") cout << 3 << endl;
    if(s=="FRI") cout << 2 << endl;
    if(s=="SAT") cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N, i, j;
    int A[200000];
    int mem[200000];
    int tmp;
    int max = -1;
    int maxn = 0;

    scanf("%d", &N);
    for (i = 0; i < N;i++){
        scanf("%d", &A[i]);
        mem[i] = 0;
        if(max < A[i]){
            max = A[i];
        }
    }
    for (i = 0; i < N;i++){
        if(A[i] == max){
            maxn++;
        }
    }

    for (i = 0;i<N;i++){
        tmp = 0;
        if(maxn > 1){
            mem[i] = max;
            continue;
        }

        if(A[i] != max){
            mem[i] = max;
            continue;
        }

        if(i == 0){
            tmp = A[1];
        }
        else{
            tmp = A[0];
        }
        for (j = 0; j < N; j++){
            if(j!=i){
                if(tmp<A[j]){
                    tmp = A[j];
                }
            }
        }
        mem[i] = tmp;
    }
    for (i = 0; i < N;i++){
        printf("%d\n", mem[i]);
    }
    return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int a,b,c,d,ans=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a==1||b==1||c==1||d==1){ans++;}
    if(a==4||b==4||c==4||d==4){ans++;}
    if(a==9||b==9||c==9||d==9){ans++;}
    if(a==7||b==7||c==7||d==7){ans++;}
    if(ans==4){printf("YES");}
    else{printf("NO");}
}

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



int main() {
  int a,b;
  cin >> a >>b;
  if(a>b*2){cout << a-b*2 << endl;}else{cout << 0 << endl;}
}


Measured memory_bytes: 256