akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
main( )
{
  int a, b;
  double c;
 
  scanf("%d%d",&a, &b);
  c = (double)a/b;
  printf("%d %d %f\n", a/b, a%b, c);
  
  return 0 ;
 
 
}
 

 

Measured memory_bytes: 636
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    let [D, T, S] = lines[0].split(' ').map( _ => parseInt(_))
 
    let ans = D <= T * S ? "Yes" : "No"
    console.log(ans)
});

Measured memory_bytes: 30064
void main()
{
    long k, a, b;
    rdVals(k, a, b);

    long rate = 1;

    if (k <= a)
    {
        rate.writeln;
        return;
    }

    if (b >= a)
    {
        writeln(-1);
        return;
    }

    rate += (k - b - 1) / (a - b) * 2;

    rate.writeln;
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//or-> ||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	ll X;
	cin>>X;
	DBG("","","","");
	ll n500,n5;
	n500=X/500;
	n5=(X-500*n500)/5;
	cout<<(n500*1000+n5*5)<<endl;
	return 0;
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
int al[26];
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int h,w;cin>>h>>w;
	for(int i = 0; h > i; i++){
		for(int j = 0; w > j; j++){
			char c;cin>>c;
			al[c-'a']++;
		}
	}
	int f = (w/2)*(h/2);
	int o = (h*w)%2;
	int t = (h*w-f*4-o)/2;
	for(int i = 0; 26 > i; i++){
		int z = min(f,al[i]/4);
		f-=z;
		al[i] -= z*4;
	}
	if(f){
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; 26 > i; i++){
		int z = min(t,al[i]/2);
		t-=z;
		al[i] -= z*2;
	}
	if(t){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
	long a, b, c, d,k,x,tmp,r;
	scanf("%ld", &a);
	scanf("%ld", &b);
	scanf("%ld", &c);
	scanf("%ld", &d);
	long c1 = c;
	long d1 = d;
	x = c * d;
	if (c1 < d1) {
		tmp = c1;
		c1 = d1;
		d1 = tmp;
	}
	r = c1 % d1;
	while (r != 0) {
		c1 = d1;
		d1 = r;
		r = c1 % d1;
	}
	x = x / d1;
	k = b-a+(a-1)/c+(a-1)/d-b/c-b/d+b/x-(a-1)/x+1;
	printf("%ld", k);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

total = abs(A[0])
cancel = [0 for _ in range(N)]
cancel[0] = abs(A[1]) - (abs(A[1] - A[0]) + abs(A[0]))

for i in range(1, N-1):
    total += abs(A[i]-A[i-1])
    cancel[i] = abs(A[i+1] - A[i-1]) - (abs(A[i+1] - A[i]) + abs(A[i] - A[i-1]))

total += abs(A[N-1]-A[N-2]) + abs(A[N-1])
cancel[N-1] = abs(A[N-2]) - (abs(A[N-1]) + abs(A[N-1] - A[N-2]))

for c in cancel:
    print(total+c)


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 300200;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int a[N];

long long get(int l, int r)
{
        int cur = -1;
        long long cnt = 0;
        for(int i = r; i >= l; i--){
                if(cur != a[i]){
                        cnt += a[i];
                }
                cur = a[i] - 1;
        }
        return cnt;
}

void solve()
{
        cin >> n;
        vector < int > v;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
                if(a[i] == 0){
                        v.push_back(i);
                }
                if(a[i] > a[i - 1] + 1){
                        cout << -1 << "\n";
                        return;
                }
        }
        if(a[1] > 0){
                cout << -1 << "\n";
                return;
        }
        v.push_back(n + 1);
        long long ans = 0;
        for(int i = 0; i + 1 < v.size(); i++){
                ans += get(v[i], v[i + 1] - 1);
        }
        cout << ans << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 1912
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
idx_minA = A.index(min(A)) + 1

if N <= K:
    print(1)
else:
    ans = float('inf')
    for i in range(max(1, idx_minA - K + 1), idx_minA + 1):
        ans = min(ans, 1 + math.ceil((i - 1) / (K - 1)) + math.ceil((N - (i + K - 1)) / (K - 1)))
    print(ans)


Measured memory_bytes: 13812
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
c = 0
for i in range(n - 1):
    t = cnt = 0
    # 動かす数字の位置
    x = a.index(b[i])
    while x != i:
        # 動かす数字の所にあるべき数字
        y = a.index(b[x])
        # a[x], a[y] = b[x], b[i]
        a[x], a[y] = a[y], a[x]
        cnt += 1
        # t += b[x] + b[i]
        t += a[x] + a[y]
        x = y
    if cnt:
        c += min(t, (b[i] + b[0]) * 2 + t - (b[i] - b[0]) * cnt)
print(c)


Measured memory_bytes: 5628
#include <iostream>
#include <string>

int main(int argc, const char * argv[]) {
    // insert code here...
    int m,n;
    std::string str;
    
    std::cin >> m;
    
    n = m - ((m / 10) * 10);
    if ((m<=99) & (m>=90)) {
        str = "Yes";
    }
    else if(n == 9) {
        str = "Yes";
    }else {
        str = "No";
    }
    std::cout << str << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      	String s = sc.next();
        char[] c = s.toCharArray();
      	
      	for(int i=0;i<s.length();i++){
        	if(i%2 == 0){
            	System.out.print(c[i]);
            }
        }
      System.out.println();
        }
	}

Measured memory_bytes: 47464
import sys
n,l=map(int,input().split())
ls=[]
for i in range(n):
    ls.append(l+i)  #iは0から始まるので-1した。

ls.sort()
st=0
hoge=0
sum_ls=sum(ls)

def i_hantei(k):
    if k!=0:
        return True
    return False

#上限と下限が0以下または0以上ではないか調べる。
if ls[-1]<0:
    print(sum_ls-ls[-1])
    sys.exit()
if ls[0]>0:
    print(sum_ls-ls[0])
    sys.exit()

for i in range(n):
    if ls[i]<0:
        continue
    else:
        if i_hantei(i)==False:
            hoge=ls[i]
            break
        if abs(ls[i-1])<=abs(ls[i]):
            hoge=ls[i-1]
        else:
            hoge=ls[i]
        break
    
print(sum_ls-hoge)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <tuple>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

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

  int n, m;
  cin >> n >> m;
  vector<int> deg(n);
  vector<vector<int>> g(n);
  for (int rep = 0; rep < m; ++rep) {
    int u, v;
    cin >> u >> v;
    ++deg[u - 1]; ++deg[v - 1];
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
  if (m <= n + 1) {
    puts("No");
    return 0;
  }
  for (int i = 0; i < n; ++i)
    if (deg[i] % 2) {
      puts("No");
      return 0;
    }
  if (m == n + 2 && count(deg.begin(), deg.end(), 4) == 2) {
    int u = find(deg.begin(), deg.end(), 4) - deg.begin();
    queue<pair<int, int>> q;
    for (const auto& v : g[u])
      q.emplace(u, v);
    while (!q.empty()) {
      int x = q.front().first, y = q.front().second;
      q.pop();
      if (deg[y] == 4 && y == u) {
        puts("Yes");
        return 0;
      }
      if (deg[y] == 4) continue;
      for (const auto& v : g[y])
        if (v != x)
          q.emplace(y, v);
    }
    puts("No");
  } else
    puts("Yes");

  return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    string ans;
    if(x >= a && x <= a + b){
        ans = "YES";
    }else{
        ans = "NO";
    }

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

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M) cin >> A[i];
    sort(A.rbegin(), A.rend());

    vector<int> dp(N + 100, -1);
    dp[0] = 0;

    rep(i, N + 1) {
        for (auto a: A) {
            chmax(dp[i + match[a - 1]], dp[i] + 1);
        }
    }

    string ans = "";
    int needDigit = dp[N]; // 追加する必要のある桁数
    int remain = N;
    while (remain > 0) {
        for (auto a : A) {
            if (remain - match[a - 1] < 0) continue;
            if (dp[remain - match[a - 1]] != needDigit - 1) continue;

            ans += to_string(a);
            remain -= match[a - 1];
            needDigit--;
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	double height;
	double maxs = -1.0, mins = 1.0e18;
	while (scanf("%lf", &height) != EOF) {
		if (maxs < height) maxs = height;
		if (mins > height) mins = height;
	}
	printf ("%.1lf\n", maxs - mins);
//	system("PAUSE");
	return 0;
}

Measured memory_bytes: 0
N = int(input())
S = input()
L = [str(i).zfill(3) for i in range(1000)]
count = 0
for l in L:
    try:
        i = S.index(l[0])
        j = S.index(l[1], i + 1)
        k = S.index(l[2], j + 1)
        count += 1
    except:
        continue
print(count)


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

using str = string;
using ss = stringstream;

int a[200010];
int b[200010];

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

    int n;cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];

    int pos=0;
    for(int i=n-1;i>=0;i-=2,pos++)b[pos]=a[i];
    for(int i=n%2;i<n;i+=2,pos++)b[pos]=a[i];

    for(int i=0;i<n;i++)cout<<b[i]<<" ";

    return 0;
}


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

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    
    if (N > 81) {
        cout << "No";
        return 0;
    }

    for (int i = 0; i < 10; i++) {
        if ((double)N/i == floor((double)N/i)) {
            if ((double)N/i < 10) {
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;
    REP(i,S.size()){
        int num = S[i];
        num += N;
        if(num>90)num-=26;
        printf("%c",num);
    }
    cout<<endl;
}


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

const int mod=1000000007,N=100100,inf=INT_MAX;
inline void upd(int&x,const int&y){x+=y-mod;x+=x>>31&mod;}
int sm[N],n;
void add(int x,int y){for(;x<=n+1;x+=x&-x)upd(sm[x],y);}
int qry(int x){int ans=0;for(;x;x-=x&-x)upd(ans,sm[x]);return ans;}
int m,a[N],b[N];
pair<int,int>c[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=m;++i)cin>>b[i];
	for(int i=1;i<=n;++i){
		int u=lower_bound(b+1,b+m+1,a[i])-b;
		if(u==1)c[i].first=inf;else c[i].first=a[i]-b[u-1];
		if(u==m+1)c[i].second=inf;else c[i].second=b[u]-a[i];
	}
	for(int i=1;i<=n;++i)a[i]=c[i].first,b[i]=c[i].second;
	sort(a+1,a+n+1);sort(b+1,b+n+1);
	for(int i=1;i<=n;++i){
		c[i].first=lower_bound(a+1,a+n+1,c[i].first)-a;
		c[i].second=-(lower_bound(b+1,b+n+1,c[i].second)-b);
	}
	sort(c+1,c+n+1);add(1,1);
	for(int i=1;i<=n;++i){
		c[i].second=-c[i].second;if(i>1&&c[i]==c[i-1])continue;
		if(a[c[i].first]==inf||b[c[i].second]==inf)continue;
		add(c[i].second+1,qry(c[i].second));
	}
	cout<<qry(n+1)<<'\n';
	return 0;
}


Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_3_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] line;
            int i, j;
            
            do
            {
                line = ReadIntAr();
                i = line[0];
                j = line[1];
                if (i == 0 && j == 0) return;
                else if( i<j) Console.WriteLine("{0} {1}", i, j);
                else Console.WriteLine("{0} {1}", j, i);
            } while (line != null);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 15936
