akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

// dp[i] := [i, n) の部分文字列に含まれない文字列の最小の長さ
int dp[200005];
vector<vector<int>> pos(26);
int n;

int get_next(int x, char c){
    int id = c - 'a';
    return *lower_bound(pos[id].begin(), pos[id].end(), x);
}

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

    string s;
    cin >> s;
    n = s.length();
    for(int i = 0; i < n; ++i){
        int id = s[i] - 'a';
        pos[id].push_back(i);
    }
    // 番兵
    for(int i = 0; i < 26; ++i) pos[i].push_back(n);
    
    fill(dp, dp + n, INF);
    dp[n] = 1;
    for(int i = n - 1; i >= 0; --i){
        for(char c = 'a'; c <= 'z'; ++c){
            int next = get_next(i, c);
            chmin(dp[i], dp[next + 1] + 1);
        }
    }

    int now = dp[0];
    int now_pos = 0;
    string res = "";
    while(now > 0){     // DPの経路復元
        --now;
        for(char c = 'a'; c <= 'z'; ++c){
            int next = get_next(now_pos, c);
            if(dp[next + 1] == now){    // c と substring([next+1, n)) が条件を満たせば
                res += c;
                now_pos = next + 1;
                break;
            }
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 2196
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void output(ll rc, ll lc)
{
    for (ll j = 0; j < rc - 1; j++)
    {
        cout << "0 ";
    }

    ll v = (rc + lc);
    ll v2 = v / 2;
    if (v % 2 == 0)
    {
        cout << v2 << " " << v2 << " ";
    }
    else
    {
        if (rc % 2 == 0)
        {
            cout << v2 << " " << v2 + 1 << " ";
        }
        else
        {
            cout << v2 + 1 << " " << v2 << " ";
        }
    }
    for (ll j = 0; j < lc - 1; j++)
    {
        cout << "0 ";
    }
}

void solve()
{
    string S;
    cin >> S;
    ll N = S.size();
    ll rc = 0;
    ll lc = 0;
    for (ll i = 0; i < N; i++)
    {
        if (i > 0 && S[i - 1] != S[i] && S[i] == 'R')
        {
            output(rc, lc);
            lc = 0;
            rc = 0;
        }

        if (S[i] == 'R')
        {
            rc++;
        }
        else if (S[i] == 'L')
        {
            lc++;
        }
    }

    output(rc, lc);

    return;
}

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


Measured memory_bytes: 640
import Data.List
f::Int->[String]->[(String,Int,Int)]
f _ []=[]
f c (e:es)=let t=words e
           in (t!!0,(-1::Int)*(read (t!!1)::Int),c):f (c+1) es

main = do
       u<-getLine
       a<-getContents
       let t=sort $ f 1 (lines a)
       mapM_ putStrLn $ map (\(_,_,x)->show x) t

Measured memory_bytes: 1020
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
	ll n, m;
	scanf("%lld %lld", &n, &m);
	ll dap = n*n;
	for (int i = 1; i <= n; i++)
	{
		if (m < i) {
			ll gap = n / i*m;
			gap += max(min(n%i, m - 1),(ll)0);
			dap -= gap;
		}
		else
			dap -= n;
	}
	printf("%lld", dap);
}

Measured memory_bytes: 128
import sys
fastinput = sys.stdin.readline
N=int(fastinput())
A=[int(fastinput()) for i in range(N)]
B = [a for a in A]
B.sort(reverse=True)
First = B[0]
Second = B[1]
Findex = A.index(First)
if First == Second:
    for i in range(N):print(First)
else:
    for a in A:
        if a==First:print(Second)
        else:print(First)


Measured memory_bytes: 14112
S = input()
S = S[::-1]

ws = ['maerd','remaerd','esare','resare']
i = 0
while i < len(S):
    for w in ws:
        if w == S[i:i+len(w)]:
            i += len(w)
            break
    else:
        print('NO')
        exit()
print('YES')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,K;
ll sum[100];
ll rev[100];

int main(){
	cin >> n >> K;
	vector<ll> v(n);
	rep(i,n){
		cin >> v[i];
		sum[i+1] = sum[i]+v[i];
	}
	reverse(ALL(v));
	rep(i,n)rev[i+1] = rev[i] + v[i];
	reverse(ALL(v));
	ll res = 0;
	rep(i,n+1){
		rep(j,n+1){
			if(n-j <= i-1 || i+j > K)continue;
			ll ans = sum[i] + rev[j];
			vector<ll> d;
			rep(k,i)if(v[k] < 0)d.push_back(v[k]);
			for(ll k = n-1;k >= n-j;k--)if(v[k] < 0)d.push_back(v[k]);
			sort(ALL(d));
			rep(k,min((ll)d.size(),K-(i+j)))ans -= d[k];
			res = max(ans,res);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#入力値の取得
_in =input().split()

#_in = ["10", "21"]
#文字の結合
cont_str = _in[0] + _in[1]

#数字に変換
cont_num = int(cont_str)


#平方数の判定
#総当たり頭悪そう　1<= ab <= 100 なので 4*4~ 100*100
sqrt_flag = False
for i in range(4, 500):
        sqrt = i * i
        #print(sqrt)
        if cont_num == sqrt:
            sqrt_flag = True
            break
if sqrt_flag:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 38384
#include <stdio.h>

int main(void) {
	int i,j,all;
	int num2;
	char ch;
	int num[4][13];
	
	scanf("%d",&all);
	
	for(i=0;i<4;i++){
		for(j=1;j<14;j++){
			num[i][j] = 0;

			
		}

	}

	for(i=0;i<all;i++){

			scanf(" %c",&ch); 
			scanf(" %d",&num2);
			switch(ch){
				case 'S':
					num[0][num2] = 1;
						break;
				case 'H':
					num[1][num2] = 1;
						break;
				case 'C':
					num[2][num2] = 1;
						break;
				case 'D':
					num[3][num2] = 1;
						break;
				default:

						break;
				
			}
	}
	
	for(i=0;i<4;i++){
		for(j=1;j<14;j++){
			if(num[i][j] == 0){
				switch(i){
				case 0:
					printf("%c",'S');
						break;
				case 1:
					printf("%c",'H');
						break;
				case 2:
					printf("%c",'C');
						break;
				case 3:
					printf("%c",'D');
						break;
				default:

						break;
					
					
				}
				num[i][j] = j;
				printf(" %d",num[i][j]);
				
					printf("\n");
			}
		}

	}
	
	
	
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

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

        final String[] dayS = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

        while (true) {
            int year = 2004;
            int month = Integer.parseInt(sc.next());
            int date  = Integer.parseInt(sc.next());

            if (month == 0 && date == 0) break;

            if (month == 1 || month == 2) {
                year--;
                month += 12;
            }

            int day = (year + year / 4 - year / 100 + year / 400 + (13 * month + 8) / 5 + date) % 7;

            System.out.println(dayS[day]);
        }
    }
}

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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 500005
int n;
int nex[MN],vi[MN],fr[MN],tot=0;
int mx[MN],fa[MN];
int vx[MN],vf[MN];
int res[MN];
int X[MN];
void add(int x,int y){
	nex[++tot]=fr[x];fr[x]=tot;vi[tot]=y;
}
vector<pair<pii,int> > Qry;

void dfs(int x,int z,int mxx){
	mx[x]=mxx;
	//cerr<<x<<"@@@"<<mx[x]<<endl;
	Qry.pb(mp(mp(mx[x]-1,x),x));
	Qry.pb(mp(mp(mx[fa[x]]-1,x),-x));
	X[x]=z;
	if(mx[x]>x){
	}else mxx=x;
	for(int i=fr[x];i;i=nex[i])if(vi[i]!=fa[x]){
		fa[vi[i]]=x;dfs(vi[i],mxx==x?vi[i]:z,mxx);
	}
}

void dfs2(int x){
	//cerr<<x<<" "<<X[x]<<' '<<vf[X[x]]<<' '<<vx[x]<<endl;
	if(fa[x]==1)res[x]=1;else res[x]=vx[x]+res[mx[x]]-vf[X[x]];
	for(int i=fr[x];i;i=nex[i])if(vi[i]!=fa[x]){
		dfs2(vi[i]);
	}
}

namespace T{
	int f[MN];
	void init(int n){for(int i=1;i<=n;++i)f[i]=-1;}
	int gf(int x){return f[x]<0?x:f[x]=gf(f[x]);}
	void mg(int x,int y){x=gf(x);y=gf(y);f[x]+=f[y];f[y]=x;}
	inline int sz(int x){return -f[gf(x)];}
}

void Answer(){
	sort(Qry.begin(),Qry.end());
	int G=0;
	T::init(n);
	while(G<(int)Qry.size()&&Qry[G].ft.ft<=0){
			if(Qry[G].sd<0){
				vf[-Qry[G].sd]=1;
			}else vx[Qry[G].sd]=1;++G;
	}
	for(int i=1;i<=n;++i){
		for(int v=fr[i];v;v=nex[v]){
			if(vi[v]<i){
				T::mg(i,vi[v]);
			}
		}
		//cerr<<i<<'@'<<Qry[G].ft.ft<<endl;
		for(;G<(int)Qry.size()&&Qry[G].ft.ft==i;++G){
			int now=Qry[G].ft.sd,Sz=1;
			if(now<=i){Sz=T::sz(now);goto HALA;}
			//if(now==2)cerr<<now<<"!"<<endl;
			for(int v=fr[now];v;v=nex[v]){
				//if(now==2)cerr<<vi[v]<<"@"<<endl;
				if(vi[v]<=i)Sz+=T::sz(vi[v]);
			}
			HALA:
			//cerr<<now<<' '<<Qry[G].sd<<'&'<<Sz<<endl;
			if(Qry[G].sd<0){
				vf[-Qry[G].sd]=Sz;
			}else vx[Qry[G].sd]=Sz;
		}
	}
}

int main(){
	read(n);
	for(int i=1,x,y;i<n;++i){
		read(x);read(y);
		add(x,y);add(y,x);
	}
	dfs(1,0,0);
	//for(int i=1;i<=n;++i)cerr<<i<<' '<<mx[i]<<' '<<fa[i]<<endl;
	Answer();
	//LLLINE;for(int i=1;i<=n;++i)cerr<<i<<' '<<vx[i]<<' '<<vf[i]<<endl;LLLINE;
	for(int i=1;i<=n;++i)if(mx[fa[i]]<i)vf[i]=0;
	dfs2(1);
	for(int i=2;i<=n;++i)printf("%d ",res[i]);
	return 0;
}


Measured memory_bytes: 37996
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define rrep(i,n) for(int i=n ; i>=0 ; i--)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;


int main(){
    int n; cin >> n;
    int b; cin >> b;
    if(n >= 13) cout << b << endl;
    else if(n >= 6) cout << (b/2) << endl;
    else cout << 0 << endl;


}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#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 = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int atk1,atk2,hp1,hp2;
    cin >> hp1 >> atk1 >> hp2 >> atk2;
    while(hp1 > 0 || hp2 > 0){
        hp2 -= atk1;
        if(hp2 <= 0) break;
        hp1 -= atk2;
        if(hp1 <= 0) break;
    }
    if(hp2 <= 0) dunk("Yes");
    else dunk("No");
    return 0;
}

Measured memory_bytes: 3636
inf = 10**9+7
mod = 10**9+7
n, m = map(int, input().split())
c = list(map(int, input().split()))
dp = [[inf for j in range(n+1)]for i in range(m+1)] #i番目まででj払う時に必要な最小枚数
dp[0][0] = 0
for i in range(m):
    dp[i+1][0] = 0
    for j in range(n):
        if j+1-c[i] >= 0:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-c[i]]+1, dp[i+1][j+1-c[i]]+1)
        else:
            dp[i+1][j+1] = dp[i][j+1]
