akhauriyash/Code-Regression huggingface dataset:
/*input
141421 35623
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
vector<int> v[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(;k<=n+1;k++){
        ll low=(k*(k-1))/2;
        ll high=((n+(n-k+1))*(k))/2;
        //cout<<low<<' '<<high<<'\n';
        ans+=high-low+1;
        ans%=MOD;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 8336
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

typedef long long ll;
int dp[100200];
int main() {
  int N,K; cin >> N >> K;
  int h[100200];
  for ( int i = 1; i <= N; i++ ) {
    cin >> h[i];
  }

  for ( int i = 0; i <= 100150; i++ ) dp[i] = 2000000000;
  dp[1] = 0;
  for ( int i = 1; i  <= N; i++ ) {
    for ( int j = 1; j <= K && i+j <= N; j++ ) {
      dp[i+j] = min( abs(h[i+j] - h[i]) + dp[i],dp[i+j]);
    }
  }
  //  for ( int i = 1; i <= N; i++ ) cout << dp[i] << " ";
  //  cout << endl;
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1024
//
//  ALDS1_7_C.cpp
//  AizuOnlineJudge
//
//  Created by jiji on 2019/09/05.
//  Copyright © 2019 jiji4000. All rights reserved.
//

#include<iostream>

using namespace std;

// node最大量
#define MAX 100005
#define NIL -1

struct Node {
    int parent;
    int left;
    int right;
};

// 配列で保持する
Node gNode[MAX];
int n;

/**
    根→左→右の順番で出力する
*/
void preOrder(int node){
    // 根である自身を出力する
    cout << " " << node;
    // 左
    if(gNode[node].left != NIL){
        preOrder(gNode[node].left);
    }
    // 右
    if(gNode[node].right != NIL){
        preOrder(gNode[node].right);
    }
}

/**
    左部分木 → 根節点 → 右部分木の順番で節点をまわること
*/
void inOrder(int node){
    if(node == NIL){
        return;
    }
    // 左を探す
    if(gNode[node].left != NIL){
        inOrder(gNode[node].left);
    }
    // 左がなくなったら左を出力する
    cout << " " << node;
    // 右
    if(gNode[node].right != NIL){
        inOrder(gNode[node].right);
    }
}

/**
    左部分木 → 右部分木 → 根節点の順番
*/
void postOrder(int node){
    if(node == NIL){
        return;
    }
    // 左を探す
    if(gNode[node].left != NIL){
        postOrder(gNode[node].left);
    }
    // 右
    if(gNode[node].right != NIL){
        postOrder(gNode[node].right);
    }
    // 右がなくなったら右を出力する
    cout << " " << node;
}

int main(){
    int leftIndex,rightIndex,nodeIndex,node,root;
    leftIndex = rightIndex = nodeIndex = node = root = 0;
    
    cin >> n;
    // 1.初期化
    for(int i = 0;i < n;++i){
        gNode[i].parent = gNode[i].left = gNode[i].right = NIL;
    }
    // 2.nodeに代入していく
    for(int i = 0;i < n;++i){
        cin >> nodeIndex >> leftIndex >> rightIndex;
        gNode[nodeIndex].left = leftIndex;
        gNode[nodeIndex].right = rightIndex;
        
        if(leftIndex != NIL){
            gNode[leftIndex].parent = nodeIndex;
        }
        if(rightIndex != NIL){
            gNode[rightIndex].parent = nodeIndex;
        }
    }
    
    // 3.rootを探す
    for(int i = 0;i < n;++i){
        if(gNode[i].parent == NIL){
            root = i;
            break;
        }
    }

    // 木の先行巡順回
    cout << "Preorder" << endl;
    preOrder(root);
    cout << endl;
    // 木の中間巡順回
    cout << "Inorder" << endl;
    inOrder(root);
    cout << endl;
    // 木の後行巡順回
    cout << "Postorder" << endl;
    postOrder(root);
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 3096
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *
def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1/f

def solve():
    s = input().strip()
    print(s[:3])

def main():
    # n = getN()
    # for _ in range(n):
    solve()
if __name__ == "__main__":
    solve()


Measured memory_bytes: 72452
#include<bits/stdc++.h>
using namespace std;
int n,v,a[200003],b,e;
int main(){
cin>>n;
b=ceil((double)(n+1)/2);
e=(n%2==0)?(-1):(1);
for(int i=1;i<=n;i++){
cin>>v,a[b]=v;
b+=i*e;
e*=-1;}
for(int i=1;i<=n;i++)
cout<<a[i]<<" ";}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define F first
#define S second
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
int main(){
  int n, m;
  int coin[20],  dp[50001]={};
  fill(dp, dp + 50001, INF);
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> coin[ i ];
    dp[coin[ i ]] = 1;
  }
  for(int i = 1; i <= n; i++){
    for(int j = 0; j < m; j++){
      if( i  - coin[ j ]  > 0 && dp[i - coin[ j ]])
        dp[ i ] = min(dp[ i ], dp[ i - coin[ j ]] + 1);
    }
  }
  cout << dp[ n ] << endl;
  return 0;
}

