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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K; cin >> N >> K;
    vector<i64> A(N);

    i64 s = 0;
    REP(i, N) {
        cin >> A[i];
        s += A[i];
    }

    vector<i64> divisor;
    for (i64 i = 1; i * i <= s; i++) {
        if (s % i == 0) {
            divisor.pb(i);
            divisor.pb(s / i);
        }
    }

    i64 maxd = 0;
    for (i64 d : divisor) {
        vector<i64> rem(N);
        REP(i, N) rem[i] = A[i] % d;
        sort(rem.begin(), rem.end());

        vector<i64> declC(N + 1, 0);
        REP(i, N) declC[i + 1] = declC[i] + rem[i];
        i64 n_inc = declC[N] / d;

        i64 reqK = declC[N - n_inc];
        if (reqK <= K) chmax(maxd, d);
    }
    cout << maxd << endl;

    return 0;
}


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

int main() {
  int N;
  string str;
  int K;
  cin >> N >> str >> K;
  
   for (int i = 0; i < N; i++) {
    
    if (str.at(i) != str.at(K-1) ) {
  str.at(i) = '*'; 
 
   }
    
   }
  
    
      cout << str << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var a, b, x int
	if _, err := fmt.Fscan(reader, &a, &b, &x); err != nil {
		panic(err)
	}
	if a%x == 0 {
		fmt.Println(b/x - (a/x - 1))
	} else {
		fmt.Println(b/x - a/x)
	}
}


