akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
 
 
int main(void){
	ll a,b,q;
	cin>>a>>b>>q;
	ll s[100010];
	ll t[100010];
	ll x[100010];
	s[100008] = -99999999999;
	s[100009] = 99999999999;
  	t[100008] = -99999999999;
	t[100009] = 99999999999;
	rep(i,a){
		cin>>s[i];
	}
	rep(i,b){
		cin>>t[i];
	}
	rep(i,q){
		cin>>x[i];
	}
	sort(s,s+a);
	sort(t,t+b);
	rep(i,q){
		ll point = x[i];
		ll ans = 999999999999;
		ll sb = 0;
		ll se = a-1;
		ll tb = 0;
		ll te = b-1;
		ll check;
		while(se-sb >= 2){
			check = (sb+se)/2;
			if(s[check]<=point){
				sb = check;
			}else{
				se = check;
			}
		}
		while(te-tb >= 2){
			check = (tb+te)/2;
			if(t[check]<=point){
				tb = check;
			}else{
				te = check;
			}
		}
		if(s[sb] > point){
			se=sb;
			sb = 100008;
		}
		if(s[se] < point){
			sb = se;
			se = 100009;
		}
		if(t[tb] > point){
			te=tb;
			tb = 100008;
		}
		if(t[te] < point){
			tb = te;
			te = 100009;
		}

		ans = min(ans,max(point-s[sb],point-t[tb]));
  
		ans = min(ans,max(s[se]-point,t[te]-point));
   
		ans = min(ans,min((point-s[sb])*2+t[te]-point,point-s[sb]+(t[te]-point)*2));

      ans = min(ans,min((point-t[tb])*2+s[se]-point,(point-t[tb])+(s[se]-point)*2));
		cout<<ans<<endl;
	}
 
	return 0;
}

Measured memory_bytes: 3712
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int P, Q, R;
	cin >> P >> Q >> R;
	int res = P + Q + R;
	if (P > Q && P > R)res -= P;
	else if (Q > R)res -= Q;
	else res -= R;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

import static java.lang.Integer.parseInt;

/**
 * Elementary data structures - Queue
 */
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br_que = new BufferedReader(new InputStreamReader(System.in));
        String line;
        
        //read
        line = br_que.readLine();
        int n = parseInt(line.substring(0, line.indexOf(' ')));
        int q = parseInt(line.substring(line.indexOf(' ') + 1));
        Deque<Process> queue = new ArrayDeque<>();
        
        for(int i = 0; i < n; i++) {
            line        = br_que.readLine();
            String name = line.substring(0, line.indexOf(' '));
            int time    = parseInt(line.substring(line.indexOf(' ') + 1));
            
            //スーパーインターフェイスQueueのofferメソッドを使う
            queue.offer(new Process(name, time));
        }
        
        //solve
        int elapse = 0;
        StringBuilder sb = new StringBuilder();
        while(!queue.isEmpty()) {
            Process p = queue.poll();
            if(p.time <= q) {
                elapse += p.time;
                sb.append(p.name + " " + elapse + "\n");
            } else {
                p.time -= q;
                elapse += q;
                queue.offer(p);
            }
        }
        System.out.print(sb);
    }
}

class Process {
    String name;
    int time;
    
    Process(String name, int time) {
        this.name = name;
        this.time = time;
    }
}
 


Measured memory_bytes: 52680
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  string s;
  cin >> n >> s;
  long e = 0;
  long w = 0;
  long rev;
  rep(i,n){
    if(s.at(i) == 'E') e++;
    if(s.at(i) == 'W') w++;
  }
  long mini = 1e6;
  rev = e;
  bool west = false;
  rep(i,n){
    if(west){
      rev++;
      west = false;
    }
    if(s.at(i) == 'W'){
      west = true;
    }
    if(s.at(i) == 'E'){
      rev--;
    }
    mini = min(rev,mini);
  }
  cout << mini << endl;
}


Measured memory_bytes: 900
import sys
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
X = [i for i in range(N)]

def par(i):
    if X[i] == i:
        return i
    tmp = par(X[i])
    X[i] = tmp
    return tmp
    
ans = N
for _ in range(M):
    x, y, z = map(int, input().split())
    
    px = par(x-1)
    py = par(y-1)
    if px != py:
        ans -= 1
        X[py] = px

print(ans)

Measured memory_bytes: 7088
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b||b==c||c==a)&&!(a==b&&b==c))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <regex>
#include <algorithm>
#include <map>
#include <typeinfo>
#include <cstdlib>