Measured memory_bytes: 1364
import java.util.Scanner;

public class Main {

	static int N,T,L,B;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		for(;;){
			N=cin.nextInt();
			T=cin.nextInt();
			L=cin.nextInt();
			B=cin.nextInt();
			if(N==0)break;
			int[] a = new int[N+1];
			double[][] dp=new double[T+1][N+1];
			for(int i=0;i<L;i++){
				a[cin.nextInt()]=1;
			}
			for(int i=0;i<B;i++){
				a[cin.nextInt()]=2;
			}
			dp[0][0]=1.0;
			/*
			for(int i=0;i<T;i++){
				for(int j=0;j<N;j++){
					if(a[j]==0){
						for(int k=1;k<=6;k++){
							int next=j+k;
							if(next>N){
								next= N - (next%(N));
							}
							dp[i+1][next]+=dp[i][j]/6.0;
						}
					}
					else if(a[j]==1){
						if(i+2<=T){
							for(int k=1;k<=6;k++){
								int next=j+k;
								if(next>N){
									next= N - (next%(N));
								}
								dp[i+2][next]+=dp[i][j]/6.0;
							}							
						}
					}
					else if(a[j]==2){
						dp[i+1][0]+=dp[i][j];
					}
				}
			}*/
			for(int i=0;i<T;i++){
				for(int j=0;j<N;j++){
					double dt=dp[i][j]/6.0;
					for(int k=1;k<=6;k++){	
						int next=j+k;
						if(next>N){
							next= N - (next%(N));
						}
						if(a[next]==0){
							dp[i+1][next]+=dt;
						}
						else if(a[next]==1){
							if(i+2<=T)
								dp[i+2][next]+=dt;
						}
						else{
							dp[i+1][0]+=dt;
						}
					}
				}
			}
			for(int i=0;i<=T;i++){
				for(int j=0;j<=N;j++){
//					System.out.printf("%.4f ",dp[i][j]);
				}
//				System.out.println();
//				System.out.println();
			}
			double ans=0.0;
			for(int i=0;i<T+1;i++){
				ans+=dp[i][N];
			}
			System.out.printf("%.6f\n",ans);
			
		}
	}
}

Measured memory_bytes: 24576
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
int main() {

int N;
cin>>N;
long Answer=0;
long A;
for(int i=1;i<N+1;i++){
A=N/i;
Answer+=i*A*(A+1)/2;
}


cout<<Answer<<endl;

}

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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'r'){
      if(s.substr(i,7) == "remaerd") i+=6;
      else if(s.substr(i,6) == "resare") i+=5;
      else{
        cout << "NO" << endl;
        return 0;
      }
    }
    else if(s.substr(i,5) == "maerd" || s.substr(i,5) == "esare"){
      i+=4;
    }
    else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=1e7+10;
ll a[505][505];
int prime[maxn],isprime[maxn],tmp;
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
void init(int n){
	REP(i,2,n){
		if(!isprime[i]) prime[++tmp]=i;
		REP(j,1,tmp){
			if((ll)i*prime[j]>n) break;
			isprime[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
}
ll lcm(ll x,ll y){
	return (x/__gcd(x,y))*y;
}
int main(){
	int n=read();
	if(n==2){
		printf("4 7\n23 10\n");
		return 0;
	}
	init(1e7);
	int l=1,r=n;
	for(int i=2;i<=2*n;i+=2){
		int u;
		if(i%4) u=prime[r--];
		else u=prime[l++];
		REP(j,1,n){
			int k=i-j;
			if(k>=1 && k<=n) a[j][k]=u;
		}
	}
	l=n+1,r=n*2;
	for(int i=(n&1)?2:3;i<=2*n;i+=2){
		int u;
		if(i%4) u=prime[r--];
		else u=prime[l++];
		REP(j,1,n){
			int k=n+1+j-i;
			if(k>=1 && k<=n) a[j][k]*=u;
		}
	}
	REP(i,1,n) REP(j,1,n) if((i+j)&1){
		a[i][j]=1;
		REP(k,0,3){
			int u=i+dir[k][0],v=j+dir[k][1];
			if(u>=1 && u<=n && v>=1 && v<=n) a[i][j]=lcm(a[i][j],a[u][v]);
		}
		a[i][j]++;
	}
	REP(i,1,n) REP(j,1,n) printf("%lld%c",a[i][j],j==jend?'\n':' ');
    return 0;
}


Measured memory_bytes: 48384
#include <stdio.h>

int a[200010],n;
int bs(int k){
	if(a[0]>=k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<k)l=m;
		else r=m;
	}
	return r;
}
int bs2(int k){
	if(a[0]>k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<=k)l=m;
		else r=m;
	}
	return r;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int k;
		scanf("%d",&k);
		printf("%d %d\n",bs(k),bs2(k));
	}
}



