akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll a,b;
    cin>>a>>b;
  cout<<6-a-b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


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

    if(N == 0)cout << 1 << endl;
    else cout << 0 << endl;


}



Measured memory_bytes: 3628
import java.util.Scanner;

public class Main
{
    public int computeMultiplication(int a, int b)
    {
        if(a > 9 || b > 9 || a == 0 || b == 0)
        {
            return -1;
        }

        return a * b;
    }

    public static void main(String args[]) {
        int a, b;
        Scanner sc = new Scanner(System.in);
        Main m = new Main();
        //System.out.println("Enter a string");
        a = sc.nextInt();
        b = sc.nextInt();
        System.out.println(m.computeMultiplication(a, b));
    }
}


Measured memory_bytes: 22100
import sys
from collections import deque
import copy
import heapq
import math

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


count = 0

def dfs(N, adj_list, nd, visit_num, is_visit):
    global count
    is_visit[nd] = True
    if visit_num == N:
        count += 1
    for adj in adj_list[nd]:
        if is_visit[adj] == False:
            dfs(N, adj_list, adj, visit_num + 1, is_visit)
            is_visit[adj] = False


def main():
    global count
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    adj_list = {}
    for i in range(M):
        input_raw = read_func().strip().split()
        [a, b] = [long(input_raw[0]), long(input_raw[1])]
        if a not in adj_list:
            adj_list[a] = [b]
        else:
            adj_list[a].append(b)

        if b not in adj_list:
            adj_list[b] = [a]
        else:
            adj_list[b].append(a)
    is_visit = [False for i in range(N + 1)]

    dfs(N, adj_list, 1, 1, is_visit)

    print count






if __name__ == '__main__':
    main()


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

int main()
{
    int x;
    cin >> x;
    int ans = 0;
    if(400 <= x && x < 600) ans = 8;
    if(600 <= x && x < 800) ans = 7;
    if(800 <= x && x < 1000) ans = 6;
    if(1000 <= x && x <1200) ans = 5;
    if(1200 <= x && x < 1400) ans = 4;
    if(1400 <= x && x < 1600) ans = 3;
    if(1600 <= x && x < 1800) ans = 2;
    if(1800 <= x && x < 2000) ans = 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>

using namespace std;

int lcs(string x,string y){
  int m=x.size();
  int n=y.size();
  int c[m+1][n+1];
  for(int i=0;i<=m;i++)
    c[i][0]=0;
  for(int i=1;i<=n;i++)
    c[0][i]=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(x[i-1]==y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i-1][j],c[i][j-1]);
    }
  }
  return c[m][n];
}

int main(){
  int n; cin >> n;
  for(int i=0;i<n;i++){
    string x,y;
    cin >> x >> y;
    cout << lcs(x,y) << endl;
  }
}

Measured memory_bytes: 7060
#include<iostream>
using namespace std;
#define INFTY (int)(1e9)


int partition(int A[], int p, int r){
	int x = A[r];
	int i = p-1;
	for(int j = p; j < r; j++){
		if(A[j] <= x){
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

int main(){
	int n, A[100002], p;

	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>A[i];
	}
	
	p = partition(A,0,n-1);
	
	for(int i = 0; i < n; i++){
		if(i)cout<<" ";
		if(i == p) cout<<"["<<A[i]<<"]";
		else cout<<A[i];
	}cout<<endl;
	return 0;
}


Measured memory_bytes: 3392
#include<cstdio>

using namespace std;

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

int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long n[9], res = 0;
    rep (i, 9) scanf("%llx", n + i);
    while (true) {
      long long sum = 0;
      rep (j, 8) sum += n[j];
      sum -= n[8];
      if (sum == 0) break;
      long long bit = sum & -sum;
      res ^= bit;
      rep (j, 9) n[j] ^= bit;
    }
    printf("%llx\n", res & ((1LL << 32) - 1));
  }
  return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES  // M_PI等のフラグ
#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


void solve(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans;
    ans = a * c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
}


int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]
txy.sort(key=lambda x: x[0])
now = 0, 0, 0
for t, x, y in txy:
    dist = x - now[1] + y - now[2]
    if not (t - now[0] >= dist and (t - now[0]) % 2 == dist % 2):
        print("No")
        break
    now = t, x, y