int main(void)
{
  /* declaration */
  std::string input;
  std::regex sep(" ");
  std::vector<std::string> svec;
  std::vector<int> ivec;
  int sum=0;

  /* input */
  std::getline(std::cin >> std::ws, input);
  auto ite = std::sregex_token_iterator(input.begin(), input.end(), sep, -1);
  auto end = std::sregex_token_iterator();

  /* separate string and convert to integer */
  while(ite != end)
    svec.push_back(*ite++);
  for(int i=0; i<svec.size(); i++)
    ivec.push_back(std::stoi(svec[i]));

  /* calculate problem */
  int a=ivec[0];
  int b=ivec[1];

  /* print */
  if((a*b)%2==0){
    std::cout << "No" << std::endl;
  }else{
    std::cout << "Yes" << std::endl;
  }

  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int a[5];
  scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
  sort(a, a+5);
  printf("%d %d %d %d %d\n", a[4], a[3], a[2], a[1], a[0]);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int INF = 1000000;

int A[100];
int B[100];
int C[100];

int N, Ma, Mb;

map<int, int> ma;
map<int, int> mb;

void dfs(int s, int d, int aa, int bb, int cc, bool isA){
    if(s == d){
        if(cc == 0) return;
        int sum;
        if(isA){
            sum = -aa*Mb + bb*Ma;
            if(ma.find(sum) != ma.end()){
                int ccc = ma[sum];
                cc = min(cc, ccc);
            }
            ma[sum] = cc;
        }
        else{
            sum = aa*Mb - bb*Ma;
            if(mb.find(sum) != mb.end()){
                int ccc = mb[sum];
                cc = min(cc, ccc);
            }
            mb[sum] = cc;
        }
        return;
    }
    int a = A[s];
    int b = B[s];
    int c = C[s];
    dfs(s+1, d, aa, bb, cc, isA);
    dfs(s+1, d, aa+a, bb+b, cc+c, isA);
}

int main(){
    cin >> N >> Ma >> Mb;

    REP(i,N){
        int a, b, c;
        cin >> a >> b >> c;
        A[i] = a; 
        B[i] = b; 
        C[i] = c; 
    }

    dfs(0, N/2, 0, 0, 0, true);
    dfs(N/2, N, 0, 0, 0, false);

    int ans = INF;
    if(ma.find(0) != ma.end()){
        ans = min(ans, ma[0]);
    }
    if(mb.find(0) != mb.end()){
        ans = min(ans, mb[0]);
    }

    for(auto&& a : ma){
        int r = a.first;
        int c = a.second;
        if(mb.find(r) != mb.end()){
            ans = min(ans, c+mb[r]);
        }
    }

    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
/*

  _|_|                              _|  _|    _|
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|
_|    _|  _|_|          _|          _|  _|_|
_|    _|  _|          _|      _|    _|  _|  _|
  _|_|    _|        _|_|_|_|    _|_|    _|    _|

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=3*5005;
char s[maxn],t[maxn];
vi marks,markt;
int a[maxn],b[maxn];
int main(){
    int n;scanf("%d%s%s",&n,s+1,t+1);
    if(s[1]=='1')marks.pb(0);
    rep(i,1,n-1)if(s[i]!=s[i+1])marks.pb(i);
    if(s[n]=='1')marks.pb(n);
    if(t[1]=='1')markt.pb(0);
    rep(i,1,n-1)if(t[i]!=t[i+1])markt.pb(i);
    if(t[n]=='1')markt.pb(n);
    int cnts=marks.size(),cntt=markt.size(),add=cntt-cnts;
    int ans=1e9+100;
    rep(i,1,cnts)a[i+cntt]=marks[i-1];
    rep(i,1,cntt)a[i+cnts+cntt]=n;
    for(int i=0;i<=cnts+cntt;i+=2){
        int tmp=0;
        rep(j,1,i)b[j]=0;
        //cout<<markt[0]<<endl;
        rep(j,1,cntt)
        b[i+j]=markt[j-1];
        rep(j,1,cnts+cntt-i)b[j+i+cntt]=n;
        rep(j,1,cnts+cntt*2)tmp+=abs(a[j]-b[j]);
        ans=min(ans,tmp);
    }
 /*   rep(i,-cnts,cnts+add){//从开头通过的
        int tmp=0;
        int but=add-i;//从结尾通过的
        if(i<0){
            rep(j,1,-i)tmp+=abs(s[i-1]-0);
            rep(j,-i+1,cnts)tmp+=abs(s[i-1]-t[j+i-1]);
            rep(j,cnts+i+1,cnts)tmp+=abs(n-t[j-1]);
        }
        else{
            rep(j,cnts+but+1,cnts)tmp+=abs(s[i-1]-n);
            for(int j=cnts+but;j>=i;j--)tmp+=abs(s[i-1]-t[i-1]);
            rep(j,1,i)tmp+=t[i];
        }
        ans=min(ans,tmp);
        cout<<tmp<<endl;
    }*/
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3900
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif

vector<int> cache(N,inf) , a;
int dp(int cur){
	if(cur == 0) 
		return 0 ;
	if(cur < 0)
		return inf ;
	int& ans = cache[cur] ;
	if(ans != inf) return ans ;
	return ans = min(inf,min( dp(cur - 1) + abs(a[cur] - a[cur-1]), dp(cur - 2) + abs(a[cur] - a[cur-2]))) ;
}
void solve()
{
	int n ;
	cin >> n ;
	a.resize(n);
	for(auto &it : a) cin >> it; 
	cout << dp(n-1) ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n;
  cin >> n;

  vector<pair<ll, ll>> w(n);
  rep(i, n) {
    cin >> w[i].second >> w[i].first;
  }

  sortAl(w);

  ll rt = 0; // remaining time
  ll prev_dead_line = 0;

  rep(i, n) {
    rt += (w[i].first - prev_dead_line) - w[i].second;
    prev_dead_line = w[i].first;
    if (rt < 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3456
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::iter::Iterator;

fn main() {
    input!{
        cs: chars, 
    }

    if cs[2]==cs[3] && cs[4] == cs[5]{
        println!("Yes")
    }else{
        println!("No")
    }

}


Measured memory_bytes: 4352
import java.lang.System;
import java.util.LinkedList;
import java.util.Scanner;

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

        LinkedList<Integer> queue = new LinkedList<Integer>();
        while (sc.hasNextInt()) {
            int n = sc.nextInt();

            if (n > 0) {
                queue.push(n);
            } else {
                System.out.println(queue.pop());
            }
        }
    }
}

Measured memory_bytes: 17208
#include<stdio.h>

int main(void){
   int N,M;
   scanf("%d %d",&N,&M);
   int n[N];
   int sum=0;
   int cnt=0;
   for(int i=0;i<N;i++){
      scanf("%d",&n[i]);
      sum +=n[i];
   }
   for(int i=0;i<N;i++){
      if(n[i]*4*M>=sum){
         cnt++;
      }
   }
   if(cnt>=M){
      printf("Yes");
   }else{
      printf("No");
   }
   return 0;
}

Measured memory_bytes: 1736
#include <iostream>
using namespace std;
int main()
{
	long long int H, W;
	cin >> H >> W;
	if (H == 1 || W == 1)
		cout << "1" << "\n";
	else if (H % 2 == 0)
		cout << H / 2 * W << "\n";
	else
		cout << H / 2 * W + W - W / 2 << "\n";
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
map<int,int>mp;
const int N=2e5+100;
int dp[50][500][500];///前n个a有i，b有j的最小花费
int a[50],b[50],c[50];
int inf=0x3f3f3f3f;
string s;
int n;
int slove(int a,int b)
{
    int k;
    if((a==1&&s[0]=='o')||(a==2&&s[0]=='x')) k=b;
    else k=3-b;
    vector<int>ve;
    ve.push_back(a);ve.push_back(b);
    for(int i=1;i<n;i++){
        if(s[i]=='o'){
           if(ve[i]==1) ve.push_back(ve[i-1]);
           else ve.push_back(3-ve[i-1]);
        }
        else {
            if(ve[i]==1) ve.push_back(3-ve[i-1]);
            else ve.push_back(ve[i-1]);
        }
    }
    if(ve[n]==ve[0] && k==ve[n-1]) {
        for(int i=0;i<ve.size()-1;i++){
            if(ve[i]==1) cout<<'S';
            else cout<<'W';
        }
        return 1;
    }
    return 0;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>s;
    int f=0;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=2;j++){
            f=slove(i,j);
            if(f) break;
        }
        if(f) break;
    }
    if(!f) cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    int check = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    for (int i = 1; i < N;i++)
    {
        if(A[i-1] == A[i]){
            check = 1;
        }
    }
    if(check == 1){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 1024
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int 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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll X) {
  int i = 0;
  ll d = 100;
  while (d < X) {
    double v = d * 1.01;
    d = floor(v);
    i++;
  }

  cout << i << endl;
}

int main() {
  ll X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
 
using namespace std;


int main()
{ 
	queue<int> que;
	vector<int> arr[100001];
	int n;
	cin>>n;
	int arr2[100000][2];
	int arr3[100001];
    int arr4[100001];
	for(int i=0;i<100001;i++){arr3[i]=-1;arr4[i]=0;}
	map<pair<int,int>,int> map;
	for(int i=0;i<n-1;i++){
		cin>>arr2[i][0]>>arr2[i][1];
		arr[arr2[i][0]].push_back(arr2[i][1]);
		arr[arr2[i][1]].push_back(arr2[i][0]);
	}
	int num;
	num=arr[1].size();
	for(int i=2;i<=n;i++){
		int cur=arr[i].size();
		if(cur>num)num=cur;
	}
	cout<<num<<endl;
	que.push(1);
  	arr4[1]=1;
	arr3[1]=0;
	int cur;
	while(!que.empty()){
		cur=que.front();
		que.pop();
		int clo=arr3[cur];
		for(int i=0;i<arr[cur].size();i++){
			if(!arr4[arr[cur][i]]){
				que.push(arr[cur][i]);
				clo=clo%num+1;
				arr3[arr[cur][i]]=clo;
              	arr4[arr[cur][i]]=1;
				map.insert(pair<pair<int,int>,int>(make_pair(cur,arr[cur][i]),clo));
			}
		}
	}
	for(int i=0;i<n-1;i++){
		if(!map.count(make_pair(arr2[i][0],arr2[i][1]))){
			int c=arr2[i][0];
			arr2[i][0]=arr2[i][1];
			arr2[i][1]=c;
		}
		cout<<map.at(make_pair(arr2[i][0],arr2[i][1]))<<endl;
	}
	return 0;
}


	


Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef pair<ll,pi> pii;
typedef vector<pi> vpi;
typedef set<ll> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e18;
ll MOD = 1e9+7;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()

ll left[100100], right[100100];
ll ans;
ll N,K;
ll A[100100];

int main(){
  cin>>N>>K;
  for (int i=1;i<=N;++i)cin>>A[i];
  --K;
  ans = INF;
  for (int i=1;i<=N;++i){
    if (i+K > N)break;
    ll a = A[i], b = A[i+K];
    if ((a > 0 && b > 0) || (a < 0 && b < 0))ans = min(ans, max(abs(a), abs(b)));
    else ans = min(ans, abs(a)+abs(b)+ min(abs(a),abs(b) ) );
  }
  cout<<ans;
}

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


void solve(){
    int n;cin>>n;
    if(n>=400 && n<=599){
        cout<<8<<'\n';
        return;
    }else if(n>=600 && n<=799){
        cout<<7<<'\n';
        return;
    }else if(n>=800 && n<=999){
        cout<<6<<'\n';
        return;
    }else if(n>=1000 && n<=1199){
        cout<<5;
        return;
    }else if(n>=1200 && n<=1399){
        cout<<4;
        return;
    }else if(n>=1400 && n<=1599){
        cout<<3;
        return;
    }else if(n>=1600 && n<=1799){
        cout<<2;
        return;
    }else if(n>=1800 && n<=1999){
        cout<<1;
        return;
    }
}


int main(){
    //ll tt;cin>>tt;
    //while(tt--){
        solve();
    //}
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  vector<int>vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
  int count=0;
  rep(i,N-1) {
repl(j,i+1,N) {
count +=vec.at(i)*vec.at(j);
}
  }
  cout << count << endl;
}
  
  


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

int main()
{
		int m=0;
		int n[10000];
		while (1) {
				cin >> n[m];
				if (n[m]==0) break;
				else m++;
		}

		for (int i=0; i<m; i++) {
				cout << "Case " << i+1 << ": " << n[i] << "\n";
		}
}

Measured memory_bytes: 3120
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]

ans = 0
for i in range(1<<H):
    for j in range(1<<W):
        cnt = 0
        for k in range(H):
            for l in range(W):
                if i & 1 << k or j & 1 << l: continue
                if c[k][l] == '#':
                    cnt += 1
        
        if cnt == K:
            ans += 1

print(ans)            


Measured memory_bytes: 9144
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

A, V = input_int()
B, W = input_int()

T = one_int()

speed = (V-W)

kyori = abs(B-A)

if speed*T >= kyori:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9188
#include <iostream>

#include <algorithm>

using namespace std; 
int main() 
{ 
int n, a[205]; 
while(cin >> n) { 
for(int i = 0; i < 2 * n; i ++) 
cin >> a[i]; 
sort(a , a + 2 * n); 
int ans = 0; 
for(int i = 2 * n - 1; i >= 0 ; i -= 2) 
ans += a[i - 1]; 
cout << ans << endl; 
} 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    string s; cin >> s;
    int n = int(s.size());
    vector<int> a(n, 0);
    rep(i, n) {
        if (s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') {
            a[i]=1;
        }
    }

    int ans = 0;
    rep(i, n) FOR(j, i+1, n+1) {
        if (accumulate(a.begin()+i, a.begin()+j, 0)==j-i) {
            ans = max(ans, j-i);
        }
    }

    cout << ans << endl;
}

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

int n, len, ans, cnt, tanka[5] = {5, 7, 5, 7, 7};
string s[50];
bool flag;

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

  while (true) {
    cin >> n;
    if (n == 0) break;

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

    cnt = len = ans = 0;
    flag = false;

    for (int i = 0; i < n; ++i) {
      if (flag) break;

      ans = i + 1;
      len = 0;

      for (int j = i; j < n; ++j) {
        len += s[j].size();
        //cout << len << " " << s[j] << endl;

        if (len == tanka[cnt]) {
          cnt++;
          len = 0;
          if (cnt == 5) {
            cout << ans << endl;
            flag = true;
          }
        }
        else if (len < tanka[cnt]) {
          continue;
        }
        else if (len > tanka[cnt]) {
          len = 0;
          cnt = 0;
          break;
        }
      }

    }

      for (int i = 0; i < 49; ++i) s[i] = "";
  }

  return 0;
}

Measured memory_bytes: 3104
#include<cstdio>
const int mo=1e9+7;
int inv[1000050],fnv[1000050],fac[1000050],n,ans,pw,p;
int pow(int a,int k){
	int ret=1;
	while (k){
		if ((k&1))ret=ret*1ll*a%mo;
		a=a*1ll*a%mo;k>>=1;
	}
	return ret;
}
int C(int n,int m){return fac[n]*1ll*fnv[n-m]%mo*fnv[m]%mo;}
int main(){
	scanf("%d",&n);
	fnv[0]=fac[0]=1;
	for (int i=1;i<=n;i++)fac[i]=fac[i-1]*1ll*i%mo;
	fnv[n]=pow(fac[n],mo-2);
	inv[n]=fnv[n]*1ll*fac[n-1]%mo; 
	for (int i=n-1;i>=1;i--){fnv[i]=fnv[i+1]*1ll*(i+1)%mo;inv[i]=fnv[i]*1ll*fac[i-1]%mo;}
	ans=n,pw=p=1;
	for (int i=2;i<=n;i++){
		pw=pw*2%mo;
		p=(pw-p+mo)%mo;
		(ans+=p*1ll*C(n,i)%mo*inv[i]%mo)%=mo;
	}
	ans=ans*1ll*inv[n]%mo*pow(pow(3,n),mo-2)%mo;
	printf("%d\n",ans);
} 

Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	if (A >= K) {
		cout << K << endl;
	}
	else if (A+B>=K){
		cout << A << endl;
	}
	else {
		cout << 2*A + B - K << endl;
	}

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main() {
	string a,b,c;
  	cin>>a>>b>>c;
  
  	if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)){
    	cout<<"YES"<<endl;
    }else{
    	cout<<"NO"<<endl;
    }
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 55;
int n,  avg;
int a[maxn];
ll dp[maxn][maxn*maxn][maxn];

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

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

  dp[0][0][0] = 1;

  for (int i=0; i<n; i++) {
    for (int j=0; j<maxn*maxn; j++) {
      for (int k=0; k<n; k++) {
	if (j+a[i]<maxn*maxn) {
	  dp[i+1][j+a[i]][k+1] += dp[i][j][k];
	}
	dp[i+1][j][k] += dp[i][j][k];
      }
    }
  }

  ll ans = 0;
  for (int k=1; k<=n; k++) {
    ans += dp[n][k*avg][k];
  }

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


Measured memory_bytes: 66560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int di=n%10;
	switch(di){
		case 2:;
		case 4:;
		case 5:;
		case 7:;
		case 9:printf("hon\n");break;
		case 3:printf("bon\n");break;
		default:printf("pon\n");
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	string s;
	cin>>s;
	int n=s.size();
	int cnt1=0;
	REP(i, n){
		if(i&1){
			if(s[i]!='0'){
				++cnt1;
			}
		}
		else{
			if(s[i]!='1'){
				++cnt1;
			}
		}
	}
	int cnt2=0;
	REP(i, n){
		if(i&1){
			if(s[i]!='1'){
				++cnt2;
			}
		}
		else{
			if(s[i]!='0'){
				++cnt2;
			}
		}
	}
	cout<<min(cnt1, cnt2)<<'\n';
	return 0;
}


Measured memory_bytes: 512
while True:
    m, f, r = map(int,input().split())
    total = m + f
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif total >= 80:
        print("A")
    elif 65 <= total < 80:
        print("B")
    elif 50 <= total < 65:
        print("C")
    elif 30 <= total < 50 and r >= 50:
        print("C")
    elif 30 <= total < 50:
        print("D")
    elif total < 30:
        print("F")


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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#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,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'


int main() {
    int n;
    cin >> n;
    vl a(n);
    rep(i, n){
        cin >> a[i];
    }
    ll s = 0;
    rep(i, n){
        s += a[i];
    }
    vl x(n);
    x[0] = s;
    rep1(i, n-2){
        x[0] -= 2 * a[i];
        i++;
    }
    rep1(i, n-1){
        x[i] = 2 * a[i-1] - x[i-1];
    }
    rep(i, n-1){
        cout << x[i] << " ";
    }
    cout << x[n-1] << endl;
    return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
const int MOD = 1000000007;

int main(void){
  int A,B;
  scanf("%d%d",&A,&B);
  if((A+B)%2 == 0){
    printf("%d\n",(A+B)/2);
  }else{
    printf("IMPOSSIBLE\n");
  }
}


Measured memory_bytes: 128
N,M = map(int,input().split())
li =[]
for i in range(M):
    li.append(list(map(int,input().split())))
    if li[i][0]>N:
        print("-1")
        exit()
st = 10**(N-1)
if N == 1:
    st = 0
for i in range(st,10**N):
    inv = True
    a = str(i)
    for j in range(M):
        if  a[li[j][0]-1] != str(li[j][1]):
            inv = False
            break
    if inv:
        print(i)
        exit()
print("-1")


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

int n, s[100];
int dp[101][101 * 100];

int rec(int idx, int sum) {
    if(idx == n) {
        if(sum % 10) return sum;
        else return 0;
    }

    if(~dp[idx][sum]) return dp[idx][sum];
    return dp[idx][sum] = max( rec(idx + 1, sum + s[idx]), rec(idx + 1, sum) );
}

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

    fill_n(*dp, 101 * 100 * 100, -1);
    cout << rec(0, 0) << endl;
}


Measured memory_bytes: 4224
#! /usr/bin/ruby

n=gets.to_i
pa,pb,pc,pd=gets.chomp.split.map(&:to_i)
ta,tb,tc,td=gets.chomp.split.map(&:to_i)
ans=10**6;
0.step(101,1)do |a|
    0.step(101,1)do |b|
        0.step(101,1)do |c|
            if(n-(a*ta+b*tb+c*tc)<=0)then
                d=0
            else
                d=(n-(a*ta+b*tb+c*tc)+td-1)/td
            end

            ans=[ans,a*pa+b*pb+c*pc+d*pd].min
        end
    end
end
puts(ans)


Measured memory_bytes: 6888
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a) {
    cout << k << endl;
  }
  else if ((a < k) && (k <= b+a)) {
    cout << a << endl;
  }
  else {
    cout << a - (k-(a+b)) << endl;
  }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int m, k;
  cin >> m >> k;
  
  if(m == 0){
    if(k == 0){
      cout << "0 0\n";
      return 0;
    }
    else{
      cout << "-1\n";
      return 0;
    }
  }
  
  if(m == 1){
    if(k == 0){
      cout << "0 0 1 1\n";
      return 0;
    }
    else{
      cout << "-1\n";
      return 0;
    }
  }
  
  if(k >= pow(2, m)){
    cout << "-1\n";
    return 0;
  }
  
  for(int i = 0; i < pow(2, m); i++){
    if(i != k) cout << i << " ";
  }
  cout << k << " ";
  for(int i = pow(2, m) - 1; i >= 0; i--){
    if(i != k) cout << i << " ";
  }
  cout << k << '\n';
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000
 