Measured memory_bytes: 2192
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> x;
	sec("ABC", "ARC", x < 1200);
	please AC;
}

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

using namespace std;

typedef long long ll;

int getL(ll k){
	int len = 0;
	while(k){
		len++;
		k /= 10;
	}
	return len;
}

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
	ll n,ans = INT_MAX,t;
	cin >> n;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			t = max(n/i,i);
			ans = min(t,ans);
		}
	}
//	cout << ans << "\n";
	cout << getL(ans) << "\n";
    
	return 0;
}

Measured memory_bytes: 256
import queue

N, M = map(int, input().split())
AB = [[] for _ in range(M + 1)]

for n in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue
    AB[a].append(0-b)

earn = 0
q = queue.PriorityQueue()

for m in range(1, M + 1):

    for job in AB[m]:
        q.put(job)

    if not q.empty():
        earn += q.get()

print(0-earn)


Measured memory_bytes: 18496
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct ss{
  int a, b;
  bool operator<(const ss &r)const{
    return b<r.b;
  }
};

int main(){
  int n;
  cin>>n;
  ss s[n];
  bool ans=true;
  REP(i, n){
    cin>>s[i].a>>s[i].b;
  }
  sort(s, s+n);
  int t=0;
  REP(i, n){
    t+=s[i].a;
    if(t>s[i].b) ans=false;
  }

  if(ans)cout<<"Yes"<<endl;
  else ECHO("No");
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
using namespace std;
static const LL INF = 1LL<<60LL;
typedef pair<int,int> pii;

char Map[1010][1010];

LL J[1010][1010],O[1010][1010],I[1010][1010];
LL m,n,k;
LL a,b,c,d;
LL res_J,res_O,res_I;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>m>>n;
    cin>>k;
    for(int y=1;y<=m;++y){
        for(int x=1;x<=n;++x){
            cin>>Map[y][x];
            if(Map[y][x]=='J'){
                J[y][x]++;
            }
            if(Map[y][x]=='O'){
                O[y][x]++;
            }
            if(Map[y][x]=='I'){
                I[y][x]++;
            }
            J[y][x]+=J[y][x-1];
            O[y][x]+=O[y][x-1];
            I[y][x]+=I[y][x-1];
        }
    }
    for(int i=0;i<k;++i){
        cin>>a>>b>>c>>d;
        int Min=min(a,c);
        int Max=max(a,c);
        for(int y=Min;y<=Max;++y){
            res_J+=J[y][d]-J[y][b-1];
            res_O+=O[y][d]-O[y][b-1];
            res_I+=I[y][d]-I[y][b-1];
        }
        cout<<res_J<<" "<<res_O<<" "<<res_I<<endl;
        res_J=0;
        res_O=0;
        res_I=0;
    }
    return 0;
}

Measured memory_bytes: 26076
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 S, W;
  cin >> S >> W;
  if(W>=S){
    cout << "unsafe\n";
  } else {
    cout << "safe\n";
  }
}

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

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

