akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using pll = pair<long long, long long>; // (right edge, damage)

int N;
long long D, A;
vector<long long> X, H;


int main() {
    cin >> N >> D >> A;
    X.resize(N); H.resize(N);
    for (int i = 0; i < N; ++i) cin >> X[i] >> H[i], H[i] = (H[i]+A-1)/A;

    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return X[i] < X[j];});

    long long res = 0;
    queue<pll> que;
    long long damage = 0;
    for (auto i : ids) {
        while (!que.empty() && que.front().first < X[i]) {
            damage -= que.front().second;
            que.pop();
        }
        H[i] -= damage;
        if (H[i] <= 0) continue;
        long long attack = H[i];
        res += attack;
        que.push({X[i] + D*2, attack});
        damage += attack;

        //cout << i << ": " << H[i] << ", " << attack << endl;
    }
    cout << res << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const long long  mod = 1000000007;



int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> acum(n+1);

  acum[0] = 0;
  rep(i,n) {
    cin >> a[i];
    a[i] %= mod;
    acum[i+1] += a[i]+acum[i];
    acum[i+1] %= mod;
  }

  ll ans = 0;

  rep(i,n-1){
    ans += (a[i]*(acum[n] - acum[i+1]+mod));
    ans %= mod;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
#define pb push_back
#define mem(a, b) memset(a, b, sizeof(a))
 
int main() {
    int q;
    LL a, b, ans;
    scanf("%d", &q);
    while (q--) {
        scanf("%lld%lld", &a, &b);
        if (a > b) swap(a, b);
        if (a == b) {
            ans = 2 * (a - 1);
        }
        else if (a == b - 1) {
            ans = 2 * (a - 1);
        }
        else {
            LL c = sqrt(a * b);
            if (c * c == a * b) c--;
            if(c * (c + 1) >= a * b) {
                ans = 2 * c - 2;
            }
            else {
                ans = 2 * c - 1;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)

class UnionFind:
    def __init__(self,N):
        self.par = [i for i in range(N)]

    def root(self,x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        if self.rx == self.ry:
            return
        self.par[self.rx] = self.ry

    def same(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        return self.rx == self.ry

N,M = [int(i) for i in input().split()]
uf = UnionFind(N)

for _ in range(M):
    x,y,_ = [int(i)-1 for i in input().split()]
    uf.unite(x,y)

ans = set()
for i in range(N):
    ans.add(uf.root(i))
print(len(ans))


Measured memory_bytes: 30248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<ll> a(n),f(n);
    rep(i,n) cin >>a[i];
    rep(i,n) cin >>f[i];

    sort(all(a));
    sort(all(f), greater<ll>());

    auto check = [&](ll x){
        ll ct = 0;
        rep(i,n){
            ll A = x/f[i];
            ct += max(0LL, a[i]-A);
        }
        return ct<=k;
    };

    ll ng=-1, ok=LLONG_MAX/3;
    while(ok-ng>1){
        ll mid = (ok+ng)/2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << "\n";
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  string a,b,c;
  cin>>a>>b>>c;
  
  int ans=0;
  
  for(int i=0;i<n;i++){
  		set <char> s;
    s.insert(a[i]);
    s.insert(b[i]);
    s.insert(c[i]);
    ans+=(s.size()-1);
  }
  
  cout<<ans;
	return 0;
}

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


typedef long long ll;

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

    ll n = 0, k = 0;
    cin >> n >> k;
    vector<int> v(n, 0);

    while(k --) {
        ll temp = 0;
        cin >> temp;
        ll t = 0;
        for(int i = 0; i < temp; i++) {
            cin >> t;
            v[t - 1] = 1;
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if(v[i] == 0) ans ++;
        // cout << v[i] << " ";
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> you(100);
  for(int i = 0;i < n;i++){
    cin >> you.at(i);
  }
  for(int i = n;i > 1 ;i--){
    cout << you.at(i - 1) << " ";
  }
  cout << you.at(0) << endl;
}


Measured memory_bytes: 3096
#pragma region template 1.0
#pragma region def
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion enddef

int main()
{
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << ' ' << Y << ' ' << Z << endl;
}
#pragma endregion template

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

int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    vector<ll> c(n),lv(m,0);
    vector<vector<ll>> a(n,vector<ll>(m));
    for (ll i = 0; i < n; i++){
        cin >> c[i];
        for (ll j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    ll ans = 50000000;
    ll price = 0;
    bool flag = true;
    bool flag2 = false;
    for (ll bit = 0; bit < (1<<n); bit++){
        price = 0;
        flag = true;
        for (ll i = 0; i < m; i++){
            lv[i] = 0;
        }

        for (ll i=0; i<n; i++){
            if (bit & (1<<i)){
                price += c[i];
                for (ll j = 0; j < m; j++){
                    lv[j] += a[i][j];
                }
            }
        }
        for (ll j = 0; j < m; j++){
            if (lv[j] < x){
                flag = false;
            }
        }
        if (flag){
            ans = min(ans,price);
            flag2 = true;
        }
    }
    if (flag2){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3604
// abc164_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    set<string> st;
    REP(i, N){
        string s;
        cin >> s;
        st.insert(s);
    }

    print(st.size());

    return 0;
}


Measured memory_bytes: 19252
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll unsigned long long

const ll MOD = 1000000000000000000;

int main() {
	//入力
	int n;
	cin >> n;
	vector<pair<int,int>> red(n), blue(n);
	rep(i, n)  cin >> red[i].first >> red[i].second;
	rep(i, n)  cin >> blue[i].first >> blue[i].second;

	//処理
	sort(blue.begin(), blue.end());
	int ans = 0;
	rep(b, n) {
		int ymax = -1;
		int rmax = 0;
		rep(r, n) {
			if (red[r].first < blue[b].first && red[r].second < blue[b].second) {
					//x,yとも小さい
				if (ymax < red[r].second) {
					ymax = red[r].second;
					rmax = r;
				}
			}
		}
		if (ymax >= 0) {
			++ans;
			red[rmax].first = INT_MAX;
		}
	}


	//出力
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3556
//winnable
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n,m;
	cin>>n>>m;
	cout<<(n*(n-1))/2+(m*(m-1))/2<<'\n';
}
int main()
{
	int t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 256
open System

[<EntryPoint>]
let main argv =
    let s = Console.ReadLine().ToCharArray()
    (if s 
        |> Array.groupBy (fun x -> x) 
        |> Array.forall (fun (key, elems) -> elems |> Array.length = 2) then 
        "Yes" 
    else 
        "No") |> Console.WriteLine
    0

Measured memory_bytes: 14176
import sys

input = sys.stdin.readline
H, W, M = map(int,input().split())
q=set(tuple(map(lambda x :int(x)-1,input().split())) for _ in range(M))

X = [0] * H
Y = [0] * W

for i, j in q:
    X[i] += 1
    Y[j] += 1
    
def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

xm = max(X)
ym = max(Y)
xms = my_index_multi(X, xm)
yms = my_index_multi(Y, ym)

ans = xm + ym - 1

bl = False
for i in xms:
    for j in yms:
        if not (i, j) in q:
            print(ans + 1)
            sys.exit()
            bl = True
            
print(ans)

Measured memory_bytes: 83412
{-# LANGUAGE TupleSections #-}

import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as C
import Data.Graph
import qualified Data.IntMap.Strict as M
import Data.List
import Data.Ord
import qualified Data.Set as S
import Data.Tree

main = sub =<< get

sub [n,m] = sol n m <$> replicateM m get >>= print

get = unfoldr (C.readInt . C.dropWhile (<'0')) <$> C.getLine 

sol n m es = S.size (s `S.difference` c)
  where
  g = buildG (1,n) $ concatMap (\[u,v] -> [(u,v),(v,u)]) es
  t = head $ dff g
  s = S.fromList $ dfs t
    where
    dfs t = f t ++ concatMap dfs (subForest t)
    f t = fmap ((rootLabel t,) . rootLabel) (subForest t)
  bs = filter (`S.notMember` s) $ fmap ((\[u,v] -> (u,v)) . sortBy (comparing (lvl!))) es
  lvl = array (1,n) . concat . zipWith (\i -> fmap (,i)) [1..] $ levels t
  r = M.fromList . map (\(p,c) -> (c,p)) $ S.toList s
  pth ps u v 
    | u==v      = ps
    | otherwise = pth ((v',v):ps) u v' where v' = r M.! v
  c = S.fromList $ concatMap (uncurry (pth [])) bs

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

void fail(){
    cout << -1 << endl;
    exit(0);
}

int main(){
    int N, B[100];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> B[i];
        B[i]--;
    }
    int A[100];
    for(int i=0; i<N; i++) A[i] = -1;

    for(int i=N-1; i>=0; i--){
        int d = i - B[i];
        bool ok = false;
        for(int j=N-1; j>=0; j--){
            if(d == 0 && A[j] == -1){
                ok = true;
                A[j] = B[i];
                break;
            }else if(A[j] == -1){
                d--;
            }
        }
        if(!ok) fail();
    }
    for(int i=0; i<N; i++) cout << A[i]+1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		String []s = new String [n];
		int anum = 0;;
		int []ab = new int [n];
		int bnum = 0;
		int abnum = 0;
		
		for(int i = 0 ; i < n ;i++) {
			s[i] = sc.next();
		}
		
		for(int i = 0 ; i < n ; i++) {
			if(s[i].charAt(0) == 'B' && s[i].charAt(s[i].length()-1) == 'A') abnum++;
			else if(s[i].charAt(0) =='B') bnum++;
			else if(s[i].charAt(s[i].length()-1) == 'A')	anum++;
			for(int j = 0 ; j < s[i].length()-1 ; j++) {
				if(s[i].charAt(j) == 'A' && s[i].charAt(j+1) == 'B') ab[i]++;
			}
		}
		
		
		int ans = 0;
		
		for(int i = 0; i < n ;i++) {
			ans += ab[i];
		}
		if(abnum == 0) {
			ans += Math.min(anum, bnum);
		}
		
		else {
			ans += abnum;
			if(anum == 0 && bnum == 0) {
				ans--;
			}
			else if(anum != 0 && bnum != 0) {
				ans += Math.min(anum, bnum);
			}
		}
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 31204
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll dp[1001][1001];
char a[1001][1001];
int n,m;
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,n)
	rep(j,m)
	cin>>a[i][j];
	dp[0][0]=1;
	rep(i,n){
		if(a[i][0]=='#')
		break;
		dp[i][0]=1;
	}
	rep(i,m){
		if(a[0][i]=='#')
		break;
		dp[0][i]=1;
	}
	forn(i,1,n)
	forn(j,1,m){
		if(a[i][j]=='#')
		continue;
		dp[i][j]=dp[i-1][j]+dp[i][j-1];
		dp[i][j]%=mod;
	}
	cout<<dp[n-1][m-1];
	re 0;
}

Measured memory_bytes: 9088
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
a = np.array(sys.stdin.readline().split(), dtype=np.int64)
a -= np.arange(1, n + 1)
a.sort()

def main():
    b = a[n//2]
    print(np.absolute(a - b).sum())

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 35748
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>

typedef long long ll;
using namespace std;

ll DENOM = 1000000007L;
int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int> > grd;
    for(int i=0; i<h; ++i){
        string s;
        cin >> s;
        vector<int> pgrd;
        for(auto ss : s){
            pgrd.push_back(int(ss=='#'));
        }
        grd.push_back(pgrd);
    }
    vector<vector<int> > hs(h, vector<int>(w, 0));
    vector<vector<int> > vs(h, vector<int>(w, 0));
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            if (grd[i][j] == 1) continue;
            if(hs[i][j]==0){
                int hs_tmp=0;
                for(int ctr = j; ctr < w; ++ctr){
                    if(grd[i][ctr] ==1) break;
                    hs_tmp++;
                }
                for(int ctr = j; ctr < w; ++ctr){
                    if(grd[i][ctr] ==1) break;
                    hs[i][ctr] = hs_tmp;
                }
            }
            if(vs[i][j]==0){
                int vs_tmp=0;
                for(int ctr = i; ctr < h; ++ctr){
                    if(grd[ctr][j] ==1) break;
                    vs_tmp++;
                }
                for(int ctr = i; ctr < h; ++ctr){
                    if(grd[ctr][j] ==1) break;
                    vs[ctr][j] = vs_tmp;
                }
            }
        }
    }
    vector<int> score;
    for(int i=0; i<h ;++i){
        for(int j=0; j<w; ++j){
            score.push_back(vs[i][j]+hs[i][j]-1);
        }
    }
    cout << *max_element(score.begin(), score.end()) << endl;
    return 0;
}


Measured memory_bytes: 65916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  long res;
  vector<int> t(60);
  
  res = 0;
  
  cin >> n;
  
  for (int i = 0;i<n;++i){
   cin >> t.at(i); 
  }
  
  for (int j = 0;j<n;++j){
    for (int k = j+1;k<n;++k){
      res += t.at(j)*t.at(k);
  }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;
int A[MAX]={};
int main() {
  int n,k;
  cin >> n >> k;
  for(int i=0;i<n;i++) {
    int a;
    cin >> a;
    A[a]++;
  }
  vector<int> S;
  for(int i=1;i<=200000;i++) {
    if(A[i] != 0) {
      S.push_back(A[i]);
    }
  }
  sort(S.begin(), S.end());

  int count=S.size(), j=0, max=0;
  while(count > k) {
    count -= 1;
    max += S[j++];
  }
  cout << max << endl;

  return 0;
}

Measured memory_bytes: 2168
import copy
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, K = LI()
x = [0]*N; y = [0]*N
for i in range(N):
    x[i], y[i] = LI()

X = copy.deepcopy(x); Y = copy.deepcopy(y)
X.sort(); Y.sort()

Xcandi = [0]*2; Ycandi = [0]*2
ylower = 0; yupper = N-1; ycur = (ylower+yupper)//2
ansC = []
for i in range(N-1):
    Xcandi[0] = X[i]
    for j in range(i+1,N):
        Xcandi[1] = X[j]
        for k in range(N-1):
            ylower = k+1; yupper = N - 1; ycur = (ylower + yupper) // 2
            Ycandi[0] = Y[k]
            while(True):
                cur = int(0)
                Ycandi[1] = Y[ycur]
                for l in range(N):
                    if Xcandi[0] <= x[l] <= Xcandi[1] and Ycandi[0] <= y[l] <= Ycandi[1]:
                        cur += 1
                if yupper - ylower >= 2:
                    if cur < K:
                        ylower = ycur
                        ycur = (ycur + yupper) // 2
                    else:
                        yupper = ycur
                        ycur = (ycur + ylower) // 2
                else:
                    cur = int(0)
                    Ycandi[1] = Y[yupper]
                    for l in range(N):
                        if Xcandi[0] <= x[l] <= Xcandi[1] and Ycandi[0] <= y[l] <= Ycandi[1]:
                            cur += 1
                    if cur < K:
                        break
                    else:
                        cur = int(0)
                        Ycandi[1] = Y[ylower]
                        for l in range(N):
                            if Xcandi[0] <= x[l] <= Xcandi[1] and Ycandi[0] <= y[l] <= Ycandi[1]:
                                cur += 1
                        if cur < K:
                            Ycandi[1] = Y[ylower+1]
                    cur = (Xcandi[1] - Xcandi[0])*(Ycandi[1] - Ycandi[0])
                    ansC.append(cur)
#                    print(Xcandi,Ycandi)
                    break


#print(ansC)
print(min(ansC))


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans=0;
	for(int i=0;i<n;++i){
		int l,r; cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
	int main() {
		long long n,goukei=0,saidai=0,saisyou=0,flag=1;
		cin >> n;
		long long a[10000];			

		while (n > 0) {
			cin>>a[n];
			if (flag==1) {
				saisyou = a[n];
				saidai = a[n];
			}
		
		    

			goukei += a[n];
			if (saidai<a[n]) {
			
				saidai = a[n];

			}
			if (saisyou>a[n]){
			
				saisyou = a[n];
			
			}
			n--;
			flag = 0;
		}
		cout << saisyou<<" "<< saidai<<" "<< goukei<<endl;
		return 0;

		

}

Measured memory_bytes: 1236
// Author       : Naresh Bharasagar
            // CF Handle    : Nareshhhh
            // Programme    : B.Tech Computer Science & Engineering
            // Organization : Indian Institute of Technology Guwahati

#include<bits/stdc++.h>
using namespace std;
typedef long long int loo;


#define loop(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define rep(r) for(auto i=1; i<=r; ++i)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define v(name,type,size) vector<type> name(size)
#define vloo vector<loo>
#define outa(a,n) loop(i,0,n) cout << a[i] << " ";
#define p0(a) cout << #a << endl
#define mod(a) a%1000000007
#define pb(l) push_back(l)
#define ppb pop_back()
#define ff first
#define ss second
#define input(a) for(auto &i: a) cin >> i;
#define prnt(v) for(auto it: v) cout << it << " ";
#define deb0(i) cout << "[i=" << i << "]" << endl;
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define INF 1000000000
#define M 1000000007

loo power(loo x, loo y, loo p) { 
    loo res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

bool sortbysec(const pair<loo,loo> &a, const pair<loo,loo> &b) { 
    return (a.second < b.second); 
}

string decToBin(loo n)
{
	string s = "0";
	if(n == 0) return s;
	s = "";
    while (n > 0)
    { 
        s += (n % 2) + '0';
        n = n / 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
 
loo binToDec(string s)
{
    loo ans = 0;
    reverse(s.begin(), s.end());
    loop(i, 0, s.size())
    {
    	ans += pow(2, i)*(s[i] - '0');
    }
    return ans;
}

int main() {
	fast_io

    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);

    loo n;
    cin >> n;
    loo a[n];
    input(a);
    bool f=true;
    loop(i,0,n) {
        if(a[i]%2==0) {
            if(a[i]%3==0 || a[i]%5==0) continue;
            else {
                cout << "DENIED" << endl;
                f=false;
                break;
            }
        }
    }
    if(f) cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n;
    cin>>n;
    ll ans = INF;
    for(int i = 1; i <= sqrt(n); i++) if(n%i==0 and i+n/i < ans) ans = i+n/i;
    cout<<ans-2<<endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_7_A2
{
    class Program
    {
        static void Main(string[] args)
        {
            //中間試験の点数m、期末試験の点数f、再試験の点数r
            //m,f≤50、r≤100
            //試験を受けていない場合　点数は-1

            //F：中間試験と期末試験のいずれかを欠席 or 中間試験と期末試験の合計が30未満
            //A：中間試験と期末試験の合計が80以上
            //B：中間試験と期末試験の合計が65以上80未満
            //C：中間試験と期末試験の合計が50以上65未満
            //D：中間試験と期末試験の合計が30以上50未満　再試が50以上でC
            ///////////////////////////////////////////////////////////////////////////

            //以下の手順を繰り返す

            Score judge= new Score();
            List<string> record = new List<string>();       //成績を格納するString型Listの変数recordを宣言

            while (true)                                    //break条件にならない限り以下を繰り返す
            {
                string[] score = Console.ReadLine().Split(' ');
                int m = int.Parse(score[0]);
                int f = int.Parse(score[1]);
                int r = int.Parse(score[2]);

                //m,f,rがすべて-1の時　処理を終了
                if (m == -1 && f == -1 && r == -1)
                {
                    break;
                }

                //そうでないとき
                else
                {
                    judge.ScoreJudge(m, f, r, record);
                }
            }
            foreach (string i in record)
            {
                Console.WriteLine(i);
            }
        }
    }
    class Score
    {
        public void ScoreJudge(int m, int f, int r, List<string> record)
        {
            if (m + f < 30 || m == -1 || f == -1)    //Fの場合
            {
                record.Add("F");
            }

            else if (80 <= m + f)                             //Aの場合
            {
                record.Add("A");
            }

            else if (65 <= m + f && m + f < 80)         //Bの場合
            {
                record.Add("B");
            }

            else if (50 <= m + f && m + f < 65)         //Cの場合
            {
                record.Add("C");
            }

            else if (30 <= m + f && m + f < 50)         //Dの場合
            {
                if (50 <= r)
                {
                    record.Add("C");
                }
                else
                {
                    record.Add("D");
                }
            }
        }
    }
}




Measured memory_bytes: 15964
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
using namespace std;
int dp[101][10001], w[101], v[101], n;
int main() {
	int W;
	cin >> n;
	cin >> W;
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = n; i >= 0; i--) dp[i][W] = 0;
	for (int j = W; j >= 0; j--) dp[n][j] = 0;
	for (int i = n - 1; i >= 0; i--)
		for (int j = 0; j <= W; j++) {
			if (w[i] > j) dp[i][j] = dp[i + 1][j];
			else dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
		}
	cout << dp[0][W] << endl;
	return 0;
}

Measured memory_bytes: 7028
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>
#include<functional>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define EPS 1e-9
#define PI 3.14159265359
const ll mod = 1000000007;
const ll OO = (ll)1e9;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(ll base, ll power){
	if (power == 0)
		return 1;
	if (power == 1)
		return (base % mod);
	if (power % 2 == 0)
		return (fast_power(((base*base) % mod), power / 2LL) % mod);
	else return ((base*fast_power(((base*base) % mod) % mod, power / 2LL)) % mod);
}
//#pragma warning (disable : 4996)
void Qalbaz()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(3);
}

int main(){

	Qalbaz();

	ll n, x, y, ans = OO, a, b;
	cin >> n;
	for (ll i = 1; i*i <= n; i++)
	{
		if (n % i == 0)
		{
			x = i;
			y = n / i;
			a = 0, b = 0;
			while (x)
				a++, x /= 10;
			while (y)
				b++, y /= 10;
			ans = min(ans, max(a, b));
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int f[15][15];

void findKth(int k, int i, int j)
{
    putchar(j + '0');
    if(i == 1) return;
    if(j)
    {
        if(k <= f[i - 1][j - 1])
        {   
            findKth(k, i - 1, j - 1);
            return;
        }
        else k -= f[i - 1][j - 1];
    }
    if(k <= f[i - 1][j])
    {
        findKth(k, i - 1, j);
        return;
    }
    findKth(k - f[i - 1][j], i - 1, j + 1);
}

int main()
{
    int k; scanf("%d", &k);
    if(k < 10) return printf("%d", k), 0;
    for(int i = 0; i < 10; i++)
        f[1][i] = 1;
    for(int i = 2; i <= 10; i++)
    for(int j = 0; j < 10; j++)
    {
        f[i][j] = f[i - 1][j];
        if(j) f[i][j] += f[i - 1][j - 1];
        if(j < 9) f[i][j] += f[i - 1][j + 1];
    }
    int x = k - 9;
    for(int i = 2; i <= 10; i++)
    for(int j = 1; j < 10; j++)
    {
        if(x <= f[i][j]) {findKth(x, i, j); goto END;}
        x -= f[i][j];
    }
    END: return 0;
}

Measured memory_bytes: 128
#include  "bits/stdc++.h"
//#include  <iostream>
 using namespace std;
 
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define mem(a,v)    memset((a), (v), sizeof (a))
#define FOR(i,a,n)  for(int i = (a); i<(n); ++i) 
#define FORE(i,a,n) for(int i = (a); i<=(n); ++i)
#define mp(a , b)   make_pair(a , b)
#define pb(a)       push_back(a)

#define anal         '\n'

#define mod 1000000009


typedef long long ll;


 

int main(){
     
 IOS;
 
 #ifndef ONLINE_JUDGE  
    freopen("input.in", "r", stdin);
    freopen("output.in", "w", stdout);
 #else
// online submission
#endif 

 // -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
   
    int k , a, b;
     cin >> k >> a >> b;

      while(a <= b){
      	 if(a % k == 0){
      	 	  cout << "OK";
      	 	  return 0;
      	 }
        a++;
      }
      cout << "NG";
  return  0 ;      
}        


Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main () {
	int a,b;
	while(cin >> a >> b){
		int i = a + b;
		int n = 0;
		//cout << i / 10 << endl;
		while(i != 0){
			i /= 10;
			n++;
		}
		cout << n << endl;
	}

}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n;
map<long long,long long>q;
map<long long,long long>::iterator it;
long long  modl(long long a, long long b, long long c)        //快速幂取余a^b%c
{
	long long res=1;
	for(int i=0;i<b;i++)
	{
		res=res*a%c;
	}
	return res;
//    long long res, t;
//    res = 1 % c;
//    t = a % c;
//    while (b)
//    {
//        if (b & 1)
//        {
//            res = res * t % c;
//        }
//        t = t * t % c;
//        b >>= 1;
//    }
//    return res;
}
long long mod=1e9+7;
int main()
{
    q.clear();
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        long long num;
        cin>>num;
        q[num]++;
    }
    if(q[0]>1)
    {
        cout<<"0"<<endl;
    }
    else if(q[0]==1||q[0]==0)
    {
        int num=0;
        for(it=q.begin();it!=q.end();it++)
        {
            if(it->second==2)
            {
                num++;
            }
            else if(it->second>2)
            {
                cout<<"0"<<endl;
                return 0;
            }
        }
        num%=mod;
        cout<<modl(2,num,mod)%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans=0;
    ll l=1,r=n-1;
    if(n%2==1){
        ll lx=a[0],ly=a[0];
        ll rx,ry;
        while(l<r){
            rx=a[r],ry=a[r-1];
            r-=2;
            ans+=rx-lx;
            ans+=ry-ly;
            lx=a[l],ly=a[l+1];
            l+=2;
            ans+=rx-lx;
            ans+=ry-ly;
        }
        rx=a[n-1],ry=a[n-1];
        l=0,r=n-2;
        ll sum=0;
        while(l<r){
            lx=a[l],ly=a[l+1];
            l+=2;
            sum+=rx-lx;
            sum+=ry-ly;
            rx=a[r],ry=a[r-1];
            r-=2;
            sum+=rx-lx;
            sum+=ry-ly;
        }
        ans=max(ans,sum);
    }else{
        ll lx=a[0],rx=a[n-1];
        ans+=rx-lx;
        ll ly,ry;
        r=n-2;
        while(l<r){
            ry=a[r],ly=a[l];
            ans+=ry-lx;
            ans+=rx-ly;
            l++;
            r--;
            if(l>=r) break;
            rx=a[r],lx=a[l];
            ans+=rx-ly;
            ans+=ry-lx;
            r--;
            l++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include<stdio.h>
int main()
{
	int i=0,x=1,n,k;
	scanf("%d",&n);
	scanf("%d",&k);
	while(i<n)
	{
		if(x>k)
		{
			x=x+k;
		}
		if(x<=k)
		{
			x=x*2;
		}
		i++;
	}
	printf("%d\n",x);
	return 0;
}

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



Measured memory_bytes: 3640
function Main(input){
	input = input.split("\n");
  var TA = input[1].split(" ");
  var T = TA[0]*1;
  var A = TA[1]*1;
  var H = input[2].split(" ").map(a=>~~a).map(a=>Math.abs(T-a*0.006-A));
  var n = 0;
  var tmp = H[n];
  for(var i = 1; i < H.length;i++){
  	if(tmp > H[i]){
    	tmp = H[i]
     ;
     n = i;
    }
  }
  return n + 1;
}

console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7500
#include <stdio.h>
 
int main() {
    int i, A, K, N[200001];
    long long int tmp;
 
    scanf("%d%d", &A, &K);
    
    for (i = 0; i < A; i++) {
        scanf("%d", N + i);
    }
 
    for (i = K; i < A; i++) {
        if (N[i] >N[i - K]) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    
}

Measured memory_bytes: 2440
use std::io;
use std::collections::HashMap;


fn read_int() -> i64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf);
    let trlen = buf.trim_right().len();
    buf.truncate(trlen);
    if let Ok(v) = buf.parse::<i64>() {
        v
    } else {
        panic!("Failed to read integer")
    }
}


fn main() { 
    let n = read_int() as usize;
    let mut coll = vec![0; n];
    let mut orig: HashMap<i64, i64> = HashMap::new();
    let mut ans = 0;

    for i in 0..n {
        let tmp = read_int();
        coll[i] = tmp;
        orig.insert(tmp, i as i64);
    }

    coll.sort();


    for (i, el) in coll.iter().enumerate() {
        let tmp: i64 = match orig.get(el) {
            Some(val) => *val,
            None => 0 // Can't happen
        };
        if (i as i64 - tmp).abs() % 2 == 1 {
            ans += 1
        }
    }

    println!("{}", ans / 2);
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

int main() {
  long long x, y; cin >> x >> y;
  if(x > y) {
    cout << min(abs(x+y)+1, abs(x-y)+2) << endl;
  } else {
    cout << min(abs(x+y)+1, abs(x-y)) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    n = I()
    c = list(S())
    i,j = 0,n-1
    ans = 0
    while i<j:
        while c[i]=='R':
            i += 1
            if i==n-1:
                break
        while c[j]=='W':
            j -= 1
            if j==0:
                break
        if i<j:
            c[i],c[j] = c[j],c[i]
            i += 1
            j -= 1
            ans += 1
    print(ans)
    exit()

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

typedef long long ll;

int main(void)
{
    int num,i,j;
    cin>>num;
    int val;
    vector<int> number;
    for(i = 0; i < num; i++)
    {
        cin>>val;
        number.push_back(val);
    }
    sort(number.begin(),number.end());
    for(i = 0; i < num-1; i++)
    {
        if(number[i] == number[i+1])
        {
            cout<<"NO\n";
            return 0;
        }
    }
    cout<<"YES\n";
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, P, W, G, Y;
  cin >> N;
  P=0;
  W=0;
  G=0;
  Y=0;
  vector<char> S(N);
  for (int i=0; i<N; i++) {
    cin >> S[i];
  }
  for (int j=0; j<N; j++) {
    if (S[j]=='P') {
      P=P+1;
    }
    else {
      if (S[j]=='W') {
      	W=W+1;
      }
      else {
        if (S[j]=='G') {
          G=G+1;
        }
        else {
          Y=Y+1;
        }
      }
    }
  }
  if (P==0||W==0||G==0||Y==0) {
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

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

        int result = 0;
        for (int i = 1; i < 50000; i++) {
            int ans = i * 108 / 100;
            if (ans == n) {
                result = i;
                break;
            }
        }
        if (result != 0) {
            System.out.println(result);
        } else {
            System.out.println(":(");
        }
        sc.close();
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int now = 0;
    int left = 0;
    int right = 0;
    for (int i = 0;i < n;i++){
        if (s[i] == '(') now++;
        else if (s[i] == ')'){
            if (now > 0) now--;
            else left++;
        }
    }
    rep(i,left) s = '(' + s;
    rep(i,now) s+=')';

    cout << s << endl;

    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int cnt0 = 0;
    int cnt1 = 0;
    for (int i = 0; i < 2; i++){
        if (i == 0){
            for (int j = 0; j < s.size(); j++){
                if(j % 2 == 0 && s[j] != (char)(i + '0')) cnt0++;
                if(j % 2 != 0 && s[j] == (char)(i + '0')) cnt0++;
            }
        }
        else{
            for (int j = 0; j < s.size(); j++){
                if(j % 2 == 0 && s[j] != (char)(i + '0')) cnt1++;
                if(j % 2 != 0 && s[j] == (char)(i + '0')) cnt1++;
            }
        }
    }
    cout << min(cnt0, cnt1) << endl;
}  

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

int main(){
  int n ;
  cin >> n ;
  vector<float> v(n) ;
  for(int i=0; i<n; i++)
    cin >> v.at(i) ;
  sort(v.begin(),v.end());
  for(int i=1; i<n; i++){
    v.at(i) = (v.at(i)+v.at(i-1))/2 ;
  }
  cout << v.at(n-1) << endl ;
}

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

int main(void)
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a + b > c + d){cout << "Left" << endl;}
    else if(a + b == c + d){cout << "Balanced" << endl;}
    else{cout << "Right" << endl;}
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()

    val a = BooleanArray(1000)
    (1..9).forEach { i ->
        (1..9).forEach { j ->
            a[i * j] = true
        }
    }

    val ret = if (a[n]) "Yes" else "No"

    println(ret)
}

Measured memory_bytes: 31388
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll H, W;
    cin >> H >> W;
    if(H==1 || W==1){
        cout << 1 << el;
        return;
    }
    ll h1=W/2, h2=W/2;
    if(W%2){
        h1++;
    }
    ll sum = (h1+h2)*(H/2);
    if(H%2){
        sum += h1;
    }
    cout << sum << el;
}



Measured memory_bytes: 256
import re 
S=input()
def YM(S):
  if re.match("(00|1[3-9]|[2-9][0-9])(0[1-9]|1[0-2])",S):
    return "YYMM"
  elif re.match("(0[1-9]|1[0-2])(00|1[3-9]|[2-9][0-9])",S):
    return "MMYY"
  elif re.match("(0[1-9]|1[0-2])(0[1-9]|1[0-2])",S):
    return "AMBIGUOUS"
  else:
    return "NA"
print("{}".format(YM(S)))

Measured memory_bytes: 3188
n=int(input())
g=set()
for i in range(n):
    si=int(input())
    g2=set()
    for gg in g:
        g2.add(si+gg)
    g=g|g2
    g.add(si)
#    print(g2,g)

g3=list(g)
g3.sort(reverse=True)
for gg in g3:
    if gg%10!=0:
        print(gg)
        break
if gg%10==0:
   print(0)     

Measured memory_bytes: 5336
#include <iostream>

using namespace std;

int main()
{
	int w, h;
	int x, y, r;
	int c_u, c_d;	// 円の上、した
	int c_l, c_r;	// 円の左、右
	int flag;

	cin >> w >> h >> x >> y >> r;

	flag = 1;
	c_u = y + r;
	c_d = y - r;
	c_l = x - r;
	c_r = x + r;

	if(c_u <= h && 0 <= c_d && 0 <= c_l && c_r <= w)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

using namespace std;

int main(){
    double W,H,x,y;
    cin >> W >> H >> x >> y;

    cout << setprecision(35) << W*H/2.000000000<< " ";

    if(x == W/2.000000000 && y == H/2.000000000){
        cout << "1" << endl;
    }else{
        cout << "0" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int b,c,d,i,j,p[101][101];
	char a[101][101];
	scanf("%d%d",&b,&c);
	for(i=0;i<b;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<b;i++){
		d=-1;
		for(j=0;j<c;j++){
			if(a[i][j]=='c'){
				p[i][j]=0;
				d=0;
			}
			else if(d!=-1){
				++d;
				p[i][j]=d;
			}
			else{
				p[i][j]=-1;
			}
		}
	}
	for(i=0;i<b;i++){
		for(j=0;j<c;j++){
			printf("%d",p[i][j]);
			if(j!=c-1){
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2808
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, Z, W;
vi A;

int main() {
    cin >> N >> Z >> W;
    A.resize(N);
    rep(i, N) cin >> A[i];

    if (N == 1) {
        write(abs(A[0] - W));
    }
    else if (N == 2) {
        int ans = max(abs(A[0] - A[1]), abs(A[2] - W));
        write(ans);
    }
    else {
        int ans = max(abs(A[N - 1] - W), abs(A[N - 2] - A[N - 1]));
        write(ans);
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[5];
		sc.nextLine();
		while (n-- > 0) {
			String s = sc.nextLine();
			if (s.length() == 0) continue;
			switch (s.charAt(0)) {
				case 'M':
					a[0]++;
					break;
				case 'A':
					a[1]++;
					break;
				case 'R':
					a[2]++;
					break;
				case 'C':
					a[3]++;
					break;
				case 'H':
					a[4]++;
					break;
			}
		}

		long answer = 0;
		for (int i = 0; i < a.length - 2; i++) {
			for (int j = i + 1; j < a.length - 1; j++) {
				for (int k = j + 1; k < a.length; k++) {
					answer += a[i] * a[j] * a[k];
				}
			}
		}
		System.out.println(answer);

	}
}


Measured memory_bytes: 91484
A, B, M = map(int, input().split())
lis_a = list(map(int, input().split()))
lis_b = list(map(int, input().split()))
lis_price = []

lis_price.append(min(lis_a) + min(lis_b))

for i in range(M):
    x, y, c = map(int,input().split())
    lis_price.append(lis_a[x-1] + lis_b[y-1] - c)

print(min(lis_price))


Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

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

  LL sum = (LL)0;
  for (auto c: s) {
    sum += c - '0';
  }
  if (stoll(s) % sum == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }   
}


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

int main() {
	int N;
	std::cin >> N;
	std::vector<int> v(N);
	for (int i = 0; i < N; ++i) std::cin >> v[i];
	auto v2 = v;
	std::sort(v2.begin(), v2.end());
	int target = (N + 1) / 2 - 1;
	for (int i = 0; i < N; ++i) {
		if(v[i]<=v2[target])
			std::cout << v2[target + 1] << "\n";
		else
			std::cout << v2[target] << "\n";
	}
}

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

int main() {
  int A, B, C, p = 0;
  cin >> A >> B;
  C = A;
  
  for (int i = 0; i < B - A + 1; i++) {
    if (C % 10 == C/10000 % 10 and C/10 % 10 == C/1000 % 10 and C/1000 % 10 == C/10 % 10 and C/10000 % 10 == C % 10) {
      p += 1;
    }
	C++;
  }
  cout << p << endl;
}


Measured memory_bytes: 3636
h, w = map(int, input().split())

a = []
for i in range(h):
    s = input()
    if '#' in s:
        a.append(s)

b = [[a[x][y] for x in range(len(a))] for y in range(w)]
a = []
for x in b:
    if '#' in x:
        a.append(x)


for i in range(len(a[0])):
    for x in a:
        print(x[i], end='')
    print()


Measured memory_bytes: 4468