using namespace std;
 
int main()
{
long long i=0,n,k=0,mi,ma;
cin>>n;
while (i<n){
	long long a;
	cin>>a;
	i+=1;
	k+=a;
	if(i==1) {
	mi=a;
	ma=a;
}
	
	else if(mi>a) mi=a;
	if(ma<a) ma=a;
}
    cout<<mi<<' '<<ma<<' '<<k<<endl;
    return 0;
}


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

using namespace std;

typedef long long LL;
#define N 300000

LL n,x,y,a[N],deg[N],tot,head[N];
struct edge{LL v,nxt;}e[N];

void add(LL x,LL y){e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot;}

void dfs(LL u,LL fa){
	if (deg[u]==1) return;
	LL o=0; a[0]=-1;
	LL sum=0;
	for (LL i=head[u],v;i;i=e[i].nxt)
		if ((v=e[i].v)!=fa){
			dfs(v,u);
			sum+=a[v];
			if (a[v]>a[o]) o=v;
		}
	if (sum<a[u]||sum>a[u]*2){puts("NO"); exit(0);}
	LL k=a[u]*2-sum;
	if (a[o]-k>sum-a[o]){puts("NO"); exit(0);}
	a[u]=k;
}

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i) scanf("%lld",a+i);
	if (n==2){puts(a[1]==a[2]?"YES":"NO"); return 0;}
	for (LL i=1;i<n;++i){
		scanf("%lld%lld",&x,&y);
		add(x,y); add(y,x);
		++deg[x]; ++deg[y];
	}
	for (LL i=1;i<=n;++i)
		if (deg[i]>1){
			dfs(i,0);
			puts(a[i]==0?"YES":"NO");
			return 0;
		}
	
	return 0;
}
			