int main(){
	int n,k,t;
	while(cin >> n >> k && n || k){
		bool flag = true;
		vector<int> blood(k);
		for(int i=0;i<k;i++){
			cin >> blood[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<k;j++){
				cin >> t ;
				blood[j]-=t;
				if(blood[j]<0)flag = false;
			}
		}
		if(flag)cout << "Yes";
		else cout << "No";
		cout << endl;
	}
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;

string s;

int n , a , b , c , d;

bool travel(int S , int T){
	for(int i = S + 1 ; i < T ; ++ i)
		if(s[i] == '#' && s[i + 1] == '#')
			return 0;
	return 1;
}

int main(){
	cin >> n >> a >> b >> c >> d;
	cin >> s;
	a --;
	b --;
	c --;
	d --;
	if(c < d){
		if(travel(a , c) && travel(b , d))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else{
		bool flag = 0;
		for(int i = max(0 , b - 1) ; i < d && i + 2 < n ; ++ i)
			if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
				flag = 1;
		if(flag && travel(a , c) && travel(b , d))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;	
	}
	return 0;
}

Measured memory_bytes: 644
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    l=list(map(int,input().split()))
    m=max(l)
    for i in range(3):
        l[i]-=m
    ans=0
    for i in range(3):
        ans+=l[i]//(-2)
        l[i]+=l[i]//(-2)*2
    if sum(l)==-2:
        ans+=1
    elif sum(l)==-1:
        ans+=2
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin>>N>>A>>B;
    vector<ll> X(N);
    rep(i,N)cin>>X[i];
    print(X);
    ll ans = 0;
    rep(i,N-1){
        ans += min(B, (X[i+1]-X[i]) * A);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
n, k = [int(i) for i in input().split(" ")]
s = input()
t = ""

for i in range(n):
    if i == k - 1:
        if s[i] == "A":
            t += "a"
        elif s[i] == "B":
            t += "b"
        else:
            t += "c"
    else:
        t += s[i]

print(t)

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

#define inf 10000000000000
#define ll long long
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int a[100005][4];
int N;
int dp[100005][4];
int solve(int day, int task){
    
    if(day == N)
        return 0;
    
    if(dp[day][task] != -1)
        return dp[day][task];

    int ans = 0;

    if(task == 0){
        ans = max(ans , a[day][1] + solve(day+1,1));
        ans = max(ans , a[day][2] + solve(day+1,2));
        ans = max(ans , a[day][3] + solve(day+1,3));
    }else if(task == 1){
        ans = max(ans , a[day][2] + solve(day+1,2));
        ans = max(ans , a[day][3] + solve(day+1,3));
        
    }else if(task == 2){
        ans = max(ans , a[day][1] + solve(day+1,1));
        ans = max(ans , a[day][3] + solve(day+1,3));
    }else if(task == 3){
        ans = max(ans , a[day][2] + solve(day+1,2));
        ans = max(ans , a[day][1] + solve(day+1,1));
    }

    return dp[day][task] = ans;
}

int main() {
    IOS;
    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif // ONLINE_JUDGE
    
    cin>>N;

    for(int i=0;i<N;i++){
        cin>>a[i][1]>>a[i][2]>>a[i][3];
    }

    memset(dp, -1, sizeof dp);
    cout<< solve(0,0);

    return 0;    
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    sort(A.rbegin(), A.rend());
    ll edge[2];
    int idx = 0;
    int a = 0;
    while(a < N-1 && idx < 2){
        if(A[a] == A[a+1]){
            edge[idx] = A[a];
            idx++;
            a+=2;
        }
        else a++;
    }
    if(idx == 2) cout << edge[0]*edge[1] << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1024
from itertools import product
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a, b, c in product(range(A+1), range(B+1), range(C+1)):
    if 500*a + 100*b + 50*c == X:
        ans += 1
print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"strings"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	a := make([]string, H)
	for i := 0; i < H; i++ {
		fmt.Scan(&a[i])
	}
	fmt.Println(strings.Repeat("#", W+2))
	for i := 0; i < H; i++ {
		fmt.Println("#" + a[i] + "#")
	}
	fmt.Println(strings.Repeat("#", W+2))
}

Measured memory_bytes: 640
#include <stdio.h>
#define N 100

int n, M[N][N];
int d[N], q[N];

void bfs(int s) {
  int u, v, i, x = 0, m = 0;
  
  for (i = 0; i < n; i++) {
    d[i] = 101;
  }
  
  q[s] = 0;
  d[s] = 0;
  
  while (x != 1) {
    u = q[m];
    
    for (v = 0; v < n; v++) {
      if (M[u][v] == 0) {
        continue;
      }
      if (d[v] != 101) {
        continue;
      }
      d[v] = d[u] + 1;
      q[++s] = v;
    }
    if (m == n - 1) {
      for (i = 0 ; i < n ; i++) {
        if (d[i] == 101) {
          d[i] = -1;
        }
      }
      x = 1;
    }
    m = m + 1;
  }
  
  for (u = 0; u < n; u++) {
    printf("%d %d\n", u + 1, d[u]);
  }
}

int main() {
  int u, v, k, i, j;
  
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }
  
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);
    u--;
    for (j = 0; j < k; j++) {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  bfs(0);
  
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
using namespace std;

vector<int> split(string s,char c){
	vector<int> v;string tmp;
	for(int i=0;i<s.size();i++){
		if(s[i]==c){
			v.push_back(stoi(tmp));
			tmp ="";
		}
		else tmp += s[i];
	}
	if(tmp!="")v.push_back(stoi(tmp));
	return v;
}

int total[26];
int main(void){
	string s,p;
	cin >> s >> p;
	int n = s.size();
	bool f = false;
	for(int i=0;i<s.size();i++){
		int cnt = 0;
		for(int j=0;j<p.size();j++){
			if(s[(i+j)%n] == p[j])cnt++;
		}
		if(cnt == p.size())f = true;
	}
	if(f)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(){
 
    string s;
    
    cin >> s;
    
  int S = s.size();
   
    for(int i = 0;i <= S - 1;i++){
    if(i%2 == 0){
    cout<<s[i];
    }
        
        
    }
    
    cout << endl;
    
    
    return 0;

}

Measured memory_bytes: 512
#A
S = input()

print("ABC" if S == 'ARC' else 'ARC')

##D
#N,K = map(int,input().split())
#A = list(map(int,input().split()))

#list = []
#list.append(1)
#last = 0
#for n in range(N):
#	inp = A[list[-1] - 1]
#	if inp in list:
#		last = inp
#		break
#	else:
#		list.append(inp)

#head = list.index(last)

#remain = (K - head) % (len(list) - head)

#print(list[head + remain])


##C
#N,M,X = map(int,input().split())
#C = []
#A = []

#for c in range(N):
#	p = list(map(int,input().split()))
#	C.append(p[0])
#	A.append(p[1:])

#minCost = sum(C)
#result = -1

#for i in range(2 ** N):
#	rikai = [0] * M
#	cost = 0
#	for n in range(N):
#		if i >> n & 1 == 0:
#			continue
#		cost+=C[n]		
#		for m in range(M):
#				rikai[m]+=A[n][m]
	
				
#	ok = True
#	if all(x >= X for x in rikai):
#		if result == -1:
#			result = cost
#		else:
#			result = min(result,cost)


#print(result)


Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    long long int H,N;
    cin >> H >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    
    long long int total = 0;
    for(int i=0;i<N;i++) total += A[i];
    if(H <= total) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.*
import java.util.*

const val MOD = 1000000007L
fun solve(H: Int, W: Int, a: Array<String>) {
    val dp = Array(H){ LongArray(W) }
    for(i in H -1 downTo 0){
        for(j in W-1 downTo 0){
            if(a[i][j] == '#') continue
            dp[i][j] = when{
                i == H - 1 && j == W - 1 -> 1
                i == H - 1 -> dp[i][j+1]
                j == W - 1 -> dp[i+1][j]
                else -> (dp[i+1][j] + dp[i][j+1]) % MOD
            }
        }
    }
    // for(i in 0 until H){
    //     for (j in 0 until W){
    //         print(dp[i][j])
    //     }
    //     println()
    // }
    println(dp[0][0])
    return
}

fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map{ it.toInt() }
    val a = Array(H){ readLine()!! }
    solve(H, W, a)
}


Measured memory_bytes: 52760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a)&-(a))
#define clean(a,b) memset(a,b,sizeof(a))
const int mod = 1e9 + 7;
const int inf=0x3f3f3f3f;
const int maxn = 1e6+9;

int _;

//========================================================================

char s[maxn];
//========================================================================

int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    int l=strlen(s);
    if(n<l) 
    {
        for(int i=0;i<n;i++)
        {
            printf("%c",s[i]);
        }
        puts("...");
    }
    else printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void solve(){
	
	string s, t;
	cin >> s;
	cin >> t;
	t.pop_back();
	
	if(s == t) cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

int main(){

	fastcin
	
	solve();
	      
	return 0;
}
	



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> d;
    for(int i=0;i<2*n;i++){
        int t;
        cin>>t;
        d.push_back(t);
    }
    sort(d.begin(),d.end());
    int ans=0;
    for(int i=0;i<d.size();i+=2){
        ans+=d[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    ll fir = 0;
    ll sec = 0;
    ll sei = 0;
    for(ll i=0;i<n-1;i++){
        if(n>=4){
            if(a[i]==a[i+1]&&a[i+1]==a[i+2]&&a[i+2]==a[i+3]){
                if(sei<a[i]){
                    sei = a[i];
                }
            }
        }
        if(a[i]==a[i+1]){
            if(fir<a[i]){
                sec = fir;
                fir = a[i];
            }else if(sec<a[i]&&fir!=a[i]){
                sec = a[i];
            }
        }
    }
    cout << max(fir*sec,sei*sei) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll k, a, b;
    cin >> k >> a >> b;
    rp(i, a, b + 1)
    {
        if (i % k == 0)
        {
            ce("OK");
            exit(0);
        }
    }
    ce("NG");
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner teclado = new Scanner(System.in);
        int n = teclado.nextInt();
        int a = teclado.nextInt();
        int b = teclado.nextInt();
        int nb = (b*1);
        int na = (n*a);
        if(na <= nb){
            System.out.println(na);
        }else{
            System.out.println(nb);
        }
            
            
    }
    
}

Measured memory_bytes: 21716
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,avx,avx2,mmx,abm")
#pragma GCC optimize("unroll-loops,inline")
#include <bits/stdc++.h>

using namespace std;

static const int buf_size = 4096;
 
static unsigned char buf[buf_size];
static int buf_len = 0, buf_pos = 0;
 
inline bool isEof() {
    if (buf_pos == buf_len) {
        buf_pos = 0;
        buf_len = fread(buf, 1, buf_size, stdin);
        if (buf_pos == buf_len)
            return 1;
    }
    return 0;
}
 
inline int getChar() {
    return isEof() ? -1 : buf[buf_pos++];
}
 
inline int peekChar() {
    return isEof() ? -1 : buf[buf_pos];
}
 
inline int readChar() {
    int c = getChar();
    while (c != -1 && c <= 32)
        c = getChar();
    return c;
}
  
template<class T = int>
inline T readInt() {
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-') {
        s = -1;
        c = getChar();
    } else if (c == '+')
        c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}

const int MOD = 998244353;
const int MAXN = 3010;
int n, s;
int a[MAXN];
int dp[MAXN];

signed main() {
	//scanf("%d%d", &n, &s);
	n = readInt();
	s = readInt();
	for (int i = 1; i <= n; i++)
		a[i] = readInt();
		//scanf("%d", &a[i]);
	int ans = 0;
	for (int i = 0; i <= s; i++)
		dp[i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int w = s - a[i]; w >= 1; w--) {
			dp[w + a[i]] += dp[w];
			dp[w + a[i]] -= MOD * (dp[w + a[i]] >= MOD);
		}
		dp[a[i]] += i;
		dp[a[i]] -= MOD * (dp[a[i]] >= MOD);
		ans += dp[s];
		ans -= MOD * (ans >= MOD);
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int A, B, k, C;

int gcd(int a, int b){
    return b==0? a:gcd(b, a%b);
}

int main(){
    scanf("%d %d %d", &A, &B, &k); C = gcd(A, B);
    int cnt = 0;
    for(int i=C;i>=1;--i) if(C%i==0){
        ++cnt; if(cnt==k){
            printf("%d\n", i); return 0;
        }
    }
    return 0;
}


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

const int mxN = 1e3 + 4, mod = 1e9 + 7;
char grid[mxN][mxN];
long long dp[mxN][mxN];
int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			cin >> grid[i][j];
	dp[1][1] = 1;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j)
			if(grid[i][j] != '#')
				dp[i][j] += (dp[i][j - 1] + dp[i - 1][j]) % mod;
	}
	cout << dp[n][m];
}


