akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define PI 3.141592653589793238

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

signed main() {
    SCIN(S);
    ll N = S.length();
    ll p = 0, g = 0;
    REP(i, N) if(S[i] == 'g') p++;
    if(p <= N - p)
        cout << p - (N + 1) / 2 << "\n";
    else
        cout << N / 2 - ((N + 1) / 2 - (p - N / 2)) << "\n";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n=0;
	char a[3],b[3];
	cin>>a>>b;
	for(int i=0;i<3;i++){
		if(a[i]==b[i]) n++;
	}
	cout<<n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INF = 1ll << 60;

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

int dp[3010][3010];

int main() {
  string s, t;
  cin >> s >> t;

  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j <= t.size(); j++) {
      if (s[i - 1] == t[j - 1]) chmax(dp[i][j], dp[i - 1][j - 1] + 1);
      chmax(dp[i][j], dp[i - 1][j]);
      chmax(dp[i][j], dp[i][j - 1]);
    }
  }

  string res = "";
  int i = s.size(), j = t.size();
  while (0 < i && 0 < j) {
    if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j--;
    } else {
      i--;
      j--;
      res = s[i] + res;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    char c[n];
    int sz=0;
    for(int i=0;i<n;i++){
        cin>>c[i];
        if(c[i]=='R')sz++;
    }
    int pos=0,ans=0;
    while(pos<sz){
        while(c[pos]=='R')pos++;
        if(pos>=sz)break;
        pos++;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3784
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if((x+r) <= W && (x-r) >= 0 && (y+r) <= H && (y-r) >= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26388
#include<iostream>
#include<string>
using namespace std;
int main() {
  string a,b,c="",res;
  int n,l=0,d=0,carry=0;
  bool flag;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;

    if(a.length() > 80 || b.length() > 80) {
      cout<<"overflow"<<"\n";
      goto NEXT;
    }

    l = min(a.length(),b.length());
    flag = a.length() > b.length();
    d=0;
    carry=0;

    for(int i=0; i<l; i++){
      d = a.at(a.length()-i-1) + b.at(b.length()-i-1) - 96 + carry;
      carry=0;
      if(d>9) {
	carry = d/10;
	d %= 10;
      }
      c+=string( 1, d+48 );
    }

    if(flag){
      for(int i=l;i<a.length(); i++){
	d = a.at(a.length()-i-1) -48 + carry;
	carry=0;
	if(d>9){
	  carry = d/10;
	  d %= 10;
	}
	c+= string( 1, d+48 );
      }
    } else {
      for(int i=l;i<b.length(); i++){
	d = b.at(b.length()-i-1) -48 + carry;
	carry=0;
	if(d>9){
	  carry = d/10;
	  d %= 10;
	}
	c+= string( 1, d+48 );
      }
    }

    if(carry) c+= string ( 1, '1' );

    res = string(c.rbegin(),c.rend());

    if(res.length() >80) {
      cout<<"overflow"<<endl;
      goto NEXT;
    }

    cout<<res<<endl;

  NEXT:
    res="";
    c="";
  }
}

Measured memory_bytes: 0
lis = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
N = int(input())
for l in range(N):
    a,b,c,d,=map(int,input().split())
    lis[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" "+str(lis[i][j][k]),end="")
        print()
    if i<3:
        print("#"*20)


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
int n, a[101];
long long ans;
void dfs(int x) {
	if (x == n + 1) {
		long long s = 0;
		for (int i = 1; i <= n; i++) {
			s += a[i];
		}
		ans = max(ans, s);
		return;
	}
	if (a[x] < 0) {
		int b[101] = {0};
		for (int i = 1; i <= n; i++) {
			b[i] = a[i];
		}
		for (int i = x; i <= n; i += x) {
			a[i] = 0;
		}
		dfs(x + 1);
		for (int i = 1; i <= n; i++) {
			a[i] = b[i];
		}
	}
	dfs(x + 1);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = n; i > n / 2; i--) {
		long long s = 0;
		for (int j = i; j <= n; j += i) {
			s += a[j];
		}
		if (s > 0) {
			continue;
		}
		for (int j = i; j <= n; j += i) {
			a[j] = 0;
		}
	}
	dfs(1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BShiritori {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    string s;
	    char before;
	    bool res = true;
	    map<string, int> mp;
	    for(int i=0; i<n; i++){
            in >> s;
            if(i == 0){
                mp[s] = 1;
                before = s[s.length()-1];
                continue;
            }
            if(before != s[0] || mp[s]){
                res = false;
                break;
            }
            mp[s] = 1;
            before = s[s.length()-1];
	    }
	    ans(res, out);
	}
};


int main() {
	BShiritori solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int ctoi(char c){
    if(c=='0'){
        return 0;
    }
    else if(c=='1'){
        return 1;
    }
    else if(c=='2'){
        return 2;
    }
    else if(c=='3'){
        return 3;
    }
    else if(c=='4'){
        return 4;
    }
    else if(c=='5'){
        return 5;
    }
    else if(c=='6'){
        return 6;
    }
    else if(c=='7'){
        return 7;
    }
    else if(c=='8'){
        return 8;
    }
    else{
        return 9;
    }
}

int main() {
    string S;
    cin>>S;
    int64_t result=0;
    for (int tmp = 0; tmp < (1 << (S.size()-1)); tmp++) {
        bitset<10> plus(tmp);
        int64_t num=0,sum=0;
        for(int i=0;i<S.size();i++){
            if(plus.test(i)){
                num*=10;
                num+=ctoi(S.at(i));
                sum+=num;
                num=0;
            }
            else{
                num*=10;
                num+=ctoi(S.at(i));
            }
            if(i==S.size()-1){
                sum+=num;
            }
        }
        result+=sum;
    }
    cout<<result<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{   
    int n;
    cin>>n;
    ll cure=0;
    vector<int>d(n);
    rep(i,n){
        cin>>d[i];
    }
    rep(i,n){
        FOR(j,i+1,n){
            cure+=d[i]*d[j];
        }
    }
    cout<<cure<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#define M_PI 3.14159265358979323846

using namespace std;

typedef struct location {
        double x, y;
        int deg;

        location():
                x(0.0), y(0.0), deg(0)
                {
                }
} location;

int main()
{
        location loc;
        int d, a;

        while (true) {
                scanf("%d,%d", &d, &a);
                if (d == 0 && a == 0)
                        break;
                loc.x += d * sin(loc.deg * M_PI / 180);
                loc.y += d * cos(loc.deg * M_PI / 180);
                loc.deg += a;
        }
        cout << static_cast<int>(loc.x) << endl;
        cout << static_cast<int>(loc.y) << endl;

        return 0;
}

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

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int n, m, c, s, g;
vector< vector< int > > cost;

int main() {

    while(cin >> n >> m >> c >> s >> g, n) {
        int mindis[20][101][101], mincost[101][101];
        fill_n(**mindis, 20 * 101 * 101, INF);
        fill_n(*mincost, 101 * 101, INF);
        for(int i = 0; i < c; i++)
            for(int j = 1; j <= n; j++)
                mindis[i][j][j] = mincost[j][j] = 0;

        for(int i = 0; i < m; i++) {
            int x, y, d, c1; cin >> x >> y >> d >> c1;
            c1--;
            mindis[c1][x][y] = mindis[c1][y][x] = min(d, mindis[c1][y][x]);
        }
        vector< int > p(c);
        for(int i = 0; i < c; i++) cin >> p[i];

        for(int i = 0; i < c; i++) {
            cost.resize(c, vector< int >(200 * 100 + 1, 0));
            vector< int > q(p[i]);
            for(int j = 0; j < p[i] - 1; j++) cin >> q[j];
            q[p[i] - 1] = 200 * 100;
            int prev = 1;
            for(int j = 0; j < p[i]; j++) {
                int r; cin >> r;
                for(int k = prev; k <= q[j]; k++) {
                    cost[i][k] = cost[i][k - 1] + r;
                }
                prev = q[j] + 1;
            }
        }

        for(int l = 0; l < c; l++)
            for(int k = 1; k <= n; k++)
                for(int i = 1; i <= n; i++)
                    for(int j = 1; j <= n; j++)
                        mindis[l][i][j] = min(mindis[l][i][j], mindis[l][i][k] + mindis[l][k][j]);

        for(int j = 1; j <= n; j++)
            for(int k = 1; k <= n; k++)
                for(int l = 0; l < c; l++)
                    if(mindis[l][j][k] != INF)
                        mincost[j][k] = min(mincost[j][k], cost[l][mindis[l][j][k]]);

        for(int k = 1; k <= n; k++)
            for(int i = 1; i <= n; i++)
                for(int j = 1; j <= n; j++)
                    mincost[i][j] = min(mincost[i][j], mincost[i][k] + mincost[k][j]);

        if(mincost[s][g] != INF) cout << mincost[s][g] << endl;
        else cout << -1 << endl;
    }
}

Measured memory_bytes: 4436
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a, b := nextInt(), nextInt()

	sum := 0

	for i := 0; i < 2; i++ {
		if a > b {
			sum += a
			a--
		} else {
			sum += b
			b--
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vec d(n);
  loop(i,n)cin>>d[i];
  ll m;
  cin>>m;
  vec t(m);
  loop(i,m)cin>>t[i];
  sort(all(d));
  sort(all(t));
  bool check=true;
  ll now=0;
  loop(i,m){
    while(t[i]!=d[now]){
      now++;
      if(now==n){
        check=false;
        goto end;
      }
    }
    now++;
  }
  end:
  if(check)putout("YES");
  else putout("NO");
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> L(3);
    cin >> L[0] >> L[1] >> L[2];
    vector<int> l(N);
    for(int i=0; i<N; i++) {
        cin >> l[i];
    }

    int ans = numeric_limits<int>::max();
    for(int bit=0; bit<(1<<2*N); bit++) {
        int cost = 0;
        vector< vector<int> > list(4);
        for(int i=0; i<N; i++) {
            list[bit>>2*i & 3].push_back(l[i]);
        }
        if(list[0].empty() || list[1].empty() || list[2].empty()) continue;
        for(int j=0; j<3; j++) {
            cost += 10 * (list[j].size() - 1);
            cost += abs(L[j] - accumulate(list[j].begin(), list[j].end(), 0));
        }
        ans = min(ans, cost);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
n = 4

def f(S, n):
    for i in range( 1 << n-1 ):
        cand_str = ""
        cand_str += S[0]

        # loop for 0th, 1th, ..., n-2th digits
        for j in range(n-1):

            # get n-2th bit when j=0 
            t = i & (1 << n-2-j)
            if t:
                cand_str += "+"
            else:
                cand_str += "-"
            cand_str += S[j+1]
            
        if eval(cand_str) == 7:
            return cand_str + "=7"

print(f(S, n))
        
        
    


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
int a,b,i,c;
for(i=0;i<4;i++){
scanf("%d %d\n",&a,&b);
if(a==1){
c=6000*b;
}
else if(a==2){
c=4000*b;
}
else if(a==3){
c=3000*b;
}
else if(a==4){
c=2000*b;
}
printf("%d\n",c);
}
return 0;
}


Measured memory_bytes: 1992
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func f(x int, a []int) (int, int) {
	if len(a) == 1 {
		return a[0], a[0]
	}

	l := 0
	r := len(a) - 1
	for l+1 != r {
		m := (l + r) / 2
		if a[m] > x {
			r = m
		} else {
			l = m
		}
	}

	if x == a[l] {
		pos := max(0, l-1)
		d0 := a[l] - a[pos]
		d1 := a[r] - a[l]
		out(d0, d1)
		if d0 < d1 {
			l, r = pos, l
		}
	}
	return a[l], a[r]
}

const inf = 1001001001001

func main() {
	sc.Split(bufio.ScanWords)
	A, B, Q := getInt(), getInt(), getInt()
	s := make([]int, A)
	t := make([]int, B)
	for i := 0; i < A; i++ {
		s[i] = getInt()
	}
	for i := 0; i < B; i++ {
		t[i] = getInt()
	}

	for i := 0; i < Q; i++ {
		x := getInt()
		s0, s1 := f(x, s)
		t0, t1 := f(x, t)

		if s0 > x {
			s0, s1 = inf, s0
		} else if s1 < x {
			s0, s1 = s1, inf
		}

		if t0 > x {
			t0, t1 = inf, t0
		} else if t1 < x {
			t0, t1 = t1, inf
		}

		// out(x, "----")
		// out(s0, s1, t0, t1)
		s0 = abs(x - s0)
		s1 = abs(s1 - x)
		t0 = abs(x - t0)
		t1 = abs(t1 - x)
		// out(s0, s1, t0, t1)
		a0 := max(s0, t0)
		a1 := max(s1, t1)
		a2 := min(s0, t1)*2 + max(s0, t1)
		a3 := min(s1, t0)*2 + max(s1, t0)
		ans := min(min(a0, a1), min(a2, a3))
		out(ans)
	}
}


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

int main(){

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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}

int main(void){
    string s;
    cin>>s;
    ll k;
    cin>>k;
    --k;
    int itr;
    rep(i, s.size()){
        if(s[i]!='1') {
            itr=i;
            break;
        }
    }
    if(itr<=k){
        cout<<s[itr]<<endl;
    }
    else cout<<s[0]<<endl;
    return 0;

}

Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=1;
  string s;
  cin>>n>>s;
  char c=s[0];
  for(ll i=1;i<n;i++){
    if(c!=s[i])ans++;
    c=s[i];
  }
  cout<<ans<<endl;
}


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

using namespace std;

int main()
{
    int w, l = 0, r = 0;
    cin >> w;
    for (int i = 0; ; i++) {        
        r += pow(3, i);
        if (l <= w && w <= r) {
            w -= pow(3, i);
            r -= pow(3, i);
            cout << '+';
            for (int j = i - 1; j >= 0; j--) {
                if (r - pow(3, j) < abs(w)) {
                    if (w > 0) {
                        w -= pow(3, j);
                        cout << '+';
                    } else {
                        w += pow(3, j);
                        cout << '-';
                    }
                } else {
                    cout << 0;
                }
                r -= pow(3, j);
            }
            cout << endl;
            break;
        }
        l = r + 1;
    }    
    return 0;
}

Measured memory_bytes: 3280
n = int(input())

primes = [2]

for i in range(3, 10**5+4, 2):
    ind = 0
    while primes[ind] ** 2 <= i:
        if i % primes[ind] == 0:
            break
        ind += 1
    else:
        primes.append(i)
        
print(min([x for x in primes if x >=n]))

Measured memory_bytes: 9332
sx, sy, tx, ty = map(int,input().split())
ans = []
for i in range(tx-sx):
	ans += 'R'
for i in range(ty-sy):
	ans += 'U'
for i in range(tx-sx):
	ans += 'L'
for i in range(ty-sy+1):
	ans += 'D'
for i in range(tx-sx+1):
	ans += 'R'
for i in range(ty-sy+1):
	ans += 'U'
ans = ans + ['L' , 'U']
for i in range(tx-sx+1):
	ans += 'L'
for i in range(ty-sy+1):
	ans+= 'D'
ans += 'R'
print(''.join(ans))

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

int main(){
    int N, Y;
    cin >> N >> Y;
    int itiman = -1, gosen = -1, sen = -1;
    for(int x = 0;x <= N; x++){
        for(int y = 0;y <= N-x; y++){
            int c = N-x-y;
            int total = 10000*x + 5000*y + c*1000;
            if(Y == total){
                itiman = x;
                gosen = y;
                sen = N -x - y;
                x = 3000;
                y = 3000;
            }
        }
    }
    cout << itiman << " " << gosen << " " << sen << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>

using namespace std;

void swap(int &x,int &y){
     int temp;
     temp = x;
     x = y;
     y = temp;
     }

main(){
       int a,b,c;
       scanf("%d %d %d",&a,&b,&c);
       if(a > b)swap(a,b);
       if(a > c)swap(a,c);
       if(b > c)swap(b,c);
       printf("%d %d %d\n",a,b,c);
       return 0;
       }

Measured memory_bytes: 1188
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

def score(c) :
  if c == 'r' : return P
  if c == 's' : return R
  if c == 'p' : return S

ret = 0
for fr in range(K) :
  U = list(T[fr::K])
  s = 0
  s += score(U[0])
  for i in range(1, len(U)) :
    if U[i] == U[i-1] :
      U[i] = '#'
    else :
      s += score(U[i])
  ret += s
  
print(ret)


Measured memory_bytes: 49264
import math

MOD = 10**9 + 7

n, m = map(int, input().split())
if n == m:
    print(2 * math.factorial(n) * math.factorial(m) % MOD)
elif abs(n - m) == 1:
    print(math.factorial(n) * math.factorial(m) % MOD)
else:
    print(0)

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
int dp[100001],n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	dp[i]=i;
	for(int j=6;j<=n;j*=6)
		for(int i=j;i<=n;i++)
			dp[i]=min(dp[i],dp[i-j]+1);
	for(int j=9;j<=n;j*=9)
		for(int i=j;i<=n;i++)
			dp[i]=min(dp[i],dp[i-j]+1);
	printf("%d",dp[n]);
}

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

ll qpow(ll x, ll k)
{
    ll res = 1;
    while(k)
    {
        if(k&1) res = res*x%mod;
        x = x*x%mod;
        k /= 2;
    }
    return res;
}

int main()
{
	ll n; cin >> n;
	ll ans = qpow(10, n) - 2*qpow(9, n) + qpow(8, n);
	ans = (ans%mod+mod)%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	long long A, B, V, W, T;
	scanf("%lld %lld %lld %lld %lld", &A, &V, &B, &W, &T);
	if (V > W) {
		if (llabs(B - A) <= (V - W) * T) printf("YES");
		else printf("NO");
	} else printf("NO");
	return 0;
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
#define N 300
#define A 300
#define mod 998244353
int a[N+1],dp1[2][N*A+1],dp2[2][N*A+1],Sum[N+1];
int main(){
	int n,imp=0,power=1,i,j;scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",a+i),Sum[i]=Sum[i-1]+a[i],power=3ll*power%mod;
	dp1[0][0]=1;
	for(i=1;i<=n;i++)for(j=0;j<=Sum[i];j++)
		dp1[i&1][j]=(2*dp1[i-1&1][j]%mod+(j>=a[i]?dp1[i-1&1][j-a[i]]:0))%mod
//		,printf("dp[%d][%d]=%d\n",i,j,dp1[i&1][j])
		;
	for(i=Sum[n]+1>>1;i<=Sum[n];i++)imp+=3ll*dp1[n&1][i]%mod,imp%=mod;
	if(!(Sum[n]&1)){
		dp2[0][0]=1;
		for(i=1;i<=n;i++)for(j=0;j<=Sum[i];j++)
			dp2[i&1][j]=(dp2[i-1&1][j]+(j>=a[i]?dp2[i-1&1][j-a[i]]:0))%mod;
		imp-=3ll*dp2[n&1][Sum[n]>>1]%mod;if(imp<0)imp+=mod;
	}
	power-=imp;if(power<0)power+=mod;
	printf("%d\n",power);
	return 0;
}
/*1
4
1
1
1
2
*/
/*2
6
1
3
2
3
5
2
*/
/*3
20
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9
3
2
3
8
4
*/

Measured memory_bytes: 1664
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {
	int N;
	cin >> N;
	string s,t;
	cin >> s >> t;
	for(int i=0;i<s.size();i++){
		if(s.substr(i,s.size())==t.substr(0,t.size()-i)){
			string x = t.substr(t.size()-i,t.size());
			cout << s.size()+x.size() << endl;
			return 0;
		}
	}
	cout << s.size()+t.size() << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
typedef struct{
    string s;
    int gozen;
    int gogo;
}data;
int main(){
    data array[9];rep(i,9)cin>>array[i].s>>array[i].gozen>>array[i].gogo;
    rep(i,9)cout<<array[i].s<<" "<<array[i].gozen+array[i].gogo<<" "<<array[i].gozen*200+array[i].gogo*300<<endl;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        UL N; cin >> N;
        switch (N % 10) {
        case 3: cout << "bon" << endl; return;
        case 0:case 1:case 6:case 8: cout << "pon" << endl; return;
        default: cout << "hon" << endl;
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<stdio.h>

using namespace std;

int main(){

  int d, w, h;
  int n;
  int i;
  int tmp;
  int tmp_1, tmp_2;

  while(1){
    cin >> d >> w >> h;

    if(d==0 && w==0 & h==0)
      break;
    
    cin >> n;

    int r[n];

    if(d<=w && d<=h){
      tmp_1=d*d;
      if(w<=h){
	tmp_2=w*w;
      } else {
	tmp_2=h*h;
      }
    } else {
      tmp_1=w*w;
      tmp_2=h*h;
    }
       
    tmp=tmp_1+tmp_2;
    tmp=sqrt(tmp);
    tmp/=2;

    for(i=0;i<n;i++){
      cin >> r[i];
    }

    for(i=0;i<n;i++){
      if(r[i]>tmp){
	cout<< "OK" << endl;
      } else {
	cout<< "NA" << endl;
      }
    }
  }
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if(S.length() % 2 == 0 && S.substr(0, N/2) == S.substr(N/2, N/2)) cout << "Yes" << endl;
  else cout << "No" << endl; 
}

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

const int MOD = 1e9 + 7;
 
int main() {
 
 int n;
  cin >> n;
  vector<int> dp(n + 1, 0);
  
  dp[0] = 1;
  
  for(int s = 3; s <= n; ++s) {
	for(int i = 3; s - i >= 0; ++i) {
		dp[s] += dp[s-i];
      	dp[s] %= MOD;
    }
  }
  
  cout << dp[n] << '\n';
  return 0;
}

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

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;cin>>a>>b;
    a=gcd(a,b);
    b=1;
    for(ll i=2;i*i<=a;i++){
        if(a%i!=0)continue;
        b++;
        while(a%i==0)a/=i;
    }
    if(a!=1)b++;
    cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int len;
char str[1000];
int main(){
	scanf("%s",str+1);
	len=strlen(str+1);
	if (len%2==0) {puts("No"); return 0;}
	bool jay=true;
	for (register int i=1; i<=len; ++i)
	if (str[i]!=str[len-i+1]) {puts("No"); return 0;}
	int n=(len-1)/2;
	for (register int i=1; i<=n; ++i)
	if (str[i]!=str[n-i+1]) {puts("No"); return 0;}
	
	for (register int i=(len+3)/2; i<=len; ++i)
	if (str[i]!=str[len-i+(len+3)/2]) {puts("No"); return 0;}
	puts("Yes"); 
return 0;	
}

Measured memory_bytes: 256
#include <stdio.h>

int absi(int num) {
    return num < 0 ? -num : num;
}

int main() {
    char ans[50], i, j;
    int gakuseiX[50], gakuseiY[50], cpX, cpY, gakseiDist[50], dist, n, m;
    scanf("%d %d", &n, &m);

    for(i = 0;i < n;i++) {
        scanf("%d %d", &gakuseiX[i], &gakuseiY[i]);
        ans[i] = 0;
        gakseiDist[i] = 2000000000;
    }

    for(i = 0; i < m;i++) {
        scanf("%d %d", &cpX, &cpY);
        for(j = 0; j < n;j++) {
            dist = absi(gakuseiX[j] - cpX) + absi(gakuseiY[j] - cpY);
            if(gakseiDist[j] > dist) {
                gakseiDist[j] = dist;
                ans[j] = i + 1;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define fr(x, a) for(auto &x:a)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl
ll mx=-1e18;
ll mn=1e18;
ll M=1e9+7;

ll mod(ll x)
{
	return ((x%M+M)%M);
}

void solve()
{//cartesian set
	ll n; cin>>n;
	ll a=1,b=1,c=1;
	ff(1,n+1)
		a=mod(mod(a)*mod(10));
		
	ff(1,n+1)
		b=mod(mod(b)*mod(9));	
	b=mod(mod(b)*mod(2));
	
	ff(1,n+1)
		c=mod(mod(c)*mod(8));

	ll ans=mod(mod(a)-mod(b)+mod(c));
	cout<<ans;
}

int main()
{
	solve();
}
/*




*/


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    string s;
    cin >> s;

    if (s=="Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s=="Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else if (s=="Rainy")
    {
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
def findans(i,j,li):
    if i>=len(li) or j<0:
        return 0
    if i==j:
        dp[i][j]=li[i]
    if i+1==j:
        dp[i][j]=max(li[i],li[j])
    if dp[i][j]!=-1:
        return dp[i][j]
    ans1=li[i]+min(findans(i+2,j,li),findans(i+1,j-1,li))
    ans2=li[j]+min(findans(i,j-2,li),findans(i+1,j-1,li))
    dp[i][j]=max(ans1,ans2)
    return dp[i][j]
n=int(input())
li=[int(k) for k in input().split()]
dp=[[-1 for i in range(n)] for j in range(n)]
x=sum(li)
a=findans(0,n-1,li)
b=x-a
print(a-b)


Measured memory_bytes: 180232
from collections import Counter
mod=998244353
N=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
  print(0)
  exit()
D=Counter(d)
l=len(D)

ans=1
for i in range(l):
  if i==0:
    if D[i]!=1:
      print(0)
      exit()
  else:
    if D[i]==0:
      print(0)
      exit()
    else:
      ans=(ans*((D[i-1]**D[i])%mod))%mod
print(ans)

Measured memory_bytes: 19936
def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())
    a_list = [int(x) - 1 for x in input().rstrip().split(" ")]

    ans = 0
    likes = {i: set() for i in range(n)}
    for i, a in enumerate(a_list):
        if a in likes[i]:
            ans += 1
        likes[a].add(i)

    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 106868
using System;
using System.Linq;
using System.Collections.Generic;

namespace Miscelleneous {
   class Program {
      public static int cin() { return int.Parse(Console.ReadLine()); }
      public static void print(object s) { Console.WriteLine(s.ToString()); }
      static bool[,] Map;
      static void Main(string[] args) {
         string s;
         int x0=0, y0=0;
         bool shut;

         while (true) {
            shut=false;
            Map=new bool[8,8];
            for (int j = 0; j<8; j++) {
               s=Console.ReadLine();
               if (string.IsNullOrEmpty(s)) goto End;
               for (int i = 0; i<8; i++) {
                  Map[i,j]=s[i]=='1';
                  if (!shut&&s[i]=='1') { shut=true; x0=i; y0=j; }
               }
            }
            print(Image(x0,y0));
            Console.ReadLine();
         }
         End:
         Console.ReadLine();
      }

      static int[,,] F = { 
         { { 0,0 },{ 1,0 },{ 0,1 },{ 1,1 } } ,
         { { 0,0 },{ 0,1 },{ 0,2 },{ 0,3 } } ,
         { { 0,0 },{ 1,0 },{ 2,0 },{ 3,0 } } ,
         { { 0,0 },{ -1,1 },{ 0,1 },{ -1,2 } },
         { { 0,0 },{ 1,0 },{ 1,1 },{ 2,1 } },
         { { 0,0 },{ 0,1 },{ 1,1 },{ 1,2 } }
      };

      static char Image(int x, int y) {
         char Res;
         bool go;
         for (int g = 0; g<6; g++) {
            go=true;
            for (int j = 0; j<4; j++) {
               if (!G(x+F[g,j,0],y+F[g,j,1])) { 
                  go=false; break; 
               }
            }
            if (go) { Res=(char)(65+g); return Res; }
         }
         return 'G';
      }

      static bool G(int x, int y) {
         if (x<0||x>=8||y>=8) return false;//Heaven
         return Map[x,y];
      }

   }
}

Measured memory_bytes: 8784
n=int(input())
l=sorted(list(map(int,input().split())))
import bisect
ans=0
for i in range(n):
  for j in range(i):
    index=bisect.bisect_right(l,l[i]-l[j])#このindexよりも右側のものでかつjより左のものが当てはまるもの
    ans += max(j - index,0)
print(ans)


Measured memory_bytes: 3316
//IN THE NAME OF LORD
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int              long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi             vector<vector<int>>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             9e18
#define ALL(a)          a.begin(),a.end()
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define from(i,n)       for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)   for(int i=j;i<(int)n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
string s;
int N;
int dp[3003][3003];
int findans(int i,int small){
  if(small<0 || small>N-i-1)
    return 0;
  if(i==N-1)
    return 1;
  if(dp[i][small]!=-1)
    return dp[i][small];
  int ans = 0;
  if(s[i]=='>')
    ans = (findans(i,small-1) + findans(i+1,small-1))%mod;
  
  else
    ans = (findans(i,small+1) + findans(i+1,small))%mod;

  return dp[i][small] = ans;
}
int32_t main()
{
    c_p_c();                    
    cin>>N>>s;
    int ans = 0;
    for(int i=0;i<=N+1;i++)
      for(int j=0;j<=N+1;j++)
        dp[i][j] = (i==N-1)?1:0;

    for(int i=s.length()-1;i>=0;i--){
      int from,to,inc;
      if(s[i]=='>')
        from = 0, to = N, inc = 1;
      else
        from = N, to = -1, inc = -1;
      for(int j=from;j!=to;j+=inc){
            
            if(s[i]=='>')
              dp[i][j] = (j-1>=0?(dp[i][j-1]+dp[i+1][j-1]):0)%mod;
            else
              dp[i][j] = (j+1<N-i-1?dp[i][j+1]:0) + (j<N-i-1?dp[i+1][j]:0)%mod;
          
      }
    }


    for(int i=1;i<=N;i++){
      ans = ( ans+dp[0][i-1])%mod;
     // cout<<ans<<endl;
    }
    ans = (ans+mod)%mod;
    cout<<ans;



 cerr << "proc time: " << 1.0 * clock() / CLOCKS_PER_SEC << "s    ";
    return 0;
        
}


Measured memory_bytes: 74240
def examA():
    L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = I()

    ans = L[K-1]
    print(ans)
    return

def examB():
    H, W = LI()
    if H==1 or W==1:
        print(1)
        return
    ans = H*W//2 + (H*W)%2
    print(ans)
    return

def examC():
    a,b,c = LI()
    if c-(a+b)<=0:
        print("No")
        return
    judge = (c-a-b)**2-4*a*b
    if judge>0:
        print("Yes")
    else:
        print("No")
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 4848
import java.util.*;
 
public class Main {
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x = sc.nextInt();
    int a[] = new int[N];
    
    for(int i=0; i<N; i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int cnt = 0;
    int sum = 0;
    for(int i=0; i<N; i++){
      sum = sum + a[i];
      cnt++;
      if(sum >= x) {
        break;
      }
    }
    if(sum == x) {	    	
      System.out.println(cnt);
    }
    else if (cnt != 0) {
      System.out.println(cnt - 1);
    }else{
      System.out.println(0);
    }
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    char a[n][n], b[m][m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < m; j++){
            cin >> b[i][j];
        }
    }

    bool exist = false;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i+m-1 >= n || j+m-1 >= n) continue;

            bool match = true;
            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    if(a[i+k][j+l] != b[k][l]) match = false;
                }
            }
            if(match) exist = true;
        }
    }

    if(exist){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	int d;
	vector<int> cnt(2001);
	FOR(i, 1, n - 1) {
		FOR(j, i + 1, n) {
			ll keiyu = abs(x - i) + 1 + abs(y - j);
			d = min(j - i, keiyu);
			cnt[d]++;
		}
	}
	FOR(k, 1, n - 1) {
		pv(cnt[k])
	}
}

Measured memory_bytes: 256