else:
    print("Yes")


Measured memory_bytes: 28148
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
const int INF=(1<<30)-1;
const int MAX=310;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int main(){
	int x,y;
	cin>>x;
	cin>>y;
	y=y/2;
	cout<<x+y<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  static int count=0;
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int [] Array = new int[n];
    for(int i = 0; i<n; i++){
      Array[i] = sc.nextInt();
    }

    System.arraycopy(Array,0,shell_sort(Array, n),0,n);
    for(int i =0; i<n; i++){
      System.out.println(Array[i]);
    }
  }

  static int [] insertion_sort(int [] A, int n, int g){
    int value;
    int j;
    for(int i =g; i<n;i++){
      value = A[i];
      j = i-g;
      while(j>=0 && A[j]>value){
        A[j+g] = A[j];
        j = j-g;
        count++;
      }
      A[j+g] = value;
    }
    return A;
  }

  static int [] shell_sort(int [] A, int n){
    //Gの逆順の配列
    int [] B = new int[n];
    int m = 0;
    for(int i = 1; i <= n; i = i * 3 + 1) {
    B[m] = i;
    m++;
  }
  //Gの配列にBを逆順で入れる
  int [] G = new int[m];
  int j = 0;
  for(int i = m-1; i>=0;i--){
    G[j] = B[i];
    j++;
  }
    System.out.println(m);
    for(int i =0; i<m; i++){
      System.arraycopy(A,0,insertion_sort(A, n, G[i]),0,n);
      if(i!=m-1)System.out.printf("%d ",G[i]);
    }
    System.out.println(G[m-1]);
    System.out.println(count);
    return A;
  }
}