#include<cstdio>

using namespace std;
typedef long long LL;
const LL mod=1000000007,N=200005;
LL je[N+5];
LL x,y;
LL Gcd(LL a, LL b, LL &x, LL &y)
{
	if(!b)
	{
		x=1;
		y=0;
		return a;
	}
	LL gcd=Gcd(b,a%b,x,y);
	LL tmp=x;
	x=y;
	y=tmp-(a/b)*y;
	return gcd;
}
LL C(LL m,LL n)
{
	Gcd(je[m]*je[n-m]%mod,mod,x,y);
	return je[n]*(x+mod)%mod;
}
int main()
{
	LL H,W,A,B;
	je[0]=1;
	for(LL i=1;i<=N;i++)
		je[i]=(je[i-1]*i)%mod;
	scanf("%lld%lld%lld%lld",&H,&W,&A,&B);
	LL ans=0;
	for(LL i=B+1;i<=W;i++)
	{
		LL tmp=(C(H-A-1,i-1+H-A-1)*C(W-i,W-i+A-1))%mod;
		ans=(ans+tmp)%mod;
	}
	printf("%lld",ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a,b;

int main(){
    cin >> a >> b;
    ll ans = max(a+b, a-b);
    ans = max(ans, a*b);
    cout << ans << endl;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.Bool (bool)

main :: IO ()
main = do
  let
    modulus = 998244353 :: Int
  [_, s] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    f :: [Int] -> Int
    f = VU.last . snd . foldl step (1, VU.replicate (succ s) 0)
      where
        step :: (Int, VU.Vector Int) -> Int -> (Int, VU.Vector Int)
        step (d, v) x = (2 * d `mod` modulus, VU.generate (succ s) g)
          where
            g :: Int -> Int
            g i = (2 * (v VU.! i) + bool 0 d (i == x) + bool 0 (v VU.! (i - x)) (x < i)) `mod` modulus
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print . f $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    int n; cin >> n;
    vl a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(rng(a));
    sort(rng(b));

    if (n % 2 == 0) {
        prt((b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1);
    } else {
        prt(b[n / 2] - a[n / 2] + 1);
    }

    return 0;
}


Measured memory_bytes: 6428
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  int c[5];
  fill(c, c + 5, 0);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M') c[0]++;
    else if (s[0] == 'A') c[1]++;
    else if (s[0] == 'R') c[2]++;
    else if (s[0] == 'C') c[3]++;
    else if (s[0] == 'H') c[4]++;
  }
  sort(c, c + 5);
  if (c[2] == 0) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          for (int m = 0; m <2; m++) {
            if (i + j + k + l + m != 3) continue;
            int res = 1;
            if (i) res *= c[0];
            if (j) res *= c[1];
            if (k) res *= c[2];
            if (l) res *= c[3];
            if (m) res *= c[4];
            ans += res;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	string s;
	cin >> s;
	if((s[0]==s[1]&&s[1]==s[2])||
		(s[1] == s[2] && s[2] == s[3]))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        boolean approved = true;
        for(int i = 0 ; i < n ; i++){
            int a = scanner.nextInt();
            if(a % 2 == 0){
                if(a % 3 == 0 || a % 5 == 0){
                    ;
                }else{
                    approved = false;
                    break;
                }
            }
        }

        System.out.println(approved ? "APPROVED" : "DENIED");

    }

}

Measured memory_bytes: 23124
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    t = input()
    for i in range(len(s)):
        if s.index(s[i]) != t.index(t[i]):
            print('No')
            return
    print('Yes')
        
        
        
            
        
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll n,a[100000];
ll dpt[100000];
ll dp(ll i){
	if(dpt[i]!=-1){
		return dpt[i];
	}
	if(i==n-1){
		return 0;
	}
	if(i==n-2){
		return abs(a[i]-a[n-1]);
	}
	dpt[i]=min(abs(a[i]-a[i+1])+dp(i+1),abs(a[i]-a[i+2])+dp(i+2)) ;
	return dpt[i];
}
int main(){
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=0;i<n;++i){
    	cin>>a[i];
    }
   memset(dpt,-1,sizeof(dpt));
    cout<<dp(0);
    return 0;
}

