akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

/**
 * Change a Little Bit
 * 
 * https://atcoder.jp/contests/abc150/tasks/abc150_e
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long MOD = 1000000007;

            int N = sc.nextInt();
            long[] C = new long[N];
            for (int i = 0; i < N; i++) {
                C[i] = sc.nextLong();
            }

            Arrays.sort(C);

            long P = pow(2, N - 1, MOD);

            long ans = 0;
            for (int i = 0; i < N; i++) {
                ans = (ans + C[i] * ((P + P * (N - i) % MOD))) % MOD;
            }

            ans = (ans * P) % MOD;

            System.out.println(ans);
        }
    }

    static long pow(long A, long B, long MOD) {
        if (B == 0) {
            return 1;
        } else if (B % 2 == 0) {
            long C = pow(A, B / 2, MOD);
            return C * C % MOD;
        } else {
            long C = pow(A, B - 1, MOD);
            return A * C % MOD;
        }
    }

}


Measured memory_bytes: 65232
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
long ans;

int main(){
    scanf("%ld", &n);
    ans = (n / 11)*2;
    if(n % 11 == 0){
        printf("%ld\n", ans);
    }else if(n % 11 <= 6){
        printf("%ld\n", ans+1);
    }else{
        printf("%ld\n", ans+2);
    }
}


Measured memory_bytes: 256
-- wide-flip.hs --- Wide Flip

-- author: Seong Yong-ju <sei40kr@gmail.com>

solve :: Int -> Int -> Int -> String -> Int
solve _ _ t [] = t
solve _ _ t [_] = t
solve n k t (c:c':cs)
  | c /= c' = solve n (succ k) (min t . max k $ n - k) (c' : cs)
  | otherwise = solve n (succ k) t (c' : cs)

main :: IO ()
main = do
  s <- getLine
  let l = length s
  print $ solve l 1 l s


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;


struct E{
    int to,id;
};

using graph = vector<vector<E>>;;
vector<int> col(100005);
void dfs(graph &G,int v,int p = -1,int c = -1){
    int k = 1;
    for(E e : G[v]){
        int nv = e.to;
        if(nv == p) continue;
        if(k == c) k++;
        col[e.id] = k; k++;
        
        dfs(G,nv,v,col[e.id]);
    }
}

int main(){
    int n;cin >> n;
    graph G(n);
    rep(i,n-1){
        int a,b;cin >> a >> b;
        --a;--b;
        G[a].emplace_back((E){b,i});
        G[b].emplace_back((E){a,i});
    }
    dfs(G,0);

    int mx = 0;
    rep(i,n-1) mx = max(mx,col[i]);
    cout << mx << endl;
    rep(i,n-1){
        cout << col[i] << endl;
    }

    
}

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

using namespace std;

int main() {
	int k;
	scanf("%d", &k);
	if (k == 1) {
		puts("1");
		puts("1");
		return 0;
	}
	int n = (k + 3) / 4 * 2;
	printf("%d\n", n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int color = (i + j) % n;
			if ((i & 1) && color + n < k) {
				color += n;
			}
			printf("%d ", color + 1);
		}
		puts("");
	}
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;    

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    bool out[200]={false};
    string s;
    cin>>s;
    rep(i,s.size()){
	int a=(int)s[i];
	out[a]=true;
    }
    for(int i=97;i<=122;i++){
	if(!out[i]){
	    cout<<(char)i<<'\n';
	    return 0;
	}
    }
    cout<<"None"<<'\n';
    
    return 0;
}


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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long n;
  cin >> n;
  long long min = __LONG_LONG_MAX__;
  for (long long i = 1; i <= sqrt(n); i ++) {
    if (n % i == 0) {
      long long s = i + n / i - 2;
      if (s < min) min = s;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int p[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &p[i]);
	int ans = 0;
	for (i = 0; i < n; i++)
	{
		if (p[i] == i + 1)
		{
			ans++;
			p[i] ^= p[i + 1];
			p[i + 1] ^= p[i];
			p[i] ^= p[i + 1];
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    for(int i=0;i<M;i++){
        cin >> B[i];
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        int A[M], sum = C;
        for(int j=0;j<M;j++){
            cin >> A[j];
        }
        for(int k=0;k<M;k++){
            sum += A[k] * B[k];
        }
        if(sum > 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    long long int ar[n+5];
    for(int i=0;i<n;i++)scanf("%lld",&ar[i]);

    long long int dp[n+2];
    dp[0]=0;

    dp[1]=abs(ar[1]-ar[0]);
    for(int i=2;i<n;i++)
    {
        int second=i-k;
        if(second<0)second=0;
        dp[i]=dp[second]+abs(ar[second]-ar[i]);
        for(int j=second+1;j<i;j++)
        {
            int dif=abs(ar[j]-ar[i]);
            dp[i]=min(dp[j]+dif,dp[i]);
        }
    }

//    cout<<"Dp array is : "<<endl;
//    for(int i=0;i<n;i++)cout<<dp[i]<<" ";
//    cout<<endl;

    printf("%lld\n",dp[n-1]);

    return 0;

}


Measured memory_bytes: 5284
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n, x;
int a[100010];

void init() {
}

void input() {
	cin >> n >> x;
	REP(i, n) cin >> a[i];
}

void solve() {
	LL res = 0;
	if(a[0] > x) {
		res = a[0]-x;
		a[0] = x;
	}
	FOR(i, 1, n){
		int tmp = 0;
		if(a[i-1] + a[i] > x){
			tmp = a[i-1] + a[i]- x;
			a[i] -= tmp;
			res += tmp;
		}
	}
	cout << res << endl;
}

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








Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    ll count = 0;
    REP(i,N){
        if(i%2 == 0&&A[i]%2 == 1)count++;
    }
    cout << count << "\n";
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
void ads(ll &a, ll b){a += b;if (a >= mod)a -= mod;}
void mis(ll &a, ll b){a -= b;if (a >= mod)a -= mod; if (a < 0)a += mod;}
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}
const int maax = 2 * 100 * 1000 + 56;
ll dp[maax];
ll val[4 * maax];
ll ix[maax];

void build(int id, int l, int r)
{
	if (l == r)
	{
		ix[l] = id;
		val[id] = 0;
		return;
	}
	int mid = (l+r)/2;
	build(2*id, l, mid);
	build(2*id+1, mid+1, r);
	val[id] = max(val[2*id], val[2*id+1]);
}
	
ll query(int id, int l , int r, int x, int y)
{
	if (l >= x && r <= y)
	{
		return val[id];
	}
	else if (r < x || l > y)
		return (0);
	int mid = (l+r)/2;	
	ll c = query(2*id,l,mid,x,y);
	ll d = query(2*id+1,mid+1,r,x,y);
	return (max(c,d));
}

void update(int l)
{
	int x = ix[l];
	while (x >= 1)
	{
		val[x] = max(val[x],dp[l]);
		x /= 2;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	vi h(n),b(n);
	REP(i,0,n)cin>>h[i];
	REP(i,0,n)h[i]--;
	REP(i,0,n)cin>>b[i];
	build(1,0,n-1);
	ll ans = 0;
	REP(i,0,n)
	{
		dp[h[i]] = query(1,0,n-1,0,h[i]-1) + b[i];
		ans = max(ans,dp[h[i]]);
		update(h[i]);
	}
	cout << ans;
}


Measured memory_bytes: 11264
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		HashMap<String,Long> gram=new HashMap();
		long ans=0L;
		for(int i=0; i<N; i++) {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		}

		for(long num : gram.values()) {
			ans+=(num-1)*num/2L;
		}
		p(ans);

	}
	public static void p(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 56388
def report(k, r):
    print('{} x {}'.format(k, r[k]))

ans = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

N = int(input().rstrip())
for i in range(N):
    S = input().rstrip()
    ans[S] += 1

report('AC', ans)
report('WA', ans)
report('TLE', ans)
report('RE', ans)


Measured memory_bytes: 9136
import sys
read=sys.stdin.readline
def find(x):
    if(par[x]==x):
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
        else:
            par[a]=b
            if rank[a]==rank[b]:
                rank[b]+=1
def same(a,b):
    return find(a)==find(b)
def Kruskal(Edge,E):
    cost=0
    Edge.sort(key=lambda x:x[2])
    for i in range(E):
        f,t,c=Edge[i]
        if(not same(f,t)):
            union(f,t)
            cost+=c
    return cost
    
N=int(input())
par=[];p=[];dic={};rank=[]
for i in range(N):
    par.append(i)
    rank.append(0)
    p.append(tuple(map(int,read().split())))
    dic[p[i]]=i
xp,yp=sorted(p,key=lambda x:x[0]),sorted(p,key=lambda x:x[1])
Edge=[]
for i in range(N):
    if(i>0):
        Edge.append((dic[xp[i]],dic[xp[i-1]],abs(xp[i][0]-xp[i-1][0])))
        Edge.append((dic[yp[i]],dic[yp[i-1]],abs(yp[i][1]-yp[i-1][1])))
    if(i<N-1):
        Edge.append((dic[xp[i]],dic[xp[i+1]],abs(xp[i][0]-xp[i+1][0])))
        Edge.append((dic[yp[i]],dic[yp[i+1]],abs(yp[i][1]-yp[i+1][1])))
print(Kruskal(Edge,len(Edge)))

Measured memory_bytes: 124360
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect
import itertools


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, X] = string_to_int(inputs[0])
    A = string_to_int(inputs[1])

    count = 0
    for i in range(N-1):
        if A[i] > X:
            count += abs(X - A[i])
            A[i] = X
        if A[i] + A[i+1] >= X:
            count += abs(X - (A[i+1] + A[i]))
            A[i+1] = X - A[i]
    return count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


Measured memory_bytes: 64112
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
long long n,k,x,y,sum;
int main(){
	cin>>n>>k>>x>>y;
	if(n>k)sum=(k*x)+y*(n-k);
	else sum=x*n;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 632
import fractions as f

N = int(input())
A = [int(x) for x in input().split()]

if N == 2:
    print(max(A))
else:
    A = sorted(A)
    l1,l2 = [],[]
    c1,c2 = 0,0
    for i in range(1,N):
        a = f.gcd(A[0],A[i])
        l1 += [a]
        if a == 1:
            c1 += 1
            if c1 >= 2:
                break
    for j in range(2,N):
        a = f.gcd(A[1],A[j])
        l2 += [a]
        if a == 1:
            c2 += 1
            if c2 >= 1:
                break

    if c1 >= 2 and c2 >= 1:
        print(1)
    else:
        ans1, ans2 = 1,1
        if c1 < 2:
            l1.pop(l1.index(min(l1)))
            ans1 = l1[0]
            for i in range(1,len(l1)):
                ans1 = f.gcd(ans1,l1[i])
        if c2 < 1:
            ans2 = l2[0]
            for i in range(1,len(l2)):
                ans2 = f.gcd(ans2,l2[i])
        print(max(ans1,ans2))


Measured memory_bytes: 16164
#include <cstdio>

const int MAXN = 2E5 + 10;

char s[MAXN];
int que[MAXN], tail;

int main(){
	scanf("%s", s);
	for (int i = 0; s[i]; ++i)
		if (s[i] == 'T' && tail >= 0 && que[tail] == 'S')
			--tail;
		else
			que[++tail] = s[i];
	printf("%d\n", tail);
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N,M;
  cin >> N >> M;
  vl x(N),y(M);
  ll xsum = 0;
  rep(i,N) {
    cin >> x[i];
    xsum += i*x[i] - (N-i-1) * x[i];
    xsum %= MOD;
  }
  ll ysum = 0;
  rep(i,M) {
    cin >> y[i];
    ysum += i*y[i] - (M-i-1) * y[i];
    ysum %= MOD;
  }
  cout << 1ll * xsum * ysum % MOD << endl;
  return 0;
}

Measured memory_bytes: 1792
n, m = (int(x) for x in input().split())
a = [0] * m
for i in range(m):
    a[i] = int(input())
dp = [0] * (n + 1)
mod = 1000000007
dp[0] = 1
j = 0

if m > 0:
    for i in range(1, n + 1):
        if i == a[j]:
            dp[i] = 0
            if j != m - 1:
                j += 1
        elif i >= 2:
            dp[i] = (dp[i - 1] + dp[i - 2]) % mod
        else:
            dp[i] = dp[i - 1] % mod
else:
    for i in range(1, n + 1):
        if i >= 2:
            dp[i] = (dp[i - 1] + dp[i - 2]) % mod
        else:
            dp[i] = dp[i - 1] % mod
print(dp[n])

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

int main(){
  int n;
  cin >> n;
  int ans=1;
  vector<string> w(n);
  for(int i=0;i<n;i++){
    cin >> w.at(i);
    if(i!=0){
      ans*=(w.at(i-1).at(w.at(i-1).size()-1)==w.at(i).at(0));
    }
  }
  sort(w.begin(),w.end());
  for(int i=1;i<n;i++)
    ans*=(w.at(i-1)!=w.at(i));
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for _ in range(n)]
b=max(a)
c=a.count(b)
if c>1:
  for i in range(n):
    print(b)
else:
  d=sorted(a, reverse=True)
  e=d[1]
  f=0
  h=0
  while f!=b:
    g=a[h]
    if f<g:
      f=g
    h=h+1
  for i in range(h-1):
    print(b)
  print(e)
  for i in range(n-h):
    print(b)
    

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

typedef long long ll;
const int maxn = 1e5 + 5, mod = 998244353;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

#define eb emplace_back

int n, m, sg[maxn], cnt[3][maxn], mx[3], vis[maxn], pw[maxn];
vector<int> e[maxn];

void solve(int *cnt, int &mx)
{
	m = gi();
	for (int i = 1; i <= n; ++i) e[i].clear();
	for (int u, v, i = 1; i <= m; ++i) {
		u = gi(); v = gi();
		if (u > v) swap(u, v);
		e[u].eb(v);
	}
	fill(vis, vis + n + 1, 0);
	for (int u = n; u >= 1; --u) {
		for (int v : e[u]) vis[sg[v]] = u;
		int mex = 0;
		while (vis[mex] == u) ++mex;
		mx = max(mx, sg[u] = mex);
		cnt[sg[u]] = (cnt[sg[u]] + pw[u]) % mod;
	}
}

int main()
{
	n = gi();
	int base = ((ll)1e18) % mod;
	pw[0] = 1;
	for (int i = 1; i <= n; ++i) pw[i] = (ll)pw[i - 1] * base % mod;
	for (int i = 0; i < 3; ++i) solve(cnt[i], mx[i]);

	int ans = 0;
	for (int i = 0; i <= mx[0]; ++i)
		for (int j = 0; j <= mx[1]; ++j)
			ans = (ans + (ll)cnt[0][i] * cnt[1][j] % mod * cnt[2][i ^ j]) % mod;
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 7424
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var antennas = new int[5];
        for (int i = 0; i < antennas.Length; i++)
        {
            antennas[i] = int.Parse(Console.ReadLine());
        }
        var k = int.Parse(Console.ReadLine());

        Console.WriteLine(antennas[4] - antennas[0] <= k ? "Yay!" : ":(");
    }
}


Measured memory_bytes: 11092
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
dx=[0,1,0,-1,1,1,-1,-1]
dy=[1,0,-1,0,1,-1,1,-1]#周囲八マスの進み方：マスから出ないか判定して調べる

for i in range(h):
    for j in range(w):
        count=0
        if s[i][j]=='.':
            for k in range(8):
                x=j+dx[k]
                y=i+dy[k]
                if 0<=x<=w-1 and 0<=y<=h-1:
                    if s[y][x]=='#':
                        count+=1
                        
            s[i][j]=str(count)

for i in s:
    print(*i,sep='')

Measured memory_bytes: 3572
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int n;
    scan(n);
    auto ans = (n + 1) / 2;
    writeln(ans);
}




void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}





Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
    //n--;
    long i = 0;
    //答えはこのリストに集約
    ArrayList<Character> name = new ArrayList<Character>();

    while(n>0) {
      n--;  //1から始まるので調整(while文の中で引くのはn=1の時も処理を行うため)
      i = n % 26;
      name.add((char)(i + 'a'));  //余りとアルファベットの紐付け
      n /= 26;
    }
    Collections.reverse(name);  //リストを反転させる
    for(char c: name) {
      System.out.print(c);
    }

    //もっと簡潔にかける(上記)
    /*
    ArrayList<Long> name = new ArrayList<Long>();

    //String base26 = Integer.toString(n-1, 26);

    while(n > 0) {
      long tmp = n % 26;
      n /= 26;
      /*if(i==0){
        tmp++;
      }
      if(tmp == 0){
        tmp += 97;
      }else {
        tmp += 96;
      }
      name.add(tmp);
      i++;
    }

    //listから配列へ変換(int)
    long[] hoge = new long[name.size()];
    for(int j=0; j<name.size();j++) {
      hoge[j] = name.get(j);
    }
    //System.out.println(name.get(0));
    //System.out.println(hoge[0]);

    String[] ansname =new String[name.size()];
    //数値をストリングに変換して， 文字列配列にいれる
    for(int j=0; j<name.size();j++) {
      String ans = Character.toString((char) hoge[j]);
      ansname[name.size()-j-1] = ans;
    }
    for(int j=0; j<name.size();j++) {
      System.out.print(ansname[j]);
    }
    */
	}
}


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

