akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int a;
	cin >> a;
	cout << a / 3 << endl;
	return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

#define maxn 3005
ll dp[maxn][maxn][2];
int N;
ll A[maxn];

ll solution(int i, int j, int p) {
    if (i > j || j < i) {
        return 0;
    }

    if (dp[i][j][p] != -1) {
        return dp[i][j][p];
    }

    if(p == 0) {
        dp[i][j][p] = max(solution(i + 1, j, (p + 1) % 2) + A[i], solution(i, j - 1, (p + 1) % 2) + A[j]);
    } else {
        dp[i][j][p] = min(solution(i + 1, j, (p + 1) % 2) - A[i], solution(i, j - 1, (p + 1) % 2) - A[j]);
    }

    return dp[i][j][p];
}

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%lld", A + i);
    }

    memset(dp, -1, sizeof(dp));
    printf("%lld\n", solution(0, N - 1, 0));

    return 0;
}

Measured memory_bytes: 141568
#include <algorithm>
#include <math.h>
#include <map>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void A_Remaining_Balls(void) {

	string S, T;
	cin >> S >> T;

	int A, B;
	cin >> A >> B;

	string U;
	cin >> U;

	if (S.compare(U) == 0)	A--;
	else					B--;

	cout << A << " " << B;
	return;
}

int main(void) {

	A_Remaining_Balls();
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int X,Y,Z,K;
ll A[1010],B[1010],C[1010];

int main(){
    cin >> X >> Y >> Z >> K;
    for(int i=1;i<=X+Y+Z;i++){
        if(i<=X) cin >> A[i];
        else if(i<=X+Y) cin >> B[i-X];
        else cin >> C[i-X-Y];
    }
    vector<ll> v1,v2;
    for(int i=1;i<=X;i++){
        for(int j=1;j<=Y;j++){
            v1.push_back(A[i]+B[j]);
        }
    }
    sort(v1.begin(),v1.end(),greater<ll>());
    for(int i=1;i<=min(K,(int)v1.size());i++){
        for(int j=1;j<=min(K,Z);j++){
            v2.push_back(v1[i-1]+C[j]);
        }
    }
    sort(v2.begin(),v2.end(),greater<ll>());
    for(int i=0;i<K;i++) cout << v2[i] << endl;
}

Measured memory_bytes: 43364
a = [i for i in map(int, input().split())]
b = [i for i in map(int, input().split())]
c = [i for i in map(int, input().split())]

n = int(input())

for i in range(n):
    num = int(input())
    for j in range(3):
        if a[j] == num:
            a[j] = 0
        if b[j] == num:
            b[j] = 0
        if c[j] == num:
            c[j] = 0

ans = "No"
if max(a) == 0:
    ans = "Yes"
if max(b) == 0:
    ans = "Yes"
if max(c) == 0:
    ans = "Yes"

if (a[0] == 0) and (b[1] == 0) and (c[2] == 0):
    ans = "Yes"
if (a[2] == 0) and (b[1] == 0) and (c[0] == 0):
    ans = "Yes"
if (a[0] == 0) and (b[0] == 0) and (c[0] == 0):
    ans = "Yes"
if (a[1] == 0) and (b[1] == 0) and (c[1] == 0):
    ans = "Yes"
if (a[2] == 0) and (b[2] == 0) and (c[2] == 0):
    ans = "Yes"
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python

from sys import stdin, stderr

def main():
   N, A, B = map(int, stdin.readline().split())
   T = N / (A+B)
   res = A*T
   R = N % (A+B)
   res += min(R, A)
   print(res)

   return 0

if __name__ == '__main__': main()


Measured memory_bytes: 2568
use proconio::input;

const A: usize = 1000_000;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut ma = 0;
    let mut ac = vec![0; A + 1];
    for &a in &a {
        ac[a] += 1;
        ma = ma.max(a);
    }

    let mut pc = true;
    for i in (0..=ma).skip(2) {
        let mut c = 0;
        for j in (0..=ma).skip(i).step_by(i) {
            c += ac[j];
        }
        if c > 1 {
            pc = false;
            break;
        }
    }

    println!("{} coprime", if pc {
        "pairwise"
    } else {
        let mut v = a[0];
        for i in 1..n {
            v = num_integer::gcd(a[i], v);
        }
        if v == 1 {
            "setwise"
        } else {
            "not"
        }
    });
}