Measured memory_bytes: 3328
import numpy as np
H,W,K = map(int,input().split())
s = [list(input()) for _ in range(H)]
aw = [0,0]
ans = np.zeros((H,W))
jud = False
cnt = 1
for i in range(H):
    L = 0
    jud = False
    for j in range(W):
        if s[i][j] == "#":
            ans[i][L:] = cnt
            cnt += 1
            L = j+1
            jud = True
    if jud == False and i != 0:
        ans[i] = ans[i-1]
for i in range(H):
    if ans[i][0] == 0:
        continue
    else:
        for k in range(i):
            ans[k] = ans[i]
    break

for i in range(H):
    k = list(map(int,ans[i]))
    k = [str(a) for a in k]
    print(" ".join(k))


Measured memory_bytes: 15216
import sys
input = sys.stdin.readline

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

a = [0]*n

for i in range(n):
    a[i] = v[i] - c[i]

a.sort(reverse=True)
# print(a)

ans = 0
for i in a:
    if i > 0:
        ans += i

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
char o[51],e[51];
scanf("%s",o);
scanf("%s",e);
for(int i = 0; o[i] != '\0'; i++){
printf("%c",o[i]);
if(e[i] != '\0') printf("%c",e[i]);
}
return 0;
}

Measured memory_bytes: 128
from operator import itemgetter
n = int(input())
l = []
for i in range(n):
    pair = input().split()
    l.append([pair[0], int(pair[1])])