Measured memory_bytes: 1840
fun main(args: Array<String>) {
    a100(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}


fun a100(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    println(if (args[0].split(" ").map { it.toInt() }.any { it > 8 }) ":(" else "Yay!")
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int A[100000];
	for (int i = 0; i < N; i++) cin >> A[i];
	int check_sum = N-K;
	int count = 1;
	while (check_sum > 0) {
		check_sum -= K - 1;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(20000000)

n = int(input())
g = [[] for i in range(n)]
c = [-1 for i in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    w = w % 2
    g[u].append([v, w])
    g[v].append([u, w])


def dfs(p, d):
    if c[p] == -1:
        c[p] = d
        for x, w in g[p]:
            dfs(x, d ^ w)


dfs(0, 0)

for i in range(len(c)):
    print(c[i])


Measured memory_bytes: 82256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> v(n);
	inc(i, n) { cin >> v[i].FI; }
	inc(i, n) { cin >> v[i].SE; }
	sort(ALL(v));
	
	vector<int> a(n), b(n), c;
	inc(i, n) {
		a[i] = v[i].FI;
		b[i] = v[i].SE;
	}
	c = b;
	sort(ALL(c));
	
	inc(i, n) {
		if(a[i] > c[i]) { cout << "No" << endl; return 0; }
	}
	inc(i, n - 1) {
		if(a[i + 1] <= c[i]) { cout << "Yes" << endl; return 0; }
	}
	
	inc(i, n - 1) { assert(c[i] < c[i + 1]); }
	
	map<int, int> mp;
	inc(i, n) { mp[c[i]] = i; }
	
	vector<int> f(n, 0);
	int x = 0;
	inc(i, n) {
		if(f[i] != 0) { continue; }
		int p = i;
		do {
			f[p] = 1;
			p = mp[b[p]];
			x++;
		} while(p != i);
		x--;
	}
	
	cout << (x <= n - 2 ? "Yes" : "No") << endl;
	
	return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



// aとbの最大公約数
ll gcd(ll a, ll b) {
	if (a < b) gcd(b, a);
	ll r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}

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

// 約数列挙
vector<int> divisor(int n){
	vector<int> ret;
	for (int i = 1; i*i <= n; i++){
		if (n%i == 0){
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	return ret;
}

signed main(){

	int N;
	vector<int> A;
	cin >> N;
	A.resize(N);
	rep(i, N) cin >> A[i];

	vector<int> div = divisor(A[0]);

	int ans = -INF;
	for (auto d : div){
		int cnt = 0;
		for (int i = 0; i < N; i++){
			if (A[i] % d == 0) cnt++;
		}
		if (cnt >= N - 1) {
			ans = max(ans, d);
		}
	}

	div = divisor(A[1]);
	for (auto d : div){
		int cnt = 0;
		for (int i = 0; i < N; i++){
			if (A[i] % d == 0) cnt++;
		}
		if (cnt >= N - 1) {
			ans = max(ans, d);
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 10;
const double pi = acos(-1);

void solve(){
    int n, a, b, i;
    cin >> a >> b;
    int l = b * 10, r = (b + 1) * 10;
    for1(i, l, r - 1){
        int tmp = i * 8;
        tmp /= 100;
        if(tmp == a){
            cout << i; return;
        }
    }
    cout << -1;
}

signed main() {
    //freopen(".INP", "r", stdin); 
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import Control.Arrow
import Control.Monad
import Control.Monad.ST
import Control.Monad.State.Strict
import Data.Char
import Data.Function
import Data.List
import Data.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.Unsafe as B

type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
 
parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
 
parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

main :: IO ()
main = do
  !n <- readLn :: IO Int
  !mat <- U.unfoldrN (3*n-1) parseInt <$> C.getContents
  let as = U.slice 0 n mat
  let bs = U.slice n n mat
  let cs = U.slice (2*n) (n-1) mat
  let bonus = U.zipWith (\i i' -> if i+1 == i' then cs U.! (i-1) else 0) as (U.tail as)
  print $ U.sum bs + U.sum bonus

ex1 :: (U.Vector Int, U.Vector Int, U.Vector Int)
ex1 = (U.fromList [3,1,2], U.fromList [2,5,4], U.fromList [3,6])


Measured memory_bytes: 508
W, H, N = map(int, input().split())
wl = 0
wr = W
hu = 0
hl = W

for _ in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        if x > wl:
            wl = x
    elif a == 2:
        if x < wr:
            wr = x
    elif a == 3:
        if y > hu:
            hu = y
    else:
        if y < hl:
            hl = y

if wl >= wr or hu >= hl:
    print(0)
else:
    ans = (wr - wl) * (hl - hu)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

vector<bool> ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,t,m,y,z;
    string s;
    cin>>n>>s;
    for(ll prev1=0;prev1<2;prev1++){
        for(ll curr1=0;curr1<2;curr1++){
            ll curr=curr1;
            ll prev=prev1;
            ans.assign(n,false);
            bool x = prev;
            ans[n-1] = prev;
            ans[0] = curr;
            for(int i=0;i<(n-1);i++){
                if(!curr){
                    if(s[i]=='o'){
                        ans[i+1] = ans[(i-1+n)%n];
                    }
                    else{
                        ans[i+1] = !ans[(i-1+n)%n];
                    }
                }
                else{
                    if(s[i]=='o'){
                        ans[i+1] = !ans[(i-1+n)%n];
                    }
                    else{
                        ans[i+1] = ans[(i-1+n)%n];
                    }
                }
                prev = curr;
                curr = ans[i+1];
            }
            if(curr!=x)continue;
            if(!curr){
                if(s[n-1]=='o'){
                    if(ans[n-2]!=ans[0])continue;
                }
                else{
                    if(ans[n-2]==ans[0])continue;
                }
            }
            else{
                if(s[n-1]=='o'){
                    if(ans[n-2]==ans[0])continue;
                }
                else{
                    if(ans[n-2]!=ans[0])continue;
                }
            }
            for(int i=0;i<n;i++){
                cout<<(ans[i]?'W':'S');
            }
            return 0;
        }
    }
    cout<<-1;


    return 0;
}

Measured memory_bytes: 592
# nの定義
n = int(input())

# p,qの定義
p, q = [list(map(int, input().split())) for _ in range(2)]

# 全体数,nListを定義
sumN = 1
pList = [0] * n
qList = [0] * n
for i in range(n):
    sumN *= i + 1
    pList[i] = i + 1
    qList[i] = i + 1

sumN = sumN // n

pSum = 0
qSum = 0

for i in range(n - 1):
    pSum += pList.index(p[i]) * sumN
    pList.pop(pList.index(p[i]))

    qSum += qList.index(q[i]) * sumN
    qList.pop(qList.index(q[i]))

    sumN = sumN // (n - i - 1)

print(abs(pSum - qSum))


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

int N, dat[300000];
void init(int n_) {
	N = 1;
	while (N < n_)N *= 2;
	for (int i = 0; i < 2 * N - 1; i++)dat[i] = INT_MAX;
}
void update(int k, int a) {
	k += N - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}
int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l)return INT_MAX;
	if (a <= l&&r <= b)return dat[k];
	else {
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
}
int main() {
	int n, q; cin >> n >> q;
	init(n);
	rep(i, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)
			printf("%d\n", query(x, y + 1, 0, 0, N));
		else
			update(x, y);
	}
}

Measured memory_bytes: 4200
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main(void){
	int r,c;
	cin >> r >> c;
	int map[r+1][c+1];
	for(int i = 0;i <= c; ++i){
		map[r][i] = 0;
	}
	for(int i = 0;i < r; ++i){
		map[i][c] = 0;
		for(int j = 0;j < c; ++j){
			cin >> map[i][j];
			map[i][c] += map[i][j];
			map[r][j] += map[i][j];
			map[r][c] += map[i][j];
			cout << map[i][j] << " ";
		}
		cout << map[i][c] << endl;
	}
	for(int i = 0;i < c; ++i){
		cout << map[r][i] << " ";
	}
	cout << map[r][c] << endl;


	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>

int main(){
    int a;
    int b;
    cin >> a >> b;
    if(b-a >= 2019) cout << 0 << endl;
    else{
        a %= 2019;
        b %= 2019;
        int ans = 2020;
        if(a < b){
            for(int i = a;i<=b;i++){
                for(int j = i + 1;j<=b;j++){
                    ans = min(ans,i*j%2019);
                }
            }
            cout << ans << endl;
        }
        else cout << 0 << endl;
    }
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
first=a.pop(0)
ans=0
for i in range(n):
  if first+a[i]-b[i] <= 0:
    ans+=first+a[i]
    first=0
  elif first-b[i]>=0:
    ans+=b[i]
    first=a[i]
  else:
    ans+=b[i]
    first=a[i]-(b[i]-first)
print(ans)    

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

int main() {
  long N,W;
  cin>>N>>W;
  vector<long> w(N);
  vector<long> v(N);
  long sum=0;
  for(int i=0;i<N;i++) cin>>w[i]>>v[i],sum+=v[i];
  vector<vector<long>> dp(N+1,vector<long>(sum+1));

  for(int i=0;i<N;i++){
    for(int j=0;j<=sum;j++){
      dp[i][j]=1e15;
    }
  }
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=sum;j++){
      if(j-v[i]>=0) dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  long ans=0;
  for(int i=0;i<=N;i++){
    for(long j=0;j<=sum;j++){
      //cout<<dp[i][j]<<" ";
      if(dp[i][j]<=W) ans=max(ans,j);
    }
    //cout<<endl;
  }
cout<<ans<<endl;
}


Measured memory_bytes: 83016
ar=STDIN.gets.split
a =ar[0].to_f
b =ar[1].to_f
kakuc =ar[2].to_f*Math::PI/180.0

c=Math::sqrt(a*a+b*b-2*a*b*Math::cos(kakuc))
s=a*b*Math::sin(kakuc)/2
l=a+b+c
h=s/a*2

puts s
puts l
puts h

Measured memory_bytes: 8900
<?php
 
$n = trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));
$alice = 0;
$bob = 0;
foreach ($a as $k => &$v) {
  $max = 0;
  foreach($a as $key => $val) {
    if ($val > $max) {
      $mindex = $key;
      $max = $val;
    }
  }
  $a[$mindex] = 0;
  if ($k % 2 == 0){
    $alice += $max;
  }else{
    $bob += $max;
  }   
}

echo ($alice - $bob);

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e,i,n,k;
    cin>>k;
    char s[105];
    cin>>s;
    n=strlen(s);
    if(n<=k) cout<<s;
    else{
        for(i=0;i<k;i++) cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[][] a = new long[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = sc.nextLong();
			}
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i][k] == 0 || a[k][j] == 0 || a[i][j] == 0) continue;
					if (a[i][k] + a[k][j] < a[i][j]) {
						System.out.println(-1);
						return;
					}

					if (a[i][k] + a[k][j] == a[i][j]) {
						a[i][j] = 0;
						a[j][i] = 0;
					}
				}
			}
		}

		long answer = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				answer += a[i][j];
			}
		}

		System.out.println(answer / 2);
	}
}