Measured memory_bytes: 20472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll h,w,d;
  cin >> h >> w >> d;
  ll si = h*w / d + 1;
  vector<vector<pair<ll,ll>>> pos(d,vector<pair<ll,ll>>(si));
  //cout << 0 << endl;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      ll in;
      cin >> in;
      ll syou = in / d;
      ll mod = in % d;
      pos[mod][syou] = make_pair(i,j);
    }
  }
  //cout << 1 << endl;
  vector<vector<ll>> cost(d,vector<ll>(si));
  for(int i = 0;i < d;i++){
    cost[i][0] = 0;
    for(int j = 1;j < si;j++){
      cost[i][j] = cost[i][j - 1] + abs(pos[i][j].first - pos[i][j - 1].first) + abs(pos[i][j].second - pos[i][j - 1].second);
    }
  }
  //cout << 2 << endl;
  ll q;
  cin >> q;
  for(int i = 0;i < q;i++){
    ll l,r;
    cin >> l >> r;
    ll mod = l % d;
    //cout << mod << " " << r / d << " " << l / d << endl;
    cout << cost[mod][r / d] - cost[mod][l / d] << endl;
  }
}

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

int main() {

	int n, x;
	scanf("%d %d", &n, &x);
	int ans = 0;
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}
	sort(v.begin(), v.end());
	int i = 0;
	while(true) {
		if(i == n) {
			break;
		}
		x -= v[i];
		if(x < 0) {
			break;
		}
		ans++;
		i++;
	}
	if(x > 0) {
		printf("%d\n", ans - 1);
	}else {
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 256
// Contest: AtCoder Beginner Contest 147 (https://atcoder.jp/contests/abc147)
// Problem: A: Blackjack (https://atcoder.jp/contests/abc147/tasks/abc147_a)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int a, b, c; cin >> a >> b >> c;
    cout << (a + b + c >= 22 ? "bust" : "win");

    return 0;
}

Measured memory_bytes: 256
# include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
    m=(S%3600)/60;
    S=S%3600;
    s=S%60;
	printf("%d",h);
	printf(":");
	printf("%d",m);
	printf(":");
	printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 2664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String s2 = sc.next();int count = 0;
		for(int i = 0; i < 3; i++) {
			if(s.charAt(i) == s2.charAt(i))count++;
		}
		System.out.println(count);
		sc.close();

	}
}

Measured memory_bytes: 21844
<?php
    fscanf(STDIN, "%d", $N);
    $L = explode(" ", trim(fgets(STDIN)));
 
    rsort($L);
 
    $answer = 0;
 
    for ($i = 0; $i < $N; $i++) {
        $answer += min($L[$i * 2], $L[$i * 2 + 1]);
    }
 
    echo $answer . PHP_EOL;


Measured memory_bytes: 4604
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    boolean check = true; int total =0; int[] A = new int[N];
    for (int i =0; i<N; i++) {
      int b = sc.nextInt();
      A[b]++; total += b;
    }
    if (N % 2 == 1 && A[0] != 1) check = false;
    for (int i=N-1; i>0; i -=2) {
      if (A[i] != 2) check = false;
    }
    if (check) {
      long ans =1;
      for (int i =1; i<= N/2; i++) {
        ans *= 2; ans %= 1000000007;
      }
      System.out.println(ans);
    } else {
      System.out.println(0);
    }
  } 
}

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