Measured memory_bytes: 15872
<?php
$input = trim(fgets(STDIN));
list($N, $K) = explode(' ', $input);

$input = trim(fgets(STDIN));
$Xs = explode(' ', $input);

$min = PHP_INT_MAX;
for($i=0; $i<$N; $i++) {
    if(!isset($Xs[$i + $K - 1])) continue;

    $r = $Xs[$i];
    $l = $Xs[$i + $K - 1];
    
    $min = min(abs($l) + abs($r - $l), abs($r) + abs($r - $l), $min);
}

echo $min;


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

int INFTY = 1000000000, cnt = 0;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];
    for (int i = 0; i < n1; ++i) L[i] = A[left + i];
    for (int i = 0; i < n2; ++i) R[i] = A[mid + i];
    L[n1] = INFTY; R[n2] = INFTY;
    int i = 0, j = 0;
    for (int k = left; k < right; ++k) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            ++i;
            ++cnt;
        }
        else {
            A[k] = R[j];
            ++j;
            ++cnt;
        }
    }
}

void mergeSort(int A[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int n, S[500010];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> S[i];

    mergeSort(S, 0, n);
    for (int i = 0; i < n; ++i) {
        if (i) cout << ' ';
        cout << S[i];
    }
    cout << endl << cnt << endl;
    
    return 0;
}


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

const int N = 1e5 + 7;

int n, m;
int p[N];
vector <int> ad[N * 2];
bool mrk[N * 2];
int c[N * 2];
int cnt = 1;
void dfs(int v) {
	mrk[v] = 1;
	c[v] = cnt;
	for (int i = 0; i < ad[v].size(); i++)
		if (!mrk[ad[v][i]])
			dfs(ad[v][i]);
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> p[i];
	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		ad[n + x].push_back(n + y);
		ad[n + y].push_back(n + x);
	}
	for (int i = 1; i <= n; i++) {
		ad[p[i]].push_back(n + i);
		ad[n + i].push_back(p[i]);
	}
	for (int i = 1; i <= 2 * n; i++)
		if (!mrk[i])
			dfs(i), cnt++;	
	int res = 0;
	for (int i = 1; i <= n; i++)
		if (c[i] == c[n + i])
			res++;
	cout << res;
	return 0;
}