l2 = l[:]
# point rev. sort
sub = sorted(l2, key=itemgetter(1), reverse=True)
# name sort
l_sorted = sorted(sub, key=itemgetter(0))
for i in range(n):
    for j in range(n):
        if (l[j] == l_sorted[i]):
            print(j+1)

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N;
	cin >> N;
	VI pos(N+1);
	eFOR(i,1, N) {
		int a;
		cin >> a;
		pos[a]=i;
	}
	int ans = 0;
	set<int> visted = { 0,N + 1 };

	eFOR(i, 1, N) {
		int R, L;
		auto itr = visted.lower_bound(pos[i]);

		R = *itr;
		L = *(--itr);

		ans += i * (pos[i] - L)*(R - pos[i]);

		visted.insert(pos[i]);
	}

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



Measured memory_bytes: 11264
from bisect import bisect
T = [165.0,170.0,175.0,180.0,185.0]
c = [""]*6
for _ in xrange(input()):
    c[bisect(T,float(raw_input()))] += "*"
for i,a in zip(xrange(1,7),c):
    print "{}:{}".format(i,a)

Measured memory_bytes: 4304
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long g = gcd(A,B);
		if(g == 1){
			Console.WriteLine(1);
			return;
		}
		var di = PrimDec(g);
		Console.WriteLine(di.Count + 1);
		
		
		
		
		
	}

	static Dictionary<long,long> PrimDec(long A){
	 	Dictionary<long,long> D=new Dictionary<long,long>();
	 	if(A==1)return null;
	 	long rem=A;
	 	for(long i=2;i*i<=A;i++){
	 		if(rem%i==0){
	 			long cnt=0;
	 			while(rem%i==0){cnt++;rem/=i;}
	 			D.Add(i,cnt);
	 		}
	 		if(rem==1)break;
	 	}
	 	if(rem!=1)D.Add(rem,1);
	 	return D;
	}

	long gcd (long a, long b){ return a == 0 ? b : gcd(b % a, a);}
	long A,B;
	public Sol(){
		var d = rla();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

string s;

int main(void){
    cin >> s;
    int n = s.size()/2;
    int res;
    for(int i = 0; i < n; i++){
        string a, b;
        a = s.substr(0, i);
        b = s.substr(i, i);
        if(a == b) res = 2*a.size();
    }
    cout << res << endl;
    return 0;
}


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

int a[555][555], b[555][555];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            a[i][j] = min({i, n - i - 1, j, n - j - 1});
    long r = 0;
    for(int k = 0; k < n * n; k++) {
        int p;
        scanf("%d", &p);
        p--;
        r += a[p / n][p % n];
        b[p / n][p % n]++;
        queue<pair<int, int>> q;
        q.emplace(p / n, p % n);
        while(!q.empty()) {
            auto [i, j] = q.front();
            q.pop();
            if(i && a[i - 1][j] > a[i][j] + 1 - b[i][j])
                a[i - 1][j] = a[i][j] + 1 - b[i][j], q.emplace(i - 1, j);
            if(i + 1 < n && a[i + 1][j] > a[i][j] + 1 - b[i][j])
                a[i + 1][j] = a[i][j] + 1 - b[i][j], q.emplace(i + 1, j);
            if(j && a[i][j - 1] > a[i][j] + 1 - b[i][j])
                a[i][j - 1] = a[i][j] + 1 - b[i][j], q.emplace(i, j - 1);
            if(j + 1 < n && a[i][j + 1] > a[i][j] + 1 - b[i][j])
                a[i][j + 1] = a[i][j] + 1 - b[i][j], q.emplace(i, j + 1);
        }
    }
    cout << r << endl;
    return 0;
}


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