int main(){
	int s;
	cin >> s;
	int m=1;
	int tmp=s;
	while(true){
		if(tmp==4 || tmp==2 || tmp==1){
			cout << m+3 << endl;
			break;
		}
		m++;
		if(tmp%2==0){
			tmp= tmp/2;
		}else tmp= 3*tmp + 1;
	}
	return 0;
}




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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << std::fixed << std::setprecision(10);

	int a, b;
	cin >> a >> b;

	if (a < 10 && b < 10) {
		cout << a * b << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K % 2ll == 1ll)
    cout << B - A << endl;
  else
    cout << A - B << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// const double PI=acos(-1.0);

int main(){
    fastIO;
    int n,x,t; cin>>n>>x>>t;
    ll rta=0;
    while(n>0){
		n-=x;
		rta+=t;
	}
    cout<<rta<<endl;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N; cin >> N;
    set<int> s;
    REP(i, N)
    {
        int A; cin >> A;
        s.insert(A);
    }
    cout << s.size() - !(s.size() % 2) << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll, ll> P;

ll solve_id(int k, ll x, ll d){
    //if(x%d != (x + d * 3 - (x / d) * d)%d)cout<<k<<' '<<x<<' '<<d<<endl;
    if(x < 0) x += (abs(x) / d) * d;
    //if(x + d * 3 < 0) cout<<k<<' '<<x<<' '<<d<<endl;
    x = (x + d * 3)%d;
    return (k * x) % d;
}

int main() {
    ll X, D;
    cin>>N>>X>>D;
    if(D == 0){
        cout<<N * (X != 0) + 1<<endl;
        return 0;
    }else if(D < 0){
        X = -X;
        D = -D;
    }
    //multimap<ll, P> mp;
    vector<pair<ll, P> > mp;
    ll pm = X < 0 ? -1 : 1;
    for(ll i = 0; i < N + 1; ++i){
        ll id = solve_id(i, X, D);
        P p = make_pair(pm * ((abs(X * i - id)) / D) + i * (i - 1) / 2,
                pm * ((abs(X * i - id)) / D) + i * (N * 2 - 1 - i) / 2 + 1);
        mp.emplace_back(id, p);
    }
    ll ans = 0, id = -1;
    P now = make_pair(-INF, -INF);
    mp.emplace_back(D, make_pair(0, 1));
    sort(ALL(mp));
    for(auto tu : mp){
        //cout<<now.fi<<' '<<now.se<<endl;
        //cout<<tu.fi<<' '<<tu.se.fi<<' '<<tu.se.se<<endl;
        //cout<<ans<<endl;
        if(id != tu.fi) {
            id = tu.fi;
            ans += now.se - now.fi;
            now = tu.se;
        }else{
            if(now.se < tu.se.fi){
                ans += now.se - now.fi;
                now = tu.se;
            }else{
                now.se = max(now.se, tu.se.se);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8432
#include <stdio.h>
#define limit 100000

int par[limit];
long long rank[limit];

void init(int N){
  for(int i = 0;i < N;i++){
    par[i] = i;
    rank[i] = 1;
  }
}

int root(int x){
  if(x == par[x]) return x;
  return par[x] = root(par[x]);
}

int same(int x,int y){
  if(root(x) == root(y))
    return 1;
  return 0;
}

long long unite(int x,int y){
  x = root(x);
  y = root(y);
  if(x == y) return 0;

  if(rank[x] < rank[y]){
    par[x] = y;
    rank[y] += rank[x];
    return rank[x]*(rank[y]-rank[x]);
  }else{
    par[y] = x;
    rank[x] += rank[y];
    return rank[y]*(rank[x]-rank[y]);
  }
}

int main(void){
  long long N,M;
  scanf("%lld%lld",&N,&M);

  int A[M],B[M];
  for(int i = 0;i < M;i++){
    scanf("%d%d",&A[i],&B[i]);
    A[i]--; B[i]--;
  }

  init(N);
  long long ans[M];
  ans[M-1] = N*(N-1)/2;
  for(int i = M-1;i > 0;i--){
    ans[i-1] = ans[i]-unite(A[i],B[i]);
  }

  for(int i = 0;i < M;i++){
    printf("%lld\n",ans[i]);
  }

  return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

struct X {
  int a;
  int b;
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> V;
  rep(i, N) {
	int a, b;
	cin >> a >> b;
	if(a <= M)
	  V.emplace_back(a - 1, b);
  }
  sort(V.begin(), V.end(), [](auto l, auto r) {
	  return l.first < r.first;
  });

  priority_queue<int> Q;

  ll sum = 0;
  auto vi = V.begin();
  rep(i, M) {
	// cout << "day " << i << endl;
	while(vi != V.end() && (*vi).first <= i) {
	  Q.push((*vi).second);
	  // cout << "push " << (*vi).first << "," << (*vi).second << endl;
	  vi++;
	}
	if(!Q.empty()) {
	  sum += Q.top();
	  // cout << "select " << Q.top() << endl;
	  Q.pop();
	}
  }
  cout << sum << endl;

}


Measured memory_bytes: 1908
#include <iostream>
#include <string.h>
using namespace std;

int main(void){
	int count=0;
	char a[100];
	cin >> a;
	for(int i=0; i<(int)strlen(a)/2; i++){
		if(a[i] != a[strlen(a)-i-1])	count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e+10
#define ll long long
int main(){
  int n, k;
  cin >> n >> k;
  ll h[n];
  ll cost[n] = {};
  for(int i=0;i<n;i++){
    cin >> h[i];
    cost[i] = INF;
  }
  cost[0] = 0;
  for(int i=0;i<n;i++){
    for(int j=1;i+j<n && j<=k;j++){
      cost[i+j] = min(abs(h[i]-h[i+j])+cost[i], cost[i+j]);
    }
  }
  cout << cost[n-1] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  ll t = 0;
  REP(i, n) {
    x -= a[i];
    if (x == 0) {
      cout << i + 1 << endl;
      return 0;
    }
    if (x < 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << n - 1 << endl;
  return 0;
}


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

using namespace std;

int main(){
  
  string s;
  int Anum[26] = {0};
  
  cin >> s;
  for(int i=0;i<s.size();i++){
    Anum[s[i]-'a']++;
  }
  int f = 0;
  for(int i=0;i<26;i++){
    if(Anum[i] % 2 != 0){
      f = 1;
    }
  }
  
  if(!f){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
const int XP = 1e9 + 7;
int n,x,y,nr[1<<17],dp[2][1<<17];
vector <int> G[1<<17];
bool viz[1<<17];
void dfs(int x)
{
    viz[x]=1;
    dp[0][x]=dp[1][x]=1;
    for(int i=0;i<(int)G[x].size();++i)
        if(!viz[G[x][i]])
        {
            dfs(G[x][i]);
            dp[0][x]=1LL*dp[0][x]*dp[1][G[x][i]]%XP;
            dp[1][x]=1LL*dp[1][x]*(dp[0][G[x][i]]+dp[1][G[x][i]])%XP;
        }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>x>>y;
        nr[x]++;
        nr[y]++;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int rad=0;
    for(int i=1;i<=n;++i) if(nr[i]==1) rad=i;
    dfs(rad);
    cout<<(dp[0][rad]+dp[1][rad])%XP;
    return 0;
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n; cin>>n;
  ll ans{};
  while(n--){
    int a; cin>>a;
    ans += --a;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ms(x, t) memset(x, t, sizeof(x))
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define endl "\n"
typedef pair<int, int> pll;
typedef pair<int, pll> plll;
typedef vector<int> vl;
typedef vector<vector<int>> vvl;
typedef vector<pll> vpll;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}

const int limit = 1e5 + 1;
const int inf = 1e7;
const int mod = 1e9 + 7;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}

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

using namespace std;

#define pb push_back

main() {
    int n; scanf ("%d", &n);
    vector < int > ans;
    int skip = -1;
    int cnt = 1;
    while (n - cnt > 0) {
        ans.pb(cnt);
        n -= cnt;
        cnt++;
    }
    if (n) {
        skip = cnt - n;
        ans.pb(cnt);
    }
    for (int to : ans) {
        if (to == skip) continue;
        printf ("%d\n", to);
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	char S[100010], T[100010];
	int N = 0;
	int M = 0;
	while ((S[N] = getchar_unlocked()) >= 'a') N++;
	while ((T[M] = getchar_unlocked()) >= 'a') M++;

	int n[100001][26];
	rep(i, 26) n[N - 1][i] = -1;
	for (int i = N - 1; i >= 0; i--) {
		n[N - 1][S[i] - 'a'] = i;
	}
	for (int i = N - 1; i >= 1; i--) {
		memcpy(n[i - 1], n[i], sizeof(n[i]));
		n[i - 1][S[i] - 'a'] = i;
	}

	int OK = 1;
	ll kotae = 0;
	int k = N - 1;
	rep(i, M) {
		int k2 = n[k][T[i] - 'a'];
		if (k2 == -1) {
			OK = 0;
			break;
		}

		if (k2 > k) kotae += k2 - k;
		else kotae += k2 - k + N;
		k = k2;
	}

	if (OK) printf("%lld", kotae);
	else printf("-1");

	Would you please return 0;
}

Measured memory_bytes: 10624
import Control.Monad  -- replicateM

main = do 
  n  <- readLn
  ss <- replicateM n getLine
  putStr . unlines . map snakeType $ ss

snakeType s
  | isTypeA s = "A"
  | isTypeB s = "B"
  | otherwise = "NA"

isTypeA s =
  length s > 4 && s == ">'" ++ eqs ++ "#" ++ eqs ++ "~"
  where eqs = replicate ((length s - 4) `div` 2) '='

isTypeB s =
  length s > 4 && s == ">^" ++ qs ++ "~~"
  where qs = concat $ replicate ((length s - 4) `div` 2) "Q="

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int K, A, B;
  cin >> K >> A >> B;
  int x = B / K;
  if (A <= K * x)
    cout << "OK" << '\n';
  else
    cout << "NG" << '\n';
  return 0;
}


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

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


Measured memory_bytes: 768
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
using deck = vector< pair<char,int> >;
using size = vector< pair<char,int> >::size_type;

void bubble_sort(deck &d) {
	for (size i = 0;i != d.size();++i) {
		for (size j = d.size()-1;j != i;--j) {
			if (d[j].second < d[j-1].second) {
				swap(d[j],d[j-1]);
			}
		}
	}
}

bool selection_sort(deck &d) {
	bool stable = true; // default to stable
	for (size i = 0;i != d.size()-1;++i) {
		size same_value_pos = i;
		size min_i = i;
		for (size j = i+1;j != d.size();++j) {
			if (d[j].second < d[min_i].second) {
				min_i = j;
			}
			if (d[j].second == d[i].second) {
				same_value_pos = j;
			}
		}
		if (min_i != i) {
			swap(d[min_i],d[i]);
		}
		if (same_value_pos != i && min_i > same_value_pos) {
			stable = false;
		}
	}
	return stable;
}

int main(void) {
	int n;
	cin >> n;
	deck deck_1 = deck(n);
	// read cards
	for (auto itr = deck_1.begin();itr != deck_1.end();++itr) {
		cin >> itr->first >> itr->second;
	}
	deck deck_2 = deck(deck_1);
	// bubble sort and output
	bubble_sort(deck_1);
	for (size i = 0;i != deck_1.size();++i) {
		cout << deck_1[i].first << deck_1[i].second << (i == deck_1.size()-1 ? "\n" : " ");
	}
	cout << "Stable" << endl; // bubble sort must be stable
	// selection sort and output
	bool stable = selection_sort(deck_2);
	for (size i = 0;i != deck_2.size();++i) {
		cout << deck_2[i].first << deck_2[i].second << (i == deck_2.size()-1 ? "\n" : " ");
	}
	cout << (stable ? "Stable" : "Not stable") << endl;
	return 0;
}

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

int main(){
    int S;
    cin >> S;
    int h, m ,s;
    h = S / 3600;
    S = S - h * 3600;
    m = S / 60;
    S = S - m * 60;
    s = S;
    cout << h << ':' << m << ':' << s << endl;
    return 0;
}


Measured memory_bytes: 3100
n, m = map(int, input().split())
height = list(map(int, input().split()))
ans = [1 for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    if height[a - 1] >= height[b - 1]:
        ans[b - 1] = 0
    if height[a - 1] <= height[b - 1]:
        ans[a - 1] = 0

print(ans.count(1))


Measured memory_bytes: 20004
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    cin >> n >> k;
    if((n - 1)%(k - 1) == 0){
        cout << (n - 1)/(k - 1) << endl;
    }else{
        cout << (n - 1)/(k - 1) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// 1_1_A
#include<stdio.h>
void OutPut(int [], int);
void InsertionSort(int [], int);

int main()
{
    int i, length;
    int numbers[100];

    scanf("%d", &length);
    for(i = 0; i < length; i++){
        scanf("%d", &numbers[i]);
    }

    OutPut(numbers, length);
    InsertionSort(numbers, length);

    return 0;
}

void InsertionSort(int numbers[], int length){
    int i, j, v;
    for(i = 1; i < length; i++){
        v = numbers[i];
        j = i - 1;
        while(j >= 0 && numbers[j] > v){
            numbers[j + 1] = numbers[j];
            j--;
        }
        numbers[j + 1] = v;
        OutPut(numbers, length);
    }

    return;
}

void OutPut(int numbers[], int length){
    int i;
    for(i = 0; i < length - 1; i++){
        printf("%d ", numbers[i]);
    }
    printf("%d\n", numbers[length - 1]);

    return;
}

Measured memory_bytes: 600
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> x = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            x.add(sc.nextInt());
        }
        if (n >= m) {
            System.out.println(0);
            return;
        }
        Collections.sort(x);

        List<Integer> sub = new ArrayList<>();
        for (int i = 0; i < m - 1; i++) {
            int k = x.get(i + 1) - x.get(i);
            sub.add(k);
        }
        Collections.sort(sub);
        int ans = 0;
        int k = m - n;
        for (int i = 0; i < k; i++) {
            ans += sub.get(i);
        }
        System.out.println(ans);
    }
}


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

using namespace std;

bool check_num(int num){
	map<int, int> check;
	int n_digit = to_string(num).length();

	int digit = n_digit-1;

	while (digit >= 0){
		int quot = num/pow(10, digit);
		num = num - quot * pow(10, digit);
		check[quot] = 0;
		digit -= 1;
	}

	if (check.size() == 3){
		return true;
	}
	else{
		return false;
	}
}

int main(){
	int N;
	cin >> N;
	int ans = 0;

	int N_digit = to_string(N).length();
	vector<vector<int>> num_list;
	for (int d=1; d<=N_digit; d++){
		vector<int> num = {};
		if (d == 1){
			num = {3, 5, 7};
			num_list.push_back(num);
		}
		else{
			num = {};
			for (int n : num_list[d-2]){
				num.push_back(10*n+3);
				num.push_back(10*n+5);
				num.push_back(10*n+7);
			}
			num_list.push_back(num);
		}
	}

	for (vector<int> num : num_list){
		for (int n : num){
			if (n <= N){
				if (check_num(n)){
					ans += 1;
				}
			}
			else{
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
const main = input => {
  for(let i = 9;i >= 0; i--){
    if(i === 0) {
      console.log('No');
      return;
    }
    if(input % i === 0) {
      if((input / i) <= 9){
        console.log('Yes');
        return;
      }
    }
  }
} 
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
def func(A, B, x):
    import math
    return math.floor(A * x / B) - A * math.floor(x / B)

def main():
    A, B, N = map(int, input().split())
    n = 1
    if(N < B):
        n = N
    else:
        n = B -1
    print(func(A, B, n))




main()

Measured memory_bytes: 62148
# coding: utf-8 
N,T = [int(i) for i in input().split(" ")]
array = input().split(" ")
ans = 0
fin = 0
for x in array:
    time = int(x)
    if time <= fin:
        ans += (time + T - fin)
    else:
        ans += T
    fin = time + T
print(ans)

Measured memory_bytes: 20856
use std::io;
use std::collections::HashSet;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().chars().collect::<Vec<char>>();
	let mut set = HashSet::new();
	for i in s {
		set.insert(i);
	}
	let mut a = 'a' as u8;
	let mut flag = true;
	while a <= ('z' as u8) {
		if set.insert(a as char) {
			break;
		}
		if a == ('z' as u8) {
			flag =false;
		}
		a+=1;
	}
	if flag {
		println!("{}", (a as char));
	}else{
		println!("None");
	}
}

Measured memory_bytes: 4352
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::HashMap;

use itertools::Itertools;

use maplit::*;

use proconio::{input, fastout};
use proconio::marker::*;

const INF: usize = 1_000_000_007;

#[fastout]
fn solve() {
  input!{
    a: i64, b: i64, c: i64, k: i64,
  };

  if k <= a + b {
    println!("{}", min(k, a));
  } else {
    println!("{}", a - min(c, k - (a + b)));
  }
}

fn main() {
  std::thread::Builder::new()
    .name("big stack size".into())
    .stack_size(32 * 1024 * 1024)
    .spawn(|| {
      solve();
    })
    .unwrap()
    .join()
    .unwrap();
}


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

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

void solve(std::string S) {
  // solver code

  for (int i = 0; i < S.size(); i++) {
    cout << "x";
  }

  cout << endl;
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

ll dp[10005];

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

  ll h,n;cin>>h>>n;
  vector<pair<ll, ll> > waza(n);
  for(int i=0;i<n;i++){
    ll a,b;cin>>a>>b;
    waza[i] = {a,b};
  }
  sort(waza.begin(), waza.end());
  for(int i=1;i<=h;i++)dp[i]=100000000;
  for(int i=0;i<=h;i++){
    for(int j=0;j<n;j++){
      ll a = waza[j].first;
      ll b = waza[j].second;
      // cout<<i<<':'<<dp[i]<<endl;
      ll nx = min(i+a, h);
      dp[nx] = min(dp[i] + b, dp[nx]);
    }
  }

  cout<<dp[h]<<endl;
  
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int price = 700;
    if(s[0] == 'o') price += 100;
    if(s[1] == 'o') price += 100;
    if(s[2] == 'o') price += 100;

    cout << price << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXM 1000000000
#define MAXN 100000

void solver(int n, int m) {
	if (m%n == 0) {
		printf("%d\n", m/n);
		return;
	}

	int i;
	int factor = m/n;

	EFOR(i, factor-1, 0) {
		if (m%i == 0) {
			printf("%d\n", i);
			return;
		}
	}
	printf("1\n");
}

int main() {
	int m,n;

	scanf("%d %d", &n, &m);

	solver(n, m);
	return 0;
}


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

int main(){
  long long int a,b;
  cin >> a >> b;
  if(b/2019 - (a-1)/2019 > 0){
    cout << 0;
    return 0;
  }
  int k = a - a%2019;
  a = a - k;
  b = b - k;
  int m = 2018;
  for(int i = a; i < b; i++){
    for (int j = i+1; j <= b; j++){
      m = min(m, (i*j)%2019);
    }
  }
  cout << m;
}

Measured memory_bytes: 256