Measured memory_bytes: 59116
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;
    cin>>N;
    long long a[N];
    long long b[N];
    long long mi=0;
    long long ma=0;
    for(long long i=0;i<N;i++){
    cin>>a[i];
    cin>>b[i];}
    sort(a,a+N);
    sort(b,b+N);
    if(N%2==1){
    mi=a[(N-1)/2];
    ma=b[(N-1)/2];
    cout<<ma-mi+1<<endl;}
    else{
    mi=a[N/2]+a[N/2-1];
    ma=b[N/2]+b[N/2-1];
    cout<<(ma-mi)+1<<endl;}}


Measured memory_bytes: 6776
S,n;main(s){for(;scanf("%d",&n)*n;printf("%d\n",S)){int d[]={S=1,2,3},a,b,t;for(;n--;S+=*d)scanf("%s",&s),t=d[a=s%265%3],d[a]=d[b=s%1668%5],d[b]=7-t;}}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i=0;i<N;i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  int ans=1000000007;
  for (int i=0;i<N-K+1;i++){
    ans=min(ans,h[i+K-1]-h[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long lint;

lint max(lint x,lint y,lint z){
	return max(x,max(y,z));
}

lint getMaxDif(lint x,lint y,lint z){
	return max(abs(x-y),abs(x-z),abs(y-z));
}

int main(){
	lint A,B;
	scanf("%lld%lld",&A,&B);

	lint ans;
	ans = min((A-3*(A/3)) * B, (B-3*(B/3)) * A);
	ans = min(ans, abs(A-3*(A/3+1)) * B);
	ans = min(ans, abs(B-3*(B/3+1)) * A);
	ans = min(ans, getMaxDif((A/2)*(B-B/3), (A/2+A%2)*(B-B/3), A*(B/3)));
	ans = min(ans, getMaxDif((B/2)*(A-A/3), (B/2+B%2)*(A-A/3), B*(A/3)));
	ans = min(ans, getMaxDif((A/2)*(B-B/3-(B%3>0)), (A/2+A%2)*(B-B/3-(B%3>0)), A*(B/3+(B%3>0))));
	ans = min(ans, getMaxDif((B/2)*(A-A/3-(A%3>0)), (B/2+B%2)*(A-A/3-(A%3>0)), B*(A/3+(A%3>0))));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
const ll INF = 1e18;
using namespace std;
using namespace atcoder;


struct Edge {
    ll from;
    ll to;
    ll cost;
    Edge(ll f, ll t, ll c) {
        from = f;
        to = t;
        cost = c;
    }
};


// UnionFind with Size;
struct UnionFind {
    vector<int> size;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
            size[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        par[x] = root(par[x]);
        return par[x];
    }

    int getSize(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        return size[root(x)];
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y); 
        if (rx == ry) return false;
        if (size[rx] < size[ry]) swap(x, y);
        size[rx] += size[ry];
        par[ry] = rx; 
        return true;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll kruskal(vector<Edge> &edges, int V) {
    sort(edges.begin(), edges.end(), [](const Edge &a, const Edge &b) {
        return a.cost < b.cost;
    });
    dsu d(V);
    ll res = 0;
    for (Edge& e: edges) {
        if (false == d.same(e.to, e.from)) {
            d.merge(e.to, e.from);
            res += e.cost;
        }
    }
    return res;
}

void Main()
{
    ll n, M;
    cin >> n >> M;

    vector<ll> A(M), B(M);
    rep(i, M) cin >> A[i] >> B[i];
    
    dsu d(n);
    rep(i, M) {
        d.merge(A[i]-1, B[i]-1);
    }

    ll siz = d.groups().size();
    put(siz-1);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > > 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define err(n) cout<<n<<" ";
#define t1 cout<<",";

void err_mask(ll n){
	if(n==0)return;
	while(n){
		cout<<n%2;
		n/=2;
	}
	cout<<" ";
}
ll MOD= 98244353;

void add_self (ll& a, ll b){
	a+= b;
	a%=MOD;
}

void sub_self (ll& a, ll b){
	a-=b;
	a= ((a%MOD)+MOD)%MOD;
}

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

void min_self(double& a, double b){
	a= min(a,b);
}


bool conflict(pll a, pll b){
	if(b.fr> a.sc)return 0;
	else return 1;
}


int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j;

ll a,b;cin>>a>>b;
cout<<max((ll)0, a-(2*b));
}
	

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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define debug(x) cout << '>' << #x << ':' << x << " ";
#define nl '\n'
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define int long long int

void solve(){
    int n;
    cin >> n;
    int cnt = 0;
    bool ans = false;
    f(i, 0, n){
        int u, v;
        cin >> u >> v;
        if(u == v){
            cnt++;
        }
        else {
            cnt = 0;
        }
        if(cnt >= 3){
            ans = true;
        }
    }
    if(ans){
        cout << "Yes" << nl;
    }
    else {
        cout << "No" << nl;
    }
}
main()
{
    IO;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
	int T = 1;
    // cin >> T;
    fo(c, 1, T){
        solve();
        // cout<<"Case #"<<c<<": ";
    }
    return 0;
}

Measured memory_bytes: 3648
H,W = map(int,input().split())
D = [[0]*(W) for i in range(H)]

for i in range(H):
    S = input()
    for j in range(W):
        s = S[j]
        if s=='.':
            D[i][j] = 1

ans = 0
import heapq

for i in range(H):
    for j in range(W):
        if D[i][j] == 1:
            tmp = 0
            h = [[0,i,j]]
            visited = [[0]*W for i in range(H)]
            while h!=[]:
                w,nowi,nowj = heapq.heappop(h)
                tmp = max(tmp,w)
                visited[nowi][nowj] = 1
                if 0<nowi<H-1:
                    for k in [-1,1]:
                        if D[nowi+k][nowj]==1 and visited[nowi+k][nowj]==0:
                            heapq.heappush(h,[w+1,nowi+k,nowj])
                            visited[nowi+k][nowj]=1
                elif nowi+1<=H-1:
                    if D[nowi+1][nowj]==1 and visited[nowi+1][nowj]==0:
                        heapq.heappush(h,[w+1,nowi+1,nowj])
                        visited[nowi+1][nowj]=1
                elif nowi-1 >=0:
                    if D[nowi-1][nowj]==1 and visited[nowi-1][nowj]==0:
                        heapq.heappush(h,[w+1,nowi-1,nowj])
                        visited[nowi-1][nowj]=1

                if 0<nowj<W-1:
                    for k in [-1,1]:
                        if D[nowi][nowj+k]==1 and visited[nowi][nowj+k]==0:
                            heapq.heappush(h,[w+1,nowi,nowj+k])
                            visited[nowi][nowj+k]=1
                elif nowj-1>=0:
                    if D[nowi][nowj-1]==1 and visited[nowi][nowj-1]==0:
                        heapq.heappush(h,[w+1,nowi,nowj-1])
                        visited[nowi][nowj-1]=1
                elif nowj+1 <= W-1:
                    if D[nowi][nowj+1]==1 and visited[nowi][nowj+1]==0:
                        heapq.heappush(h,[w+1,nowi,nowj+1])
                        visited[nowi][nowj+1]=1
            ans = max(ans,tmp)
            
print(ans)

Measured memory_bytes: 62684
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 101
int x[N],y[N],h[N],n;
int main(){
    cin>>n;
    lol(i,n)cin>>x[i]>>y[i]>>h[i];
    lol(i,N)lol(j,N){
	set<int> st;
	int lim=mod*2;
	lol(k,n){
	    int w=abs(i-x[k])+abs(j-y[k]);
	    if(h[k]==0)lim=min(lim,w);
	    else st.insert(h[k]+w);
	}
	if(st.size()==1){
	    int res=*st.begin();
	    if(!(1<=res&&res<=lim))continue;
	    cout<<i<<" "<<j<<" "<<res<<endl;
	}
	if(st.size()==0){
	    cout<<i<<" "<<j<<" "<<1<<endl;
	}
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

    ll ans = 1;
    rep(i, sqrt(N)+1) {
        ans = i * i;
    }

    print(ans);
}




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

char s[105];

inline bool ispalindrome(int p, int q)
{
	for(; p<q; p++, q--)
		if(s[p] != s[q])
			return false;
	return true;
}

int main(int argc, char** argv)
{
	int n = 0;
	char c; while((c = getchar()) != '\n') s[n++] = c;
	puts((ispalindrome(0, n - 1) && ispalindrome(0, (n - 1 >> 1) - 1) && ispalindrome((n + 3 >> 1) - 1, n - 1))? "Yes": "No");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


ll gcd(ll a, ll b)
{
	ll c;

	while((c=a%b))
	{
		a=b;
		b=c;
	}
	return b;
}


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


int lsb(int v)
{
	for(int i=0;v;i++)
	{
		if((v>>i)&1) return i;
	}
	return 0;
}


int solve(vi&a, int m)
{
	int b=lsb(a[0]);
	for(int ma:a)
	{
		if(b!=lsb(ma)) return 0;
	}

	ll x=1;
	for(int ma:a)
	{
		x=lcm(x, ma/2);
		if(x>m) break;
	}
	return (m/x+1)/2;
}


int main(void)
{
	int n, m;
	while(scanf("%d%d", &n, &m)==2)
	{
		vi a(n);

		for(auto&ma:a) scanf("%d", &ma);
		printf("%d\n", solve(a, m));
	}
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if(a==0 && b==0 && c==0) break;
			
			int n = sc.nextInt();
			int[] ans = new int[a+b+c+1];
			int[] s = new int[n];
			int[] t = new int[n];
			int[] u = new int[n];
			int r;
			
			for(int i=0;i<n;i++){
				s[i] = sc.nextInt();
				t[i] = sc.nextInt();
				u[i] = sc.nextInt();
				r = sc.nextInt();
				if(r==1){
					ans[s[i]] = 1;
					ans[t[i]] = 1;
					ans[u[i]] = 1;
				}		
			}
			
			for(int i=0;i<n;i++){
				if(ans[s[i]]==1 && ans[t[i]]==1 && ans[u[i]]==0) ans[u[i]] = 2;
				else if(ans[t[i]]==1 && ans[u[i]]==1 && ans[s[i]]==0) ans[s[i]] = 2;
				else if(ans[u[i]]==1 && ans[s[i]]==1 && ans[t[i]]==0) ans[t[i]] = 2;
			}
			
			for(int i=1;i<=a+b+c;i++){
				if(ans[i]==0) System.out.println("2");
				else if(ans[i]==1) System.out.println("1");
				else if(ans[i]==2) System.out.println("0");
			}

		}
	}	
}

Measured memory_bytes: 28328
#include <fstream>
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

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

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

  int sum_val = 0; 
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= n; b++)
      for (int c = 1; c <= n; c++)
        sum_val += gcd(gcd(a,b),c);

  cout << sum_val << "\n";
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;

    rep(i,n) {
        if((i+1)%2 == 1){
            if(a[i]%2 == 1){
                ans++;
            }
        }
    }

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

Measured memory_bytes: 3624
n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
f = gets.chomp.split.map(&:to_i)

a.sort!
f.sort!.reverse!

array = a.zip(f)
array.sort_by!{|x,y| -x*y}

def ok?(array, threashold, k)
  array.each do |x, y|
    if x * y > threashold
      k -= x - (threashold / y).to_i
    end
    return false if k < 0
  end
  return true
end

minans = 0
maxans = 10**12
while true
  threashold = (minans + maxans) / 2
  if ok?(array, threashold, k)
    maxans = threashold
  else
    minans = threashold
  end

  # p [minans, maxans]
  if maxans - minans <= 1
    if ok?(array, minans, k)
      puts minans
      break
    else
      puts maxans
      break
    end
  end
end


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

typedef long long ll;
const int maxn = 4005;
typedef pair<int, int>par;
const ll mod = 998244353;

ll dp[maxn][maxn][2];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in", "r",stdin);
    #endif // acm

    int n, s;
    cin >> n >> s;

    int a;
    for( int i = 1; i <= n; i++ ){
        cin >> a;
        for( int j = 1; j <= s; j++ ){
            dp[i][j][0] = (dp[i-1][j][0] + dp[i-1][j][1])%mod;
            if( j >= a )
                dp[i][j][1] = (dp[i-1][j-a][1] + dp[i-1][j-a][0])%mod;
        }
        dp[i][a][1] = (dp[i][a][1] + i)%mod;
    }

    ll sol = 0;
    for( int i = 1; i <= n; i++ )
        sol = (sol + (dp[i][s][1] * (n-i+1))%mod)%mod;

    cout << sol << "\n";
    return 0;
}


Measured memory_bytes: 188288
#include <iostream>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  long int s=0;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      s+=a[i]*a[j];
    }
  }
  
  cout<<s<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>


using namespace std;

int main()
{


	string str;


	cin >> str;

	string ans = "Yes";

	for (int i = 0; i < str.length(); i++) {
		
		if (str[i] == 'R' && i % 2 == 1) {

			ans = "No";
			break;

		}
		if (str[i] == 'L' && i % 2 == 0) {

			ans = "No";
			break;

		}

	}

	cout << ans << endl;






	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, n) for (size_t i = 0; i < (n); i++)
#define REP(n) FOR(i, n)
#define cinv(v, n) REP(n) {cin>>(v)[i];}
#define nvec(T, v, n) vector<T> v(n); cinv(v, n)
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}


