akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;

#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    freopen ("in.txt", "r", stdin);
#endif
}

const int NMAX = 2500;
vii G[NMAX],RG[NMAX];
ll dist[NMAX];
int NN;
bool visited[2][NMAX];


void add_edge(int a, int b, int w = 0) {
    G[a].emplace_back(b, w);
    RG[b].emplace_back(a,w);
}

void bellman_ford(int s) {
    dist[s] = 0;
    FOR(i,NN-1) {
        FOR(j,NN) {
            if(dist[j] != INFL) {
                for(auto it : G[j]) {
                    if (visited[0][it.first] && visited[1][it.first])
                        dist[it.first] = min(dist[it.first], dist[j] + it.second);
                }
            }
        }
    }
}

bool hasNegCycle() {
    FOR(j,NN) {
        if(dist[j] != INFL) {
            for(auto it : G[j]) {
                if (visited[0][it.first] && visited[1][it.first] && dist[it.first] > dist[j] + it.second) return true;
            }
        }
    }
    return false;
}

void dfs0(int node=0){
    visited[0][node]=1;
    for(ii c:G[node]){
        if (!visited[0][c.first])
            dfs0(c.first);
    }
}

void dfs1(int node=NN-1){
    visited[1][node]=1;
    for(ii c:RG[node]){
        if (!visited[1][c.first])
            dfs1(c.first);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int m,p;
    cin >> NN>>m>>p;
    fill(dist, dist + NN, INFL);
    FOR(i,m){
        int u,v,c;cin>>u>>v>>c;
        add_edge(u-1,v-1,p-c);
    }
    memset(visited,false,sizeof(visited));
    dfs0();
    dfs1();
    bellman_ford(0);
    cout << (hasNegCycle()?-1:max(0LL,-dist[NN-1]));

}


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

typedef long long int ll;
typedef unsigned long long int ull;

int main(){
    string s;
    cin>>s;
    bool Af = false,Bf = false;
    for(int i=0;i<3;i++) {
        if(s[i]=='A') Af=true;
        if(s[i]=='B') Bf=true;
    }
    if(Af and Bf) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
string s;
int x11, y11, x22, y22, x33, y33, x44, y44;
      
int main() {  
    ios::sync_with_stdio(false);
    cin >> x11 >> y11 >> x22 >> y22;
 
    int dx = x22 - x11;
    int dy = y22 - y11;
 
    x33 = x22 - dy;
    y33 = y22 + dx;
 
    x44 = x11 - dy;
    y44 = y11 + dx;
 
    cout << x33 << " " << y33 << " " << x44 << " " << y44 << endl;
  
    return 0;  
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
/*biginner 148 ~F~*/
/**/
int N;
vector<int> to[100005];
/*各頂点(index)と隣接している頂点の集合を表す隣接リスト*/

vector<int> dist;

void dfs(int v, int d = 0, int p = -1) {
	dist[v] = d;
	for (int u : to[v]) {
		if (u == p) continue;
		dfs(u, d + 1, v);
	}
}

vector<int> calcDist(int s) {
	dist = vector<int>(N); /*初期化*/
	dfs(s);
	return dist;
}/*DFSにより始点から各頂点への距離を計算する関数*/

int main() {
	cin >> N;
	int u, v;
	cin >> u >> v;
	--u; --v;
	for (int i = 0; i < N - 1; i++) {
		int A, B;
		cin >> A >> B;
		--A; --B;
		to[A].push_back(B);
		to[B].push_back(A);
	}/*input*/

	vector<int> dist_U = calcDist(u);
	vector<int> dist_V = calcDist(v);

	/*高橋君(v)が先に行ける頂点の中で
	青木君(u)から最も遠い頂点が答え*/
	int mx = 0;
	for (int i = 0; i < N; ++i) {
		if (dist_U[i] < dist_V[i]) {
			mx = max(mx, dist_V[i]);
		}
	}
	int ans = mx - 1;/*二人が合流する頂点は必ず
					 最深の一つ手前になる*/
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10744
#include"bits/stdc++.h"
using namespace std;
int main(){
    vector<int> A(3);
    for(int i=0;i<3;i++){
        cin>>A.at(i);
    }
    sort(A.begin(),A.end());
    cout<<A.at(0)<<" "<<A.at(1)<<" "<<A.at(2)<<endl;
}


Measured memory_bytes: 3104
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    ab = [list(map(int, input().split())) for _ in range(N)]
    ab.sort(key=lambda a: a[1])
    t = 0
    for a,b in ab:
        t += a
        if t>b:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 53972
program sum
    implicit none
    integer i,n,m,q,a(10),d(50,4),score1,flag
    read(*,*) n,m,q
    do i = 1, q
        read(*,*) d(i,1),d(i,2),d(i,3),d(i,4)
    end do

    do i = 1, n
        a(i)=1
    end do
    
    score1=0
    flag=n
    do while ( flag>0 )
        call routine(a,d,n,m,q,score1,flag)
    end do
    write(*,*) score1
end program sum

subroutine routine(a,d,n,m,q,score1,flag)
    implicit none
    integer :: a(10), d(50,4), n, m, q, j, score, score1, flag

    score=0
    if ( flag==n ) then
        do while (a(n)<=m)
            do j = 1, q
                if ( a(d(j,2))-a(d(j,1))==d(j,3) ) then
                    score=score+d(j,4)
                end if
            end do
            if ( score>score1 ) then
                score1=score
            end if
            score=0
            a(n)=a(n)+1
        end do
        flag=flag-1
    else if ( a(flag)<m ) then
        a(flag)=a(flag)+1
        do j = flag+1, n
            a(j)=a(flag)            
        end do
        flag=n
    else
        flag=flag-1
    end if
end subroutine routine

Measured memory_bytes: 2852
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
--import           Control.Monad.Loops
import           Data.IORef
import           Data.Maybe
import qualified Data.Text           as T
import qualified Data.Text.IO        as T
import           GHC.Base
import           System.IO

import qualified Data.Array          as A
import qualified Data.IntMap         as I
import           Data.List
import qualified Data.Map            as M
import qualified Data.Set            as S
import qualified Data.Vector         as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

-- main
main :: IO ()
main = buyingSweets

buyingSweets :: IO ()
buyingSweets = do
  x :: Int <- readLn
  a :: Int <- readLn
  b :: Int <- readLn
  print $ (x - a) `mod` b

Measured memory_bytes: 508
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    int res = 1;

    cin >> a >> b >> c;

    if (a >= b && a >= c) {
        if (b + c == a) cout << "Yes";
        else cout << "No";
    }
    else if (b >= a && b >= c) {
         if (a + c == b) cout << "Yes";
        else cout << "No";
    }
    else {
        if (a + b == c) cout << "Yes";
        else cout << "No";
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define read(x)	 freopen(x, "r", stdin);
#define write(x) freopen(x, "w", stdout);
// #define xihaad

int main()
 {
#ifdef xihaad
	read("input.txt");
	// write("output.txt");
#endif

string s;
cin>>s;
int l=s.length();
if(s[l-1]!='s')
cout<<s<<"s";
else
cout<<s<<"es";


   return 0;

}


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

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define REPR(i,a) for(int i = a; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
template<typename A> void psn(A a){ cout << a << endl; }
template<typename A, typename... B> void psn(A a, B... b){ cout << a << ' '; psn(b...); }

vector< vector<double> > d(8, vector<double>(8, 0.0));

int kaijou(int n){
    return n == 1 ? 1 : n * kaijou(n - 1);
}

int main(void) {

    int N;
    double sum = 0;
    cin >> N;

    vi x(N), y(N);

    REP(i, N) cin >> x[i] >> y[i];

    int p = kaijou(N - 1) * 2;
    
    REP(i, N){
        REPA(j, i, N){
            d[i][j] = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
            sum += d[i][j] * p;
        }
    }
    
    sum /= kaijou(N);
    
    cout << std::setprecision(20) << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n , m;
vector < int > v[N];
int mark[N];
int ans[N + N];
int ql , qr;
void dfs1(int node){
	for(int next : v[node]){
		if(!mark[next]){
			mark[next] = 1;
			ans[qr++] = next;
			dfs1(next);
			return;
		}
	}
}
void dfs2(int node){
	for(int next : v[node]){
		if(!mark[next]){
			mark[next] = 1;
			ans[--ql] = next;
			dfs2(next);
			return;
		}
	}
}
int main(){
	scanf("%d %d" , &n , &m);
	for(int i = 1 ; i <= m ; ++i){
		int a , b;
		scanf("%d %d" , &a , &b);
		v[a].emplace_back(b);
		v[b].emplace_back(a);
	}
	ql = N;
	qr = N;
	ans[qr++] = 1;
	mark[1] = 1;
	dfs1(1);
	dfs2(1);
	printf("%d\n" , qr - ql);
	for(int i = ql ; i < qr ; ++i){
		printf("%d%c" , ans[i] , " \n"[i == (qr - 1)]);
	}
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(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;
}

int main() {
    // 前処理
  COMinit();
  
  int N, K;
  cin >> N >> K;
  
  for (int i = 1; i <= K; i++) {
    cout << COM(N-K+1, i) * COM(K-1, i-1) % MOD << endl;
  }
}
  
  
  

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

using namespace std;

int k;
long long sum;
int gcd(int a, int b)
{
	return b ? gcd(b, a%b): a;
}
int main()
{
  cin >> k;
  for(int a = 1; a <= k; a++)
  {
		for(int b = 1; b <= k; b++)
        {
			for(int c = 1; c <= k; c++)
            {
				int d = gcd(a, b);
              	d = gcd(d, c);
              	sum += d;
            }
        }
  }
  cout << sum << endl;
return 0;
}

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

int main(void){
	double N;
	cin >> N ;
	double left = (N/1.08);
	double right = ( (N+1)/1.08 );
	for(int i = (int)left-1;i<=(int)right+1;i++){
		if(i>=left && i<right){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,a,n) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int x,a,b,c;
int main() {
    cin >> a >> b >> c >> x;
    
    int count = 0;
    rep(i,0,a+1){
        rep(j,0,b+1){
            rep(k,0,c+1){
                if(x == i*500+j*100+k*50){
                    count++;
                }
            }
        }
    }
    pout(count);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	vll a(3);
	rep(i, 3)cin >> a[i];

	int k;
	cin >> k;

	sort(all(a));

	rep(i, k) {
		a[a.size() - 1] *= 2;
	}

	ll ans = a[0] + a[1] + a[2];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// AtCoder ABC120: B - K-th Common Divisor
// 2019.9.9 bal4u
// Template for Online Contest

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef long long ll;

#define gc() getchar()
#define pc(c) putchar(c)

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

ll inL() {  // long long 整数の入力
	ll n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

void outL(ll n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int ins(char *s) { // 文字列の入力
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

void outs(char *s) {  // 文字列の表示
	while (*s) pc(*s++);
}

#define MIN(a,b)  ((a)<=(b)?(a):(b))
#define MAX(a,b)  ((a)>=(b)?(a):(b))
#define ABS(a)    ((a)>=0?(a):-(a))
inline static int chmax(int *a, int b) { if (*a < b) *a = b; }
inline static ll  chmaxL(ll *a, int b) { if (*a < b) *a = b; }
inline static int chmin(int *a, int b) { if (*a > b) *a = b; }
inline static ll  chminL(ll *a, int b) { if (*a > b) *a = b; }

int cmp_int(const void *u, const void *v) { return *(int *)u - *(int *)v; }

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int main()
{
	int i, A, B, K, g;

	A = in(), B = in(), K = in();
	g = gcd(A, B);
	for (i = g; i >= 1; i--) if (g % i == 0) {
		if (--K == 0) break;
	}
	out(i);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector <string> card,memo;
string suzi,m;
int n,k,ans,p,but;


int main(){

    while(1){

        cin >> n >> k;
        if(n==0&&k==0)break;

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

        if(k==2){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    if(i!=j){
                        suzi=card[i]+card[j];
                        but=0;
                        while(1){
                            if(p==ans)break;
                            if(memo[p]!=suzi);
                            else {
                                but++;
                                break;
                            }
                        p++;
                        }
                        p=0;
                        if(but==0){
                                ans++;
                               memo.push_back(suzi);
                    }
                }
                but=0;
            }
        }

    }

        if(k==3){
                 for(int i=0;i<n;i++){
                    for(int j=0;j<n;j++){
                        for(int a=0;a<n;a++){
                    if(i!=j&&j!=a&&a!=i){
                        suzi=card[i]+card[j]+card[a];
                        but=0;
                        while(1){
                            if(p==ans)break;
                            if(memo[p]!=suzi);
                            else {
                                but++;
                                break;
                            }
                        p++;
                        }
                        p=0;
                        if(but==0){
                                ans++;
                               memo.push_back(suzi);
                    }
                }
                but=0;
                }
            }
        }

        }

        if(k==4){

                for(int i=0;i<n;i++){
                    for(int j=0;j<n;j++){
                        for(int a=0;a<n;a++){
                            for(int b=0;b<n;b++){
                    if(i!=j&&i!=a&&i!=b&&j!=a&&j!=b&&a!=b){
                        suzi=card[i]+card[j]+card[a]+card[b];
                        but=0;
                        while(1){
                            if(p==ans)break;
                            if(memo[p]!=suzi);
                            else {
                                but++;
                                break;
                            }
                        p++;
                        }
                        p=0;
                        if(but==0){
                                ans++;
                               memo.push_back(suzi);
                    }
                }
                but=0;
                    }
                }
            }
        }

        }

        cout << ans << endl;
        memo.clear();
        card.clear();
        ans=0;
    }


return 0;
}

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

class island{
	public:
		int a;
		int b;
};

bool operator<(const island& land1,const island& land2){
	return land1.b<land2.b;
}

bool operator>(const island& land1,const island& land2){
	return land1.b>land2.b;
}

int main(){
	int N,M;
	cin>>N>>M;
	vector<island>arr;
	int tmp1,tmp2;
	for(int i=0;i<M;++i){
		island tmp;
		cin>>tmp1>>tmp2;
		tmp.a=tmp1;
		tmp.b=tmp2;
		arr.push_back(tmp);
	}
	sort(arr.begin(),arr.end());
	/*
	for(int i=0;i<M;++i){
		cout<<arr[i].a<<" "<<arr[i].b<<endl;
	}
	*/
	int last=0;
	int ans=0;
	for(int i=0;i<M;++i){
		if(arr[i].a>=last){
			ans++;
			last=arr[i].b;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << (n+1)/2-1 << endl;
  return 0;
}

Measured memory_bytes: 256
a = []
5.times {a << gets.to_i}
r = a.map {|i| ((i.to_f/10).ceil*10).to_i - i}
loi = r.index(r.max)
lo = a[loi]
a.delete_at(loi)
p a.inject(0) {|sum, i| sum+((i.to_f/10).ceil*10).to_i} + lo

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 100001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
int main()
{
    AKASH_PATEL;
    SVNIT_SURAT;
    int n,m;
    cin>>n>>m;
    int ans=(n*(n-1))/2+(m*(m-1))/2;
    print(ans)
    return 0;
}





Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int A;
	int B;

	scanf("%d",&A);
	scanf("%d",&B);

	if((A==1&&B==2)||(A==2&&B==1)){
		printf("3");
	}else if((A==1&&B==3)||(A==3&&B==1)){
		printf("2");
	}else if((A==2&&B==3)||(A==3&&B==2)){
		printf("1");
	}else{
		printf("error");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007
#define hell 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;


int main()
{
    int n;
    cin>>n;
    int ans = 0;
    for(int i=1; i<=n; i++)
    {
        if(i%2)
        {
            int cnt = 0;
            for(int j=1; j<=i; j++)
            {
                if(i%j == 0 ) cnt++;
            }
            if(cnt == 8)
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}








Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string S;
  std::cin >> N >> S;

  std::vector<std::unordered_set<char>> left(N);
  std::vector<std::unordered_set<char>> right(N);
  for (i64 i = 1; i < N; ++i) {
    left[i] = left[i - 1];
    left[i].insert(S[i - 1]);
  }
  for (i64 i = N - 2; i >= 0; --i) {
    right[i] = right[i + 1];
    right[i].insert(S[i + 1]);
  }

  std::unordered_set<std::string> answers;
  for (i64 i = 0; i < N; ++i) {
    for (const char& l : left[i]) {
      for (const char& r : right[i]) {
        answers.insert({l, S[i], r});
      }
    }
  }

  std::cout << answers.size() << std::endl;
  return 0;
}

Measured memory_bytes: 28032
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while (sc.hasNext()) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            int C = sc.nextInt();
            boolean check = A * A + B * B == C * C || A * A + C * C == B * B || B * B + C * C == A * A;
            System.out.println(check ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 33740
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N,K,X,Y;
	scanf("%d %d %d %d",&N,&K,&X,&Y);

	int ans = 0;

	if(K >= N){

		printf("%d\n",N*X);
		return 0;
	}
	ans = K*X+(N-K)*Y;

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
A = [int(i) for i in input().split()]

# dp[i][j]: fの最大値
# i: 決定した桁数
# j: K以下確定フラグ
dp = [[-float("inf")] * 2 for _ in range(61)]

# 初期条件
dp[0][0] = 0

for i in range(60):
    one = 0 # 0の個数
    for a in A:
        if (a >> (59 - i)) & 1:
            one += 1
    zero = N - one # 1の個数

    for j in range(2):
        if dp[i][j] < 0:
            continue

        """ Xの(上から)i桁目を0にする -> 無条件"""
        dp[i+1][j | ((K >> (59 - i)) & 1)] = max(dp[i+1][j | ((K >> (59 - i)) & 1)], dp[i][j] + one * (1 << (59 - i)))

        """
        Xの(上から)i桁目を1にする場合の条件
        -> K以下未満が確定 or Kを超えない
        """
        if j or (K >> (59 - i)) & 1:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + zero * (1 << (59 - i)))

print(max(dp[60]))

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

int main() {
  int n, k;
  cin >> n >> k;
  int sum = 1;
  int count = 0;
  while (count < n) {
    if (sum * 2 <= sum + k) {
      sum *= 2;
      count++;
    }
    else {
      sum += k;
      count ++;
    }
  }
  
  cout << sum << endl;

} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
using namespace std;
typedef long long ll;


int main(){
        ll N, M, a, b;
        cin >> N >> M;
        map<ll, ll> m;
        ll Count = 0;
        for(ll i=0; i<N; i++){
                cin >> a >> b;
                m[a] += b;
        }
        for(auto ite = m.begin(); ite!=m.end(); ++ite){
                if(M <= ite->second){
                        cout << Count + ite->first * M;
                        break;
                }
                else{
                        Count += ite->second * ite->first;
                        M -= ite->second;
                }
        }
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int sum(int l,int r) {
	return (l + r)*(r - l + 1) / 2;
}

signed main(void) {
	int n,k;
	cin >> n >> k;
	int ans = 0;
	FOR(i, k, n + 2) {
		int l = sum(0, i-1);
		int r = sum(n - i + 1, n);
		ans += (r - l + 1);
	}
	print(ans%mod);
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)

struct Unionfind{
  vector<int> rank,p,si;//木の高さの管理=rank,p=親の管理
  Unionfind(){}
  //初期化
  Unionfind(int size){
    rank.resize(size,0);
    p.resize(size,0);
    si.resize(size,1);
    for(int i=0;i<size;i++){
      makeSet(i);
    }
  }
  void makeSet(int x){
    p[x]=x;//親を自分にする。
    rank[x]=0;//最初の高さは0
    si[x]=1;
  }
  //同じ集合か判定。
  bool same(int x,int y){
    return (findSet(x)==findSet(y));
  }
  //集合を併合
  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }
  void link(int x,int y){
    if(x!=y){
      if(rank[x]<rank[y]){
	  p[x]=y;
	  si[y]+=si[x];
      }
      else{
	p[y]=x;
	if(rank[x]==rank[y]){
	  rank[y]++; 
	}
	si[x]+=si[y];
      }
      
    }
  }
  int siz(int x){
    int a=findSet(x); 
    return si[a];
  }             
  //経路圧縮
  int findSet(int x){
    //自分自身と親が等しくなるまで再帰
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,k,l;
  cin>>n>>k>>l;
  Unionfind uf1(n+1);
  Unionfind uf2(n+1);
  rep(i,k){
    int p,q;
    cin>>p>>q;
    uf1.unite(p,q);
  }
  rep(i,l){
    int p,q;
    cin>>p>>q;
    uf2.unite(p,q);
  }
  map<pair<int,int>,int > M;
  rep(i,n){
    M[make_pair(uf1.findSet(i+1),uf2.findSet(i+1))]++;
  }
  rep(i,n){
    cout<<M[make_pair(uf1.findSet(i+1),uf2.findSet(i+1))]<<' ';
  }
  return(0);
}


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

int main()
{
    int N;
    cin >> N;
    map<string, int> mp;
    for (int i = 0; i < N; i++)
    {
        string S;
        cin >> S;
        mp[S]++;
    }
    cout << mp.size() << endl;
}

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

Measured memory_bytes: 2660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long

using namespace std;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<int> p(a), q(b), r(c);
    iFOR(i, 0, a) cin >> p[i];
    iFOR(i, 0, b) cin >> q[i];
    iFOR(i, 0, c) cin >> r[i];

    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());

    vector<int> eaten_red(x);
    vector<int> eaten_gre(y);

    iFOR(i, 0, x) eaten_red[i] = p[i];
    iFOR(i, 0, y) eaten_gre[i] = q[i];

    int exchanging;
    int tail_red = x - 1;
    int tail_gre = y - 1;

    int plus_red, plus_gre;

    iFOR(i, 0, c) {
        exchanging = r[i];

        plus_red = exchanging - eaten_red[tail_red];
        plus_gre = exchanging - eaten_gre[tail_gre];

        if (plus_red < 0 && plus_gre < 0) break;

        if (plus_red > plus_gre) {
            eaten_red[tail_red] = exchanging;
            tail_red--;
            if (tail_red < 0) tail_red = 0;
        } else {
            eaten_gre[tail_gre] = exchanging;
            tail_gre--;
            if (tail_gre < 0) tail_gre = 0;
        }
    }

    cout << accumulate(eaten_red.begin(), eaten_red.end(), 0LL) + accumulate(eaten_gre.begin(), eaten_gre.end(), 0LL) << endl;

    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=3583;
int i,j,M,n,m,cnt,c[505];bool bz[N+5];
ll a[505][505],p;
int main(){
	c[0]=1;
	fo(i,2,N)if (!bz[i]) {
		c[++cnt]=i;
		for(j=i<<1;j<=N;j+=i) bz[j]=1;
	}
	scanf("%d",&n);
	M=n/2+1;
	fo(i,1,n){
		p=i&1?c[i/2+1]:c[i/2]*2;
		for(j=2-(i&1),m=M+1;j<=n;j+=2,m++) a[i][j]=p*c[m];
	}
	fo(i,1,n){
		p=(i&1?2:4)*c[i/2]*c[i/2+1];
		if (!(i&1)) a[i][j=1]=p*c[M+1]+1,m=M+1;else
		a[i][j=2]=p*c[M+1]*c[M+2]+1,m=M+2;
		for(j+=2;j<=n;j+=2,m++) a[i][j]=p*c[m]*c[m+1]+1;
	}
	fo(i,1,n)
	fo(j,1,n) printf("%lld%c",a[i][j],j<n?' ':'\n') ;	
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,suma=0,sumb=0;
  cin >> n;
  vector<int> c(n);
  for(int i=0; i<n; i++){
    cin >> c.at(i);
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  for(int i=0; i<n; i+=2){
    suma += c.at(i);
  }
  for(int i=1; i<n; i+=2){
    sumb += c.at(i);
  }
  cout << suma - sumb << endl;
}

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

using namespace std;

long MOD = 1000000007;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    long X, Y;
    cin>>X>>Y;

    if((2*X-Y)%3!=0 || (2*Y-X)%3!=0){
        cout<<0<<endl;
        return 0;
    }


    long a = X*2/3-Y/3;
    long b = -X/3+Y*2/3;
    if(a<0 || b<0){
        cout<<0<<endl;
        return 0;
    }

    long ans = 1;
    for(int i=a+b; i>1; --i){
        ans*=i;
        ans%=MOD;
    }
    for(int i=a; i>1; --i){
        ans = ans * modinv(i, MOD) % MOD;
    }
    for(int i=b; i>1; --i){
        ans = ans * modinv(i, MOD) % MOD;
    }

    cout<<ans<<endl;

    return 0;
}

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

int main() {
  int N;  
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int ret = 0;
  for(int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      ret += a.at(i);
    }
    else {
      ret -= a.at(i);
    }
  }
  
  cout << ret << endl;
}

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();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        if (n > k)
            System.out.println(x * k + y * (n - k));
        else
            System.out.println(x * n);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, std::vector<long long> d){
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            if(i==j)continue;
            ans += d[i] * d[j];
            
        }
        
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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

using namespace std;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) > abs(x-b)){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e9;
int main(){
	int A,B;cin>>A>>B;
	cout<<(A-1)*(B-1)<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < K; i++) {
    if (i % 2 == 0) {
      if (A % 2 == 1) {
        A--;
      }
      B += A / 2;
      A -= A / 2;
    } else {
      if (B % 2 == 1) {
        B--;
      }
      A += B / 2;
      B -= B / 2;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}

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


int main() {
    int N;cin >> N;
    string S;cin >> S;
    int ans = 0;
    int M = 0;
    for (int i = 0;i < N;i++){
        char c;c = S.at(i);
        if (c == 'I'){
            ans++;
            M = max(ans,M);
        }else{
            ans--;
        }
    }
    cout << M << endl;

}       

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

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

#define ll   int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>

const ll mod = 1000000007 ;
const ll N=1e6+5;

int main()
{
    FAST
    ll tc,i,j,k;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
        string s,s1;
        cin>>s>>s1;
        ll ans=0;
        for(i=0; i<s.size(); i++)
        {
            if(s[i]!=s1[i])
                ans++;
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3748
#include <stdio.h>

int swap(int *x, int *y) {int z = *x;*x = *y;*y = z;}

int op(int x, int y, int o){
  switch(o){
  case 0: return x - y;
  case 1: return x + y;
  case 2: return x * y;
  }
}

int check(int a, int b, int c, int d){
  int r, op1, op2, op3;
  char ope[3] = {'-', '+', '*'};
  for(r = 0;r < 4;r++){
    for(op1 = 0;op1 < 3;op1++){
      for(op2 = 0;op2 < 3;op2++){
	for(op3 = 0;op3 < 3;op3++){
	  if(op(op(a, b, op1), op(c, d, op3), op2) == 10){
	    printf("((%d %c %d) %c (%d %c %d))\n", a, ope[op1], b, ope[op2], c, ope[op3], d); return 1;}
	  if(op(op(op(a ,b , op1), c, op2), d, op3) == 10){
	    printf("(((%d %c %d) %c %d) %c %d)\n", a, ope[op1], b, ope[op2], c, ope[op3], d); return 1;}
	}
      }
    }
    if(r % 2 == 0) swap(&a, &b); else if(r == 1) swap(&c, &d);
  }
  return 0;
}

int main(){
  int a, b, c, d;
  while(scanf("%d%d%d%d", &a, &b, &c, &d) && a && b && c && d){
    if(check(a, b, c, d)) continue;
    else if(check(a, c, d, b)) continue;
    else if(check(a, d, b, c)) continue;
    else if(check(c, b, a, d)) continue;
    else if(check(d, b, a, c)) continue;
    else if(check(d, c, a, b)) continue;
    printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include<iostream>
using namespace std;
int main(){
	int c = 0;
	char w[100];
	cin>>w;
	for(int i=0; w[i] != '\0'; i++){
		for(int j=0; w[j] != '\0'; j++){
			if(w[j] == w[i]){
				c++;
			}
		}
		if(c%2 != 0 ){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int sum = 0;

      if(A*C<=B){
        System.out.println(C);
      }else{
        for(int i = 1;i*A<=B;i++){
          sum++;
        }
          System.out.println(sum);
      }
  }
}


Measured memory_bytes: 22612
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  long long A;
  long double B;
  scanf("%lld", &A);
  scanf("%Lf", &B);
  long double multiple = B*A+0.005;
  long long ans = (long long)multiple;
  std::cout << ans << std::endl;
  return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll a;
  scanf("%lld",&a);
  ll b;
  scanf("%lld",&b);
  ll h;
  scanf("%lld",&h);
  cout << (a+b)*h/2 << endl;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,ll> P;

int N;
vector<int> V[110000];
int color[110000];

//二部グラフならtrueを返す
bool dfs(int x,int c){
  color[x]=c;
  for(int i=0;i<V[x].size();i++){
    //隣接している頂点が同じ色ならfalse
    if(color[V[x][i]]==c) return false;
    //隣接している頂点がまだ塗られていないなら-cで塗る
    if(color[V[x][i]]==0 && !dfs(V[x][i],-c)) return false;
  }
  return true;
}


int main(){
    int M,a,b;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>a>>b;
        a--; b--;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    if(dfs(0,1)){
        int count=0;
        for(int i=0;i<N;i++){
            if(color[i]==1) count++;
        }
        cout<<(ll)count*(N-count)-M<<endl;
    }else{
        cout<<(ll)N*(N-1)/2-M<<endl;
    }
}


Measured memory_bytes: 6912
import math

n = int(input())
a = list(map(int, input().split()))
mean = sum(a)/n

sub1 = math.floor(mean)
sub2 = math.ceil(mean)

ans1 = 0
ans2 = 0

for i in range(n):
    ans1 += (a[i]-sub1)**2
    ans2 += (a[i]-sub2)**2
    
print(min(ans1,ans2))

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll N;
    string S;
    cin >> N >> S;
    vector<ll> W(N , 0);
    vector<ll> E(N , 0);
    ll sum_W = 0;
    ll sum_E = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'W'){
            sum_W++;
        }else{
            sum_E++;
        }
        W[i] = sum_W;
        E[i] = sum_E;
    }
    ll ans = N;
    for(int i = 1; i < N; i++){
        ans = min(ans, W[i - 1] + sum_E - E[i]);
    }

    ans = min(ans , sum_E);

    cout << ans << endl;

}


Measured memory_bytes: 5380
# coding: utf-8
#Problem Name: Prime Number
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

__max = 999999
List = [False,True]*(__max/2+1)
List[1] = False
List[2] = True
for i in xrange(3,int(__max**.5)+1,2):
    List[i**2::i] = [False]*len(List[i**2::i])

List = [i for i in xrange(2,__max) if List[i]]

while True:
    try:
        n = int(raw_input())
        print __import__('bisect',fromlist=['bisect_right']).bisect_right(List,n)
    except:
        break

Measured memory_bytes: 17036
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int c=a-b;
    int h[n];
    for(int i=0;i<n;i++)cin>>h[i];
    int l=0,r=1000000000;
    while(r-l>1){
        long long mid=(l+r)/2;
        long long x=0;
        for(int i=0;i<n;i++)if(mid*b<h[i])x+=(h[i]-mid*b-1)/c+1;
        if(x<=mid)r=mid;
        else l=mid;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray()
    val q = readLine()!!.toInt()
    val frontAdd = CharArray(q) { '.' }
    var frontI = q - 1
    val backAdd = CharArray(q) { '.' }
    var backI = 0
    var mode = true
    for (i in 1..q) {
        val inList = readLine()!!.split(' ')
        if (inList[0] == "1") {
            mode = !mode
        } else {
            val (t, f, c) = inList
            if ((mode && f == "1") || (!mode && f == "2")) {
                frontAdd[frontI--] = c[0]
            } else {
                backAdd[backI++] = c[0]
            }
        }
    }
    val ans = frontAdd.filter { it != '.' }.toCharArray() + s + backAdd.filter { it != '.' }
    if (!mode) ans.reverse()
    println(ans.joinToString(""))
}


Measured memory_bytes: 77736