Measured memory_bytes: 298428
/* AtCoder My Practice
 * author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>
#include <stdlib.h>

#define N_MAX (200001)

typedef struct _range {
    int upper, lower;
    struct _range *ubound, *lbound;
} Range;

Range *newRange(int lower, int upper) {
    Range *range = (Range*)malloc(sizeof(Range));
    range->lower = lower;
    range->upper = upper;
    return range;
}

int idx[N_MAX];
long long sum;
Range range;

void calc(int value, int index) {
    Range *tmp = &range;
    long long len;
    for (;;) {
        if (tmp->lower <= index && index <= tmp->upper) {
            len = (long long)(tmp->upper - tmp->lower + 1);
            sum += (len * (len + 1LL) / 2LL) * (long long)value;
            len = (long long)(tmp->upper - index);
            sum -= (len * (len + 1LL) / 2LL) * (long long)value;
            len = (long long)(index - tmp->lower);
            sum -= (len * (len + 1LL) / 2LL) * (long long)value;
            if (tmp->lower == index) {
                tmp->lower++;
            } else if (tmp->upper == index) {
                tmp->upper--;
            } else {
                tmp->lbound = newRange(tmp->lower, index - 1);
                tmp->ubound = newRange(index + 1, tmp->upper);
                tmp->lower = tmp->upper = index;
            }
            break;
        } else if (index < tmp->lower) {
            tmp = tmp->lbound;
        } else {
            tmp = tmp->ubound;
        }
    }
}


int main(void){
    int i, n;
    
    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        idx[a] = i;
    }
    
    range.upper = n - 1;
    
    for (i = 1; i <= n; i++) {
        calc(i, idx[i]);
    }
    
    printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 5120
import itertools
n, m, q = map(int, input().split())
a = []
b = []
c = []
d = []
for i in range(q):
    abcd=list(map(int, input().split()))
    a.append(abcd[0])
    b.append(abcd[1])
    c.append(abcd[2])
    d.append(abcd[3])
one_to_m = [i+1 for i in range(m)]
A = list(map(list, list(itertools.combinations_with_replacement(one_to_m, n))))
maximum = 0
for line in A:
    score = 0
    for i in range(q):
        if c[i] == line[b[i]-1] - line[a[i]-1]:
            score += d[i]
    if maximum < score:
        maximum = score
print(maximum)


Measured memory_bytes: 96940
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}


Measured memory_bytes: 2564
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	cin >> s;
	int n = s.size();
	for(int i=0;i < n - 1;i++){
		if(s[i] == 'A' && s[i + 1] == 'C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

cnt = defaultdict(int)

N = int(input())
for _ in range(N):
    cnt[input()] += 1

M = int(input())
for _ in range(M):
    cnt[input()] -= 1

ans = 0
for c in cnt.values():
    ans = max(ans, c)
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int n, u, v, ma;
vector<vector<int>> G;
vector<int> d;
void dfs(int i, int p, int f, int dep) {
    if(ma < dep) {
        ma = dep;
        if(f) {
            d[i] = dep;
            v = i;
        } else {
            u = i;
        }
    }
    for(auto e : G[i]) {
        if(e == p) {
            continue;
        }
        dfs(e, i, f, dep + 1);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    G.resize(n);
    d.resize(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1, 0, 1);
    ma = 0;
    dfs(u, -1, 1, 1);
    if(ma % 3 == 2) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
}


Measured memory_bytes: 24448
#include<stdio.h>

int main() {
	int H, N;
	scanf("%d", &H);
	scanf("%d", &N);

	int A;
	int Q = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A);
		Q += A;
	}
	if (Q >= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {
    }
    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    int ans = INF;
    rep(ii, n) rep(jj, n) {
        if (ii == jj) continue;
        int p = x[ii] - x[jj];
        int q = y[ii] - y[jj];
        UnionFind uf(n);
        rep(i, n) rep(j, n) {
            if (x[i] - x[j] == p && y[i] - y[j] == q) {
                uf.unite(i, j);
            }
        }
        int now = 0;
        rep(i, n) now += uf.root(i) == i;
        chmin(ans, now);
    }
    if (n == 1) ans = 1;
    cout << ans << endl;
}

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

int main(){
  int n,p;
  cin >> n >> p;
  if(n==1){
    int t;
    cin >> t;
    if(t%p) cout << 1 << endl;
    else cout << 0 << endl;
  }else{
  bool flag=true;
  int tem = 0;
  for(int i=0;i<n;i++){
    cin >> tem;
    if(tem%2!=0) flag =false;
  }
  long long int ans = 1;
  ans = ans << (n-1);
  if(flag&&p==0) cout << 2*ans << endl;
    else if(flag&&p==1) cout << 0 << endl;
  else cout << ans << endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: i64 = read();

    if n >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

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

    vector<int> l(N), r(N);
    vector<int> par(N, -1);
    for (int i = 0; i < N; ++i) {
        int v;
        cin >> v;
        cin >> l[v] >> r[v];
        if (l[v] >= 0) par[l[v]] = v;
        if (r[v] >= 0) par[r[v]] = v;
    }

    int root = min_element(par.begin(), par.end()) - par.begin();
    vector<int> order[3];

    function<void(int)> dfs = [&](int v) {
        if (v < 0) return;
        order[0].push_back(v);
        dfs(l[v]);
        order[1].push_back(v);
        dfs(r[v]);
        order[2].push_back(v);
    };
    dfs(root);

    string way[3] = {"Preorder", "Inorder", "Postorder"};

    for (int i = 0; i < 3; ++i) {
        cout << way[i] << endl;
        for (int v : order[i]) {
            cout << " " << v;
        }
        cout << endl;
    }
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> vp(n);
  rep(i, n) {
    int a;
    cin >> a;
    vp[i] = make_pair(a, i);
  }
  sort(vp.begin(), vp.end());
  rep(i, n) {
    if (vp[n - 1].second == i) {
      cout << vp[n - 2].first << endl;
    }
    else {
      cout << vp[n - 1].first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

long long N;
vector<long long> A;
map<long long, int> M;

long long confort = 0;

int zpos = 0;
void insertM(int pos){
	if(pos == 0){
		M[A[0]] = 1;
		return;
	}
	if(pos == 1){
		if(M.count(A[pos]) == 0){
			M[A[pos]] = 2;
			M[A[0]] = 0;
		}
		else{
			M[A[0]]++;
		}
		confort += A[0];
		return;
	}
	//まずconfortを計算しそのあと後用の処理をする。
	long long a;
	for(int i=zpos; i<pos; i++){
		a = A[i];
#ifdef DEBUG1
		printf("insertM: pos=%d, i=%d, a=%lld, M[a]=%d\n", pos, i, a, M[a]);
#endif
		if(M[a] == 0) continue;
		confort += a;
		M[a]--;
		if(M[a] == 0){
			zpos = i;
		}
		break;
	}
	M[A[pos]] += 2;
}

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

	cin >> N;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end(), std::greater<long>()); //降順でソート

	for(int i=0; i<A.size(); i++){
		insertM(i);
	}
	printf("%lld\n", confort);
	return 0;

}

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

buttons = []
for i in range(n):
    num = int(input())
    buttons.append(num - 1)

counter = 0
i = 0
while buttons[i] != -1:
    if i == 1:
        print(counter)
        break
    else:
        counter += 1
        _i = i
        i = buttons[i]
        buttons[_i] = -1
else:
    print(-1)

Measured memory_bytes: 7084
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int n,k;cin>>n>>k;
    vector<int> a(n);
    int m=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        m=max(m,a[i]);
    }
  int g=a[0];
    for(int i=0;i<n;i++){
        g=gcd(g,a[i]);
    }
    if(k>m||k%g!=0){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    cout<<"POSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
T = list(map(int, input().split()))

A = 0
B = 0
C = 0
for i in range(N):
    if T[i] % 2 != 0:
        A += 1
    elif T[i] % 4 == 0:
        B += 1
    else:
        C += 1

if A > B + 1:
    print("No")
elif C != 0 and A > B:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 14252
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;


fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let S:Vec<_> = iter.next().unwrap().chars().collect();
    let T:Vec<_> = iter.next().unwrap().chars().collect();
    let N = S.len();
    let M = T.len();

    let mut ans:Vec<_> = Vec::new();

    'outer:for i in 0..(N-M+1){
        for j in 0..M{
            if S[i+j] != '?' && S[i+j] != T[j]{
                continue 'outer;
            }
        }
        let mut tmp_str = String::new();
        tmp_str = S[..i].iter().fold(tmp_str,|ret,x| format!("{}{}",ret,x));
        tmp_str = T[..].iter().fold(tmp_str,|ret,x| format!("{}{}",ret,x));
        tmp_str = S[i+M..].iter().fold(tmp_str,|ret,x| format!("{}{}",ret,x));
        ans.push(tmp_str.replace("?","a"));
    }

    ans.sort();

    if ans.len() == 0{
        ans.push("UNRESTORABLE".to_string());
    }

    println!("{}",ans[0]);

}

Measured memory_bytes: 4352
s = input()
if len(s) == 2:
    if s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)
else:
    flag = False
    for i in range(len(s)-2):
        if s[i] == s[i+1] or s[i] == s[i+2]:
            flag = True
            break
    
    if flag:
        print(i+1, i+3)
    else:
        print(-1, -1)

Measured memory_bytes: 3188
N = int(input())
S = input()

S = S.replace('R', '0')
S = S.replace('G', '1')
S = S.replace('B', '2')
lis = [[0, 0, 0] for _ in range(N)]
index_lis = [0, 2, 1, 0]
for i in range(N):
  j = N-1-i
  for k in range(j):
    lis[k][int(S[j])] += 1


count = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    if S[i] != S[j]:
      if 2*j-i < N:
        if S[2*j-i] == S[i] or S[2*j-i] == S[j]:
          count += lis[j][index_lis[int(S[i])+int(S[j])]]
        else:
          count += lis[j][int(S[2*j-i])] - 1
      else:
        count += lis[j][index_lis[int(S[i])+int(S[j])]]
print(count) 

Measured memory_bytes: 69076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,res=0;
  cin>>a>>b;
  if(a<4) res += 100000*(4-a);
  if(b<4) res += 100000*(4-b);
  if(a==1 && b==1) res+=400000;
  cout<<res;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define REP(i, b, e) for(int i = (int)(b); i < (int)(e); i++)
#define rep(i, n) REP(i, 0, n)
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

ll a[101010], b[101010], sa[101010], sb[101010];
int n, k;

int main(){
	cin>>n>>k;
	rep(i, n) cin>>a[i], b[i] = max(a[i], 0LL);
	rep(i, n) sa[i+1] += a[i]+sa[i], sb[i+1] = b[i] + sb[i];
	ll ans = -1e18;
	for(int i = 0; i + k <= n; i++) {
		ll tmp1 = sa[i+k] - sa[i], tmp2 = 0;
		tmp1 += sb[i], tmp2 += sb[i];
		tmp1 += sb[n] - sb[i+k], tmp2 += sb[n] - sb[i+k];
		ans = max({ans, tmp1, tmp2});
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3328
#!/usr/bin/env ruby

A, B = gets.split.map(&:to_i)

if A == B
  puts "Yay!"
elsif A+B < 16
  if 2*[A,B].min + 2*([A,B].max - [A,B].min) <= 16
    puts "Yay!"
  else
    puts ":("
  end
else
  puts ":("
end


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		n %= 10;
		if (n == 3) {
			System.out.println("bon");
		} else if (n == 0 || n == 1 || n == 6 || n == 8) {
			System.out.println("pon");
		} else {
			System.out.println("hon");
		}
	}
}


Measured memory_bytes: 35728
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))
ans = 0
for i in range(q):
    bot = -1
    top = n
    x = t[i]
    while top - bot > 1:
        mid = (top+bot)//2
        if s[mid] >= x:top = mid
        else:bot = mid
    if top < n and s[top] == x:ans += 1
print(ans)
    


Measured memory_bytes: 16708
from heapq import heappush,heappop
from collections import defaultdict
from math import log,floor

def solve(N,A,B,C,D):
    memo = defaultdict(lambda: float('inf'))
    memo[N] = 0
    q = [(0, N)]
    best = float('inf')
    while q:
        cost, u = heappop(q)
        if cost > memo[u] or cost > best:
            continue
        if u == 1:
            best = min(best, cost+D)



        for dc, nu, flag in (
            (A+D*(u%2), u//2, True),
            (A+D, u//2+1, u%2==1),
            (B+D*(u%3), u//3, u%3 <= 1),
            (B+D, u//3+1, u%3 > 1),
            (C+D*(u%5), u//5, u%5<=2),
            (C+D*((-u)%5), u//5+1, u%5>2)):
            if not flag:
                continue
            nc = cost+min(dc,(u-nu)*D)
            if memo[nu] > nc:
                memo[nu] = nc
                heappush(q, (nc,nu))
    return best
def solve2(N,A,B,C,D):
    pass


T = int(input())

for _ in range(T):
    print(solve(*map(int,input().split())))

Measured memory_bytes: 78312
var
  e1,e2:array[0..100]of boolean;
  a,b,c,d,i,j,s:integer;
begin
  readln(a,b,c,d);
  s:=0;
  fillchar(e1,sizeof(e1),false);
  fillchar(e2,sizeof(e2),false);
  for i:=a to b-1 do e1[i]:=true;
  for i:=c to d-1 do e2[i]:=true;
  for i:=0 to 100 do if (e1[i]=true)and(e2[i]=true) then inc(s);
  writeln(s);
end.

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

using namespace std;

class UnionFind {
 private:
  std::vector<int> parent;

 public:
  UnionFind(int n) : parent(n, -1) {}

  int root(int x) {
    if (parent[x] < 0) return x;
    return parent[x] = root(parent[x]);
  }

  bool is_same(int x, int y) { return root(x) == root(y); }

  int size(int x) { return -parent[root(x)]; }

  bool unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) std::swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (auto&& e : A) {
    cin >> e;
  }
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    uf.unite(u, v);
  }
  if (N < 2 * (N - M - 1)) {
    cout << "Impossible" << '\n';
    return 0;
  }
  if (uf.size(0) == N) {
    cout << 0 << '\n';
    return 0;
  }
  map<int, vector<int>> mp;
  for (int i = 0; i < N; i++) {
    mp[uf.root(i)].emplace_back(A[i]);
  }
  vector<int> vec;
  int64_t res = 0;
  for (auto&& [k, v] : mp) {
    sort(v.begin(), v.end());
    res += v.front();
    for (int i = 1; i < (int)v.size(); i++) {
      vec.emplace_back(v[i]);
    }
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < (int)mp.size() - 2; i++) {
    res += vec[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 10012
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 100010
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
  char a,b,c;
  int num=0;
  cin>>a>>b>>c;
  if (a=='1')
    num++;
  if (b=='1')
    num++;
  if (c=='1')
    num++;
    cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * Author: Anmol Choudhary
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    map<string,int>mp;
    rep0(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    int mx=-1;
    for(auto it=mp.beg;it!=mp.en;++it){
        mx=max(mx,it->s);
    }
    for(auto it=mp.beg;it!=mp.en;++it){
        if(it->s==mx) cout<<it->f<<"\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m,k;cin>>n>>m>>k;
	if(n+m+k > 21){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
	return 0;
}


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

const int INF = 1001001001;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    ll ans = 1000;
    ll tmp = a[0];
    rep(i, 1, n){
        if(a[i] <= tmp) tmp = a[i];
        else{
            ans = ans%tmp + (ans/tmp)*a[i];
            tmp = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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


int main (){
    cout << fixed << setprecision(8);
    ll n;
    cin >> n;
    priority_queue<double , vector<double>,greater<double>> a;
    

    rep(i,n)  {
        double b;
        cin >> b;
        a.push(b);
        
    }

    rep(i,n-1){
        double b=0;
        b+=a.top();
        a.pop();

        b+=a.top();
        a.pop();

        b /= 2;
        a.push(b);

    }

    cout << a.top() << endl;


}

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

typedef long long ll;


int main() {
	ll W,H;
	cin>>W>>H;
	ll x,y;
	cin>>x>>y;
	float ans1 = W*H/2.0;
	int ans2 = 0;
	if(2*x == W&& 2*y == H){
		ans2 = 1;
	}
	cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();
        String[] NMC = line.split(" ");
        int N = Integer.parseInt(NMC[0]);
        int M = Integer.parseInt(NMC[1]);
        int C = Integer.parseInt(NMC[2]);
        
        line = scan.nextLine();
        String[] B_str = line.split(" ");
        int[] B = new int[M];
        for (int i = 0; i < M; i++) {
            B[i] = Integer.parseInt(B_str[i]);
        }
        
        int count = 0;
        for (int i = 0; i < N; i++) {
            line = scan.nextLine();
            String[] A_str = line.split(" ");
            int num = 0;
            
            int[] A = new int[M];
            for (int j = 0; j < M; j++) {
                A[j] = Integer.parseInt(A_str[j]);
                num += A[j] * B[j];
            }
            num += C;
            if (num > 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	string s;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> s;
			if(s == "snuke"){
				printf("%c%d\n", 'A'+j, i+1);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n = ri()
    for a in range(1, 10):
        for b in range(1, 10):
            if a*b == n:
                print("Yes")
                return
    print("No")


if __name__ == '__main__':
    main()


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

fun solve(N: Int, L: IntArray){
    // 2つ長さa, b(a < b)を選んで、b <= c < a + bなるcを探す
    val sortedLengths = L.sorted()
    val lmax = sortedLengths.last()
    var ans = 0
    for(i in 0 until N){
        for(j in i + 1 until N){
            val (a, b) = sortedLengths[i] to sortedLengths[j]
            ans += sortedLengths.lowerBound(a + b) - j - 1
        }
    }
    println(ans)
    return
}

fun <T : Comparable<T>> List<T?>.lowerBound(
        element: T,
        fromIndex: Int = 0,
        toIndex: Int = size
): Int {
    var low = fromIndex
    var high = toIndex
    while (low < high) {
        val mid = (low + high) / 2
        if (element <= this.get(mid)!!) {
            high = mid
        } else {
            low = mid + 1
        }
    }
    return low
}


fun <T : Comparable<T>> List<T?>.upperBound(
        element: T,
        fromIndex: Int = 0,
        toIndex: Int = size
): Int {
    var low = fromIndex
    var high = toIndex
    while (low < high) {
        val mid = (low + high) / 2
        if (element >= this.get(mid)!!) {
            low = mid + 1
        } else {
            high = mid
        }
    }
    return low
}




fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val L = IntArray(N)
    for (i in 0 until N) {
        L[i] = sc.next().toInt()
    }
    solve(N, L)
}



Measured memory_bytes: 41244
#include<bits/stdc++.h>
using namespace std;
int side[4];
int main()
{
	int i;
	for(i=0;i<3;i++)
		scanf("%d",&side[i]);
	sort(side,side+3);
	printf("%d",side[0]*side[1]/2);
	return 0;
} 

Measured memory_bytes: 256
N,M=map(int,input().split())
shi=[[] for i in range(N+1)]
py=[]
for i in range(M):
    p,y=map(int,input().split())
    shi[p].append(y)
    py.append([p,y])
for i in range(N+1):
    shi[i].sort()
shidic=[{} for i in range(N+1)]
for i in range(N+1):
    for j in range(len(shi[i])):
        shidic[i][shi[i][j]]=j+1
for P,Y in py:
    print(str(P).zfill(6)+str(shidic[P][Y]).zfill(6))

Measured memory_bytes: 70236
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin
N = int(F.readline())

for i in range(1, N+1):
    if N % i == 0:
        A = i
        B = N / i
        if A < 10 and B < 10:
            print('Yes')
            sys.exit()

print('No')


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n>>m;
    	if(n==1||m==1)
    	{
    		cout<<1;
    		return 0;
    	}
    	ll x=(n*m+1)/2;
    	cout<<x;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, ans = 0;
  scanf("%d", &n);
  int a[n], b[n], c[n-1];
  for (int i=0; i<n; i++) {
    scanf("%d", a+i);
  }
  for (int i=0; i<n; i++) {
    scanf("%d", b+i);
  }
  for (int i=0; i<n-1; i++) {
    scanf("%d", c+i);
  }
  ans += b[0];
  for (int i=1; i<n; i++) {
    ans += b[i];
    if (a[i]-a[i-1]==1) {
      ans += c[a[i-1]-1];
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
S = input()
cnt = 0
Rl = 0
L = 0
R = 0
ans = [0]*(len(S))
for i in range(len(S)):
    if i == len(S) - 1 or (S[i] == 'L' and S[i+1] == 'R'):
        cnt += 1
        ans[L] = cnt//2 + (cnt&1 and 1 - Rl&1)
        ans[R] = cnt//2 + (cnt&1 and Rl&1)
        cnt = 0
        Rl = 0
    else:
        cnt += 1
        if S[i] == 'R':
            Rl += 1
        if S[i] == 'R' and S[i+1] == 'L':
            R = i
            L = i+1
print(' '.join([str(i) for i in ans]))


Measured memory_bytes: 10492
#abc142d

def gcd(x,y):
 while y:
  x,y=y,x%y
 return x

a,b=map(int,raw_input().split())
z=gcd(a,b)
s=set()
i=2
while i*i<=z:
 while z%i==0:
  s.add(i)
  z/=i
 i+=1
if z>1:
 s.add(z)
print len(s)+1


Measured memory_bytes: 2568
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll mad=998244353;
int ans;
int n,m,a,b;
bool c[101]={};
string x;
int main() {
	for(int i=1;i<=9;++i){
		for(int j=1;j<=9;++j){
			c[i*j]=1;
		}
	}
	cin>>a;
	if(c[a]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv;

void main() {
  long x, y;
  auto s = map!(x => x.to!long)(readln.chomp.split);
  x = s[0];
  y = s[1];
  long res = 0;
  while (x <= y) {
    x *= 2;
    ++res;
  }
  writeln(res);
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {

    int a, b;
    char op;
    cin >> a >> op >> b;

    if (op == '+') {
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }

}

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

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  if(a+k-1>=b-k){
    for(int i=a;i<=b;i++){
      cout<<i<<endl;
    }
  }else{
    int count=1;
    for(int i=a;count<=k;i++){
      count++;
      cout<<i<<endl;
    }
    count=1;
    for(int i=b-k+1;count<=k;i++){
      count++;
      cout<<i<<endl;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include <stack>
 
using namespace std;
 
int main(void)
{
	char st[200000];
	stack <char> po;
	int i;
	scanf("%s",st);
 
	for(i = 0;i<strlen(st);i++){
		if(st[i]=='C' && po.empty()){
			po.push('C');
		}
		if(st[i]=='F' && !po.empty() && po.top() == 'C'){
			po.push('F');
		}
	}
 	
 	if((int)po.size()>=2){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
 
	return 0;
 
}

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 a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,i,k;
    cin>>a>>b>>c;
    i=0;
    k=0;
        while(1){
            if(i>=c){break;}
        i=i+a;
        k=k+1;
        if(k%7==0){i=i+b;}
    }
    cout<<k<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int main(){

int a;
int b;
cin>>a>>b;
if(a<b){

cout<<"a < b"<<endl;

}else if(a>b){

cout<<"a > b"<<endl;

}else if(a==b){

cout<<"a == b"<<endl;


}
return 0;


}

Measured memory_bytes: 1160
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 5) / 2 + 1
    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private def innerLoop(j: Int, p: Int): Unit = {
      if(j <= top){
        setCmpst(j)
        innerLoop(j + p, p)
      }
    }

    private def loop(i: Int): Unit = {
      if(i <= sqrtLimit){
        if(isPrime(i)){
          val p = 2 * i + 3
          innerLoop((p * p - 3) >>> 1, p)
        }
        loop(i + 1)
      }
    }

    private def next(i: Int): Int =
      if ((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      loop(0)
      Iterator.single(2) ++ Iterator.single(3) ++ Iterator.iterate(5)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else if(n==2)println(1)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65916
N,A,B,C,D=map(int,input().split())
S=input()
if '##' in S[A-1:C] or '##' in S[B-1:D]:
    print('No')
    exit()

if C<D:
    print('Yes')
else:
    cnt=0
    for i in range(B-1,D):
        if S[i-1]==S[i] and S[i]==S[i+1] and S[i]=='.':
            print('Yes')
            exit()
    print('No')

Measured memory_bytes: 9384