akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int a,b;
    
    while(1){
        cin >> a >> b;
        if( a == 0 && b == 0 )break;
        
        if( a < b ){
            cout << a << " " << b << endl;
        } else{
            cout << b << " " << a << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2992
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const int N = 1e5 + 18;

int distance(int p1, int p2, int d) {
    if ((p1 * p1) + (p2 * p2) <= (d*d)) return true;
    return false;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {

        int n, d;
        cin >> n >> d;
        int sum(0);
        for (int i = 0; i < n; i++) {
            int p1, p2;
            cin >> p1 >> p2;
            if (distance(p1, p2, d))
                sum++;
        }
        cout << sum << endl;

    }
    return 0;

}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n, a[100005]; 
int dp[100005]; 

int func(int ind) {
	if(ind==(n-1)) return 0; 
	if(ind>=n) return INT_MAX; 

	if(dp[ind]!=-1) return dp[ind]; 
    
	int left = abs(a[ind]-a[ind+1]) + func(ind+1); 
	int right = INT_MAX; 
	if(ind+2<n) {
		right = abs(a[ind] - a[ind+2]) + func(ind+2); 
	}

	return dp[ind] = min(left, right); 
}
signed main() {
	
	cin >> n;

	memset(dp, -1, sizeof dp); 
	
	for(int i = 0;i<n;i++) {
		cin >> a[i]; 
	}

	cout << func(0); 
}

Measured memory_bytes: 4864
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pll;
typedef vector<int> vll;
typedef vector<pll> vpll;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

//

int32_t main() {
  FAST_IO;
  int a, b;
  cin >> a >> b;
  cout << (a^b);
  rtn 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;



int main() {
	long long n, x;
	long long a[105] = {};
	long long cnt = 0;

	cin >> n >> x;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	
	for (int i = 0; i < n; i++)
	{
		if (x > 0) {
			cnt++;
			x -= a[i];
		}
		else {
			break;
		}
	}

	if (x > 0 || x < 0) {
		cout << cnt - 1 << endl;
	}
	else{
		cout << cnt << endl;
	}
}

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

int main() {
  int x;
  cin >> x;
  for (int a = 1; a < 1000; ++a) {
    ll a5 = 1;
    rep(i,5) a5 *= a;
    for (int b = -1000; b < 1000; ++b) {
      ll b5 = 1;
      rep(i,5) b5 *= b;
      if (a5-b5 == x) {
        printf("%d %d\n", a, b);
        return 0;
      }
    }
  }
  return 0;
}


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

struct Item{
  int value, weight;
};

int main(){
  Item items[101];
  int i,j,n,w,dp[102][10002]; 
  cin >> n >> w;
  for( i = 0; i <= 101; i++ ){
    for( j = 0; j <= 10001; j++ ){
      dp[i][j] = 0;
    }
  }

  for( i = 1; i <= n; i++ ) cin >> items[i].value >> items[i].weight;
  
  for( i = 1; i <= n; i++ ){
    for ( j = 1; j <= w; j++ ){
      if( items[i].weight <= j ){
	if ( items[i].value + dp[i-1][j - items[i].weight] > dp[i-1][j] )
	  dp[i][j] = items[i].value + dp[i-1][j - items[i].weight];
	else dp[i][j] = dp[i-1][j];
      }else dp[i][j] = dp[i-1][j];
    }
  }
  cout << dp[n][w] << endl;

  return 0;
}

Measured memory_bytes: 5144
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PPQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define MOD 1000000007
using namespace std;
//
int main(){
  string S;
  cin>>S;
  if(S[0]=='Y'&&S[1]=='A'&&S[2]=='K'&&S[3]=='I'){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<char, int>;

vector<int> c2p[10000];
string s, t;

int main() {
    cin >> s >> t;
    int sz = s.size();
    for(int i = 0; i < sz; i++) {
        c2p[s[i]].push_back(i);
    }

    long long int cnt = 0;
    int prep = -1;
    for(auto c : t) {
        if(c2p[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }

        auto &cand = c2p[c];
        auto pos = upper_bound(cand.begin(), cand.end(), prep);
        if(pos == cand.end())  pos = cand.begin();

        if(prep >= *pos)  cnt++;
        prep = *pos;
    }
    cout << cnt*s.size() + prep + 1 << endl;
}

Measured memory_bytes: 1472
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){

  if(u==NIL||k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y!=NIL && x==y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

/*void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL) y=z;
  else y=TreeSuccessor(z);
  
  if(y->left!=NIL) x=y->left;
  else x=y->right;
  
  if(x!=NIL) x->parent=y->parent;
  
  if(y->parent==NIL) 
    
  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent = y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){

  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if (com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }
  
  return 0;
}

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

int main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n;
	double a[110];

	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	double abajo = 0;
	for (int i = 0; i < n; i++) {
		abajo += 1.0 / a[i];
	}
	double ans = 1.0 / abajo;
	printf("%0.6lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
/*For the name of God*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
const int N = 200200;
pair<int,int>c[1000001];
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b,c,sum=0;
    cin>>a>>b;
    for(int i=0; i<b; i++)
    {
        cin>>c;
        sum=sum+c;
    }
    if(sum>=a)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
a, b = map(int, input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

aa = prime_factorize(a)
bb = prime_factorize(b)

if aa == []:
  print(b)
elif bb == []:
  print(a)
else:
  outList = []
  for _ in range(len(aa)):
    
    while len(bb) >= 1 and bb[0] < aa[0]:
      outList.append(bb[0])
      bb.pop(0)
    
    if len(bb) == 0:
      break
   
    if aa[0] == bb[0]:
      outList.append(aa[0])
      aa.pop(0)
      bb.pop(0)
    elif aa[0] < bb[0]:
      outList.append(aa[0])
      aa.pop(0)
      
    if len(bb) == 0:
      break
      
  out = 1
  for i in range(len(outList)):
    out *= outList[i]
  for i in range(len(aa)):
    out *= aa[i]
  for i in range(len(bb)):
    out *= bb[i]
  print(out)
  

      


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <pair <ll, ll>> v(n, pair <ll, ll> ());
  vector <pair <ll, ll>> u(m, pair <ll, ll> ());
  rep(i, n) cin >> v.at(i).first >> v.at(i).second;
  rep(i, m) cin >> u.at(i).first >> u.at(i).second;
  rep(i, n) {
    ll min = INF, res = 0;
    rep(j, m) {
      ll tmp = abs(v.at(i).first-u.at(j).first)+abs(v.at(i).second-u.at(j).second);
      if (min > tmp) {
        chmin(min, tmp);
        res = j+1;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    H,W=map(int,readline().split())
    a=[]
    for i in range(H):
        a_i=list(map(int,readline().split()))
        a.append(a_i)

    count=0
    operation=[]
    for y in range(H):
        for x in range(W):
            if a[y][x]%2==1 and x==W-1 and y==H-1:
                pass
            elif a[y][x]%2==1 and x==W-1:
                a[y][x]-=1
                a[y+1][x]+=1
                count+=1
                operation.append([y+1,x+1,y+2,x+1])
            elif a[y][x]%2==1:
                a[y][x]-=1
                a[y][x+1]+=1
                count+=1
                operation.append([y+1,x+1,y+1,x+2])

    print(count)
    for i in range(count):
        print(*operation[i])

if __name__=="__main__":
    main()

Measured memory_bytes: 30272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i<n;i++)
using namespace std;
typedef long long ll;




int main(){
   int n;
   cin>>n;
   int k,h;
   cin>>k;
   int c=0;
   rep(i,n){
	   cin>>h;
	   if(h>=k)c++;
   }
   cout<<c<<endl;
}



Measured memory_bytes: 256
program d20829

implicit none
integer(16) :: n, max, ans, i
integer(16), allocatable :: p(:)

read *, n
allocate(p(1:n))

max = 0
ans = 0

do i = 1, n
 read *, p(i)
 if(p(i) > max) then
  max = p(i)
 end if
 ans = ans + p(i)
end do


ans = ans - int(max / 2)

print *, ans

end program d20829

Measured memory_bytes: 2712
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i+=1)
using namespace std;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int>a(N);
  rep(i,N) cin>>a[i];
  sort(a.begin( ),a.end( ));
  int count=0;
  rep(i,N) if(a[i]>=K) {
    count+=1;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long l,r,ans=2020;
    cin>>l>>r;
    if(r-l>2019)
        return cout<<"0",0;
    for(long long i=l;i<=r;i++)
        for(long long j=i+1;j<=r;j++)
            ans=min(ans,(i*j)%2019);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
#define int ll

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

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (T e : v) {
        os << e << ", ";
    }
    os << "]";
    return os;
}

int solve(const string& s, char x){
    if(count(s.begin(), s.end(), x) == 0){
        return INF;
    }
    string t = s;
    while((size_t)count(t.begin(), t.end(), x) != t.length()){
        string tt;
        tt.resize(t.length() - 1);

        for(size_t i = 0; i < tt.length(); i++){
            tt[i] = t[i];
            if(t[i+1] == x){
                tt[i] = x;
            }
        }
        t = tt;
    }
    return s.length() - t.length();
}

signed main() {
    string s;
    cin >> s;

    int ans = s.length();
    for(char c = 'a'; c <= 'z'; c++){
        ans = min(ans, solve(s, c));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    m = 10 ** 9 + 7
    x = n - k + 1
    c = [x]
    a, b = n - k, k - 1

    for i in range(2, k + 1):
        x, _ = divmod(x * a * b, (i * (i - 1)))
        c.append(x % m)
        a -= 1
        b -= 1

    print('\n'.join(map(str, c)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> va(n, 0), vb(n, 0), vc(n - 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> va[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> vb[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> vc[i];
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		res += vb[i];
		if (i + 1 < n && va[i] + 1 == va[i + 1]) {
			res += vc[va[i] - 1];
		}

	}
	cout << res << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
 ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int c;
  cin>> c;
  cout << (c==1?0:1)<< endl;






}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<ll> h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    h.at(0)--;
    int x=0;
    for(int i=1;i<n;i++){
        if(h[i]==h[i-1]){
            continue;
        }
        else if (h[i-1]<h[i]){
            h[i]--;
        }
        else{
            x=1;
            break;
        }

    }

    if(x==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1024
import math

a, b, x = (int(i) for i in input().split())
if x>=(a*a*b)/2:
    ta=(2*(a*a*b-x))/(a*a*a)
    print(math.degrees(math.atan(ta)))
else:
    ta=(2*x)/(a*b*b)
    print(90-math.degrees(math.atan(ta)))

Measured memory_bytes: 39940
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int main(){
	string s;cin>>s;
	for(int i=0;i<12;i++){
		cout<<s[i];
		if(i==3)cout<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
def max(a,b)
	if a >= b then
		return a
	else
		return b
	end
end

def min(a,b)
	if a <= b then
		return a
	else
		return b
	end
end

w,h,n = gets.split(" ").map{|v|
	v.to_i
}

xs = 0
xe = w
ys = 0
ye = h

n.times{
	x, y, a = gets.split(" ").map{|v|
		v.to_i
	}
	if (a == 1) then
		xs = max(xs, x)
	elsif (a == 2) then
		xe = min(xe, x)
	elsif (a == 3) then 
		ys = max(ys, y)
	elsif (a == 4) then
		ye = min(ye, y)
	end
}

if (xe-xs <= 0) then
	puts "0"
	exit
end
if (ye-ys <= 0) then
	puts "0"
	exit
end

puts (xe-xs)*(ye-ys)


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

x, n = map(int, input().split())
PS = list(map(int,input().split()))

for i in range(x+1):
    if i+x not in PS and x-i not in PS:
        print(min(i+x, x-i))
        break
    elif i+x not in PS:
        print(i+x)
        break
    elif x-i not in PS:
        print(x-i)
        break

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

using namespace std;
const int N=3e5+5,mod=1e9+7;
int dp[N][20];
string s;
void Add(int &ret,int x)
{
    ret+=x;
    if(ret>=mod)
        ret-=mod;
}
int solve(int idx,int r)
{
    if(idx==(int)s.size())
        return r==5;
    int &ret=dp[idx][r];
    if(~ret) return ret;
    ret=0;
    if(s[idx]!='?')
        return ret=solve(idx+1,(r*10+(s[idx]-'0'))%13);
    for(int i=0;i<10;i++)
        Add(ret,solve(idx+1,(r*10+i)%13));
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>s;
    memset(dp,-1,sizeof dp);
    cout<<solve(0,0)<<endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K, T;
  cin >> K >> T;
  int maxa = 0, suma = 0;
  vector<int> A(T);
  for (int i = 0; i < T; i++) {
    cin >> A[i];
    maxa = max(maxa, A[i]);
    suma += A[i];
  }
  cout << max(2 * maxa - suma - 1, 0) << '\n';
  return 0;
}


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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> a(n+1);
  vector<long> b(n);
  for(int i=0;i<n+1;i++) cin >> a.at(i);
  for(int i=0;i<n;i++) cin >> b.at(i);
  for(int i=0;i<n;i++) {
    if(a.at(i)<=b.at(i)){
      b.at(i)-=a.at(i);
      ans+=a.at(i);
      if(a.at(i+1)<=b.at(i)) {
        ans+=a.at(i+1);
        a.at(i+1)=0;
      } else {
        ans+=b.at(i);
        a.at(i+1)-=b.at(i);
      };
    } else {
      ans+=b.at(i);
    };
  };
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 2000
#define add(x,y) (e[++ee].nxt=lnk[x],e[lnk[x]=ee].to=y)
#define Gmax(x,y) (x<(y)&&(x=(y)))
using namespace std;
int n,ans=N*N,ee,lnk[N+5],f[N+5],g[N+5],sz[N+5];char s[N+5];struct edge {int to,nxt;}e[N<<1];
I void dfs(CI x,CI lst=0)
{
	RI i;for(f[x]=g[x]=0,sz[x]=s[x]&1,i=lnk[x];i;i=e[i].nxt) e[i].to^lst&&
		(dfs(e[i].to,x),f[x]+=f[e[i].to]+sz[e[i].to],sz[x]+=sz[e[i].to],g[x]+=g[e[i].to]+sz[e[i].to]);
	RI u,v,t=0;for(i=lnk[x];i;i=e[i].nxt) if(e[i].to^lst)
		if((u=g[e[i].to]+sz[e[i].to])>(v=f[x]-f[e[i].to]-sz[e[i].to])) return (void)(g[x]=u-v);g[x]&=1;
}
int main()
{
	RI i,x,y;for(scanf("%d%s",&n,s+1),i=1;i^n;++i) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	for(i=1;i<=n;++i) memset(f,0,sizeof(f)),memset(g,0,sizeof(g)),memset(sz,0,sizeof(sz)),
	dfs(i),!g[i]&&ans>f[i]/2&&(ans=f[i]/2);
	return ans==N*N?puts("-1"):printf("%d\n",ans),0;
}

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

int main()
{
	// 入力 
	int n;
	cin >> n;

	int result = 0;

	if (n%2 == 0) {
		result = n;
	}
	else{
		result = n * 2;
	}
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long mi = 1e9, ma = -1e9, sum = 0;
    for (int i = 0; i < n; ++i) {
        long long x;
        cin >> x;
        mi = min(x, mi);
        ma = max(x, ma);
        sum += x;
    }
    cout << mi << ' ' << ma << ' ' << sum << endl;
    return 0;
}

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

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

int main(void)
{
    ll n;
    cin>>n;
    ll ans=1;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            ans=0;
            cout<<ans<<endl;
            return 0;
        }
    }

    rep(i,n){
        if(ans>1000000000000000000/a[i]){
            ans=-1;
            break;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 4056
function main(input){

  input = input.split(' ');
  sum = parseInt(input[0])+parseInt(input[1])+parseInt(input[2]);

  if(sum>=22)
    console.log('bust');
  else if(sum<22)
    console.log('win');
  else
    console.log('error');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a % b ? 1 : 0) << endl;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  vector<string> templates = {"dream", "dreamer", "erase", "eraser"};
  for (auto &compare : templates) {
    reverse(compare.begin(), compare.end());
  }
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  const int64_t N = static_cast<int64_t>(S.length());
  int64_t pos = 0;
  bool is_okay = true;
  while (pos < N) {
    bool matched = false;
    for (const auto &compare : templates) {
      const int64_t cm_len = static_cast<int64_t>(compare.length());
      if (S.substr(pos, cm_len) == compare) {
        pos += cm_len;
        matched = true;
        break;
      }
    }
    if (!matched) {
      is_okay = false;
      break;
    }
  }
  if (is_okay) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

int n,l,r;
long long x,y;
multiset<pair<int,int>> s1,s2,s3,s4;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> l >> r;
		s1.insert({l,r});
		s2.insert({r,l});
		s3.insert({l,r});
		s4.insert({r,l});
	}
	int p=0;
	for (int i=1;i<=n;i++){
		if (i&1){
			auto it=*s2.begin();
			if (p>it.first){
				x+=p-it.first;
				p=it.first;
			}
			if (p<it.second){
				x+=it.second-p;
				p=it.second;
			}
			s2.erase(s2.find(it));
			s1.erase(s1.find({it.second,it.first}));
		}else{
			auto it2=s1.end();
			it2--;
			auto it=*it2;
			if (p<it.first){
				x+=it.first-p;
				p=it.first;
			}
			if (p>it.second){
				x+=p-it.second;
				p=it.second;
			}
			s1.erase(s1.find(it));
			s2.erase(s2.find({it.second,it.first}));
		}
	}
	x+=abs(p);
	p=0;
	for (int i=1;i<=n;i++){
		if (i&1){
			auto it2=s3.end();
			it2--;
			auto it=*it2;
			if (p<it.first){
				y+=it.first-p;
				p=it.first;
			}
			if (p>it.second){
				y+=p-it.second;
				p=it.second;
			}
			s3.erase(s3.find(it));
			s4.erase(s4.find({it.second,it.first}));
		}else{
			auto it=*s4.begin();
			if (p>it.first){
				y+=p-it.first;
				p=it.first;
			}
			if (p<it.second){
				y+=it.second-p;
				p=it.second;
			}
			s4.erase(s4.find(it));
			s3.erase(s3.find({it.second,it.first}));
		}
	}
	y+=abs(p);
	cout << max(x,y) << "\n";
}

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

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)

using ll = long long int;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VB = vector<bool>;
using VVB = vector<VB>;




int main(){
  int n, x;
  scanf("%d%d",&n,&x);
  VI A;
  A.resize(n);
  REP(i,n) scanf("%d",&A[i]);
  //~~~~~~~ get data ~~~~~~~~~~~~~~~
  long long int ans = max(A[0] - x, 0);
  A[0] -= ans;
  for(int i = 1;i < n;i++){
    int u = A[i - 1] + A[i];
    if(u > x){
      ans += u - x;
      A[i] = x - A[i - 1];
    }
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main(){
    vector<int> a(3);
    int count = 1;
    for(int i = 0;i < 3;i++)cin >> a.at(i);
    sort(a.begin(), a.end());
    for(int i = 1;i < 3;i++){
        if(a.at(i) != a.at(i - 1))count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;


int main() {

    int N;scanf("%d",&N);
    vector<int> A(N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    sort(A.begin(),A.end(),std::greater<int>());

    int alice=0;
    int bob=0;

    for(int i=0;i<N;i+=2){
        alice+=A[i];
    }
    for(int i=1;i<N;i+=2){
        bob+=A[i];
    }

    printf("%d",alice-bob);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		for(int i=X-K+1;i<X+K;i++){
			if(i>X-K+1)System.out.print(" ");
			System.out.print(i);
		}
	}
}

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

using namespace std;

int main(){

	int n, p;
	vector<int> ps;

	cin >> n;

	for(int i = 0 ; i < n; i++) {
		cin >> p;
		ps.push_back(p);
	}

	int count = 0;
	int p_min = ps[0];

	for (int pi : ps) {
		if(pi <= p_min) {
			count++;
			p_min = pi;
		} else {
			continue;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    string S,T;
    long i,j=0,l;
    
    cin>>S>>T;
    l=S.size();
    
    for(i=0;i<l;i++)
    {
        if(S[i]!=T[i])
        {
            j++;
        }
    }
    cout<<j<<endl;
  
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, k;
deque<int> d;

int main() {
	cin >> n >> k;
	inc(i, n) { int a; cin >> a; d.PB(a); }
	
	int ans = 0;
	inc1(i, k) {
		incII(L, 0, i) {
			int R = i - L;
			if(L + R > n) { continue; }
			
			vector<int> v;
			deque<int> d2 = d;
			inc(i, L) { v.PB(d2.front()); d2.pop_front(); }
			inc(i, R) { v.PB(d2.back() ); d2.pop_back() ; }
			
			sort(ALL(v));
			int sum = 0, c = L + R;
			RF(e, v) {
				if(e < 0 && c < k) { c++; } else { sum += e; }
			}
			setmax(ans, sum);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

struct UnionFind{
    int num;
    vector<int> par,rank;
    UnionFind(int n):num(n),par(n),rank(n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    int size(int x){
        return rank[root(x)];
    }
    int count(){
        return num;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N),B(N);
    vector<pair<int,int>> C(N),D(N);
    for (int i=0;i<N;++i) cin >> A[i],C[i]={A[i],i};
    for (int i=0;i<N;++i) cin >> B[i],D[i]={B[i],i};
    sort(C.begin(),C.end());
    sort(D.begin(),D.end());
    for (int i=0;i<N;++i) if (D[i].first<C[i].first){
        cout << "No" << '\n'; return 0;
    }
    for (int i=0;i<N-1;++i) if (C[i+1].first<=D[i].first){
        cout << "Yes" << '\n'; return 0;
    }
    UnionFind uf(N);
    for (int i=0;i<N;++i) uf.merge(C[i].second,D[i].second);
    cout << (uf.count()==1?"No":"Yes") << '\n';
}

Measured memory_bytes: 3328
#include<stdio.h>
int main(void)
{
  int a,b,c;
  int x=0;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  if(a==b)
    x=x+1;
  if(b==c)
    x=x+1;
  if(a==c)
    x=x+1;
  if(x==1)
    printf("Yes");
  else
    printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B > D + C)
		cout << "Left" << endl;
	else if (A + B == C + D)
		cout << "Balanced" << endl;
	else
		cout << "Right" << endl;

	return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (h, w) = (line[0], line[1]);

    if h == 1 || w == 1{
        println!("1");
        return;
    }

    let mut ans = ((h/2*2)*(w/2*2))/2;
    if w%2 != 0{
        ans += h/2;
    }

    if h%2 != 0{
        ans += (w+1)/2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
h,w = map(int, input().split())
l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(h):
  tmp = list(map(str, input().split()))
  if tmp.count('snuke') == 1:
    a = l[tmp.index('snuke')]
    b = str(i + 1)
print(a + b)

Measured memory_bytes: 3060
import sys
from math import gcd


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    a, b, k = nm()
    arr = make_divisors(gcd(a, b))
    print(arr[-k])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
#include <iostream>

namespace myspace{
	
	class vector{
	public:
		void push_back(int);
		int size();
		int &operator[](int);
		void resize(int);
		void reserve(int);
		vector();
		vector(const vector&);
		~vector();
	private:
		int s;
		int* box;
		int capa;
	};
	
	vector::vector()
	{
		box = NULL;
		s = 0;
		capa = 0;
	}
	
	vector::vector(const vector &X)
	{
		s = X.s;
		box = new int[X.s];
		for(int i=0; i<X.s; i++)box[i] = X.box[i];
	}
	
	vector::~vector()
	{
		if(box)delete[] box;
	}
	
	int &vector::operator[](int i)
	{
		return box[i];
	}
	
	int vector::size()
	{
		return s;
	}
	
	void vector::resize(int input)
	{	
		if(capa < input)reserve(input);
		s = input;
	}
	
	void vector::reserve(int input)
	{	
		if(input <= capa)return;
		
		int* box2 = box;
		box = new int[input];
		for(int i=0; i<s; i++)box[i] = box2[i];
		delete[] box2;
		capa = input;
	}
	
	void vector::push_back(int input)
	{
		if(s+1 > capa){
			reserve(s * 2);
		}
		
		resize(s+1);	
		box[s] = input;
	}
}//??????????????????myspac

using namespace myspace;
using namespace std;

void Output(vector A)
{
    int i;
    for(i=0;i<A.size()-1;i++){
        cout << A[i] << " ";
    }
    cout << A[i] << endl;
}
 
void InsertionSort(vector A,int n)
{
    for(int i=0;i<n;i++)
    {
        int v = A[i];
        int j = i - 1;
        while(j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        Output(A);
    }
}
 
int main()
{   
    int n;
    cin >> n;
     
    vector A;
	A.resize(n);
	for(int i=0;i<n;i++){
		int a;
		cin >> A[i];
	}
    InsertionSort(A, n);
     
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1LL)) / b;
}

signed main() {
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << W * (H / 2) + ((H % 2 == 1) ? intceil(W, 2) : 0);
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    a[0]--;
    REP(i,1,n) if (a[i-1] < a[i]) a[i]--;
    REP(i,1,n) if (a[i-1] > a[i]) {
        cout << "No"  << endl;
        return;
    }
    cout << "Yes" << endl;
}

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

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef long long ll;
int p[30];
void init(int N){rep(i,N) p[i]=i;}
int find(int x){
	if(p[x]==x) return x;
	return p[x]=find(p[x]);
}
void unite(int x,int y){
	x=find(x),y=find(y);
	p[x]=y;
}
ll mod=1e9+7;
int N,M,u[10];
string s;
char c[10];
int d[10]={};
bool t[10]={};
map<char,int> mp;
ll ans=0;
ll calc(){
	vector<int> vc;
	bool use[30]={};
	rep(i,10) use[i]=true;
	rep(i,N){
		if(isdigit(s[i])){
			vc.pb(s[i]-'0');
		}else{
			int id=mp[s[i]];
			if(t[id]){
				vc.pb(u[id]/10);
				vc.pb(10+id);
				use[10+id]=1;
			}else if(d[id]==2){
				vc.pb(20+id);
				vc.pb(10+id);
				use[20+id]=use[10+id]=true;
			}else{
				vc.pb(10+id);
				use[10+id]=true;
			}
		}
	}
	int sz=vc.size();
	init(30);
	rep(i,sz/2) unite(vc[i],vc[sz-1-i]);
	vector<int> l(30,0),r(30,9);
	rep(i,30){
		if(!use[i]) continue;
		int x=find(i);
		if(i<10){
			l[x]=max(l[x],i);
			r[x]=min(r[x],i);
		}else if(i<20){
			int id=i-10;
			if(t[id]){
				r[x]=min(r[x],u[id]%10);
			}else if(d[id]==2){
			}else{
				r[x]=min(r[x],u[id]);
			}
		}else{
			int id=i-20;
			if(t[id]){
			}else if(d[id]==2){
				l[x]=max(l[x],1);
				r[x]=min(r[x],u[id]/10-1);
			}else{
			}
		}
	}
	ll ret=1;
	rep(i,30){
		if(!use[i]||i!=find(i)) continue;
		if(l[i]>r[i]) return 0;
		ret*=(r[i]-l[i]+1);
		ret%=mod;
	}
	return ret;
}
int main(){
	cin>>N>>M>>s;
	rep(i,M){
		cin>>c[i]>>u[i];
		mp[c[i]]=i;
	}
	rep(i,1<<M){
		rep(j,M) d[j]=((i>>j)&1)+1;
		bool can=true;
		rep(j,M) if(d[j]==2&&u[j]<10) can=false;
		if(!can) continue;
		rep(j,1<<M){
			rep(k,M) t[k]=(j>>k)&1;
			bool can2=true;
			rep(k,M) if(t[k]&&d[k]==1) can2=false;
			if(!can2) continue;
			ans+=calc();
			if(ans>=mod) ans-=mod;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    vector<ll> p(N);
    rep (i, N) {
        cin >> p[i];
    }

    vector<double> sum(N+1);
    sum[0] = 0;
    rep (i, N) {
        sum[i+1] = sum[i]+p[i];
    }

    double ans = 0;
    for (int i = K; i <= N; i++) {
        ans = max(ans, sum[i]-sum[i-K]);
    }

    cout << fixed << setprecision(12) << (ans+K)/2.0 << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

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

  int cnt[6];
  memset(cnt,0,sizeof(cnt));

  rep(i,n){
    double x;
    cin>>x;
    if(x < 165) cnt[0]++;
    else if(x < 170) cnt[1]++;
    else if(x < 175) cnt[2]++;
    else if(x < 180) cnt[3]++;
    else if(x < 185) cnt[4]++;
    else cnt[5]++;
  }

  rep(i,6){
    cout<<i+1<<":";
    rep(j,cnt[i]){
      cout<<"*";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k; cin>>n>>k;
    int ans = 0;
    while(n){
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
 
const int mxn = 200000;
int n;
ll a[mxn];
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	ll ret = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(!i) continue;
		ret += max(0ll, a[i - 1] - a[i]);
		a[i] = max(a[i], a[i - 1]);
	}
	
	cout << ret << endl;
 
	return 0;
}

Measured memory_bytes: 5212
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define pb push_back
#define F first
#define S second

typedef long long ll;
typedef long double ld;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll n;
	cin >> n;
	if (n < 10) {
		cout << n;
		return 0;
	}
	ll x = 9;
	ll a = 10;
	while (x <= n) {
		bool flag = true;
		for (int i = 9; i >= 0; --i) {
			if (!i) {
				flag = false;
			}
			if (i * a + x <= n) {
				x += i * a;
				break;
			}
		}
		if (!flag) break;
		a *= 10;
	}
	ll cnt = 0;
	while (x) {
		cnt += x % 10;
		x /= 10;
	}
	cout << cnt;
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
int sum;
int sort(int n){
  int i;
  sum=-n;
  for(i=1;i*i<=n;i++){
    if(n%i==0){
      sum+=i+n/i;
      if(i*i==n) sum-=i;
    }
  }
  return 0;
}
      
int main(void){
  int n;
  while(scanf("%d",&n)&&n){
    sort(n);
    if(sum==n){
      printf("perfect number\n");
    }else if(sum<n){
      printf("deficient number\n");
    }else{
      printf("abundant number\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	long int t=1;
// 	cin>>t;
	while(t--)
	{
	    long long int n;
	    cin>>n;
	    long long int ans1=1,ans2=1,ans3=1,mod=1e9+7;
	    for(long int i=0;i<n;i++)
	    {
	        ans1=(ans1*10)%mod;
	        ans2=(ans2*9)%mod;
	        ans3=(ans3*8)%mod;
	    }
	    ans1=(ans1-2*ans2+ans3)%mod;
	    ans1=(ans1+mod)%mod;
	    cout<<ans1<<endl;
	}
	return 0;
}


Measured memory_bytes: 3588