int main(){

  int a[10001] ;
  a[1] = 2;
  for(int i=2;i<=10000;i++) a[i] = a[i-1] + i;

  int n;
  while(cin >> n){
  cout << a[n] << endl;
  }
  
  return 0;
}


  

Measured memory_bytes: 1196
a = []
for i in range(5):
    a.append(int(input()))
ans = 0
mm = 10
for i in range(5):
    m = a[i] % 10
    if m > 0:
        mm = min(mm, m)
    for j in range(1, 14):
        if a[i] <= 10 * j:
            ans += 10 * j
            break

ans -= 10 - mm
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

int n;

void bfs(int start, vector<int>& score, vector<vector<int>>& a){
    vector<bool> isSearch(n, false);
    queue<int> q;
    q.push(start);
    score[start] = 0;
    isSearch[start] = true;
    while(!q.empty()){
        int x = q.front();
        isSearch[x] = true;
        q.pop();
        for(auto l: a[x]){
            if (isSearch[l] == true) continue;
            q.push(l);
            score[l] = score[x] + 1;
        }
    }

}

int main()
{
    int u, v;
    cin >> n >> u >> v;
    u--; v--;
    vector<vector<int>> a(n);
    rep(i, n - 1){
        int tmpa, tmpb;
        cin >> tmpa >> tmpb;
        tmpa--; tmpb--;
        a[tmpa].push_back(tmpb);
        a[tmpb].push_back(tmpa);
    }

    vector<int> score_t(n), score_a(n);

    bfs(u, score_t, a);
    bfs(v, score_a, a);

    int ans = 0;
    rep(i,n){
        //cout << i+1 << ":" <<score[i].first << ":"<< score[i].second <<endl;
        if (score_t[i] < score_a[i]){
            ans = max(ans, score_a[i]);
        }
    }

    cout << max(ans - 1, 0) << endl;

}