int main(){
  string s;
  cin>>s;
  long co = 0;
  for (int i = 0; i < s.length(); i++) { //index
    for (int j = 1; j <= s.length()-i; j++) { //文字数
      co+=stol(s.substr(i,j))*max(pow(2,i-1),1.0)*max(pow(2,(int)s.length()-i-j-1),1.0);
    }
  }
  cout<<co;
  
}






/* きょむ〜 */

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u32 k;
  cin >> k;

  if ((k & 1) == 0) {
    cout << -1;
    return 0;
  }

  if (k == 7 || k == 1) {
    cout << 1;
    return 0;
  }

  u64 s = 7;

  u64 ans = 0;

  rep(i, k) {
    s = (s * 10 + 7) % k;
    if (s == 0) {
      cout << i + 2;
      return 0;
    }
  }

  cout << -1;

  return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N, K; cin >> N >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    vector<ll> bt(N*(N+1)/2);
    int idx = 0;
    for(int i = 0; i < N; i++){
        ll acc = 0;
        for(int j = i; j < N; j++){
            acc += A[j];
            bt[idx] = acc;
            idx++;
        }
    }
    //rep(i, bt.size()) cout << bt[i] << " "; cout << endl;

    ll pow2[40]; pow2[0] = 1;
    for(int i = 1; i < 40; i++) pow2[i] = pow2[i-1] << 1;
    int m = 39; ll ans = 0;
    for(int t = m; t >= 0; t--){
        int cnt = 0;
        for(int i = 0; i < bt.size(); i++){
            if(((ans + pow2[t]) & bt[i]) == (ans + pow2[t])) cnt++;
        }
        if(cnt >= K) ans += pow2[t];
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(W>=x+r && x-r>=0 && H>=y+r && y-r>=0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	} 
	return 0;
}


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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)