print(dp[m][n])


Measured memory_bytes: 43892
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := iScan(), iScan()
	x := 0
	for i := 1; i < b-a; i++ {
		x += i
	}
	fmt.Println(x - a)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
const int mod = 1000000007;


int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(int i = k; i <= n+1; i++) {
    // ans += (2*n-i+1)*i/2-i*(i-1)/2+1;
    ans += (i*(n-i+1) + 1);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int k[n+5],a[30][30],num[m+5]={};
    for(int i=0;i < n;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i < n;i++){
        for(int j=0;j<k[i];j++){
            num[a[i][j]-1]++;
        }
    }
    int ans = 0;
    for(int i=0;i<m;i++){
        if(num[i]==n)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let b = read_vec::<i64>();
    let mut answers = vec![0; n];
    for i in 0..n {
        if i % 2 == 0 {
            answers[0] += b[i];
        } else {
            answers[0] -= b[i];
        }
    }
    for i in 1..n {
        answers[i] = 2 * b[i - 1] - answers[i - 1];
    }
    print_array(&answers);
}

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

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

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 14584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=105;
char s[N][N];
int dp[N][N];


void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>s[i]+1;
    memset(dp,0x3f,sizeof dp);
    if(s[1][1]=='#') dp[1][1]=1;
    else dp[1][1]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i==1&&j==1) continue;
            if(i>1){
                if(s[i][j]!=s[i-1][j]){
                    if(s[i][j]=='#') dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
                    else dp[i][j]=min(dp[i][j],dp[i-1][j]);
                }else dp[i][j]=min(dp[i][j],dp[i-1][j]);
            }
            if(j>1){
                if(s[i][j]!=s[i][j-1]){
                    if(s[i][j]=='#') dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
                    else dp[i][j]=min(dp[i][j],dp[i][j-1]);
                }else dp[i][j]=min(dp[i][j],dp[i][j-1]);
            }
        }
    }
    cout<<dp[n][m];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    ll x;
    cin >> x;
    int ans = 0;
    ll now = 100;
    while(true){
        ans++;
        now = now * 1.01;
        if (now >= x) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

int main(){
    int a,p;
    cin >> a >> p;
    cout << (a * 3 + p)/2 << endl;
    return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int IsPrime(int n)
{
  int i;

  if(n < 2)
    return 0;
  else if(n == 2)
    return 1;

  if(n % 2 == 0)
    return 0;

  for(i = 3 ; i <= n / i ; i += 2)
    {
      if(n % i == 0)
	return 0;
    }  
  return 1;
}

int main()
{
  int a,b,i,count = 0;

  scanf("%d",&a);

  for(i = 0 ; i < a ; i++)
    {
      scanf("%d",&b);
      if(IsPrime(b) == 1)
	{
	  count += 1;
	}
    }

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

  return 0;
}


Measured memory_bytes: 2072
def main():
    S = input()

    if 1 <= int(S[0]+S[1]) <= 12 and 1 <= int(S[2]+S[3]) <= 12:
        print('AMBIGUOUS')
    elif 1 <= int(S[0]+S[1]) <= 12:
        print('MMYY')
    elif 1 <= int(S[2]+S[3]) <= 12:
        print('YYMM')
    else:
        print('NA')

main()

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class ABC
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] X = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int[] Y = X.OrderBy(x => x).ToArray();
            for(int i = 0; i < N; i++)
            {
                if (X[i] <= Y[N / 2 - 1]) Console.WriteLine(Y[N / 2]);
                else if (X[i] >= Y[N / 2]) Console.WriteLine(Y[N / 2 - 1]);
            }

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 40824
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    
    for (int i = 0; i <= 10000; i++) {
        if (i * 8 / 100 == a && i * 10 / 100 == b) {
            cout << i << endl;
            return 0;            
        }
    }
    
    cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,j;
    scanf("%d",&n);

    int b[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&b[i]);
    }

    for(j=n-1;j>=0;)
    {
        printf("%d ",b[j]);
        if(j==1||j==0)
          break;
        j-=2;
    }

    if(j==1)
     --j;
    else if(j==0)
     ++j;
    for(;j<n;j+=2)
    printf("%d ",b[j]);
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