Measured memory_bytes: 9088
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int n = s.length();
        System.out.println(isPal(s) && isPal(s.substring(0, (n - 1) / 2)) && isPal(s.substring((n + 3) / 2 - 1)) ? "Yes" : "No");
        scan.close();
    }
    
    public static boolean isPal(String s){
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) != s.charAt(s.length() - i - 1)) return false;
        }
        return true;
    }
}


Measured memory_bytes: 23636
let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)
let lcm n m = n / gcd n m * m

let () = Scanf.scanf "%d %d %d %d" @@ fun a b c d ->
  Printf.printf "%d\n" @@
  b - a + 1
  - (b / c - (a - 1) / c)
  - (b / d - (a - 1) / d)
  + (b / lcm c d - (a - 1) / lcm c d)

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

using namespace std;

int p[111111];
int main() {
	int n;
	cin >> n;
	long r = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		p[i] = -a - b;
		r -= b;
	}
	sort(p, p + n);
	for (int i = 0; i < n; i += 2)
		r -= p[i];
	cout << r << endl;
	return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import heapq
import copy
from collections import defaultdict

X=[0]*3
X[0],X[1],X[2],K=map(int,input().split())
m=3

A=[[] for _ in range(m)]
for i in range(m):
    A[i]=list(map(int,input().split()))
    A[i].sort(reverse=True)
    A[i].append(-2*(10**10))