int main() {
	string n;
	cin >> n;
  char end= n[n.size()-1];
  if(end=='3'){
    cout  << "bon"  << endl;
  }
  else if(end=='0'||end=='1'||end=='6'||end=='8'){
    cout  << "pon"  << endl;
  }
  else{
    cout << "hon" << endl;
  }

}


Measured memory_bytes: 3624
N = int(input())
S = list(input())
ans = -1
for x in ['SS', 'SW', 'WS', 'WW']:
    for i, s in enumerate(S):
        if s=='o':
            if x[-1]=='S':
                x += x[-2]
            else:
                if x[-2]=='S':
                    x += 'W'
                else:
                    x += 'S'
        else:
            if x[-1] == 'S':
                if x[-2]=='S':
                    x += 'W'
                else:
                    x += 'S'
            else:
                x += x[-2]
    if x[0]==x[-2] and x[1]==x[-1]:
        ans = x[1:-1]
        break
print(ans)

Measured memory_bytes: 4140
n=int(input())
h=list(map(int, input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])

for i in range(2, n):
    a=abs(h[i]-h[i-1])
    b=abs(h[i]-h[i-2])
    dp[i]=min((dp[i-1]+a), (dp[i-2]+b))

print(dp[n-1])

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

int main(){
    int v = 0;
    int x, y, z, w;
     
    cin >> x >> y >> z; 
    w = x;
    while(1){
        if (w > y) break;
        if (z % w == 0) {
            v = v + 1;
        }
        w = w + 1;
    }
   cout << v << endl; 
}