int N, M, Q;
ll ans = 0;
int A[51], B[51], C[51], D[51];

void dfs(vector<int> v, int cnt, int las) {

  if(cnt==N) {
    ll res = 0;
    rep(i, Q) {
      if(v[B[i]]-v[A[i]] == C[i]) res += D[i];
    }
    ans = max(ans, res);
    return;
  }

  vector<int> nv = v;
  rrep(i, las, M+1) {
    nv.push_back(i);
    dfs(nv, cnt+1, i);
    nv.pop_back();
  }

}

void solve() {

  cin >> N >> M >> Q;
  rep(i, Q) {
    cin >> A[i] >> B[i] >> C[i] >> D[i];
    A[i]--, B[i]--;
  }

  vector<int> v;
  dfs(v, 0, 1);

  cout << ans << endl;
}

int main() {

  solve();

  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;
const int N=42;
const int mod=2147483647;
const int mod1=1e9+9;
const int base=43;
int n,mul[N],mul1[N];
string s;
bool used[N];
vector<pair<int,int> > damn[N],damn1[N];
void check(){
	int i,dem=0,val=0,val1=0,val2=0,val3=0;
	for(i=1;i<=n;i++){
		if(!used[i]){
//			cout<<0;
			dem++;
			val=(val*base+(int)(s[i]-'a'))%mod;
			val2=(val2*base+(int)(s[i]-'a'))%mod1;
		}
	}
	for(i=n;i>0;i--){
		if(used[i]){
//			cout<<1;
			val1=(val1*base+(int)(s[i]-'a'))%mod;
			val3=(val3*base+(int)(s[i]-'a'))%mod1;
		}
	}
//	cout<<endl;
//	if(dem==0){
//		cout<<val<<' '<<val1<<endl;
//	}
	damn[dem].push_back({(val*mul[n-dem]-val1+mod)%mod,(val2*mul1[n-dem]-val3+mod1)%mod1});
}
void back(int idx,int lim){
	if(idx==lim+1){
		check();
		return;
	}
	used[idx]=false;
	back(idx+1,lim);
	used[idx]=true;
	back(idx+1,lim);
}
void check1(){
	int dem=0,val=0,val1=0,i,val2=0,val3=0;
	for(i=n+1;i<=2*n;i++){
		if(!used[i]){
//			cout<<0;
			val=(val*base+(int)(s[i]-'a'))%mod;
			val2=(val2*base+(int)(s[i]-'a'))%mod1;
		}
//		else{
//			cout<<1;
//		}
	}
	for(i=2*n;i>n;i--){
		if(used[i]){
			dem++;
			val1=(val1*base+(int)(s[i]-'a'))%mod;
			val3=(val3*base+(int)(s[i]-'a'))%mod1;
		}
	}
//	cout<<endl;
//	if(dem==0){
//		cout<<val<<' '<<val1<<endl;
//	}
	damn1[dem].push_back({(val1*mul[n-dem]-val+mod)%mod,(val3*mul1[n-dem]-val2+mod1)%mod1});
}
void back1(int idx,int lim){
	if(idx==lim+1){
		check1();
		return;
	}
	used[idx]=false;
	back1(idx+1,lim);
	used[idx]=true;
	back1(idx+1,lim);
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int i,j,k,l,ans=0;
	cin>>n>>s;
	mul[0]=1;
	for(i=1;i<=2*n;i++){
		mul[i]=(mul[i-1]*base)%mod;
		mul1[i]=(mul1[i-1]*base)%mod;
	}
	s=" "+s;
	back(1,n);
	back1(n+1,2*n);
	for(i=0;i<=n;i++){
		sort(damn[i].begin(),damn[i].end());
		sort(damn1[i].begin(),damn1[i].end());
		for(j=0;j<damn[i].size();j++){
			//cout<<damn[i][j]<<' ';
			ans+=(int)(upper_bound(damn1[i].begin(),damn1[i].end(),damn[i][j])-lower_bound(damn1[i].begin(),damn1[i].end(),damn[i][j]));
		}
//		cout<<endl;
//		for(j=0;j<damn1[i].size();j++){
//			cout<<damn1[i][j]<<' ';
//		}
//		cout<<"cac "<<i<<endl;
	}
	cout<<ans;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

string S;

signed main()
{
    cin >> S;

    ll ans = 0;
    ll cur_a = 0;
    ll i = 0;
    while(i < S.length()) {
        if(S[i] == 'A') {
            cur_a++;
        }
        else if(i < S.length() - 1 && S[i] == 'B' && S[i+1] == 'C') {
            ans += cur_a;
            ++i;
        }
        else {
            cur_a = 0;
        }
        ++i;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 640
s=input()
if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]:
    print('Yes')
    #aabb
elif s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]:
    print('Yes')
    #abab
elif s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]:
    print('Yes')
    #abba
else:
    print('No')

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll N, K;
  cin >> N >> K;
  ll a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  ll tmp = 0;
  for (int i = 0; i < K; i++) tmp += a[i];

  for (int i = K; i < N; i++) {
    ll tmp2 = tmp - a[i-K] + a[i];
    if (tmp < tmp2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    tmp = tmp2;
  }

  return 0;
}


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

int main() {
	int n, sum=0;
	cin >> n;
	int* a = new int[n];
	int* b = new int[n - 1];
	for (int i = 1; i < n; i++) {
		cin >> b[i];
	}
	a[1] = b[1], a[2] = b[1];
	for (int i = 2; i < n; i++) {
		a[i + 1] = b[i];
		if (b[i] < b[i - 1]) a[i] = b[i];
	}
	for (int i = 1; i < n + 1; i++) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,p[10],i,max,tmp,sum=0;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }

    max=-1;
    tmp=0;
    for(i=0;i<n;i++){
        if(max<p[i]){
            max=p[i];
            tmp=i;
        }
    }

    for(i=0;i<n;i++){
        if(i!=tmp){
            sum+=p[i];
        }
    }

    sum=sum+(p[tmp]/2);

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


    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6){
        cout << b/2 << endl;
    }else cout << 0 << endl;
    return 0;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const int INF = 100001;

