akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline ll in(){
    ll x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
ll ten[12],ans;
int pos;
char ch;
inline bool query(ll x){
	printf("? %lld\n",x);fflush(stdout);
	ch=getchar();while (ch!='Y'&&ch!='N') ch=getchar();
	return (ch=='Y');
}
int main()
{
	ten[0]=1ll;pos=-1;
	for (int i=1;i<=9;++i){
		ten[i]=ten[i-1]*10ll;
		if (!query(ten[i])) {pos=i;break;}
	}
	if (pos==-1){
		for (int i=1;i<=9;++i)
		if (query(ten[i]-1ll)) {pos=i-1;break;}
		if (pos==-1) pos=9;
		printf("! %lld",ten[pos]);fflush(stdout);
	}else{
		for (int i=1;i<=pos;++i){
			int l=(i==1),r=9,res=l;
			while (l<=r){
				int mid=(l+r)>>1;
				if (query((ans+1ll*mid*ten[pos-i])*10ll+ten[pos-i+1]-1ll)) res=mid,r=mid-1;
				else l=mid+1;
			}ans+=res*ten[pos-i];
		}printf("! %lld",ans);fflush(stdout);
	}return 0;
}

Measured memory_bytes: 504
#include<iostream>
using namespace std;
#include<cstring>
#include<cstdio>
#include<cstdlib>
typedef long long ll;
ll f[30000];
ll a[300];
ll w[300];
ll ans = 0;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&a[i],&w[i]);
    memset(f,0,sizeof(f));
    for(int i=0;i<n;i++){
        for(int j=m;j>=w[i];j--){
            if(f[j-w[i]]+a[i]>f[j])
                f[j] = f[j-w[i]] + a[i];
            if(f[j]<0x3f3f3f3f)
                ans = max(ans,f[j]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3460
#include<stdio.h>

int main()
{
    int H, W, n, i, j;

    for(n = 0; ; n++)
    {
        scanf("%d %d", &H, &W);

        if(H == 0 && W == 0)
        {
            break;
        }

        for(i = 1; i <= H; i++)
        {
            for(j = 1; j <= W; j++)
            {
                if(i == 1 || i == H)
                {
                    printf("#");
                }
                
                else if(j == 1 || j == W)
                {
                    printf("#");
                }

                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");

    }

    return 0;
}


Measured memory_bytes: 2040
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

int search(vector<int>& a, int n, int x)
{
	a[n] = x;
	int i = 0;
	while (a[i] != x)
	{
		i++;
	}
	return i != n;
}

int main()
{
	int n;
	cin >> n;
	vector<int> s(n + 1);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}

	int q;
	cin >> q;
	vector<int> t(n);
	for (int i = 0; i < q; i++)
	{
		cin >> t[i];
	}

	int ans = 0;
	for (int i = 0; i < q; i++)
	{
		if (search(s, n, t[i])) ans++;
	}

	cout << ans << endl;
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

int main(){
	int h,w; cin>>h>>w;
	string B[1000];
	rep(i,h) cin>>B[i];

	mint dp[1000][1000];
	dp[0][0]=1;
	rep(i,h) rep(j,w) if(B[i][j]=='.') {
		if(i<h-1 && B[i+1][j]=='.') dp[i+1][j]+=dp[i][j];
		if(j<w-1 && B[i][j+1]=='.') dp[i][j+1]+=dp[i][j];
	}
	cout<<dp[h-1][w-1]<<'\n';

	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int main() {
  int w, a, b;
  while (cin >> w >> a >> b) {
    if ((a <= b && b < a + w)
        || (a <= b + w && b + w < a + w)
        || (b <= a && a < b + w)
        || (b <= a + w && a + w < b + w)) {
      cout << 0 << endl;
      continue;
    }
    int result = 1 << 20;
    ls(result, abs(a - b));
    ls(result, abs(a - (b + w)));
    ls(result, abs((a + w) - b));
    ls(result, abs((a + w) - (b + w)));
    cout << result << endl;
  }
}


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

#define PI 3.14159265358979323846264338327950L
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll answer = 1;
    cin >> n;
    ll remainder = (ll)pow(10, 18);
    ll arr[n];
    for (int i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        if (temp == 0) {
            answer = 0;
        }
        arr[i] = temp;
    }
    if (answer != 0) {
        for (int i = 0; i < n; i++) {
            if (arr[i] > remainder) {
                answer = -1;
            } else {
                answer *= arr[i];
                remainder /= arr[i];
            }
        }
    }
    cout << answer << "\n";

    return 0;

}


/*int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        set<int> sets;
        for (int i = 0; i < n; i++) {
            int temp;
            cin >> temp;
            if (temp % 2 == 0) {
                sets.insert(temp);
            }
        }
        ll answer = 0;
        for (auto i = sets.end() - 1; i != sets.begin() - 1; --i) {
            int number = *i;
            while (number % 2 == 0) {
                if (sets.find(number) != sets.end()) {
                    sets.erase(number);
                }f
                answer++;
                number = number / 2;
            }
        }
    }*/


Measured memory_bytes: 4436
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int i;
	int A;
	vector<int> aa;
	for (i=0;i<N;i++){
		cin>>A;
		aa.push_back(A);
	}
	int aMin = 1e10;
	for (i=-100;i<=100;i++){
		int x=0;
		for (int j=0;j<N;j++){
			x += (aa[j] - i)*(aa[j] - i);
		}
		if (aMin>x){
			aMin = x;
		}
	}
	cout<<aMin<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ary = gets.strip.split.map(&:to_i)
ans = []
count = 1
ary.each.with_index(1) do |k, i|
  if i == 1
    ans << k
  else
    if k >= ans.max
      ans << k
      count += 1
    end
  end
end
puts count



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        ll N;
        cin >> N;

        vector<pll> v(N);
        rep(i, 0, N) {
                ll x, l;
                cin >> x >> l;
                v[i].first = x - l;
                v[i].second = x + l;
        }

        sort(all(v), [](auto x, auto y) { return x.second < y.second; });

        ll tmp = -inf;
        ll ans = 0;
        rep(i, 0, N) {
                if (v[i].first >= tmp) {
                        ++ans;
                        tmp = v[i].second;
                }
                
        }

        cout << ans << endl;
}


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

using namespace std;

int cnt=1;
long long now=0;
vector<long long> res(100001,0);

void solve(int pos,int sz,int d)
{
    if(pos==sz+1) res[cnt++]=now;
    else
    {
        for(int i=max(0,d-1);i<=min(9,d+1);i++)
        {
            if(cnt>100000) return;
            now=10*now+i;
            solve(pos+1,sz,i);
            now=(now-i)/10;
        }
    }
}

int main()
{
    int k;
    cin >> k;
    for(int sz=1;sz<=10;sz++)
    {
        for(int i=1;i<=9;i++)
        {
            now=i;
            solve(2,sz,i);
        }
    }
    cout << res[k] << endl;
    return 0;
}


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

int main()
{
	int x; cin >> x;
	long long ans = 0;
	ans += 1LL * 1000 * (x / 500);
	x %= 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        int N = r.i();
        ArrayList<Resto> array = new ArrayList<>();
        for(int i = 0; i < N; i++){
            String[] temp = r.ss();
            String city = temp[0];
            int p = Int(temp[1]);
            array.add(new Resto(i+1, city, p));
        }
        array.sort((x, y) -> {
            int a = x.city.compareTo(y.city);
            if(a != 0)
                return a;
            return -x.p+y.p;
        });
        for(Resto res : array)
            println(res.id);
    }
    static class Resto{
        int id;
        String city;
        int p;
        Resto(int i, String c, int pt){
            id = i;
            city = c;
            p = pt;
        }
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 27476
def read_input():
    n = int(input())
    s = input()

    return n, s

def submit():
    n, s = read_input()

    # [count(w), count(e)]
    westside_count = [0, 0]
    eastside_count = [len([c for c in s if c == 'W']), len([c for c in s if c == 'E'])]
    min_flip = n
    for i in range(n):
        leader = s[i]

        # eastsideの人数を更新
        if leader == 'W':
            eastside_count[0] -= 1
        else:
            eastside_count[1] -= 1

        # 振り返り人数を数える
        flip = westside_count[0] + eastside_count[1]
        if flip < min_flip:
            min_flip = flip

        # westsideを更新
        if leader == 'W':
            westside_count[0] += 1
        else:
            westside_count[1] += 1

    print(min_flip)

if __name__ == '__main__':
    submit()


Measured memory_bytes: 6048
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int m,n;
    int a,c;
    double b;
    int x;
    scanf("%d%d",&m,&n);
    x=n/10000;
    for(int i=0;i<=x;i++)
    {
        b=(double)(n-10000*i)/4000+(double)(i-m)/4;
        if(b-(int)b==0&&b>=0&&(i+b)<=m)
        {
            printf("%d %d %d\n",i,(int)b,(int)(m-i-b));
            return 0;
        }

    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
slime = list(input())
slime.pop(-1)
now = slime[0]
nagasa = len(slime)

for i in range(1, nagasa):
    if now == slime[i]:
        nagasa -= 1
    else:
        now = slime[i]
print(nagasa)

Measured memory_bytes: 49136
#include<stdio.h>
int main(void)
{
 int W,H,x,y,r;
 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

 if(x+r>W||x<r)
{printf("No\n");}
else if(y+r>H||y<r)
{printf("No\n");}
else
{printf("Yes\n");}






return 0;
}


Measured memory_bytes: 2612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main() 
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout); 
    ios;
    int n;
    cin>>n;
    int ar[n];
    f(i,0,n)cin>>ar[i];
    int ans=0;
	f(i,1,n-1)
    {
       int d[3];
	   d[0]=ar[i-1];d[1]=ar[i];d[2]=ar[i+1];
	   sort(d,d+3);
	   if(d[1]==ar[i]&&d[2]>ar[i])
	    ans++;	
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

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

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

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

using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;

    if (S == "BBB" || S == "AAA") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(A: int, B: int):
    answer = A * B
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # A, B = map(int, line.split())
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    answer = solve(A, B)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,k=map(int,input().split())
A=sorted(list(map(int,input().split())))
m=0
M=0
for i in range(n-k+1):
  m=m+A[i]*cmb(n-i-1,k-1,mod)
  M=M+A[-1-i]*cmb(n-i-1,k-1,mod)
print((M-m)%(10**9+7))

Measured memory_bytes: 26724
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int a=gi();
	    int b=gi();
	    int c=gi();
	    
        System.out.println(Math.min(Math.floorDiv(b, a), c));
//        if (m<=4) {
//        	System.out.print("Heisei");
//        }else {
//        	System.out.print("TBD");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35616
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
//#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 4e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
bool prime(int n) {
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios;
    string s;
    cin >> s;
    sort(all(s));
    if(s[0] != s.back()) {
        cout << "Yes";
    }
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main ()
{
	int n[4][3][10]={},v,m,i,j,k;
	cin >> m;

	for (int a = 0; a < m; a++)
		  {
		cin >> i >> j >> k >> v;
		n[i -1][j - 1][k -1] += v;
		if (n[i - 1][j - 1][k - 1] > 9)
		{
			n[i - 1][j - 1][k - 1] = 9;
		}
		  }

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				cout << " " << n[i][j][k];

			}
			cout << endl;


		}
		if (i < 3){
				cout << "####################" << endl;
			}


	}



}

Measured memory_bytes: 3068
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

from collections import defaultdict
from collections import deque
import heapq

MOD = 998244353

def DD(arg): return defaultdict(arg)

def inv(n): return pow(n, MOD-2, MOD)

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

ROOT = 3
MOD = 998244353
roots  = [pow(ROOT,(MOD-1)>>i,MOD) for i in range(24)] # 1 の 2^i 乗根
iroots = [pow(x,MOD-2,MOD) for x in roots] # 1 の 2^i 乗根の逆元
 
def untt(a,n):
    for i in range(n):
        m = 1<<(n-i-1)
        for s in range(1<<i):
            w_N = 1
            s *= m*2
            for p in range(m):
                a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m])%MOD, (a[s+p]-a[s+p+m])*w_N%MOD
                w_N = w_N*roots[n-i]%MOD

def iuntt(a,n):
    for i in range(n):
        m = 1<<i
        for s in range(1<<(n-i-1)):
            w_N = 1
            s *= m*2
            for p in range(m):
                a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m]*w_N)%MOD, (a[s+p]-a[s+p+m]*w_N)%MOD
                w_N = w_N*iroots[i+1]%MOD
            
    inv = pow((MOD+1)//2,n,MOD)
    for i in range(1<<n):
        a[i] = a[i]*inv%MOD

def convolution(a,b):
    la = len(a)
    lb = len(b)
    deg = la+lb-2
    n = deg.bit_length()
    if min(la, lb) <= 50:
        if la < lb:
            la,lb = lb,la
            a,b = b,a
        res = [0]*(la+lb-1)
        for i in range(la):
            for j in range(lb):
                res[i+j] += a[i]*b[j]
                res[i+j] %= MOD
        return res
 
    N = 1<<n
    a += [0]*(N-len(a))
    b += [0]*(N-len(b))
    untt(a,n)
    untt(b,n)
    for i in range(N):
      a[i] = a[i]*b[i]%MOD
    iuntt(a,n)
    return a[:deg+1]

N = int(input())

nokori = [1]
for n in range(1,2*N+10):
  nokori.append((nokori[-1]*(2*n-1)*(2*n)*inv(2)*inv(n))%MOD)

dic = DD(int)
for _ in range(N*2):
  dic[int(input())] += 1
A = [dic[k] for k in dic]
  
P = []
for a in A:
  temp = 1
  count = 0
  P.append([temp])
  while a >= 2:
    temp *= a*(a-1)//2
    temp %= MOD
    count += 1
    P[-1].append((temp*gyaku_kaijo(count))%MOD)
    a -= 2

Q = []
for i in range(len(P)):
  heapq.heappush(Q,(len(P[i]),i))

while len(Q)>1:
  _,p = heapq.heappop(Q)
  _,q = heapq.heappop(Q)
  temp = convolution(P[p], P[q])
  P.append(temp)
  heapq.heappush(Q,(len(temp),len(P)-1))
Q = list(P[-1])

ans = 0
M = len(Q)

def sign(x):
  if x%2: return -1
  else: return 1

for i in range(M):
  ans += sign(i) * Q[i] * nokori[N-i]
  ans %= MOD
  
print(ans)

Measured memory_bytes: 118352
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);

    if(a==b)
        printf("%d\n",c);

    else if(a==c)
        printf("%d\n",b);

    else if(c==b)
        printf("%d\n",a);



        return 0;
}


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