Measured memory_bytes: 3116
from collections import Counter

N = int(input())
counter = [Counter(input()) for _ in range(N)]

c = counter[0]
for i in range(1,N):
  for k,v in c.items():
    c[k] = min(counter[i][k], c[k])

c = sorted(c.items())
answer = ''
for k,v in c:
  answer += k*v
print(answer)

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int INF=1e9;



int main(){
	int W,H;
	cin>>W>>H;
	vi p(W,0);
	vi q(H,0);
	rep(i,W)cin>>p[i];
	rep(i,H)cin>>q[i];
	sort(p.begin(),p.end());
	sort(q.begin(),q.end());
	p.push_back(INF);
	q.push_back(INF);
	
	int pin=0;
	int qin=0;
	int pml=H+1;
	int qml=W+1;
	ll ans=0;
	while(pin<W || qin<H){
		if(p[pin]<q[qin]){
				ans=ans+(ll)p[pin]*pml;
				pin++;
				qml--;
		}
		else{
			ans=ans+(ll)q[qin]*qml;
			qin++;
			pml--;
		} 
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(){
  char strS[51], strT[51], tmp[51];
  int lS, lT, i, j, k, count=0;

  scanf("%s %s", strS, strT);
  lS = strlen(strS);
  lT = strlen(strT);

  for(i=lS-lT; i>=0; i--){
    count = 0;
    strncpy(tmp, strS+i, lT);
    tmp[lT] = '\0';
    //printf("%s\n",tmp);
    for(j=0; j<=lT-1; j++){
      if(tmp[j]==strT[j] || tmp[j]=='?'){
        count++;
      }else{
        break;
      }
      if(count==lT){
        for(k=0; strS[k]!='\0' ;k++)if(strS[k] == '?'){
          strS[k] = 'a';
        }
        for(k=0; k<=lT-1; k++){
          strS[i+k] = strT[k];
        }
        goto next;
      }
    }
  }
  next:

  if(count!=lT){
    printf("UNRESTORABLE\n");
  }else if(count==lT){
    printf("%s\n",strS);
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
	int n;
	cin >> n;
	bool flag = true;
	rep(i,10) {
		if (i == 0) {
			continue;
		}
		if (n % i == 0) {
			if (n/i >= 10) {
				flag = false;
			} else {
				flag = true;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     string str;
     cin>>str;
     ll n=str.size(),cnt=0;
     n-=2;
     while(n>=0)
     {
         string str2,str3;
         for(int i=0;i<n/2;i++)
            str2+=str[i];
         for(int i=(n/2);i<n;i++)
            str3+=str[i];
        //cout<<str2<<" "<<str3<<endl;
         if(str2==str3)
         {
             cout<<n<<endl;
             cnt=10;
             break;
         }
         n-=2;
     }
     if(cnt==0)
        cout<<"0"<<endl;
}


Measured memory_bytes: 3588
//                                              Question ki ma ki chut !!
#include<bits/stdc++.h>
using namespace std;
#define Going_supersonic ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define allr(v) v.rbegin(),v.rend()
#define sz() size()
#define l() length()
#define lli long long int
#define ed endl
#define iv vector<lli>
#define bg() begin()
#define e() end()
#define ff first
#define ss second
lli sti(string s)
{
    lli num=0;
    lli p=1;
    for(lli it=s.l()-1;it>=0;p*=10)
        num+=(s[(it--)]-48)*p;
    return num;
}
lli n,m,cnt,mx,mn,l,sm,r;
lli dp[100002];
lli solve(iv &a, lli pos,lli k)
{
    //cout<<"Called for "<<pos<<" "<<k<<ed;
    if(dp[pos]!=-1)
        return dp[pos];
    if(pos>=n-k)
        return dp[pos]=abs(a[pos]-a[n-1]);
    lli mn=LLONG_MAX;
    for(lli i=1;i<=k;i++)
    {
        mn=min(mn,abs(a[pos]-a[pos+i])+solve(a,pos+i,k));
    }
    return dp[pos]=mn;
}
int main(){
    Going_supersonic
    lli T=1;
    //cin>>T;
    while(T--){
            lli i,j,k;
            cin>>n>>k;
            iv a(n);
            for(i=0;i<n;cin>>a[i++]);
            memset(dp,-1,sizeof(dp));
            if(k>=n)
                cout<<abs(a[0]-a[n-1])<<ed;
            else{

                cout<<solve(a,0,k)<<ed;
            }
                //for(i=0;i<10;cout<<dp[i++]<<" ");

    }

    return 0;
}


Measured memory_bytes: 14280
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;
int A,B,C;
int l[13];

// i本目まで(i+1本の)竹を使う
int dfs(int i, int a, int b, int c)
{
  if (i == N) { // N-1本の竹を全て使い終えた時点 (N回目)
    if (a > 0 && b > 0 && c > 0) {
      // 延長or短縮
      // 最初の竹に関しては合成不要なので-10*3 (最後に辻褄合わせ)
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    } else { // a=b=c=0 は不適
             // “無” に対して延長魔法を使って竹を得ることはできない
      return INF;
    }
  }
  int res = INF;
  // l[i] をどれにも使わない
  chmin(res, dfs(i+1, a, b, c));
  // l[i] をAに合成
  chmin(res, dfs(i+1, a+l[i], b, c) + 10);
  // Bに合成
  chmin(res, dfs(i+1, a, b+l[i], c) + 10);
  // Cに合成
  chmin(res, dfs(i+1, a, b, c+l[i]) + 10);
  return res;
}

int main()
{
  cin >> N >> A >> B >> C;
  REP(i,0,N) cin >> l[i];

  cout << dfs(0,0,0,0) << endl;

  return 0;
}


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

using namespace std;


int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r >= 0 && W-x>=r&&y>=r && H-y>=r){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll MAX_H=1e3;
ll MAX_W=1e3;
vll a(MAX_H*MAX_W,-1);
vector<string> s(MAX_H);

ll h,w;



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

  cin>>h>>w;
  ll ch,cw,dh,dw;
  cin>>ch>>cw>>dh>>dw;
  ch--;
  cw--;
  dh--;
  dw--;
  REP(i,h)cin>>s[i];


  auto valid=[&](ll x, ll y){
    if(x<0 || w<=x || y<0 || h<=y)
      return false;
    return true;
  };

  vll d(h*w,LLINF);
  deque<vll> que;
  vll v={cw,ch,0};
  que.push_back(v);
  d[ch*w+cw]=0;

  while(!que.empty()){
    ll x=que.front()[0];
    ll y=que.front()[1];
    ll dist=que.front()[2];
    que.pop_front();

    REP(i,4){
      ll nx=x+dx[i];
      ll ny=y+dy[i];
      if(valid(nx,ny) && s[ny][nx]=='.' && d[ny*w+nx]>dist){
        d[ny*w+nx]=dist;
        vll p={nx,ny,dist};
        que.push_front(p);
      }
    }

    for(ll dxx=-2; dxx<=2; dxx++){
      for(ll dyy=-2; dyy<=2; dyy++){
        ll nx=x+dxx;
        ll ny=y+dyy;
        if(valid(nx,ny) && s[ny][nx]=='.' && d[ny*w+nx]>dist+1){
          d[ny*w+nx]=dist+1;
          vll p={nx,ny,dist+1};
          que.push_back(p);
        }
      }
    }
  }

//  REP(i,h){
//    REP(j,w)cout<<d[i*w+j]<<" ";
//    cout<<endl;
//  }

  ll ans=d[dh*w+dw];
  if(ans==LLINF)
    ans=-1;
  cout<<ans<<endl;

}



Measured memory_bytes: 20504