Measured memory_bytes: 14592
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false),cin.tie(0)
#define inf 0x3f3f3f3f
#define ll long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;


int main()
{
	io;
	unsigned ll n, m;
	cin >> n >> m;
	unsigned ll ans = n*m / 2 + (n*m) % 2;
	if (n == 1 || m == 1)
		ans = 1;
	cout << ans;
	return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main() {
    string S,T;
    cin>>S>>T;
    for(int i=0;i<=S.length();i++){
        if(T==S.substr(i)+S.substr(0,i)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int mod=1000000007;
inline LL quick(LL a,LL b)
{
  LL r=1,base=a;
  while(b)
    {
      if(b&1) r=r*base%mod;
      base=base*base%mod;
      b>>=1;
    }
  return r;
}
int p[10005],f[10005];
inline void up(int &x,int y) {x+=y;if(x>=mod) x-=mod;}
int main( )
{
  int n,k,i,j,x,ans=0,len=0;
  n=read( );k=read( );
  for(i=1;i*i<=n;i++)
    if(n%i==0) p[++len]=i,p[++len]=n/i;
  sort(p+1,p+len+1);
  len=unique(p+1,p+len+1)-p-1;
  for(i=1;i<=len;i++)
    {
      x=p[i];
      f[i]=quick(k,(x+1)>>1);
      for(j=1;j<i;j++)
	if(x%p[j]==0) up(f[i],mod-f[j]);
      if(!(x&1)) x>>=1;
      up(ans,(LL)f[i]*x%mod);
    }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int K,A,B;
  cin >>K >> A >> B;

  int N=K;
  int ch=0;

  for(int i=1;i<100;i++){
    N = K*i;
    if(A<=N && N<=B) ch=1;
  }


  if(ch==1)cout << "OK" << endl;
  if(ch==0)cout << "NG" << endl;
}


Measured memory_bytes: 3580
const MODULO: i64 = 1_000_000_000 + 7;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace().map(|x| x.parse::<i64>().unwrap());
    let n = iter.next().unwrap();
    let a = iter.next().unwrap();
    let b = iter.next().unwrap();

    println!(
        "{}",
        ((powmod(2, n) - 1 - combination(n, a) + MODULO) % MODULO - combination(n, b) + MODULO) % MODULO
    );
}
fn fact(x: i64) -> i64 {
    let mut ret: i64 = 1;
    for i in 1..x + 1 {
        ret = ret * i % MODULO;
    }
    return ret;
}
fn powmod(x: i64, n: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    if n % 2 == 0 {
        let k = powmod(x, n / 2);
        return (k * k) % MODULO;
    } else {
        let k = powmod(x, n / 2);
        return (((k * k) % MODULO) * x) % MODULO;
    }
}
#[test]
fn test_combination() {
    assert_eq!(combination(6, 3), (6 * 5 * 4) / (3 * 2 * 1));
    assert_eq!(fact(5), 5 * 4 * 3 * 2 * 1);
    assert_eq!(combination(4, 1), 4);
    assert_eq!(combination(4, 3), 4);
    assert_eq!(powmod(2, 4), 16);
}

// aCb の計算
fn combination(a: i64, b: i64) -> i64 {
    let mut ret = 1;
    for i in 0..b {
        ret = ret * (a - i) % MODULO;
    }
    return ret * inverse(fact(b)) % MODULO;
}

// x ^ -1　(in modulo) の計算
fn inverse(x: i64) -> i64 {
    powmod(x, MODULO - 2)
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 500 ;
using namespace std ;

int n, a[N] ;

int main() {
	scanf("%d", &n) ;
	int x ;
	rep(i, 1, n) scanf("%d", &x), ++ a[x] ;
	x = 1 ;
	for ( ; !a[x] ; ++ x) ;
	if (a[x] == 1) {
		rep(i, x + 1, 2 * x) if (a[i] < 2) {
			puts("Impossible") ;
			return 0 ; 
		}
		rep(i, 2 * x + 1, n - 1) if (a[i]) {
			puts("Impossible") ;
			return 0 ;
		}
		puts("Possible") ;
	} else if (a[x] == 2) {
		rep(i, x + 1, 2 * x - 1) if (a[i] < 2) {
			puts("Impossible") ;
			return 0 ;
		}
		rep(i, 2 * x, n - 1) if (a[i]) {
			puts("Impossible") ;
			return 0 ;
		}
		puts("Possible") ;
	} else puts("Impossible") ;
	return 0 ; 
}

Measured memory_bytes: 256
import bisect
n = int(input())
a_list = sorted(list(map(int, input().split())))
b_list = sorted(list(map(int, input().split())))
c_list = sorted(list(map(int, input().split())))
ans = 0
for b in b_list:
    s = bisect.bisect_left(a_list, b)
    t = len(c_list) - bisect.bisect_right(c_list, b) 
    ans += s*t
print(ans)

Measured memory_bytes: 23156
// https://atcoder.jp/contests/agc032/tasks/agc032_a
#include <bits/stdc++.h>

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

int main(){
  int n;
  cin >> n;
  vi a, b(n);
  for (int i = 0; i < n; i++) cin >> b[i], b[i]--;
  for (int i = 0; i < n; i++) {
    if (b[i] > a.size()) {
      cout << "-1\n";
      return 0;
    }
    a.insert(a.begin() + b[i], b[i] + 1);
  }
  for(int x : a) cout << x << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

auto GCD(auto a, auto b) { //ユークリッドの互助法で最大公約数
    if(a % b == 0)return b;
    else return GCD(b, a % b);
}
auto LCM(auto a, auto b) { //GCDを使って最小公倍数を求める
    auto g = GCD(a, b);
    return (a / g) * b;
}


int n;              // 配列サイズ
vector<LL> seg;     // セグ木

void segch(int i,int x){    // 配列i番目要素をxに変更
    i += (n-1);
    seg[i] = x;
    while(i > 0){
        i = (i-1)/2;
        seg[i] = GCD(seg[2*i+1],seg[2*i+2]);    //**
    }
}

LL getq_sub(int a,int b,int k,int l,int r){ 
    // k:現在見ているノードの位置  [l,r):dat[k]が表している区間
    if(r <= a || b <= l)return -1;             //**
    else if(a <= l && r <= b)return seg[k];     
    else{                                       
        int ind = (l+r)/2;
        int vl = getq_sub(a,b,2*k+1,l,ind);
        int vr = getq_sub(a,b,2*k+2,ind,r);
        if(vl == -1)vl = vr;
        if(vr == -1)vr = vl;
        return GCD(vl,vr);                      //**
    }
}


LL getq(int a,int b){     // [a,b) の区間でminを返す
    return getq_sub(a,b,0,0,n);
}







int main() {
    cin >> n;
    vector<LL> A(n);rep(i,n)cin >> A[i];
    LL bk = A[n-1];

    // 配列の要素数を 2^x 個にするためにINFで埋める  
    rep(i,32){
        if(n <= pow(2,i)){
            n = pow(2,i);
            break;
        }
    }
    int st = A.size();
    for(int i = st;i < n;i++)A.push_back(bk);  //**

    // seg木の配列初期化
    seg.resize(2*n-1);rep(i,2*n-1)seg[i] = 1; //**
    rep(i,n)segch(i,A[i]);

    LL ans = 1;

    
    rep(i,n){
        if(i == 0){
            ans = max(ans,getq(1,n));
        }
        else if(i == n-1){
            ans = max(ans,getq(0,n-1));
        }
        else{
            LL tmp = GCD(getq(0,i),getq(i+1,n));
            ans = max(ans,tmp);
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3312
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        
        Scanner sc = new Scanner(System.in);
        
        String text = sc.nextLine();
        
        String [] arr = new String[text.length()];
        
        for (int i = 0; i < text.length(); i++) {
            //input all elements of string to an array
            arr[i] = Character.toString(text.charAt(i));
            
            //convert the elements to UpperCase or LowerCase
            if (arr[i] == arr[i].toUpperCase()) {
               arr[i]= arr[i].toLowerCase();
            }else{
               arr[i]= arr[i].toUpperCase();
            }
            
            //Print the output
            System.out.print(arr[i]);
        }
        System.out.println();
    }
}



Measured memory_bytes: 26980
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
const long long MOD = 1e9+7, INF = 1e18;
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}





signed main(){
	IOS();
	vector<pair<int,int>>ans;
	int N;
	while(cin>>N,N){
		int ret = -1,a;
		N*=2;
		for(int i = 1;i*i<=N;i++){
			if(N%i)continue;
			int t = N;
			t/=i;
			t-=i;
			t+=1;
			if(t>1&&t%2==0)if(chmax(ret,i))a = t/2;
			t = N;
			t/=N/i;
			t-=N/i;
			t+=1;
			if(t>1&&t%2==0)if(chmax(ret,N/i))a = t/2;
		}
		ans.push_back({ret,a});
	}
	for(auto e:ans){
		cout<<e.se<<" "<<e.fi<<endl;
	}
}


Measured memory_bytes: 3180