int main()
{
    int n, k;
    std::cin >> n >> k;
    std::vector<int> w(n);
    for (auto i = 0; i < n; ++i)
    {
        std::cin >> w[i];
    }
    int left{*std::max_element(w.begin(), w.end())};
    int right{std::accumulate(w.begin(), w.end(), 0)};
    while (left != right)
    {
        int candidate = (left + right) / 2;
        int i{}, truck_w{}, truck_num{};
        for (; i < n && w[i] <= candidate && truck_num < k; ++i)
        {
            truck_w += w[i];
            if (truck_w >= candidate)
            {
                truck_w = (truck_w == candidate) ? 0 : w[i];
                ++truck_num;
            }
        }
        if (i < n || (truck_num == k && truck_w > 0))
        {
            left = (right - left > 1) ? candidate : right;
        }
        else
        {
            right = candidate;
        }
    }
    std::cout << right << std::endl;
    return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,n;
  while(cin>>s,s!="#"){
    int i,j,k,x=0,y=0,a,b,c,d;
    bool m[10][10];
    memset(m,0,sizeof(m));
    for(i=0;i<s.size();i++){
      if(s[i]=='/') x=0,y++;
      else if(isdigit(s[i])) x+=s[i]-'0';
      else m[x++][y]=1;
    }
    cin>>a>>b>>c>>d;
    a--;b--;c--;d--;
    m[b][a]=0;m[d][c]=1;
    n="";
    for(i=0;i<y+1;i++){
      k=0;
      for(j=0;j<x;j++){
	if(m[j][i]){
	  if(k) n+=('0'+k);k=0;
	  n+="b";
	}else k++;      
      }
      if(k) n+=('0'+k);k=0;
      if(i!=y) n+="/";
    }
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 3176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    const string al = "abcdefghijklmnopqrstuvwxyz";
    int n;
    cin >> n;
    string s[n];
    rep(i, n) cin >> s[i];
    int num[n][26];
    rep(i, n)rep(j, 26) num[i][j] = 0;
    rep(i, n){
        rep(j, s[i].size()){
            num[i][s[i][j]-'a']++;
        }
    }
    int ans[26];
    rep(j, 26){
        int mn = 100000;
        rep(i, n){
            mn = min(num[i][j], mn);
        }
        ans[j] = mn;
    }
    rep(i, 26){
        rep(j, ans[i]){
            cout << al[i];
        }
    }cout << endl;
}


Measured memory_bytes: 256
// cout << "Case #" << k << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<vector<int>> gridgraph(int h, int w, vector<string> s) {
    vector<vector<int>> edge(h * w);
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(i - 1 >= 0) {
                edge[i * w + j].push_back((i - 1) * w + j);
            }
            if(i + 1 < h) {
                edge[i * w + j].push_back((i + 1) * w + j);
            }
            if(j + 1 < w) {
                edge[i * w + j].push_back(i * w + j + 1);
            }
            if(j - 1 >= 0) {
                edge[i * w + j].push_back(i * w + j - 1);
            }
        }
    }
    return edge;
}
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++) {
        cin >> a[i];
    }
    auto edge = gridgraph(h, w, a);
    queue<pair<int, int>> que;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(a[i][j] == '#') {
                que.push(make_pair(i * w + j, 0));
            }
        }
    }
    int ans = 0;
    while(!que.empty()) {
        auto now = que.front();
        que.pop();
        ans = max(ans, now.second);
        for(auto next : edge[now.first]) {
            if(a[next / w][next % w] == '.') {
                que.push(make_pair(next, now.second + 1));
                a[next / w][next % w] = '#';
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 64144
#include <bits/stdc++.h>
using namespace std;
 
#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)
#define f first
#define se second
#define M 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<long long, long long>
#define vi vector<int>
#define ll long long


int main(){
 
 ll a,b,c,k;
 cin>>a>>b>>c>>k;
 ll ans=0;
 ans+=min(a,k);
 k-=a;
 if(k>0){
	 k-=b;
 }
 if(k>0){
	 ans-=min(k,c);
 }
 cout<<ans;
} 


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int K;
    ll sum =0;
    cin>>K;
    REP(i,1,K+1){
        REP(j,1,K+1){
            REP(k,1,K+1){
                sum+=GCD(i,GCD(j,k));
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3628
m,k=map(int,input().split())
if k>=2**m:
    print(-1)
    quit()
elif m==1:
    if k==0:
        print("0 0 1 1")
    else:
        print(-1)
    quit()
a=[i for i in range(0,k)]+[i for i in range(k+1,2**m)]
print(" ".join(map(str,a[::-1]+[k]+a+[k])))

Measured memory_bytes: 94824
def main():
	A, B = [int(n) for n in input().split(" ")]
	d = B - A
	if d == 0:
		print(A)
		return 0
	if d == 1:
		print(A ^ B)
		return 0
	begin = A + A % 2
	end = B + B % 2 - 1
	pair = int((end - begin + 1) / 2)
	print((A * (A % 2)) ^ pair % 2 ^ (B * (1 - B % 2)))

main()

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

int main(){
    int a,b;
    cin >>a>>b;
    if(a<b){
        for( int i = 0;i < b; i++ )cout <<a;
    }else{
        for( int j = 0;j < a;j++ )cout <<b;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b, c, x, y;
    scanf("%d %d %d", &a, &b, &c);
    x = a - b;
    y = c - x;
    if(y>0){
        printf("%d\n", y);
    }
    else printf("0\n");

    return 0;
}


Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<string>s(n);
    for(int i=0; i<n; i++)
        cin>>s[i];
    sort(s.begin(),s.end());
    for(int i=0; i<n; i++)
        cout<<s[i];
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

MOD = pow(10, 9) + 7

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

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)

    #rint(n , k, fact[n], factinv[n-k], factinv[k])
    return fact[n] * factinv[n-k] * factinv[k] % MOD


fact, factinv = make_fact_list(n, MOD)

#max

ma = 0
mi = 0

#print(fact, factinv)


for i in range(k-1, n):
    x = a[i] * cbn(i, k-1, MOD, fact, factinv) 
    #print(i-1, k-1)
    ma += x

for i in range(0, n-k+1):
    y= a[i] * cbn(n-i-1, k-1, MOD, fact, factinv) 
    #print(y)
    mi += y

print((ma - mi) % MOD)

Measured memory_bytes: 88832
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

class mint{
public:
    ll x;
    static unsigned long long mod;
    static unsigned long long mod_plus;
    mint(){x = 0;}
    mint(ll _x) : x((_x < 0 ? ((_x += mod_plus) < 0 ? _x + mod_plus : _x) : _x)%mod){}
    /*mint& operator=(const ll &a){
        x = a;
        return *this;
    }*/

    mint operator-(){
        return x == 0 ? 0 : mod - x;
    }
    mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint operator+(const mint& a) const{
        mint res(*this);
        return res += a;
    }
    mint& operator-=(const mint& a){
        if((x -= a.x) < 0) x += mod;
        return *this;
    }
    mint operator-(const mint& a) const{
        mint res(*this);
        return res -= a;
    }
    mint& operator*=(const mint& a){
        (x *= a.x)%=mod;
        return *this;
    }
    /*mint& operator*=(const ll& a){
        mint temp(a);
        return *this *= temp;
    }*/
    mint operator*(const mint& a) const{
        mint res(*this);
        return res *= a;
    }
    /*mint operator*(const ll& a) const{
        mint res(*this);
        return res *= a;
    }*/
    mint pow(unsigned long long pw) const{
        mint res(1), comp(*this);
        while(pw){
            if(pw&1) res *= comp;
            comp *= comp;
            pw >>= 1;
        }
        return res;
    }
    //以下、modが素数のときのみ
    mint inv() const{
        mint res(*this);
        return res.pow(mod - 2);
    }
    mint& operator/=(const mint &a){
        (x *= a.inv().x)%=mod;
        return *this;
    }
    mint operator/(const mint &a) const{
        mint res(*this);
        return res /= a;
    }
};
ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
unsigned long long mint::mod = int(1e+9) + 7;
unsigned long long mint::mod_plus = (LLONG_MAX / mint::mod) * mint::mod;
typedef vector<mint> vm;

int main() {
    cin>>K>>S;
    N = K + S.size();
    mint ans = mint(26).pow(N);
    vm nCm(N - K);
    nCm[0] = 1;
    rep(i, N - K - 1){
        nCm[i+1] = nCm[i] * (N - i) / (i + 1);
    }
    mint c = mint(25).pow(K + 1);
    Rrep(i,N - K){
        ans -= nCm[i] * c;
        c *= 25;
    }
    cout<<ans<<endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  if(s == string(n, s[0])) {
    cout << (long long)n * k / 2 << '\n';
    return 0;
  }
  if (k == 1) {
    string ss = s;
    long long res = 0;
    for (int i = 1; i < n; i++) {
      if (ss[i] == ss[i - 1]) {
        ss[i] = 'X';
        res++;
      }
    }
    long long ans = res;
    res = 0;
    ss = s;
    for (int i = 0; i + 1 < n; i++) {
      if (ss[i] == ss[i + 1]) {
        ss[i] = 'X';
        res++;
      }
    }
    ans = min(ans, res);
    cout << ans << '\n';
  } else if(k == 2) {
    string ss = s + s;
    long long res = 0;
    for (int i = 1; i < n + n; i++) {
      if (ss[i] == ss[i - 1]) {
        ss[i] = 'X';
        res++;
      }
    }
    long long ans = res;
    res = 0;
    ss = s + s;
    for (int i = 0; i + 1 < n + n; i++) {
      if (ss[i] == ss[i + 1]) {
        ss[i] = 'X';
        res++;
      }
    }
    ans = min(ans, res);
    cout << ans << '\n';
  } else {
    string ss0 = s + s + s;
    string ss1 = s + s + s;
    for (int i = 1; i < n + n + n; i++) {
      if (ss0[i] == ss0[i - 1]) {
        ss0[i] = 'X';
      }
    }
    for (int i = 0; i + 1 < n + n + n; i++) {
      if (ss1[i] == ss1[i + 1]) {
        ss1[i] = 'X';
      }
    }
    long long cnt0 = 0, cnt1 = 0;
    for (int i = n; i < n + n; i++) {
      cnt0 += (ss0[i] == 'X');
      cnt1 += (ss1[i] == 'X');
    }
    long long res0 = 0, res1 = 0;
    string ss = s + s + s;
    for (int i = n; i < n + n; i++) {
      ss[i] = ss0[i];
    }
    for (int i = n - 1; i >= 0; i--) {
      if(ss[i] == ss[i + 1]) {
        ss[i] = 'X';
        res0++;
      }
    }
    for (int i = n + n; i < n + n + n; i++) {
      if(ss[i] == ss[i - 1]) {
        ss[i] = 'X';
        res0++;
      }
    }
    ss = s + s + s;
    for (int i = n; i < n + n; i++) {
      ss[i] = ss1[i];
    }
    for (int i = n - 1; i >= 0; i--) {
      if(ss[i] == ss[i + 1]) {
        ss[i] = 'X';
        res1++;
      }
    }
    for (int i = n + n; i < n + n + n; i++) {
      if(ss[i] == ss[i - 1]) {
        ss[i] = 'X';
        res1++;
      }
    }
    long long ans = min(cnt0 * (k - 2) + res0, cnt1 * (k - 2) + res1);
    cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[4]={0,-1,0,1};
int ny[4]={-1,0,1,0};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

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

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

typedef long long ll;

int a[200010];
int pos[40], ppos[40];

int main() {
	int i, j, n;
	cin >> n;
	ll ans = 0;
	for(i = 1; i <= n; ++i) {
		cin >> a[i];
		int k = 0;
		for(j = 0; j < 20; ++j) {
			if(a[i]&(1<<j))
				k = max(k, pos[j]);
			else
				k = max(k, ppos[j]);
		}
		ans += i - k;
		for(j = 0; j < 20; ++j) {
			if(a[i]&(1<<j)) {
				ppos[j] = pos[j];
				pos[j] = i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  int n, q;
  string s;
  vector<int> kq;
  cin >> n;
  cin >> s;
  cin >> q;
  kq.resize(q);
  for (int i = 0; i < q; i++) {
    cin >> kq[i];
  }
  
  for (int i = 0; i < q; i++) {
    ll cnt = 0;
    ll cnt_d = 0;
    ll cnt_m = 0;
    ll cnt_dm = 0;
    for (int j = 0; j < n; j++) {
      if (s[j] == 'D') {
        cnt_d++;
      } else if (s[j] == 'M') {
        cnt_m++;
        cnt_dm += cnt_d;
      } else if (s[j] == 'C') {
        cnt += cnt_dm; 
      }
      if (j >= kq[i] - 1) {
        if (s[j - kq[i] + 1] == 'D') {
          cnt_dm = cnt_dm - cnt_m;
          cnt_d--;
        } else if (s[j - kq[i] + 1] == 'M') {
          cnt_m--; 
        }
      }
    }
    cout << cnt << endl;
  }
  
 	return 0; 
}


Measured memory_bytes: 1912
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, vector<long long> t, vector<long long> x, vector<long long> y){
    long long dist = abs(0 - x[0]) + abs(0-y[0]);
    long long time = t[0] - 0;
    for (int i = 0; i < N-1; i++) {
        if (dist <= time && (dist-time)%2 == 0) {
            dist = abs(x[i] - x[i+1]) + abs(y[i] - y[i+1]);
            time = t[i+1] - t[i];
        } else {
            std::cout << "No" << std::endl;
            return;
        }
    }
    if (dist <= time && (dist-time)%2 == 0) {
        std::cout << "Yes" << std::endl;
        return;
    } else {
        std::cout << "No" << std::endl;
        return;
    }
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> x(N-1+1);
    vector<long long> y(N-1+1);
    vector<long long> t(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&t[i]);
    	scanf("%lld",&x[i]);
    	scanf("%lld",&y[i]);
    }
    solve(N, t, x, y);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

int main() {
    string s; cin >>s;
    int c0 = 0, c1 = 0;
    for (auto c:s) {if (c=='0') {c0++;}else{c1++;}}
    cout << min(c0,c1)*2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <map>
#include <iterator>
#define LL long long
#define For(x) for (int i=1;i<=n;++i)
#define rep(i,x) for (int i=1;i<=x;++i)
#define repp(i,x,y) for (int i=x;i<=y;++i) 
#define F(x) for (int i=head[x];i;i=b[i].next)
#define mk(x,y) make_pair(x,y)
#define ft first
#define sd second
#define _ b[i].v;
#define mod  998244353
const int maxn=2e2+10;
using namespace std;

int n,x[maxn],y[maxn];
LL tmp1,tmp2,tmp,ans;
map <pair<LL,LL>,int> a;

LL qsm(LL a,LL b)
{
	LL tmp=1;
	while (b)
	{
		if (b&1) tmp=(tmp*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return tmp;
}

int main()
{
	scanf("%d",&n);
	ans=(qsm(2,n)-n-1+mod)%mod;
	For (n) scanf("%d%d",&x[i],&y[i]);
	For (n)
	{
		a.clear();
		repp(j,i+1,n)
		{
			tmp1=y[i]-y[j];
			tmp2=x[i]-x[j];
			tmp=__gcd(tmp1,tmp2);
			tmp1/=tmp;
			tmp2/=tmp;
			++a[mk(tmp1,tmp2)];
		}
		for (map <pair<LL,LL>,int>::iterator k=a.begin();k!=a.end();++k)
		  ans=(ans-qsm(2,k->sd)+1+mod)%mod;
	}
	return 0*printf("%lld",ans);
}

Measured memory_bytes: 256
import sys
#sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

queries = [0 for _ in range(n)]
for _ in range(q):
	p, x = map(int, input().split())
	queries[p-1] += x

ans = [0 for _ in range(n)]

st = [(0, 0, -1)]
while st:
	l = st.pop()
	ans[l[0]] = l[1] + queries[l[0]]
	for v in adj[l[0]]:
		if v != l[2]:
			st.append((v, ans[l[0]], l[0]))

print(*ans)

Measured memory_bytes: 64980
#include "bits/stdc++.h"
 
using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;
 
#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()
 
int main()
{
	double r;
	cin >> r;
	cout << 2 * r * 3.141592;
}

Measured memory_bytes: 3788
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val S = sc.nextLine()
    val week = Seq("SUN","MON","TUE","WED","THU","FRI","SAT").zipWithIndex.toMap
    println(7 - week(S))
  }

}

Measured memory_bytes: 25660
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_ints
X = get_ints

ans = 10**9
1.step(100) do |i|
  sum = 0
  X.each do |x|
    sum += (x - i) ** 2
  end
  ans = sum if sum < ans
end

puts ans


Measured memory_bytes: 14316
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int a,b;
  cin >> a >>b;
  if(a+b > 9) {
    cout <<"error";
  } else {
    cout <<a+b;
  }
}

Measured memory_bytes: 256
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w, :x, :y, :s ,:t, :k

  def initialize
    @n = gets.to_s.to_i
  end

  def solve
    ans = 1000
    1.upto(n-1) do |a|
      b = n - a
      cnt = calc(a,b)
      ans = cnt if cnt < ans
    end
    ans
  end

  def calc(a,b)
    a.digits.sum + b.digits.sum
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 15008