using namespace std;
using ll = long long;

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

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<bool> s(f+1,false) , w(f+1,false); 
    s[0] = w[0] = true;

    rep(i,f+1){
        if(s[i]){
            if(i + c <= f) s[i+c] = true;
            if(i + d <= f) s[i+d] = true;
        }
        if(w[i]){
            if(i+a*100 <= f) w[i + a * 100] = true;
            if(i+b*100 <= f) w[i + b * 100] = true;
        }
    }
    int p = 0, max_w=0,max_s=0;
    double mx = 0;
    rep(i,f+1){
        if(s[i]){
            while(!w[p] || i > p * e  / 100){
                if(i + p > f) break;
                p++;
            }
            if(i +p > f) break;
            if(1.0 * i / (i+p) > mx){
                mx = 1.0 * i / (i+p);
                max_w = p;
                max_s = i;
            }
        }
    }
    if(max_s == 0 && max_w == 0) max_w = a * 100;
    cout << max_w + max_s << " " << max_s << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<cmath>

#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


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

	int num_digits = log10(N);

	if (N == pow(10, num_digits)) cout << 10 << endl;
	else {
		int sum = 0;
		while (N > 0) {
			sum += N % 10;
			N /= 10;
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define MAX 200005
                int main()
                {
                   string s;
                   cin>>s;
                   vector<char> ans;
                   int l = s.size();
                   for(int i = 0 ; i < l ; i++)
                   {
                        if(s[i] == '0')ans.push_back('0');
                        else if(s[i] == '1')ans.push_back('1');
                        else
                        {
                            if(!ans.empty())
                            {
                                ans.pop_back();
                            }
                        }
                   }
                   int len = ans.size();
                   for(int i = 0 ; i < len ; i++)
                   {
                        printf("%c",ans[i]);
                   }
                   puts("");
                }


Measured memory_bytes: 256
import bisect

N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
B=list(map(int,input().split()))
B=sorted(B)
C=list(map(int,input().split()))
C=sorted(C)
count=0
for num in (B):
    a=bisect.bisect_left(A,num)
    b=bisect.bisect_right(C,num)
    count+=a*(N-b)

print(count)

Measured memory_bytes: 106360
N=int(input())
s=input()
K=len(s)
mod=10**9+7
dp=[]
for i in range(N+1):
  dp.append([0]*(i+1))
dp[0][0]=1
for i in range(N):
  for j in range(i+1):
    if j>=1:
      dp[i+1][j-1]+=dp[i][j]
    else:
      dp[i+1][j]+=dp[i][j]
    dp[i+1][j+1]+=2*dp[i][j]
    dp[i+1][j-1]%=mod
    dp[i+1][j+1]%=mod
def power(x,y):
  if y==0:
    return 1
  if y==1:
    return x%mod
  if y==2:
    return (x*x)%mod
  if y%2:
    return (power(power(x,(y-1)//2),2)*x)%mod
  else:
    return power(power(x,y//2),2)
a=power(2,K)
inv=power(a,mod-2)
print((dp[N][K]*inv)%mod)

Measured memory_bytes: 138460
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    
    System.out.println(Math.max(C-(A-B), 0));
  }
}

Measured memory_bytes: 23124
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}

	xs = append(xs, x)
	sort.Ints(xs)

	ds := make([]int, 0)
	for i := 1; i < len(xs); i++ {
		ds = append(ds, xs[i]-xs[i-1])
	}

	ans := ds[0]
	for i := 0; i < len(ds); i++ {
		ans = gcd(ans, ds[i])
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


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

int main(){
    int h, w, d;
    cin >> h >> w >> d;

    vector<vector<int>> v(d);
    map<int, pair<int,int>> m;
    int a;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a;
            m[a] = {i, j};
        }
    }

    for(int i = 1; i <= d; i++){
        v[i%d].push_back(0);
    }

    for(int i = d+1; i <= h*w; i++){
        pair<int,int> bef, aft;
        aft = m[i], bef = m[i-d];
        int dist = abs(aft.first-bef.first) + abs(aft.second-bef.second);
        v[i%d].push_back(dist);
    }

    for(int i = 0; i < d; i++){
        for(int j = 1; j < v[i].size(); j++)    v[i][j] += v[i][j-1];
    }

    int q;
    cin >> q;

    int l, r;
    for(int i = 0; i < q; i++){
        cin >> l >> r;
        cout << v[r%d][r/d-(r%d==0)] - v[l%d][l/d-(l%d==0)] << endl;
    }

    return 0;
}

Measured memory_bytes: 11008
candies = [int(e) for e in input().split()]
lst = sorted(candies)


def main(lst):
    max = lst[2]

    if max == lst[0] + lst[1]:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    ans = main(lst)
    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N,tp;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    rep(i,N) cin >> tp, A[i] = tp - 1;
    rep(i,N) cin >> B[i];
    rep(i,N) cin >> C[i];
    
    int ans = 0;
    int idx = -1;
    rep(i,N){
        if(A[i] == idx+1) ans += C[idx];
        idx = A[i];
        ans += B[idx];
    }
    pr(ans);
}

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

std::pair<int, int> act[MAX];

bool compare (const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second < b.second;
}

int main()
{
    int N, s, e;
    std::scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        std::scanf("%d %d", &s, &e);
        act[i] = {s, e};
    }
    std::sort(act, act+N, compare);
    int cnt = 1, currEnd = act[0].second;
    for (int i = 1; i < N; i++) {
        if (act[i].first > currEnd) {
            currEnd = act[i].second;
            cnt++;
        }
    }
    std::printf("%d\n", cnt);
    return 0;
}



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

using namespace std;

int main()
{
    int r , d , x;
    cin >> r >> d >> x;

    for(int i = 0; i < 10; ++i){
        int ans  = x;
        x = (r * ans) - d;
        cout << x << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
import Data.Set

o = 10

c2d 'A' = 1 
c2d 'C' = 2
c2d 'G' = 3
c2d 'T' = 4

-- |
-- >>> w2d "AAA"
-- 111
-- >>> w2d "AAC"
-- 211
-- >>> w2d "AGA"
-- 131
-- >>> w2d "AGG"
-- 331
-- >>> w2d "TTT"
-- 444
-- >>> w2d "CCC"
-- 222
-- >>> w2d "CC"
-- 22

w2d :: String -> Int
w2d (c:[]) = a
    where
        a = c2d c
w2d (c:s)  = a + r*o
    where
        a = c2d c
        r = w2d s


ans _ [] = []

ans s (["insert",d]:r) = ans s' r
    where
       d' = w2d d
       s' = insert d' s

ans s (["find",d]:r) = a:(ans s r)
    where
        d'= w2d d
        a = if member d' s then "yes" else "no"

main = do
    _ <- getLine
    c <- getContents
    let i = Prelude.map words $ lines c
        o = ans empty i
    mapM_ putStrLn o



Measured memory_bytes: 49144
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>
#include <numeric>
#include <set>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)
typedef pair<int, int> P;


int main()
{
	int n;
	while (cin >> n, n){
		int ans(0);

		while (n != 1){
			if (n & 1){
				n *= 3;
				++n;
			}
			else{
				n /= 2;
			}
			++ans;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string S; cin >> S;
  int ssize = (int)S.size();
  int ans = 0;
  rep(i,ssize){
    if(i==0) continue;
    if(S[i]!=S[i-1])ans++;
  }
  cout << ans << endl;
  return 0;
}


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

struct card {
    char suit;
    int value;
    int id;
    bool operator<(const card &o) {return value<o.value;}
    bool operator<=(const card &o) {return value<=o.value;}
};

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

void quickSort(card A[], int p, int r)
{
    if(p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}

bool isStable(card A[], int n)
{
    for(int i=1; i<n; i++) {
        if(A[i-1].value==A[i].value && A[i-1].id>A[i].id) return false;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    card A[100000];
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>A[i].suit>>A[i].value;
        A[i].id=i;
    }
    quickSort(A, 0, n-1);
    if(isStable(A, n)) cout<<"Stable\n";
    else cout<<"Not stable\n";
    for(int i=0; i<n; i++) cout<<A[i].suit<<' '<<A[i].value<<'\n';
    return 0;
}

Measured memory_bytes: 2376
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b){
        for(int i=0;i<a;i++){
        cout<<b;
        }
    }
    else if(a<b)
    {
         for(int i=0;i<b;i++){
        cout<<a;
        }
    }
    else if(a==b){
        for(int i=0;i<a;i++)
    {
        cout<<a;
    }
    }
}


Measured memory_bytes: 3188
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int n;
  cin >> n;
  int nn = n*n;
  int nnn = n*n*n;
  cout << n + nn + nnn << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

signed main(){
    int n;
    int sum=0;
    cin>>n;
    int a[n],b[n];
   r(i,n)cin>>a[i];
   r(i,n)cin>>b[i];
   r(i,n)if(a[i]>b[i])sum+=a[i]-b[i];
   cout<<sum<<endl;
}

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

int ds = 6;

void dprint( int a[] ){
	for( int i = 0; i < ds; i++ ) {
		cout << a[i] << ":";
	}
	cout << endl;

	return; 
}

void dsort( int a[], int i0, int i1, int i2, int i3 ) {
	int ta[] = { a[i0], a[i1], a[i2], a[i3] };
	int min = ta[0];
	for( int i = 0; i < 4; i++ ) {
		if( min > ta[i] ) {
			min = ta[i];
		}
	}

	int t = 0;
	while( true ) {
		if( a[i0] == min ) {
			break;
		}
		t = a[i0];a[i0]=a[i1];a[i1]=a[i2];a[i2]=a[i3];a[i3]=t;
	}

	return;
}

bool dcomp( int a[], int b[] )
{
	for( int i = 0; i < ds; i++ ) {
		if( a[i] != b[i] ) {
			return false;
		}
	}

	return true;
}

bool drollcomp( int a[], int b[], int i0, int i1, int i2, int i3 )
{
	bool ret = false;
	int t = 0;
	for( int i = 0; i < 4; i++ ) {
		t = b[i0];b[i0]=b[i1];b[i1]=b[i2];b[i2]=b[i3];b[i3]=t;
		ret = dcomp( a, b );
		if( ret == true ) {
			break;
		}
	}
	return ret;
}

bool dcheck( int a[], int b[] ) {
	bool ret = false;

	ret = dcomp( a, b );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 0, 1, 5, 4 );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 0, 3, 5, 2 );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 1, 2, 4, 3 );
	if( ret == true ) {
		return ret;
	}

	return ret;
}

int main()
{
	int dx[ds], dy[ds];

	for( int i = 0; i < ds; i++ ) {
		cin >> dx[i];
	}
	dsort( dx, 0, 1, 5, 4 );
	dsort( dx, 0, 3, 5, 2 );
	dsort( dx, 1, 2, 4, 3 );

	for( int i = 0; i < ds; i++ ) {
		cin >> dy[i];
	}
	dsort( dy, 0, 1, 5, 4 );
	dsort( dy, 0, 3, 5, 2 );
	dsort( dy, 1, 2, 4, 3 );

	bool ret = false;
	ret = dcheck( dx, dy );
	cout << ( ret?"Yes":"No" ) << endl;
	
	return 0;
}


Measured memory_bytes: 3128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	m := scanInt()
	g := make([][]int, n)

	for i := 0; i < m; i++ {
		a,b := scanInt()-1, scanInt()-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	check := 1 << uint(n) -1
	ans := 0

	var dfs func(next, f int)
	dfs = func(next, f int) {
		for _, e := range g[next] {
			if f >> uint(e) & 1 == 1 {
				if check == f {
					ans++
				}
				continue
			}

			if f+(1<<uint(e)) == check {
				ans++
			} else {
				dfs(e, f+(1<<uint(e)))
			}
		}
	}

	dfs(0,1)

	fmt.Println(ans)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する


int main(){
    int n,m;
    cin>>n>>m;
    double sum=0;
    vector<double> a(n);
    rep(i,n){
        cin>>a[i];
        sum += a[i];
    }
    double Min = sum/(4*m);
    all(a);
    Re(a);
    if(a[m-1]>=Min){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


}

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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define FOR(i,a,b)  for(int i=(a); i< (b); ++i)
#define RFOR(i,b,a) for(int i=(b);i>=(a);i--)
#define REP(i,a,b)  for(int i=(a); i<=(b); ++i)
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
template<typename T>
void PrArr(const T a[] , int len){
	for(int i = 0;i <= len; i++)cout << a[i] << " ";
	cout << endl;
}
template<typename T>
void PrVec(const vector<T> a){
	for(auto it : a)cout << it << " ";
	cout << endl;
}
const int MAX = 0x7ffffff;
const int MIN = 0xcf;
const int N = 100005;
int test;
struct node{
	int val , cnt;
};
bool cmp(node a,node b)
{
	return a.cnt > b.cnt;
}
void slove()
{
	int n;cin >> n;
	vector<node> a(N) , b(N);
	for(int i = 1;i <= n ;i ++){
		int x;cin >> x;
		if(i & 1){
			a[x].val = x;
			a[x].cnt ++;
		}
		else {
			b[x].val = x;
			b[x].cnt ++;
		}
	}
	sort(a.begin(),a.end(),cmp);
	sort(b.begin(),b.end(),cmp);
	int e1 = a[0].cnt , e2 = a[1].cnt;
	int o1 = b[0].cnt , o2 = b[1].cnt;
	if(a[0].val != b[0].val)
	{
		cout << n - o1 - e1 << endl;
		return;
	}
	int ans = min(n - e1 - o2 , n - e2 - o1);
	cout << ans << endl;
}
int main()
{
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed; // 在iomanip中
#endif
	SIS;slove();
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

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

int main()
{
	int ary[100] ;
	int get ;
	int tmp = 0 ;

	for( int i = 0 ; i < 100 ; i ++ )
	{
		ary[i] = 0 ;
	}

	while( cin >> get )
	{
		ary[get-1] ++ ;

		if( ary[get-1] > tmp )
		{
			tmp = ary[get-1] ;
		}
	}

	for( int i = 0 ; i < 100 ; i ++ )
	{
		if( ary[i] == tmp )
		{
			cout << (i+1) << endl ;
		}
	}
	return 0 ;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N;
  vector<string> S(N);
  for(int i = 0;i < N; i++){
    cin >> S.at(i);
  }
  cin >> M;
  vector<string> T(M);
  for(int i = 0;i < M; i++){
    cin >> T.at(i);
  }
  
  int max = 0;
  for(int i = 0; i < N; i++){
    string s = S.at(i);
    int cost = 0;
    
    for(int n = 0; n < N; n++){
     if(s ==  S.at(n)) {cost++; }
    }
    for(int m = 0; m < M; m++){
     if(s ==  T.at(m)) {cost--; }
    }
    if(cost > max ) {max = cost;}
  }
  cout << max << endl;
  return 0;
}

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

using namespace std;

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

int main(){
    while(1){
        int h, w;
        cin >> h >> w;
        if(!h && !w)return 0;

        rep(i,h){
            rep(j,w){
                if(i == 0 || j == 0 || i == h-1 || j == w-1)printf("#");
                else printf(".");
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    int a[n + 1]; REP2(i, 1, n) cin >> a[i];
    int b[n + 1]; REP2(i, 1, n) cin >> b[i];
    int c[n]; REP2(i, 1, n - 1) cin >> c[i];

    int ans = 0;
    REP2(i, 1, n){
        ans += b[a[i]];
        if(a[i] == a[i + 1] - 1){
            ans += c[a[i]];
        }
    }
    OP(ans);
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    long int x;
    long int a, b;
    int end = 0;
 
    scanf("%ld", &x);
 
    for(long int i = -1000; i <= 1000; i++){
        for(long int j = -1000; j <= 1000; j++){
            if(i*i*i*i*i - j*j*j*j*j == x){
                a = i; b = j;
                end = 1;
                break;
            }
        }
        if(end == 1) break;
    }
    printf("%ld %ld", a, b);
}

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

int main() {
    
    int64_t n;
    cin >> n;
    vector<int> vec(10000001,1);
    for(int i=2; i<10000000; i++){
        int64_t x=i;
        while(x<=10000000){
            vec[x]++;
            x+=i;
        }
    }
    int64_t ans=0;
    rep(i,n+1){
        ans+=i*vec[i];
    }
    if(n==10000000) ans=838627288460105;
    cout << ans << endl;
}

Measured memory_bytes: 42324
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    cout << S[0] << S[1] << S[2] << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <map>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long N,K;
    cin >> N >> K;
    map<int, long long> mp;
    for(int i = 0; i < N; ++i){
        int a, b; cin >> a >> b;
        mp[a] += b;
    }
    
    for(auto it = mp.begin(); it != mp.end(); ++it){
        if(K - it->second <= 0){
            cout << it->first << endl;
            break;
        }
        K -= it->second;
    }
    return 0;
}

Measured memory_bytes: 7484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int K;
    cin>>K;
    priority_queue<int> q;
    for(int i=1;i<=9;i++){
        q.push(-i);
    }
    int x=0;
    rep(i,K){
        x=-q.top();
        q.pop();
        if(x%10!=0) q.push(-(x*10+x%10-1));
        q.push(-x*10-x%10);
        if(x%10!=9) q.push(-(x*10+x%10+1));
    }
    cout << x << endl;


    



}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, a, b;
  cin >> n >> a >> b;
  vii cnt(3);
  rep(i,n) {
    int p;
    cin >> p;
    if(p <= a) cnt[0].push_back(p);
    else if(p <= b) cnt[1].push_back(p);
    else cnt[2].push_back(p);
  }
  int ans = inf;
  rep(i,3) {
    ans = min(ans, sz(cnt[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//B - Between a and b ...: 
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ll a, b, x, ans, nA, nB;
    cin >> a >> b >> x;
    nA = a / x;
    nB = b / x;
    if(a % x == 0) nB++;
    ans = nB - nA;
    cout << ans << "\n";
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    vint t(5);
    rep(i, 5) cin >> t[i];
    
    int mn = 0;
    int rm = INF;
    rep(i, 5) {
        if (t[i]%10 < rm && t[i]%10 != 0) {
            mn = i;
            rm = t[i]%10;
        }
    } 

    int ans = t[mn];
    rep(i, 5) {
        if (i == mn) continue;
        if (t[i]%10 == 0) ans += t[i];
        else ans += (t[i]/10+1)*10;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b==c||a+c==b||b+c==a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
h, w  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()
 
print('{}'.format('#' * (w + 2)))
for _ in range(h):
    print('#{}#'.format(input()))
print('{}'.format('#' * (w + 2)))

Measured memory_bytes: 3316
#include<cstdio>
using namespace std;
int main(){
    int n,cnt=0;
    char s[110];
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            cnt++;
        }
    }
    if(cnt>n/2){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

Measured memory_bytes: 128
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
elif h % 2 == 1 and w % 2 == 1:
    print(-(-(h * w) // 2))
else:
    print((h * w) // 2)

Measured memory_bytes: 5172
#include <iostream>
using namespace std;
int cos(int n)
{
	int pos=0;
	while (n!=0)
	{
		n/=10;
		pos++;
	}
	return pos;
}
int main()
{	
	int n,total=0;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		if (cos(i)%2==1)  total++;  
	}
	cout<<total<<endl;
	return 0;
}

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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


int main(void){
    ll n;
    cin >> n;
    vector<ll>city(n+1);
    for(int i=0;i<n+1;i++){
        cin >> city[i];
    }
    sort(city.begin(),city.end());
    for(int i=0;i<n;i++){
        city[i] = city[i+1]-city[i];
    }
    ll ans = city[0];
    for(int i=1;i<n;i++){
        ans = euclidean_gcd(ans,city[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll mod = 1e9 + 7;
    string s;
    cin >> s;
    ll n = s.size();
    vvll dp(n + 1, vll(13));
    REP(i, 13) dp[0][i] = 0;
    dp[0][0] = 1;
    REP(i, n){
        ll num = (s[i] == '?') ? -1 : (s[i] - '0');
        if(num == -1){
            REP(nxt, 10){
                REP(k, 13){
                    dp[i + 1][(k * 10 + nxt) % 13] += dp[i][k];
                    dp[i + 1][(k * 10 + nxt) % 13] %= mod;
                }
            }
        }
        else{
            REP(k, 13){
                dp[i + 1][(k * 10 + num) % 13] += dp[i][k];
                dp[i + 1][(k * 10 + num) % 13] %= mod;
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 13648
#include <stdio.h>

void tmp(int *x, int *y){
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (b > c) tmp(&b, &c);
    if (a > b) tmp(&a, &b);
    if (b > c) tmp(&b, &c);
    printf("%d %d %d\n", a, b, c);
    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define MAXN 110
int n,flag;
char ch[MAXN];
int main(){
	scanf("%s",ch);
	n=strlen(ch);
	for(int i=0;i<n;i++)
		if(ch[i]=='C') flag=1;
		else if(flag&&ch[i]=='F'){ puts("Yes"); return 0;}
	puts("No");
	return 0;
}

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

typedef long long ll;

ll X, D, K;

int main() {
	scanf("%lld %lld %lld", &X, &K, &D);
	X = abs(X);
	if (X / D > K) {
		printf("%lld\n", X - K * D);
		return 0;
	} else {
		ll cnt = X / D;
		if ((K - cnt) % 2 == 0) printf("%lld\n", X % D);
		else printf("%lld\n", (D - (X % D)));
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

// const int N = int(1e5) + 10;
const int MOD = int(1e9) + 7;



int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	string k; cin >> k;
	int n = k.size();
	reverse(k.begin(), k.end());
	k = "0" + k;
	int d; cin >> d;

	vector<vector<int>> dp1(n, vector<int>(d, 0));
	dp1[0][0] = 1;
	for (int i = 1; i < n; i++) {
		for (int r = 0; r < d; r++) {
			for (int digit = 0; digit < 10; digit++) {
				(dp1[i][r] += dp1[i - 1][(r - digit % d + d) % d]) %= MOD;
			}
		}
	}

	vector<vector<int>> dp2(n + 1, vector<int>(d, 0));
	dp2[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int r = 0; r < d; r++) {
			dp2[i][r] = dp2[i - 1][(r - (k[i] - '0') + d) % d];
			for (int digit = 0; digit < k[i] - '0'; digit++) {
				(dp2[i][r] += dp1[i - 1][(r - digit % d + d) % d]) %= MOD;
			}
		}
	}

	cout << (dp2[n][0] + MOD - 1) % MOD << endl;

	return 0;
}

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

int main()
{
	string S,SS;

	getline(cin, S);
	getline(cin, SS);
	
	if (S[0] == SS[2] && S[1] == SS[1] && S[2] == SS[0])
		cout << "YES";
	else cout << "NO";

	return 0;
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int N ; cin >> N;
  
  vector<int> V(N,0);
  int sum = 0;
  int localmax = 0;
  for(int i = 0; i < N ; i++){
  	cin >> V.at(i);
    sum += V.at(i);
    if(localmax < V.at(i)) localmax = V.at(i);
  }
  
  if( localmax < sum-localmax ) Yes();
  else No();
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();

    sc.close();

    StringBuffer sb =new StringBuffer(S);

    String R = sb.reverse().toString();

    R = R.replaceAll("resare", "");
    R = R.replaceAll("esare", "");
    R = R.replaceAll("remaerd", "");
    R = R.replaceAll("maerd", "");

    if (R.equals("")) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }

  }

}

Measured memory_bytes: 28276
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s.at(5) == '1' || (s.at(6) != '4' && s.at(6) != '3' && s.at(6) != '2' && s.at(6) != '1'))
    cout << "TBD" << endl;
    else 
    cout << "Heisei" << endl;
    return 0; 
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int (i)=0,i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(x) cout << x << endl
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

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

    vector<ll> A(N);
    set<ll> B;
    ll tmp = 0, cnt = 0;
    REP(i,N){
        cin >> A[i];
        tmp = MAX(tmp,A[i]);
        B.insert(A[i]);
    }
    REP(i,N) if(A[i] == tmp) ++cnt;

    auto itr = B.end();
    --itr;
    REP(i,N){
        if(A[i] == tmp && cnt == 1){
            --itr;
            cout << *itr << endl;
            ++itr;
        }
        else cout << tmp << endl;
    }

    return 0;
}

Measured memory_bytes: 8704