akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

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

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//








int main(){


        int n;
        cin >> n;
        vector<int> p(n);
        rep(i,n) cin >> p[i];

        int cnt = 0;
        for(int i = 1; i < n-1; i++){
                if(p[i-1] < p[i] && p[i] < p[i+1]){
                        cnt++;
                }
                else if(p[i-1] > p[i] && p[i] > p[i+1]){
                        cnt++;
                }
        }

        cout << cnt << endl;
        return 0;









}

























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

using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++) cin >> vec[i];
  sort(vec.begin(),vec.end());
  int ans =0;
  
  for(int i=0; i<N; i++) {
    for(int j=0; j<i; j++) {
      for(int k=0; k<j; k++) {
        if(vec[i] != vec[j] and vec[k] != vec[j] and vec[j] + vec[k] > vec[i]) {
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define REREASE

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M))
#define ALL(v) v.begin()+1, v.end()-9

int main(){
    int N;
    cin>>N;
    //vector<vector<ll>> C(N+10,vector<ll>(N));
    VEC(ll,a,3*N);
    REP(i,3*N){
        cin>>a[i];
    }
    
    sort(ALL(a),[](auto& a, auto& b) {return a > b;});
    ll sum=0;
    REP(i,N){
        sum+=a[2*i];
    }
    cout<<sum;
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

}

Measured memory_bytes: 760
import java.util.*;

public class Main {
    static boolean[] visit;
    static boolean[][] graph;
    static int N;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M + 1];
        int[] b = new int[M + 1];
        graph = new boolean[N + 1][N + 1];
        visit = new boolean[N + 1];

        for (int i = 1; i <= M; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }

        int ans = 0;
        for (int i = 1; i <= M; i++) {
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
            Arrays.fill(visit, false);

            DFS(1);

            boolean flag = false;
            for (int j = 1; j <= N; j++) {
                if (!visit[j]) {
                    flag = true;
                }
            }
            if (flag) {
                ans++;
            }

            graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }
        System.out.println(ans);
    }

    static void DFS(int n) {
        visit[n] = true;
        for (int i = 1; i <= N; i++) {
            if (!graph[n][i]) continue;
            if (visit[i]) continue;
            DFS(i);
        }
    }
}


Measured memory_bytes: 22100
fun main(args: Array<String>) {
	val n = (readLine() ?: return).toInt()
	val s = (readLine() ?: return).toCharArray()
	val k = (readLine() ?: return).toInt()
	for (i in s.indices)
		if (s[i] != s[k-1]) s[i] = '*'
	println(String(s))
}

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

int main() {
  int a;
  cin >> a;
  
  int s3, s2, s1;
    s3 = a % 10;
    s2 = ( a - s3 ) / 10 % 10;
    s1 = ( a - s3 - s2 * 10) / 100;
  cout << s3 + s2 + s1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#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 REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int n,m;
  while(cin >> n >> m && (n||m)) {
    int a[n];
    rep(i,n) a[i]=n-i;
    rep(i,m) {
      int p,c;
      cin >> p >> c;
      rep(j,c) {
	for(int k=j+p-1; k>j; k--) swap(a[k],a[k-1]);
      }
    }
    pr(a[0]);
  }
  return 0;
}


Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

ll n,a,b;
vector<ll> h(n);