int n, a;

int main()
{
    cin >> n >> a;
    if (n % 500 <= a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cctype>
#include <map>

#define conv(c) (int)(c-'1')

using namespace std;

typedef pair<int, string> P; 

vector<string> vec;
string str;
map<P, string> mpp;

string func(string st)
{
  string s = "";
  for(int i = 0; i < st.size(); ++i)
    if(st[i] != ' ') s += st[i];

  return s;
}

void mkMap(string s, int d)
{
  if(d == 8){
    for(int i = 0; i < 3; ++i){
      string st = "";
      for(int j = 0; j < 4; ++j){
	if(i == 0){
	  st += ((s[j] == '1' || s[j+4] == '1')? "1" : "0"); 
	} else if(i == 1){
	  st += ((s[j] == '1' && s[j+4] == '1')? "1" : "0");
	} else {
	  st += ((s[j] != s[j+4])? "1" : "0");
	}
      }
      mpp[P(i, s)] = st;
    }
  } else {
    for(int i = 0; i < 2; ++i)
      mkMap(s+(char)('0'+i), d+1);
  }

  return ;
}

int p;
vector<string> rec()
{
  vector<string> v1, v2, res;
  if(isdigit(str[p])){
    v1.push_back(vec[conv(str[p])]);
    p+=2;
  } else {
    ++p;
    v1 = rec();
    ++p;
  }

  if(isdigit(str[p])){
    v2.push_back(vec[conv(str[p])]);
    p+=2;
  } else {
    ++p;
    v2 = rec();
    ++p;
  }

  for(int k = 0; k < v1.size(); ++k)
    for(int l = 0; l < v2.size(); ++l)
      for(int i = 0; i < 3; ++i)
	res.push_back(mpp[P(i, v1[k]+v2[l])]);

  return res;
}

int solve(string s)
{
  int cnt = 0;
  p = 1;
  vector<string> res = rec();

  for(int i = 0; i < res.size(); ++i)
    if(res[i] == s) cnt++;

  return cnt;
}

int main()
{
  int n;
  string s1, s2="";

  mkMap("", 0);
  for(int i = 0; i < 4; i++) s2 += "1";
  while(getline(cin, str) && str != "END"){
    getline(cin, s1);
    n = atoi(s1.c_str());

    while(n--){
      getline(cin, s1);
      vec.push_back(func(s1));
    }

    cout << solve(s2) << endl;
    vec.clear();
  }

  return 0;
}

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

int main(){
	string s;
  cin >> s;
  int counter = 0;
  if(s[0] == '1') ++counter;
  if(s[1] == '1') ++counter;
  if(s[2] == '1') ++counter;
  cout << counter << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a1,a2,a3;
scanf("%d %d %d",&a1,&a2,&a3);
  if(a1+a2+a3>=22){
    printf("bust\n");
  }
  else if(a1+a2+a3<=21){
    printf("win\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if(n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23252
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    readln.split.to!(int[]).reduce!"(a-1)*(b-1)".writeln;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
n = gets.to_i

ary = gets.split(' ').map(&:to_i)

if n == 1
  puts 'Yes'
else
  result = nil
  ary.each_index do |index|
    next if index == 0

    a = ary[index]
    aa = a - 1

    if index == (ary.length - 1)
      result =
        if a >= ary[index - 1]
          'Yes'
        else
          'No'
        end
      break
    end

    if aa > 0 && aa >= ary[index - 1] && aa <= ary[index + 1]
      ary[index] -= 1
      next
    elsif a >= ary[index - 1] && a <= ary[index + 1]
      next
    else
      result = 'No'
      break
    end
  end

  puts result
end


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

int main() {
	string inputa,inputb;
	string abc("ABCDEF");
	cin >> inputa;
	cin >> inputb;
	if ((int)abc.find(inputa) > (int)abc.find(inputb)) cout << ">" << endl;
	else if ((int)abc.find(inputa) < (int)abc.find(inputb)) cout << "<" << endl;
	else cout << "=" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n,r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << endl;
	} else {
		cout << (r + 100 * (10 - n))<< endl;
	}
}


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

int main(){
	int n;
	cin>>n;
	vector<pair<int,int> > g[n];
	for(int i=0;i<n-1;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	
	int q,k;
	cin>>q>>k;
	k--;
	
	queue<int> p;
	p.push(k);
	vector<int> used(n,0);
	used[k]=1;
	vector<long long int> dis(n,1000000000009);
	dis[k]=0;
	while(p.empty()==0){
		int np=p.front();
		p.pop();
		for(int i=0;i<g[np].size();i++){
			if(used[g[np][i].first]==0){
				p.push(g[np][i].first);
				dis[g[np][i].first]=dis[np]+g[np][i].second;
				used[g[np][i].first]=1;
				//cout<<g[np][i].second<<" "<<np<<" "<<dis[np]<<" "<<g[np][i].first<<" "<<dis[np]<<" "<<g[g[np][i].first][i].second<<endl;
			}
		}
	}
	
	for(int i=0;i<q;i++){
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		cout<<dis[x]+dis[y]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 9204
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;


int main()
{
    int n;
    scanf("%d", &n);

    int flag = 1;
    int last_t = 0;
    int last_x = 0, last_y = 0;

    while(n--)
    {
        int t, x, y;
        scanf("%d %d %d", &t, &x, &y);

        int distance = abs(x - last_x) + abs(y - last_y);
        int interval = t - last_t;

        int extra = interval - distance;

        if(distance > interval || extra%2 == 1)
            flag = 0;

        last_t = t;
        last_x = x, last_y = y;
    }
    if(flag==1)
    printf( "Yes\n");
    else
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vi a,b;

int main(){
	cin>>n>>m;
	int N=1<<n;
	vi dp(N,inf);
	a=b=vi(m);
	dp[0]=0;
	for(int i=0;i<m;i++){
		int k;
		cin>>a[i]>>k;
		for(int j=0;j<k;j++){
			int x;
			cin>>x;
			b[i]+=1<<(x-1);
		}
	}
	for(int i=0;i<N-1;i++) for(int j=0;j<m;j++) dp[i|b[j]]=min(dp[i|b[j]],dp[i]+a[j]);
	if(dp[N-1]==inf) dp[N-1]=-1;
	cout<<dp[N-1]<<endl;
}

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

int main() {
    ll x;
    cin >> x;
    ll a,b;
    rep(i,400){
        rep(j,400){
            ll ans,ansb;
            ans = i*i*i*i*i;
            ansb = j*j*j*j*j;
 
            if(ans + ansb == x){
                a = i;
                b = -j;
                goto OUT;
            }
            if(ans - ansb == x){
                a = i;
                b = j;
                goto OUT;
            }
        }
    }
    OUT:
    cout << a << " " << b << endl;
    cout << endl;
    return 0;
}


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

int main()
{
 char X,Y;
 cin >> X >> Y;
 int A = 10;
 int B = 11;
 int C = 12;
 int D = 13;
 int E = 14;
 int F = 15;
 if(X < Y) cout << "<" << endl;
 else if(X > Y) cout << ">" << endl;
 else cout << "=" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = s; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 

int main() {
    int n, m;
    cin >> n >> m;
    int tot = 0;
    vector<int> as(n);
    rep(i, n) {
        cin >> as[i];
        tot += as[i];
    }
    int cnt = 0;
    rep(i, n) {
        if (as[i] * 4 * m >= tot) ++cnt;
    }
    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)

if n<=4:
  print('0')
  exit()  

yo_list1=[1,10,100,1000]
yo1=1000
for i in range(200000):
  yo1 = yo1*10 % 2019
  yo_list1.append(yo1)

yo_dict = {i:0 for i in range(2019)}

yo2=int(s[n-1])
yo_dict[0]=1
yo_dict[yo2]=1

for i in range(1,n):
  yo2 = ( int(s[n-1-i])*yo_list1[i] + yo2 ) % 2019
  yo_dict[yo2]+=1

count=0
for i in range(2019):
  yo3 = yo_dict[i]
  if yo3>=2:
    count+=yo3*(yo3-1)//2
print(count)

Measured memory_bytes: 16664
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){
	char c=getchar();
	while(c<'0'||'9'<c) c=getchar();
	uint_fast32_t x=0;
	while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); }
	return x;
}

int main(void){
	long long a, b;
	scanf("%lld%lld", &a, &b);
	if(a==1 || b==1){
		printf("1\n");
	}else if((a%2)==0 || (b%2)==0){
		printf("%lld\n", a*b/2);
	}else{
		printf("%lld\n", (a-1)*b/2 + (b+1)/2);
	}
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d)
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n;
    ll t;
    int ans=-INF;
    cin >>n>>t;
    V a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll down=INF;
   // ll se=INF;
    map<int,int>pro;
    rep(i,n){
        if(down <a[i]){
            pro[a[i]-down]+=0;
            pro[a[i]-down]++;
            // if(se<a[i]){
            //     pro[a[i]-se]+=0;
            //     pro[a[i]-se]++;
            //     clog << (a[i] - se) << endl;
            // }
        //    clog<<(a[i]-down)<<endl;
        }
        //chmin(se,down);
        chmin(down,a[i]);
    }
    auto itr=pro.end();
    itr--;
    cout<<(itr->S)<<endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

int k, a, b;
int main() {
    cin >> k >> a >> b;
    rep(i, a, b+1){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<cmath>
int main(void){
	int a;
	scanf("%d",&a);
	for(int i=6;i>=0;i--){
		if(pow(2,i)<=a){
			printf("%d\n",(int)pow(2,i));
			return 0;
		}
	}
}


Measured memory_bytes: 128
X=[]
loop{
  x=[]
  x[0],x[1]=gets.split(" ").map{|v|v=v.to_i}
  X.push(x) if x!=[0,0]
  break if x==[0,0]
}
W1=[]
W2=[]
0.upto(150){|n|
  W1.push("#",".")
  W2.push(".","#")
}
0.upto(X.length-1){|m|
  t = X[m]
  h = t[0]
  w = t[1]
  1.upto(h){|o|
    puts W1[0..w-1].join if o%2!=0
    puts W2[0..w-1].join if o%2==0
  }
  puts ""
}

Measured memory_bytes: 6120
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b) {while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b) {return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

//dp[i][j] i番目からj-1番目までの文字列とj番目からの文字列で一致する最長の長さ
int dp[5000][5000];

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  REP(i,n-1) {
    if(s[i] == s[n-1]) {
      dp[i][n-1] = 1;
    }
  }

  for (int i=n-3; i>=0; i--) {
    for (int j=n-2; j>i; j--) {
      if (s[i] == s[j]) {
        dp[i][j] = min(dp[i+1][j+1] + 1, j-i);
      }
    }
  }

  int ans = 0;
  for (int i=n-2; i>=0; i--) {
    for (int j=n-1; j>i; j--) {
      ans = max(ans, dp[i][j]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 194944
n, k = map(int, input().split())
a = list(map(int, input().split()))

visited = [0] * (n + 1)
now = 1
check = 2 * n
loop_start = 1
while check > 0:
    if visited[now - 1] == 1:
        loop_start = now
        break
    else:
        visited[now - 1] += 1
        now = a[now - 1]
        check -= 1

visited = [0] * (n + 1)
now = loop_start
check = n
loop = 0
while check > 0:
    if visited[now - 1] == 1:
        break
    else:
        visited[now - 1] += 1
        now = a[now - 1]
        check -= 1
        loop += 1

now = 1
while k > 0:
    if now == loop_start:
        k %= loop
        if k == 0:
            break
    now = a[now - 1]
    k -= 1

print(now)


Measured memory_bytes: 32408
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
signed main(){
    int p[10]={0,1,2,3,4,5,6,7,8,9};
 
    string s;cin>>s;
    int n=s.size();
    stringstream ss(s);int a;ss>>a;ss.clear();
 
    int x=0,y=101010101010101;
 
    int d=1;rep(i,n)d*=10;
    do{
        rep(i,n)ss<<p[i];
        int b;ss>>b;
        ss.clear();
        int hoge=abs(a-b);
        int piyo=min(hoge,d-hoge);
        if(x<piyo){
            x=piyo;
            y=b;
        }
        else if(x==piyo){
            chmin(y,b);
        }
    }while(next_permutation(p,p+10));
 
    ss<<y;ss>>s;
    while(s.size()<n)s="0"+s;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 68664
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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 Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int dp[1<<18][18];
int A[20];
int B[20];

int main() {
  int n;
  while(cin>>n) {
    inputs(A,n);
    inputs(B,n);
    int inf = 0x3f3f3f3f;
    memset(dp,0x3f,sizeof(dp));
    REP(i,n) {
      dp[1<<i][i] = i;
    }
    REP(S,1<<n) {
      int cnt = __builtin_popcount(S);
      REP(i,n) {
        if (dp[S][i] == inf) continue;
        int cur = 0;
        int num1 = A[i];
        if (abs(i-(cnt-1)) % 2) num1 = B[i];
        // cout << tpl(dp[S][i], bitset<5>(S),i,cur,num1) << endl;
        REP(j,n) {
          if (S >> j & 1) continue;
          int num2 = A[j];
          if (abs(j-cnt) % 2) num2 = B[j];
          if (num1 > num2) {
            cur++;
            continue;
          }
          chmin(dp[S|1<<j][j], dp[S][i] + cur);
          cur++;
        }
      }
    }
    int ans = inf;
    REP(i,n) {
      chmin(ans, dp[(1<<n)-1][i]);
    }
    if (ans == inf) cout << -1 << endl;
    else cout << ans << endl;
  }
}


Measured memory_bytes: 18816