def calc_val(index):
    res=0
    for j in range(m):
        res-=A[j][index[j]]
    return res


def hash(index):
    a=[1,1001,1001**2]
    res=0
    for j in range(m):
        res+=a[j]*index[j]
    return res
    
    

q=[]
index=[0]*m
heapq.heappush(q,(calc_val(index),index))

used = defaultdict(int)

for i in range(K):
    res,index=heapq.heappop(q)
    print(-1*res)
    for j in range(m):
        new_index=copy.deepcopy(index)
        new_index[j]+=1
        if used[hash(new_index)]==0:
            heapq.heappush(q,(calc_val(new_index),new_index))
            used[hash(new_index)]=1

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

int main()
{
	int n, d;
	cin >> n >> d;

	if (n % (2 * d + 1) == 0)
	{
		cout << n / (2 * d + 1) << endl;
	}
	else
	{
		cout << n / (2 * d + 1) + 1 << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    cin >>d;
    if(d==25)
    {
        cout<<"Christmas"<<endl;
    }
    else if(d==24)
    {

        cout<<"Christmas Eve"<<endl;
    }else if(d==23)
    {

        cout<<"Christmas Eve Eve"<<endl;
    }else if(d==22)
    {

        cout<<"Christmas Eve Eve Eve"<<endl;
    }



}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

string s;
int x;

int main(){

    cin >> s;

    vector<char> v;
    vector<char> v2;

    for(int i = 0; i < s.length(); i++){
        v.push_back(s[i]);
        v2.push_back(s[i]);
    }

    reverse(v.begin(), v.end());

    for(int i = 0; i < v.size(); i++){
        if(v[i] != v2[i]){
            x++;
        }
    }

    cout << x/2;




}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

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

int max(int x, int y)
{
    return (x > y)?x:y;
}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << max(max(a+b, a-b), a*b);
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, ll> state;
typedef vector<vector<ll>> matrix;

void solve() {
  int n, x;
  cin >> n >> x;
  int ret = 1;
  int curr = 0;
  while(n--) {
    int t;
    cin >> t;
    curr += t;
    if(curr <= x) ret++;
  }
  cout << ret << "\n";
}

void casesolve() {
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(`in`: String) = solve(Scanner(`in`))


fun solve(sc: Scanner): String {
    val H = sc.nextLong()
    val W = sc.nextLong()

    if (H == 1L || W == 1L) {
        return "1"
    }
    return ((H * W + 1) / 2).toString()
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count[n + 1], result = n;
    count[0] = 0;
    for (int i = 1; i <= n; i++) {
        count[i] = count[i - 1];
        if (s[i - 1] == 'E') {
            count[i]++;
        }
    }
    for (int i = 1; i <= n; i++) {
        result = min(result, i - 1 - count[i - 1] + count[n] - count[i]);
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 1796
#include <stdio.h>

int main(){
	int i,a,b,c,d,p,x,y,result;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	x = a*p;
	if(p<c){
		y=b;
	}else{
		y=b+d*(p-c);
	}
	if(x<y){
		result=x;
	}else{
		result=y;
	}
	printf("%d\n",result);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int n, m;
	int ans = 0;

	fgets(str, 100, stdin);
	sscanf(str, "%d\n", &n);

	int i;

	for (i = 1; i <= n; i++) {
		int c = 0;
		int j;
		if (i % 2 == 0) {
			continue;
		}

		for (j = 1; j <= i; j++) {
			if (i % j == 0) {
				c++;
			}
		}

		if (c == 8) {
			ans++;
		}
	}

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

	return 0;
}


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


int main(void){
	char S[11];
	
	cin >> S;
	int flag=0;
	int result=1;
	int i=0;
	while(S[i] != NULL){
		if(i%2==0){
			if(S[i]!='h'){
				result=0;
				break;
			}else flag=1;
		}else{
			if(S[i]!='i'){
				result=0;
				break;
			}
			else flag=2;
		}

		i+=1;
	}
	if(flag!=2) result=0;
	if(result==1) cout << "Yes";
	else cout << "No";

	return 0;
}
		


Measured memory_bytes: 760
N = int(input())
Wlist = tuple(map(int,input().split()))
min_sum = 10**8
for t in range(1,N):
    s1 = sum(Wlist[:t+1])
    s2 = sum(Wlist[t+1:])
    diff = abs(s1-s2)
    min_sum = diff if diff<min_sum else min_sum
print(min_sum)

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

#define rep(i,n) for (int i=0; i<(n); i++)
#define repr(i,n) for (int i=(n)-1; i>=0; i--)

using namespace std;
using ll = long long;

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  vector<int> L(n+1,-1e9) , R(n+1,-1e9);
  rep(i,n) L[i+1] = max(L[i],a[i]);
  repr(i,n) R[i] = max(R[i+1],a[i]);
  rep(i,n){
    cout << max(L[i], R[i+1]) << '\n';
    
  }
}

Measured memory_bytes: 3968
//20
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<utility>

using namespace std;

struct B{
  int ty,by,lx,rx;
  bool clk(int y,int x){
    return ty<=y&&y<=by&&lx<=x&&x<=rx;
  }
};

int main(){
  for(int n;cin>>n,n;){
    int w,h;
    cin>>w>>h;
    map<string,vector<pair<B,string> > > m;
    int x=0;
    vector<string> buf(1);
    for(int i=0;i<n;i++){
      string s;
      int nb;
      cin>>s>>nb;
      if(i==0){
	buf[0]=s;
      }
      for(int j=0;j<nb;j++){
	int x,xx,y,yy;
	string l;
	cin>>x>>y>>xx>>yy>>l;
	B b={y,yy,x,xx};
	m[s].push_back(make_pair(b,l));
      }
    }
    int nm;
    cin>>nm;
    while(nm--){
      string op;
      cin>>op;
      if(op=="click"){
	int cx,cy;
	cin>>cx>>cy;
	int i;
	for(i=0;i<m[buf[x]].size();i++){
	  if(m[buf[x]][i].first.clk(cy,cx))break;
	}
	if(i<m[buf[x]].size()){
	  buf.erase(buf.begin()+x+1,buf.end());
	  buf.push_back(m[buf[x]][i].second);
	  x++;
	}
      }else if(op=="back"){
	if(x>0){
	  x--;
	}
      }else if(op=="forward"){
	if(x<buf.size()-1){
	  x++;
	}
      }else{
	cout<<buf[x]<<endl;
      }
    }
  }
  return 0;
}
  

Measured memory_bytes: 1260
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;


char S[100];

int i,j,k,X,N,M;

int main()
{
  cin>>X;
  
  N=X/500;
  M=(X-N*500)/5;
  
  i=1000*N+5*M;
  cout <<i;
  
  
  
  
  
}

Measured memory_bytes: 256
n,h,w = map(int,input().split())
a = []
b = []
for i in range(n):
    A,B = map(int,input().split())
    a.append(A)
    b.append(B)
ans = 0
for i in range(n):
    if a[i] >= h and b[i] >= w:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<int, int>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<29;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, H; cin >> N >> H;
  vector<int> a(N), b(N);
  rep(i, N) cin >> a[i] >> b[i];

  priority_queue<P, vector<P>, less<P>> que;
  rep(i, N){
    que.push(P(a[i], 0));
    que.push(P(b[i], 1));
  }

  int h = 0;
  int ans = 0;
  while (h < H){
    P now = que.top();
    int damage = now.first;
    int is_throw = now.second;
    h += damage;
    if (is_throw) que.pop();
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3188
using System;

    class Program
    {
        static void Main(string[] args)
        {
            // get a char
            char a = Convert.ToChar(Console.ReadLine());
            char val;
            if (a == 'A')
                val = 'T';
            else if (a == 'T')
                val = 'A';
            else if (a == 'C')
                val = 'G';
            else
                val = 'C';
            //output
            Console.WriteLine(val);
        }
    }

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int mod=1e9+7;
ll kpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	ll n,k,ans=0,cnt=0,s[maxn]={0};
	scanf("%lld%lld",&n,&k);
	for(ll i=k;i>=2;i--)
	{
		ll sum=k/i,pp=0;
		pp=kpow(sum,n);
		for(ll j=2;j<k;j++)
		{
			if(j*i>k)break;
			pp=(pp-s[i*j]+mod)%mod;
		}
		s[i]=pp;
		cnt=(cnt+pp)%mod;
		ans=(ans+pp*i)%mod;
	}
	ans=(ans+kpow(k,n)-cnt+mod)%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 4608
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
//#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const int INF = 1e9;
int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

int H, W;
int dp[303][303];
vector<int>v[2][303];
int calc(const string &S,const string &T) {
	REP(i, 2)REP(j, H)v[i][j].clear();
	REP(i, H) {
		FOR(j, i, H) {
			if (S[i] == T[j]) {
				v[0][j - i].push_back(H - i - 1);
			}
		}
	}
	REP(j, H) {
		FOR(i, j, H) {
			if (T[j] == S[i]) {
				v[1][i - j].push_back(H - j - 1);
			}
		}
	}
	REP(i, H) {
		VSORT(v[0][i]);
		VSORT(v[1][i]);
	}
	REP(i, H + 1) {
		REP(j, H + 1)dp[i][j] = INF;
	}
	dp[0][0] = 0;
	REP(i, H + 1)REP(j, H + 1) {
		if (i >= j) {
			int cnt = 0;
			int M = v[0][i - j].size();
			cnt = v[0][i - j].end() - lb(v[0][i - j], i);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt);
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt);
		}
		else {
			int cnt = 0;
			cnt = v[1][j - i].end() - lb(v[1][j - i], j);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt);
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt);
		}
	}
	return dp[H][H];
}
char C[303][303];
string S[303];
void solve() {
	cin >> H >> W;
	REP(i, H)REP(j, W) {
		cin >> C[i][j];
		S[j] += C[i][j];
	}
	int ans = 0;
	REP(j, W - 1) {
		//print(calc(S[j], S[j + 1]));
		ans += calc(S[j], S[j + 1]);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 2304
object Main extends App{
val Array(n,a,b) = scala.io.StdIn.readLine.split("\\s").map(_.toInt)

var cnt = 0
for (i<-1 to n){
  val hoge = i.toString.toList.map(_.toString.toInt).sum
//   println(i,hoge)
  if (hoge >= a && hoge <= b) cnt += i
}
println(cnt)
}

Measured memory_bytes: 36516