bool search(ll x){
	ll c = a - b;
	auto index = upper_bound(ALL(h),x * b);
	ll cnt = 0LL;
	for(auto i = index; i != h.end(); i++) {	
		cnt += (((*i - x * b) + c - 1LL) / c);
	}
	if (cnt <= x){
		return true;
	}
	else{
		return false;
	}
}
int main(){
	cin>>n>>a>>b;
	h.resize(n);
	for(ll i = 0; i < n; i++) {
		cin>>h[i];	
	}
	sort(ALL(h));
	ll ok = INF;
	ll ng = -1LL;
	while(abs(ok - ng) > 1LL){
		ll mid = (ok + ng) / 2LL;
		if (search(mid)){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll N;
vector<vector<ll>> V(100007);
ll C[100007],K=0,pre[100007];

int main(){
  cin >> N;
  ll a,b;
  rep(i,N-1){
    cin >> a >> b;
    V[b].pb(a);
    V[a].pb(b);
  }
  ll P;
  queue<ll> Q;
  Q.push(1);
  while(!Q.empty()){
    auto T = Q.front();
    Q.pop();
    rep(i,V[T].size()){
      if(V[T][i]!=pre[T]){
        pre[V[T][i]]=T;
        Q.push(V[T][i]);
      }
    }
  }
  ll K=0,K1=0;
  for(ll i=N;i!=1;i=pre[i]){
    K++;
  }
  K=(K-1)/2;
  for(ll i=N;i!=1;i=pre[i]){
    if(K1==K){
      P=i;
    }
    K1++;
  }
  K=0;
  Q.push(1);
  while(!Q.empty()){
    auto T = Q.front();
    Q.pop();
    K++;
    rep(i,V[T].size()){
      if(V[T][i]!=pre[T] && V[T][i]!=P){
        pre[V[T][i]]=T;
        Q.push(V[T][i]);
      }
    }
  }
  if(K>N/2){
    cout << "Fennec" << endl;
  }
  else{
    cout << "Snuke" << endl;
  }
}

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

int main(){
  string s;
  vector<bool> a(26,false);
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(a[s[i]-'a']){
      cout<<"no"<<endl;
      return 0;
    }
    else{
      a[s[i]-'a']=true;
    }
  }
  cout<<"yes"<<endl;
}


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

int main(){
	int abc[3];
	cin >> abc[0] >> abc[1] >> abc[2];
	sort(abc, abc + 3);
	int cnt = 0;
	if((abc[1] - abc[0]) % 2 == 1){
		abc[0]++;
		abc[2]++;
		cnt++;
	}
	cnt += (abc[1] - abc[0]) / 2;
	cnt += abc[2] - abc[1];
	cout << cnt << endl;
}

Measured memory_bytes: 256
s = list(map(int,[input() for i in range(5)]))
sum_time = sum(s)
s_10mod = [(10 -(i % 10)) %10 for i in s]
s_10mod.sort()
sum_10mod = sum(s_10mod) - s_10mod[-1]
print(sum_time + sum_10mod)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define THE using
#define DARK namespace
#define ONE std
#define dbg(x) cout << #x << " = " << x << endl

THE DARK ONE;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    freopen("out.txt", "w", stdout);
//    freopen("input.txt", "r", stdin);
    int n, c;
    cin >> n >> c;
    vector<pair<int, int> > v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());
    for(auto i: v)
        if(i.second <= c)
            return cout << i.first, 0;
    cout << "TLE" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;




int main() {

	char c;
	cin >> c;
	
	string s(1, c + 1);
	
	cout << s << endl;
	
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	int r,g;
	cin>>r>>g;
	cout<<g*2-r<<endl;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let C = buf_it.next().unwrap().chars().collect::<Vec<_>>();
    let N = C.len();

    let mut H = vec![0isize];
    for &c in &C{
        let h = H[H.len()-1];
        match c {
            '/' => {H.push(h+1);},
            '_' => {H.push(h);},
            '\\' => {H.push(h-1);},
            _ => {}
        }
    }
    let mut L = H.clone();
    let mut R = H.clone();
    for i in 0..N{
        L[i+1] = max(L[i],L[i+1]);
        R[N-i-1] = max(R[N-i-1],R[N-i]);
    }
    let W = L.iter().zip(R.iter()).map(|(a,b)| *min(a,b)).collect::<Vec<_>>();
    let mut ans = Vec::new();
    let mut tmp = 0;
    for i in 0..N+1{
        let h = H[i];
        let w = W[i];
        if w-h <= 0 && tmp > 0{
            ans.push(tmp);
            tmp = 0;
        } else if w-h > 0{
            tmp += w-h;
        }
    }
    println!("{}",ans.iter().sum::<isize>());
    if ans.len()==0{
        println!("0");
    } else {
        println!("{} {}",ans.len(),ans.iter().map(|a| format!("{}",a)).collect::<Vec<_>>().join(" "));
    }
}


Measured memory_bytes: 5052
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<cmath>
#include<algorithm>
#include<utility>
using namespace std;

void forbidden_list(vector<int>v,int x);
int main()
{
	int x,n;
	vector<int>v;
    cin>>x>>n;
	for(int i=0;i<n;i++)
	{
		int l;
		cin>>l;
		v.push_back(l);
	}
	forbidden_list(v,x);


	return 0;
}

void forbidden_list(vector<int>v,int x)
{
	auto it=find(v.begin(),v.end(),x);
	if(it==v.end())
		cout<<x<<endl;

	else
	{
		int min=100;
        vector<pair<int ,int>>p;
		for(int i=0;i<=101;i++)
		{
			
			auto it=find(v.begin(),v.end(),i);
			if(it==v.end())
			{
			int ab=abs(x-i);
			
			if(ab<min)
			{
				min=ab;
				p.push_back(make_pair(min,i));
		     }
			}
			else
				v.erase(it);
			}

			sort(p.begin(),p.end());
            auto it=p.begin();
            cout<<it->second<<endl;
           

		}


	}


Measured memory_bytes: 3632
import sys

def solve():
    input = sys.stdin.readline
    N, M= map(int, input().split())
    mod = 7 + 10 ** 9
    A = [True] * (N + 1)
    for _ in range(M):
        A[int(input())] = False
    DP = [0] * (N + 1)
    DP[0] = 1
    for i in range(N):
        if i < N - 1:
            if A[i + 2]: 
                DP[i + 2] += DP[i]
                DP[i + 2] %= mod
        if A[i + 1]:
            DP[i + 1] += DP[i]
            DP[i + 1] %= mod

    print(DP[N])

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    ll n;
    int k;
    cin >> n >> k;
    cout << floor(log(n)/log(k)) +1<< endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
int a, b;
void solve() {
    cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
    } else if (a >= 6 && a <= 12) {
        cout << b /2 << endl;
    } else {
        cout << 0 << endl;
    }
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

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

task = []
M = 0
for _ in range(N):
    a, b = map(int, input().split())
    task.append((b, a))

task.sort()

s = 0
ans = 'Yes'
for a, b in task:
    s += b
    if s > a:
        ans = 'No'
        break
print(ans)


Measured memory_bytes: 29444
def run_length_compress(string):
    string = string + [-1]
    n = len(string)

    begin = 0
    end = 1
    cnt = 1
    ans = []
    while True:
        if end >= n:
            break
        if string[begin] == string[end]:
            end += 1
            cnt += 1
        else:
            ans.append((cnt, string[begin]))
            begin = end
            end = begin + 1
            cnt = 1

    return ans


n = int(input())
a = list(map(int, input().split()))
a = run_length_compress(a)

ans = 0
for i, j in a:
    ans += i // 2
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;

int main()
{
	int n, m, k;

	cin>>n>>m;
	vector<int> talon;
	for(int i = 0; i < n*2; i++) talon.push_back(i+1);
	for(int i = 0; i < m; i++){
		cin>>k;

		vector<int> buf;
		if(k == 0){
			for(int j = 0; j < n; j++){
				buf.push_back(talon[j]);
				buf.push_back(talon[n+j]);
			}
		}else{
			for(int j = k; j < n*2; j++)	buf.push_back(talon[j]);
			for(int j = 0; j < k; j++)		buf.push_back(talon[j]);
		}
		talon = buf;

	}
	for(int i = 0; i < 2*n; i++)	cout<<talon[i]<<endl;
}

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

void solve() {
    int k, ans = 0;
    cin >> k;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                ans += __gcd(a, __gcd(b, c));
            }
        }
    }
    cout << ans << "\n";
}

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



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
 

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  cin >> A;
  A[1][0] += A[0][0];
  REP(i, N - 1) {
    A[0][i + 1] += A[0][i];
    A[1][i + 1] += max(A[1][i], A[0][i + 1]);
  }
  cout << A[1][N - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("in.txt", "r", stdin);
    ll n,m;
    cin>>n>>m;
    ll g=__gcd(n,m);
    if(g==1){
        cout<<n*m<<endl;
    }
    else{
        cout<<n*m/g<<endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
typedef long long lint;
using namespace std;

bool is_prime(const int p) {
    if (p <= 1) return false;
    for (int i = 2; i*i <= p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

// 5 の倍数 + 1 で素数を len 個錬成
vector<int> gen_prime(const int len) {
    vector<int> ret;
    for (int i = 11; ret.size() < len && i <= 55555; i+=5) {
        if (is_prime(i)) {
            ret.push_back(i);
        }
    }
    if (ret.size() < len) {
        cout << "oioi" << endl;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    auto ans = gen_prime(N);
    for (int i = 0; i < N; i++) {
        cout << ans[i];
        if (i < N-1) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio> 
#include <cstring>
#include <cmath>
#include <string>
using namespace std;
int main()
{
	
	long long a,b,c;
	cin>>a>>b>>c;
	if(a+b==c||a+c==b||b+c==a)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int a, b;
  cin >> a >> b;
  
  string s = to_string(b);
  for(int i = 0; i < s.size(); i++) {
    a = a * 10;
  }
  int c = a + b;
  for(int i = 0; i < 1000; i++) {
    if(i * i == c) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
W,H,N = map(int,input().split())
area = [0,W,0,H]
for _ in range(N):
  x,y,a = map(int,input().split())
  if a == 1:area[0], area[1] = max(x,area[0]), max(x,area[1])
  elif a == 2:area[0], area[1] = min(x,area[0]), min(x,area[1])
  elif a == 3:area[2], area[3] = max(y,area[2]), max(y,area[3])
  elif a == 4:area[2], area[3] = min(y,area[2]), min(y,area[3])
print((area[1]-area[0])*(area[3]-area[2]))

Measured memory_bytes: 38384
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int red = sc.nextInt();
    int blue = sc.nextInt();
    int green = sc.nextInt();
    int number = 100 * red + 10 * blue + green;
    if (number % 4 == 0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
    
  }
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli i,j,n,x;
    string t,s;
    cin>>s;
    cin>>t;
    lli l=s.length();
    lli m=t.length();
    string r=t.substr(0,l);
    if(r==s&&m==l+1){cout<<"Yes\n";}
    else{
        cout<<"No\n";
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

// 2分探索

bool A[100009];

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

	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') A[i + 1] = true;
	}

	int L = S.size();
	// left <= ans < right
	int left = 1, right = L + 1;
	while (left + 1 != right) {
		int mid = (left + right) / 2;

		bool flag = true;
		// [L-mid+1,mid] がすべて同じならok
		if (2 * mid >= L + 1) {
			for (int j = L - mid + 1; j < mid && flag; j++) {
				if (A[j] != A[j + 1]) flag = false;
			}
		}

		if (flag) left = mid;
		else right = mid;
	}

	cout << left << endl;

	return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int[] buffets = new int[n];
		int[] score = new int[n];
		int[] bonus = new int[n - 1];
		for(int i = 0; i < n; i++) {
			buffets[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0; i < n; i++) {
			score[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0; i < n - 1; i++) {
			bonus[i] = Integer.parseInt(sc.next());
		}
		System.out.println(new Main().buffet(n, buffets, score, bonus));
		sc.close();
	}
	
	public int buffet(int n, int[] buffets, int[] score, int[] bonus) {
		int prev_buffet = -1;
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += score[buffets[i] - 1];
			if(prev_buffet + 1 == buffets[i]) {
				sum += bonus[prev_buffet - 1];
			}
			prev_buffet = buffets[i];
		}
		return sum;
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double C = 2*pi*r;
        double S = pi*r*r;
        System.out.printf("%.6f %.6f\n", S, C);
        
        sc.close();
    }
}



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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 100000;
const int K = 100000;
int n, k;
int w[N], c[K];

bool check(int lmt) {
  int i, j;

  for (i=0; i<n; i++)
    if (lmt < w[i]) return false;

  memset(c, 0, sizeof(c));
  int full = -1;
  for (i=0; i<n; i++) {
    bool is_put = false;
    for (j=full+1; j<k; j++) {
      if (lmt < c[j] + w[i])
        full++; 
      else {
        c[j] += w[i];
        if (c[j] == lmt) full++;
        is_put = true;
        break;
      }
    }
    if (!is_put) return false;
  }

  return true;
}

int main() {
  int i;
  scanf("%d%d ", &n, &k);
  for (i=0; i<n; i++)
    scanf("%d ", w+i);
  memset(c, 0, sizeof(c));

  //?±?????????????(l, u]????????????????????¨??????????????¢?´¢
  int l = 0, u = 0;
  for (i=0; i<n; i++) u += w[i];
  while (u-l > 1) {
    int m = (int)(((ll)l + u)/2);
    if (check(m))
      u = m;
    else
      l = m;
  }

  printf("%d\n", u);

  return 0;
}

Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
 
const int sz=262144;
 
struct SegmentTree {
    int seg[524288];
    int sum(int l,int r,int node=1,int nodel=0,int noder=sz-1) {
        if (l>r) {
            return 0;
        }
        if (r<nodel||l>noder) {
            return 0;
        }
        if (l<=nodel&&noder<=r) {
            return seg[node];
        }
        int mid=(nodel+noder)/2;
        return max(sum(l,r,node*2,nodel,mid),sum(l,r,node*2+1,mid+1,noder));
    }
    void update(int i,int val) {
        i+=sz;
        seg[i]=val;
        while (i>1) {
            i/=2;
            seg[i]=max(seg[i*2],seg[i*2+1]);
        }
    }
};
 
SegmentTree st;
 
int ret[200000];
vector<int> son[200000];
vector<int> adj[200000];
bool visited[200000];
int arr[200000];
 
void maketree(int v) {
    visited[v]=true;
    for(int i=0;i<adj[v].size();i++) {
        int next=adj[v][i];
        if (!visited[next]) {
            son[v].push_back(next);
            maketree(next);
        }
    }
}
 
void getans(int v,int base) {
    int len=st.sum(0,arr[v]-1)+1;
    int prev=st.seg[sz+arr[v]];
    st.update(arr[v],len);
    int val=max(len,base);
    for(int i=0;i<son[v].size();i++) {
        getans(son[v][i],val);
    }
    st.update(arr[v],prev);
    ret[v]=val;
}
 
int main(void) {
    int n;
    scanf("%d\n",&n);
    vector<int> v;
    for(int i=0;i<n;i++) {
        scanf("%d",&arr[i]);
        v.push_back(arr[i]);
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for(int i=0;i<n;i++) {
        arr[i]=lower_bound(v.begin(),v.end(),arr[i])-v.begin();
    }
    for(int i=1;i<n;i++) {
        int u,v;
        scanf("%d %d\n",&u,&v);
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    maketree(0);
    getans(0,0);
    for(int i=0;i<n;i++) {
        printf("%d\n",ret[i]);
    }
}

Measured memory_bytes: 41936
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")
}

fn main() {
    let n: u64 = read();
    let mut a: Vec<(u64,u64)> = (0..n).map(|x| (read(),x)).collect();
 
    a.sort_by(|x, y| x.cmp(y).reverse());
    let max = a.iter().max();

    for i in 0..n {
        if i == max.unwrap().1 {
            println!("{}",a[1].0);
        } else {
            println!("{}",max.unwrap().0);
        }
    }
}

Measured memory_bytes: 11772
#include<iostream>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	long long n,m,d;
	double ans;
	cin>>n>>m>>d;
	if(d==0)ans=(m-1)/(double)n;
	else ans=(m-1)*2*(n-d)/(double)(n*n);
	printf("%.8f\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    for(int i=0;i<s.length();i++){
      if(s.charAt(i)!=t.charAt(i)){
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
    return;
  }
}

Measured memory_bytes: 35720
s = input()
a, b = int(s[:2]), int(s[2:])

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")


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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<ll>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
    ll n, m, k;
    cin>>n>>m>>k;
    if(n >= k)
    {
        n -= k;
    }
    else
    {
        k -= n;
        n = 0;
        m -= min(m, k);
    }
    cout<<n<<" "<<m;
}

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

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 3616
import sys


def parse(file):
    n, k = map(int, file.readline().split())
    s = file.readline()
    return n, k, s


def main(n, k, s):
    orig = s[k-1]
    return s[:k-1] + str.lower(orig) + s[k:]

if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x;
    int y;
    cin >> x;
    cin >> y;
    if (y<x*2||y>x*4||y%2==1){
        cout << "No";
    }
    else {
        cout << "Yes";
    }
}


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

int main(){
  string s;
  cin >> s;
  int n= s.size();
  bool ans = true;
  for(int i=0; i<n/2; ++i){
    if(s.at(i) != s.at(n-1-i)) ans = false;
  }
  for(int i=0; i<n/4; ++i){
    if(s.at(i) != s.at(n/2-1-i)) ans = false;
  }
  for(int i=0; i<n/4; ++i){
    if(s.at(n/2+1+i) != s.at(n-1-i)) ans = false;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	int d,t,s;
	scanf("%d%d%d",&d,&t,&s);
	if(d <= t*s)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
#include <limits.h>
 
#define MAX 2000000000
#define nMax 100000
 
typedef struct{
  int x;
  char c;
}card;
 
card M[nMax];
void merge(int, int, int , card *);
 
void mergeSort(int left, int right, card K[]){
  if((left + 1) < right){
    int mid = (left + right) / 2;
    mergeSort(left, mid, K);
    mergeSort(mid, right, K);
    merge(left, mid, right, K);
  }
}

void merge(int left, int mid, int right, card K[]){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  card L[nMax+1], R[nMax+1];
 
  for(i = 0; i < n1; i++){
    L[i] = K[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = K[mid+i];
  }
  L[n1].x = MAX;
  R[n2].x = MAX;
 
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i].x <= R[j].x)
      K[k]=L[i++];
    else
      K[k]=R[j++];
  }
}

int Partition(int e, int s){
  card tmp;
  int i, j, x;
  x = M[s].x;
  i = e - 1;
 
  for(j = e; j < s; j++){
    if (M[j].x <= x){
      i++;
      tmp = M[i];
      M[i] = M[j];
      M[j] = tmp;
    } 
  }
  tmp = M[i + 1];
  M[i + 1] = M[s];
  M[s] = tmp;
  return (i + 1);
}
   
void Quicksort(int e, int s){
  int w;
  if(e < s){
     w = Partition(e, s);
     Quicksort(e, w-1);
     Quicksort(w+1, s);
  }
}
 
int main(){
  int i, p, n;
  char c;
  card N[nMax];
 
  scanf("%d%c", &n, &c);
 
  for(i = 0; i < n; i++){
    scanf("%c%d%c", &N[i].c, &N[i].x, &c);
    M[i] = N[i];
  }
 
  p = 0;
  mergeSort(0, n, N);
  Quicksort(0, n-1);
 
  for(i = 0; i < n; i++){
    if(N[i].c != M[i].c){
      printf("Not stable\n");
      break;
    }
    if(i == (n - 1))
      printf("Stable\n");
  }
   
  for(i = 0; i < n; i++){
    printf("%c %d\n", M[i].c, M[i].x);
    }
   
  return 0;
}

Measured memory_bytes: 2960
#include <iostream>
#include <algorithm>
#include <cmath>

constexpr int MAX_N = 100, INF = (int)1e8;

int n;
int dp[MAX_N][MAX_N];

int main() {
	while (1) {
		int n, m, s, g[2];
		std::cin >> n >> m >> s >> g[0] >> g[1];
		if (n + m + s + g[0] + g[1] <= 0) {
			break;
		}
		--s;
		for (int i = 0; i < 2; ++i)
			--g[i];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j)
				dp[i][j] = INF;
		}
		for (int i = 0; i < n; ++i)
			dp[i][i] = 0;
		int a, b, c;
		for (int i = 0; i < m; ++i) {
			std::cin >> a >> b >> c;
			--a;
			--b;
			dp[a][b] = c;
		}
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				for (int k = 0; k < n; ++k)
					dp[j][k] = std::min(dp[j][k], dp[j][i] + dp[i][k]);
			}
		}
		int ans = INF;
		for (int i = 0; i < n; ++i) {
			ans = std::min(ans, dp[s][i] + dp[i][g[0]] + dp[i][g[1]]);
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  long long K;
  cin >> N >> K;
  vector<int>A(N);
  for (int i = 0; i < N; i ++) {
    cin >> A[i];
    A[i] --;
  }
  vector<int>ans;
  vector<bool>vis(N, false);
  int kj = 0;
  while (!vis[kj]) {
    vis[kj] = true;
    ans.push_back(kj);
    kj = A[kj];
  }
  int n_ = 0;
  while (ans[n_] != kj) n_ ++;
  if (K < n_) {
    int k = (int)K;
    cout << ans[k] + 1 << endl;
    return 0;
  }
  K -= (long long)n_;
  long long n = (long long)ans.size() - n_;
  K %= n;
  int a_ = (int)K;
  cout << ans[a_ + n_] + 1 << endl;
}



Measured memory_bytes: 5072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=10000 ;
int main()
{
   fast ;
   ll k,a,b  ;
   cin>>k>>a>>b ;
   ll y=b/k,x=(a-1)/k ;
   if(x<y) cout<<"OK" ;
   else cout<<"NG" ;



}



Measured memory_bytes: 3652
#include <iostream>
#define int long long
using namespace std;

signed main() {
    int h,w;
    int high, low;
    int ans = 0;

    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1;
    }else {
        low = w / 2;
        high = w - low;
        for (int i = 0; i < h; i++) {
            if (i % 2 == 0) ans += high;
            else ans += low;
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 3612
#include <cstdlib>
#include <iostream>
#include <typeinfo>
//#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  long long n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  cout << max({(n - 1) / a, (n - 1) / b, (n - 1) / c, (n - 1) / d, (n - 1) / e}) + 5 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 ll a[100002][3];
 ll r[100002][3];
 ll n;
 ll res(ll b,ll c)
 {
     ll i;
     if(b==n)
        return 0;
     if(r[b][c]==-1)
     {
         ll ma=INT_MIN;
         for(i=0;i<3;i++)
         {
             if(i==c)
                continue;
             ma=max(ma,a[b][c]+res(b+1,i));

         }
         r[b][c]=ma;
     }
     return r[b][c];
 }
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll i,j,k,x,y,c=0,m;
     string s,t;
     cin>>s>>t;
     n=s.length();
     m=t.length();
     int res[n+1][m+1];
     ll ans=0;
     string an="";
     memset(res,0,sizeof(res));
     vector<pair<ll,ll> > v;
     for(i=1;i<=n;i++)
     {
         for(j=1;j<=m;j++)
         {

             if(s[i-1]==t[j-1])
             {
                 res[i][j]=res[i-1][j-1]+1;
             }
             else
             {
                 res[i][j]=max(res[i-1][j],res[i][j-1]);
             }
             if(res[i][j]>ans)
             {
                 ans++;
                 x=i;
                 y=j;
             }
         }
     }
     if(!ans)
     {
         cout<<""<<"\n";
     }
     else
     {
         an+=s[x-1];
         i=x-1;
         j=y-1;
         c=1;

     }
    while(c!=ans)
    {
        if(s[i-1]==t[j-1])
        {
            c++;
            an+=s[i-1];
            i--;
            j--;
            //cout<<an<<"\n";

        }
        else
        {
            if(i==0)
                j--;
            else if(j==0)
                i--;
         else if(res[i-1][j]>res[i][j-1])
            i--;
         else j--;
        }
    }
    //cout<<an[c]<<"\n";
    for(i=c-1;i>=0;i--)
     cout<<an[i];
 cout<<"\n";
}


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

using namespace std;

int main(){
 int n; cin >> n;
  int count = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
    bool is_highest = true;
    for (int k = 0;k<i;k++){
      if (a[i] < a[k]){
        is_highest = false;
        break;
      }
    }
    if (!is_highest){
      continue;
    }
    count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	if((a+b+c)>=22) cout << "bust\n";
	else cout << "win\n";
	
	return 0;
}


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

int main()
{
  string s, t;
  cin >> s >> t;
  if(s.size() < t.size()) cout << "LESS" << endl;
  else if(s.size() > t.size()) cout << "GREATER" << endl;
  else{
    if(s < t) cout << "LESS" << endl;
    else if(s > t) cout << "GREATER" << endl;
    else cout << "EQUAL" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int k, q;
    ll a[5003] = {};
    cin >> k >> q;
    for (int i = 0; i < k; i++) cin >> a[i];
    while (q--) {
        ll n, x, m, b[5003] = {}, c[5003] = {};
        cin >> n >> x >> m; n--;
        x %= m;
        for (int i = 1; i <= k; i++) b[i] = b[i - 1] + a[i - 1] % m;
        for (int i = 1; i <= k; i++) c[i] = c[i - 1] + (a[i - 1] % m == 0);
        ll s = b[k] * (n / k) + b[n % k] + x, t = c[k] * (n / k) + c[n % k];
        cout << n - s / m - t << '\n';
    }
}


Measured memory_bytes: 3772
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define mod 1000000007

lli maxHappiness(lli n, vector<lli> happ[]){
	lli dp[n + 1][3] = {0};

	lli i;
	for(i = 1; i <= n; i++){
		dp[i][0] = happ[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = happ[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = happ[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	return max(dp[n][0], max(dp[n][1], dp[n][2]));
}


void solve(){
	lli n, k;
	cin >> n;
	vector<lli> happ[n + 1];
	lli i, a, b, c;
	for(i = 1; i <= n; i++){
		cin >> a >> b >> c;
		happ[i].push_back(a);
		happ[i].push_back(b);
		happ[i].push_back(c);
	}
	cout << maxHappiness(n, happ);
}

int main(){
	solve();
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double d;
const int mod=1e9+7;

int main(){
	int n,k;cin>>n>>k;
	d ans=0.0;
	int p2=1;
	for(int i=n;i>=1;i--){
		while(p2*i<k){
			p2*=2;
		}
		//cout<<n*p2<<endl;
		ans+=((1.0/double(n))*(1.0/double(p2)));
	}
	cout<<setprecision(12)<<fixed<<ans;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  unordered_map<string, int> days_map;
  for (int i = 0; i < 7; i++) {
    days_map[days[i]] = i;
  }
  string day;
  cin >> day;
  cout << 7 - days_map[day] << endl;
  return 0;
}

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

int main(){
  ll n;
  cin >> n;
  vector<vector<ll>> cnt(10, vector<ll>(10));
  for(ll i = 1; i <= n; i++){
    string s = to_string(i);
    cnt[s.front() - '0'][s.back() - '0']++;
  }
  ll ans = 0;
  for(ll i = 0; i < 10; i++) for(ll j = 0; j < 10; j++) ans += cnt[i][j] * cnt[j][i];
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long[][] dp;
    static long[] s;
    static int N;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        int K = sc.nextInt();
        double ans = 0;
        for (int i = 1; i <= N; i++) {
            double value = 1;
            double k = K;
            while (i < k) {
                k = k/2;
                value = value/2;
            }
            ans += value;
        }
        ans = ans / N;
        System.out.println(ans);

    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

std::string s;
long front[26];
long back[26];
long cnt[26];
long ind[26];
long found[26];
long cost[26];

int main(){
	std::cin >> s;
	for(int i = 0; i < 26; i++){
		front[i] = -1;
		back[i] = -1;
		ind[i] = -1;
	}
	for(long i = 0; i < s.length(); i++){
		found[s[i] - 'a']++;
		if(front[s[i] - 'a'] == -1){
			front[s[i] - 'a'] = i;
		}
	}
	for(long i = 0; i < s.length(); i++){
		if(back[s[s.length() - 1 - i] - 'a'] == -1){
			back[s[s.length() - 1 - i] - 'a'] = i;
		}
	}
	for(long i = 0; i < s.length(); i++){
		if(ind[s[i] - 'a'] == -1){
			ind[s[i] - 'a'] = i;
		}else{
			cnt[s[i] - 'a'] = std::max(cnt[s[i] - 'a'], i - ind[s[i] - 'a'] - 1);
			ind[s[i] - 'a'] = i;
		}	
	}
	long ans = LINF;
	for(long i = 0; i < 26; i++){
		//printf("%c : %ld %ld %ld\n", 'a' + i, front[i], back[i], cnt[i]);
		cost[i] = LINF;
		if(found[i] >= 1){
			cost[i] = std::max(front[i], back[i]);
			if(found[i] > 1){
				cost[i] = std::max(cost[i], cnt[i]);
			}
		}
		ans = std::min(cost[i], ans);
	}
	printf("%ld\n", ans);
	return 0;
}
		


Measured memory_bytes: 256