Measured memory_bytes: 6656
#include <cstdio>
#include <map>
#include <algorithm>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ++cnt[x];
  }
  int ans = 0;
  for (int i = 30; i >= 1; --i) {
    ans += cnt[1 << (i - 1)] / 2;
    for (auto &e : cnt) {
      if (e.first < (1 << (i - 1)) && cnt.count((1 << i) - e.first) != 0) {
        int by = min(e.second, cnt[(1 << i) - e.first]);
        ans += by;
        e.second -= by;
      }
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 11648
s=input()
k=int(input())
n=len(s)

sublst=[sorted(list(set([s[i] for i in range(n)])))]
ret=[]

def dfs(l,i):
    if len(sublst)<l+1 and n-l>0:
        sublst.append(sorted(list(set([s[i:i+l+1] for i in range(n-l)]))))
    
    ret.append(sublst[l-1][i])

    if len(ret)>=k:
        return
    
    if l<=n-1:
        for j in range(len(sublst[l])):
            if sublst[l][j][:-1]==sublst[l-1][i]:
                dfs(l+1,j)
    
    if l==1 and len(sublst[0])>i+1:
        dfs(1,i+1)

dfs(1,0)

print(ret[k-1])

Measured memory_bytes: 40304
"""
UnionFindにはいろいろな実装があるが, 本問ではparents配列にノード数を保持する実装だと非常に簡単に解ける. 
以下のようにしてノード数を保持する.
自身が子のとき, 親ノード番号を格納する.
自身が根のとき, ノード数を負の数で格納する.
つまり,　負の数のときは自身が根であり, その絶対値がその木のノード数を表す.
初期化時は、すべてのノードを−1で初期化する.
"""

N,M = map(int,input().split())

#UnionFind木の実装
#-1で初期化し、併合のたびに-1していく
par = [-1] * N  #親
rank = [0] * N #木の深さ

#木の根を求める
def find(x):
    #par[x]が負のとき(自分が代表のとき)、自身を返す
    if par[x] < 0:
        return x
    else:
        return find(par[x])

#xとyの属する集合を併合
def unite(x,y):
    x = find(x)
    y = find(y)
    #もとから同じ集合のときは何もしない
    if (x == y):
        return
    #x側を常に小さくする
    if par[x] > par[y]:
            x, y = y, x
    
    #x側に併合する、その際xの代表にノード数を加算する
    par[x] += par[y]
    par[y] = x
    

#xとyが同じ集合に属するかどうか
def same(x,y):
    return find(x) == find(y)

for i in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    unite(x,y)


ans = min(par)

print(abs(ans))


Measured memory_bytes: 77152
n,m = map(int,input().split())
l = [-1] + [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    l[a].append(b)
    l[b].append(a)
for mid in l[1]:
    if n in l[mid]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 108884
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	@SuppressWarnings("null")
	public static void main(String[] args) {
		
		int line = 0;
		Scanner sc = new Scanner(System.in);
		line = sc.nextInt();
		
		List<String> lines = new ArrayList<String>();
		int i=0;
		while(sc.hasNext()) {
			
			String lineData = sc.nextLine();
			if(lineData != null && ! lineData.equalsIgnoreCase("")) {
				 lines.add(lineData); 
				 i ++;
			}
			
			if(i==line) {
				break;
			}
		}
		
		 
		 for(i = 0; i<lines.size(); i++) {
			 System.out.println(lines.get(i).replace("Hoshino", "Hoshina"));
		 }
		

	}

}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	string s;
	stack<ll> st;
	st.push(2);
	ll ans = 0;

	cin >> s;

	REP(i, s.size()) {
		if (s[i] == '0') {
			if (st.top() == 1) {
				st.pop();
				ans++;
			}
			else {
				st.push(0);
			}
		}
		else {
			if (st.top() == 0) {
				st.pop();
				ans++;
			}
			else {
				st.push(1);
			}
		}
	}

	cout << ans * 2 << endl;
}

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

int main() {
    long long int n, ans = 0;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a+n);
    priority_queue<pair<int, int>> pq;
    ans = a[n-1];
    pq.push(make_pair(a[n-2], a[n-1]));
    pq.push(make_pair(a[n-2], a[n-1]));
    
    for(int i = n-3; i >= 0; --i) {
        auto x = pq.top();
        pq.pop();
        ans += x.first;
        pq.push(make_pair(a[i], x.first));
        pq.push(make_pair(a[i], x.second));
    }

    cout << ans << endl;

}


Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define lli long long
using namespace std ;
lli func(lli n){
    if(n==1) return 0 ;
    lli i , cnt = 0 , fact = 1 ;
    for(i=2;i*i<=n;++i){
        if(n%i==0){
            fact = i ;
            lli tn = n ;
            while(tn%i==0) tn /= i , cnt++ ;
            break ;
        }
    }
    if(cnt==0) return 1 ;
    return (sqrt(8*cnt+1)-1)/2 + func(n/pow(fact,cnt)) ;
}
int main(){
    lli n , ans = 0 ;
    cin >> n ;
    ans = func(n) ;
    cout << ans << "\n" ;
    return 0 ;
}

Measured memory_bytes: 4012
<?php
  
$n = trim(fgets(STDIN));  
$a = explode(' ',trim(fgets(STDIN)));
rsort($a);
array_values($a);

$ali = 0;
$bob = 0;
for($i=0; $i<$n; $i++){
  if ($i%2 == 0) {
    $ali += $a[$i];
  } else {
    $bob += $a[$i];
  }
}

echo $ali-$bob;

?>

Measured memory_bytes: 4604
#include<stdio.h>
main(){
  int a,b,c,temp,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
      if(a<b){
	temp=a;
	a=b;
	b=temp;
      }
    if(a<c){
      temp=a;
      a=c;
      c=temp;
    }
    if(a*a==b*b+c*c){
      puts("YES");
    }
    else{
      puts("NO");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<set>

int main(void){
    int N;
    std::cin >> N;
    std::set<std::string> s;
    std::string W;
    std::string W_last;
    std::cin >> W_last;
    s.insert(W_last);
    for(int i = 1; i < N; i++){
        std::cin >> W;
        if(W[0] != W_last[W_last.length() - 1]){
            std::cout << "No" << std::endl;
            return 0;
        }
        W_last = W;
        if(s.find(W) != s.end()){
            std::cout << "No" << std::endl;
            return 0;
        }
        s.insert(W);
    }
    std::cout << "Yes" << std::endl;
    return 0;
}

Measured memory_bytes: 256
K = int(input())

A,B = map(int,input().split())

def golf(A,B,K):
    for i in range(A,B+1):
        if i%K==0:
            return 0
    return 1

if golf(A,B,K) == 0:
    print("OK")
else:
    print("NG")    


Measured memory_bytes: 9160
#include<iostream>
#include<vector>
using namespace std;
int n;
typedef vector<int> vec;
vec tab;
void table(){
	int j;
	for(int i=2;i<=300000;i++){
		if((i-1+7)%7==0||(i-6+7)%7==0){
			for(j=0;j<(int)tab.size();j++)
				if(i%tab[j]==0)
					break;
				if((int)tab.size()==j){

					tab.push_back(i);
				}
		}
	}
}
void solve(){
	for(int i=0;tab[i]<=n&&i<(int)tab.size();i++)
	if(n%tab[i]==0){
		cout<<' '<<tab[i];
	}
	cout<<endl;
}
int main(){
	table();
	while(cin>>n,n!=1){
		cout<<n<<':';
		solve();
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  int A=1;
    cin>>N>>K;
  for(int i=0;i<N;i++) {
    if (A<K) 
      A*=2;
    else 
      A+=K;
  	}
  cout<<A<<endl;
  }

Measured memory_bytes: 3612
#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define F first
#define S second 
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, n-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 505;

const ll inf = 1e9 + 7;

int dp[maxn];
int ans[maxn][maxn];

void work(int l, int r) {
    int n = r - l + 1;
    if (n == 1) return;
    if (n == 2) {
        ans[l][r] = 1; return;
    }
    int v = dp[n]; int s = -1;
    for (int d = 1; d <= n - 1; d++) {
        int e = n - d;
        if (v == 1 + max(dp[d], dp[e])) s = d;
    }
    assert(s >= 0);
    work(l, l + s - 1); work(l + s, r);
    for (int i = l; i <= l + s - 1; i++) {
        for (int j = l + s; j <= r; j++) {
            ans[i][j] = v;
        }
    }
}

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;

    dp[1] = 1; dp[2] = 1;
    for (int j = 3; j < maxn; j++) {
        dp[j] = j;
        for (int s = 1; s <= j - 1; s++) {
            int t = j - s;
            dp[j] = min(dp[j], 1 + max(dp[s], dp[t]));
        }
    }
    int n; cin >> n;
    work(1, n);
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}




Measured memory_bytes: 2432
def main():
    s = input()
    t = input()

    print(solve(s, t))

def solve(s, t):
    xs = []
    n = len(t)
    for i in range(len(s) - n + 1):
        if match(s[i:i+n], t):
            xs.append(s[:i].replace('?', 'a') + t + s[i+n:].replace('?', 'a'))
    
    if xs:
        return min(xs)

    return 'UNRESTORABLE'

def match(x, y):
    for i, j in zip(x, y):
        if i != '?' and i != j:
            return False
    return True

main()


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

int main() {
  long long N;
  cin >> N;
  long long sum = 0;
  for (int i = 1; i <= N; i++) {
  	if (i % 3 == 0 || i % 5 == 0) {
    } else {
    	sum += i;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3640
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let s = s.trim();
    
    let v: Vec<u64> = s.split(" ").map(|c|c.parse().unwrap()).collect();
    let a = v[0];
    let b = v[1];
    
    let mut count = 1;
    let mut t = a * 2;
    loop {
        if t <= b {
            count += 1;
            t = t * 2;
        } else {
            break;
        }
    }
    
    println!("{}", count);
}

Measured memory_bytes: 4352
def c_sugar_water(A, B, C, D, E, F):
    x = set()  # 水の量が取りうるパターン
    y = set()  # 砂糖の量が取りうるパターン
    for i in range(F // 100 + 1):
        for j in range(F // 100 + 1):
            tmp = 100 * A * i + 100 * B * j
            if tmp <= F:
                x.add(tmp)
            else:
                break  # A, Bは正整数なので、Fを超えるようなjの値にする意味がない
    for i in range(F):
        for j in range(F):
            tmp = C * i + D * j
            if tmp <= F:
                y.add(tmp)
            else:
                break

    concentration = 0  # 砂糖水の濃度
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            if water == 0 and sugar == 0:
                continue  # 水も砂糖も入れていない
            elif E * (water // 100) < sugar:
                continue  # 砂糖を溶かしきれない
            elif water + sugar > F:
                continue  # ビーカーに入れられる質量を超えた
            else:
                if (100 * sugar) / (water + sugar) >= concentration:
                    concentration = (100 * sugar) / (water + sugar)
                    tmp = [water + sugar, sugar]
    ans = '{} {}'.format(tmp[0], tmp[1])
    return ans

A, B, C, D, E, F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  int a = 100;
  
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int b = 0;
    while (A % 2 == 0) {
      A /= 2;
      b++;
    }
    if (b < a) {
      a = b;
    }
    else {
      a = a;
    }
  }
  cout << a << endl;
}   

Measured memory_bytes: 256
#include <stdio.h>

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)

int N;
int A[1000];

int show(int *A, int N) {
    REP(i, N - 1)printf("%d ", A[i]);
    printf("%d\n", A[N - 1]);
}

int insertionSort(int *A, int N) {
    show(A,N);
    FOR(i, 1, N) {
        int v = A[i];
        int j = i - 1;
        while (0 <= j && v < A[j]) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        show(A, N);
    }
}

void solver() {
    scanf("%d", &N);
    REP(i, N)scanf("%d", &A[i]);
    insertionSort(A, N);
}

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


Measured memory_bytes: 1800
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
using  namespace std;   
int main()
{

	int b,c,i,j=0;
	char a;
	for(i=1;i<=6;i++)
	{
		cin>>a;
		if(a=='1')		j++;
	}
	cout<<j<<endl;
    return 0;
}

Measured memory_bytes: 384