akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define MOD 1000000007
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define vvll vector<vector<ll>>
#define mll map<ll, ll>
#define mcl map<char, ll>
#define sc set<char>
#define sll set<ll>
#define ssll stack<ll>
#define CHK(param) cout << #param << " is : " << param << "\n";
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define LAUV                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define TC       \
    ll TTTT;     \
    cin >> TTTT; \
    while (TTTT--)
using namespace std;

int32_t main()
{
    LAUV;
    // TC
    {
        ll x, n;
        cin >> x >> n;
        sll ss;
        forn(i,0,n){
            ll val;cin >> val;
            ss.insert(val);
        }
        bool found=false;
        ll ans=0;
        ll check=x,c1=x,c2=x;
        if(ss.count(check)==0){
            ans=check;
            found=true;
        }
        while(!found){
            c1--,c2++;
            if(ss.count(c1)==0 and ss.count(c2)==0){
                ans=min(c1,c2);
                found=true;
            }
            else if(ss.count(c1)==0){
                ans=c1;
                found=true;
            }
            else if(ss.count(c2)==0){
                ans=c2;
                found=true;
            }
        }
        cout<<ans<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3652
use proconio::*;
fn main(){
input!{t:usize}
for _ in 0..t{
input!{n:usize,mut a:[(usize,i64,i64);n]}
let mut z=0;
let mut b=vec![];
let mut c=vec![];
for(k,l,r)in a{z+=if l>=r{b.push((k,r-l));r}else{if k<n{c.push((n-k,l-r))}l}}
for mut a in vec![b,c]{
a.sort();
let mut s=std::collections::BinaryHeap::new();
for(k,d)in a{s.push(d);if s.len()>k{s.pop();}}
for d in s{z-=d}
}
println!("{}",z);
}
}

Measured memory_bytes: 13668
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	double p1=0,p2=0,p3=0,p4=0;
	ll n,i,k;
	vector<ll> x(102),y(102);
	
	cin>>n;
	
	for(i=1;i<=n;i++){
		cin>>x[i];
	}
	for(i=1;i<=n;i++){
		cin>>y[i];
	}
	p1=0;
	p2=0;
	p3=0;
	p4=0;
	for(i=1;i<=n;i++){
		k=x[i]-y[i];
		if(k<0) k=-k;
		if(k>p4) p4=k;
		p1+=k;
		p2+=k*k;
		p3+=k*k*k;
	}
	p2=sqrt(p2);
	p3=cbrt(p3);
	
	printf("%6lf\n",p1);
	printf("%6lf\n",p2);
	printf("%6lf\n",p3);
	printf("%6lf\n",p4);
	
	return 0;
}


Measured memory_bytes: 3336
def resolve():
    '''
    code here
    '''
    import itertools
    N = int(input())
    P = tuple([int(item) for item in input().split()])
    Q = tuple([int(item) for item in input().split()])
    # print(Q)
    all = list(itertools.permutations(range(1,N+1)))
    a = 0
    b = 0
    for i, item in enumerate(all):
        # print(item)
        if item == P:
            a = i
        if item == Q:
            b = i

    print(abs(a-b))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 13748
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> G[100100];
bool ok[100100];
int dfs(int n){
  int ans=0;
  ok[n]=false;
  for(int i:G[n])
    if(ok[i])ans^=dfs(i);
  return ans+1;
}
signed main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  for(int i=0;i<N;i++)ok[i]=true;
  ok[0]=false;
  puts(dfs(0)-1?"Alice":"Bob");
}

Measured memory_bytes: 13844
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N=ri()
ans = 0
rate = 380000.0
for i in range(N):
    x,u=input().split()
    x = float(x)
    ans += x if u=='JPY' else x*rate

print("{:11f}".format(ans))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,a;
	cin >> n >> a;
	cout << (n*n-a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)


int main() {
    int n;
    while (cin >> n && n) {
        int a[n]; rep(i, n) cin >> a[i];
        sort(a, a + n);
        int ans = inf;
        rep3(i, 1, n) {
            chmin(ans, a[i] - a[i - 1]);
        }
        out(ans);
    }
}



Measured memory_bytes: 3144
using System;

namespace AtCoder
{
    internal static class Program_D
    {
        private class Solver
        {


            // ABC147 Xor Sum 4
            public void Solve()
            {
                int k = int.Parse(Console.ReadLine());

                long test = 0;
                long memo = 0;
                for (int i = 0;; ++i)
                {
                    test = test*10 + 7;
                    if (test < k) continue;

                    test = test%k;
                    if (test == 0)
                    {
                        Console.WriteLine(i + 1);
                        return;
                    }
                    if (memo == 0)
                    {
                        memo = test;
                    }
                    else
                    {
                        if (memo == test)
                        {
                            Console.WriteLine(-1);
                            return;
                        }
                    }
                }
            }

            private static void Main(string[] args)
            {
                new Solver().Solve();
            }
        }
    }
}

Measured memory_bytes: 27484
N = int(input())
B = [int(i) for i in input().split()]
if B[0] != 1:
    print(-1)
    exit()

cn = [0]*N
for n in reversed(range(1,N+1)):
    #print('n',n)
    #print(B)
    for i in reversed(range(1,n+1)):
        if B[i-1] == i:
            #print('i',i)
            cn[n-1] = i
            break
    if cn[n-1] == 0:
        print(-1)
        exit()
    B.pop(i-1)
        
for n in range(N):
    print(cn[n])

Measured memory_bytes: 3064
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
const int N = pow(10, 5);

vector<bool> isp(N + 1, true);

long long modMult(long long a, long long b, long long m)
{
    long long res = 0;
    long long exp = a % m;
    while (b)
    {
        if (b & 1)
        {
            res += exp;
            if (res > m)
                res -= m;
        }
        exp <<= 1;
        if (exp > m)
            exp -= m;
        b >>= 1;
    }
    return res;
}
long long powMod(long long a, long long b, long long m)
{
    long long res = 1;
    long long exp = a % m;
    while (b)
    {
        if (b & 1)
            res = modMult(res, exp, m);
        exp = modMult(exp, exp, m);
        b >>= 1;
    }
    return res;
}
//powMod(a,b,MOD)
//O(log(b))?
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    V dp(k + 1);
    for (ll i = k; i >= 1; i--)
    {
        ll temp = k / i;
        dp[i] = powMod(temp, n, MOD);
        ll bai = 2;
        while (i * bai <= k)
        {
            dp[i] -= dp[i * bai];
            dp[i] += MOD;
            dp[i] %= MOD;
            bai++;
        }
        res += i * dp[i];
        res %= MOD;
    }
    cout << res << endl;
}


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

int main() {
  string sa, sb, sc; cin >> sa >> sb >> sc;
  int an = sa.size(), bn = sb.size(), cn = sc.size();
  sa += " "; sb += " "; sc += " ";
  int ai = 0, bi = 0, ci = 0;
  char turn = 'a';
  char ans = 'Z';
  while (true) {
    if (turn == 'a') {turn = sa[ai]; ai++;}
    else if (turn == 'b') {turn = sb[bi]; bi++;}
    else if (turn == 'c') {turn = sc[ci]; ci++;}
    if (ai > an) {ans = 'A'; break;}
    else if (bi > bn) {ans = 'B'; break;}
    else if (ci > cn) {ans = 'C'; break;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));

  int ok = INF;
  int ng = -INF;
  while(ok-ng > 1){
    int mid = (ok+ng)/2;
    int cnt = 0;
    REP(i, N){
      if(A[i]*A[i] <= mid) cnt--;
      if(A[i] < 0){
        int mn = mid/A[i]-5;
        while(mn*A[i] > mid) mn++;
        int pos = A.end()-lower_bound(ALL(A), mn);
        cnt += pos;
      }
      if(A[i] > 0){
        int mx = mid/A[i]+5;
        while(mx*A[i] > mid) mx--;
        int pos = upper_bound(ALL(A), mx)-A.begin();
        cnt += pos;
      }
      if(A[i] == 0){
        if(mid >= 0) cnt += N;
      }
    }

    cnt /= 2;
    if(cnt >= K) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;

  return 0;
}

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

int main() {
  std::string A, B;
  std::cin >> A >> B;

  int res = 0;
  if (A == B) {
    res = 0;
  } else if (A.length() != B.length()) {
    if (A.length() < B.length()) {
      res = -1;
    } else {
      res = 1;
    }
  } else {
    if (A < B) {
      res = -1;
    } else {
      res = 1;
    }
  }

  if (res < 0) {
    std::cout << "LESS" << std::endl;
  } else if (res > 0) {
    std::cout << "GREATER" << std::endl;
  } else {
    std::cout << "EQUAL" << std::endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int digsum(string n) {
    int sn = 0;
    FORE(x, n) sn += x - '0';
    return sn;
}
int f(int n) {
    string s = to_string(n);
    int sn = digsum(s);

    int next = -1;
    double mn = INF;
    REP(i, SZ(s)) {
        REP(d, 10) {
            string t = s;
            t[i] = d + '0';
            REPF(j, i + 1, SZ(s)) t[j] = '9';
            int m = stoll(t);
            if (m < n) continue;
            int sm = digsum(t);
            if (chmin(mn, m / sm)) {
                next = m;
            }
        }
    }
    return next;
}
signed main() {
    int K;
    cin >> K;
    int a = 1;
    REP(i, K) {
        cout << a << endl;
        a = f(a + 1);
    }
    return 0;
}



Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;


int main(){
    FASTIO
    int n,a = 0, b = 0, c = 0, d = 0;
    cin >> n;
    rep(i, 0, n){
    	string s;
    	cin >> s;
    	if(s == "AC")
    		a++;
    	else if(s == "WA")
    		b++;
    	else if(s == "TLE")
    		c++;
    	else
    		d++;
	}
	
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
}

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


int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(){
    int a[100000]={},b[100000]={};
    int n;
    cin>>n;
    for(int i=0;i<n/2;i++){
        int x,y;
        cin>>x;
        a[x]++;
        cin>>y;
        b[y]++;
    }

    int x_1=0,x_2=0,xk_1=0,xk_2=0;
    int y_1=0,y_2=0,yk_1=0,yk_2=0;
    for(int i=0;i<100000;i++){
        if(x_1<=a[i]){
            x_2=x_1;xk_2=xk_1;
            x_1=a[i];xk_1=i;
        }else if(x_2<=a[i]){
            x_2=a[i];xk_2=i;
        }
        if(y_1<=b[i]){
            y_2=y_1;yk_2=yk_1;
            y_1=b[i];yk_1=i;
        }else if(y_2<=b[i]){
            y_2=b[i];yk_2=i;
        }
    }
    if(xk_1!=yk_1){
        cout<<n-x_1-y_1<<endl;
    }
    else{
        int max_value=0;
        if(max_value<(x_1+y_2)) max_value=x_1+y_2;
        if(max_value<(x_2+y_1)) max_value=x_2+y_1;
        if(xk_1!=xk_2 && max_value<(x_2+y_2)) max_value=x_2+y_2;
        cout<<n-max_value<<endl;
    }


    return 0;
}



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

int main()
{
	int a, b;
	cin >> a >> b;
	
	if (a == 1 && b == 2)
	{
		cout << 3 << endl;
	}
	else if (a == 1 && b == 3)
	{
		cout << 2 << endl;
	}
	else if (a == 2 && b == 1)
	{
		cout << 3 << endl;
	}
	else if (a == 2 && b == 3)
	{
		cout << 1 << endl;
	}
	else if (a == 3 && b == 1)
	{
		cout << 2 << endl;
	}
	else if (a == 3 && b == 2)
	{
		cout << 1 << endl;
	}
		
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <bits/stdc++.h>
// a&1 check odd or not and a>>=1 halfs a
// (n-1-i)%i previous in circle (i+n-1)%n next one
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;


int n;
int arr[105];


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    int a;
    int sum=0;
    loop(i,0,n){
    	cin>>a;
    	sum+=a;
    	arr[i]=a;
	}
	double av=double(sum)/double(n);
//  	cout<<av<<endl;
  	int avc,avf;
  	avc=ceil(av);
  	avf=floor(av);
  	int sum1,sum2;
	loop(i,0,n){
		sum1+=(arr[i]-avc)*(arr[i]-avc);
		sum2+=(arr[i]-avf)*(arr[i]-avf);
	}
	int ans=min(sum1,sum2);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int n,a,b;
    scanf("%d\n",&n);
    scanf("%d\n",&a);
    scanf("%d\n",&b);
    if ( n == 1) {
        printf("Hello World\n");
    } else {
        printf("%d\n",a+b);
    }
    return 0;
}

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

int main() {
  int a = 0, b = 0, c = 0, d = 0, l = 0, r = 0;
  cin >> a >> b >> c >> d;

  l = a + b;
  r = c + d;
  if ( l > r ) {
    cout << "Left" << endl;
  } else if ( l == r ) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int N, tmp = 0, sum = 0;
    string K;
    cin >> N;
    vector <string> S(N);
    vector <int> T(N);
    for (int i = 0; i < N; i++) cin >> S[i] >> T[i];
    cin >> K;

    for (int i = 0; i < N; i++) {
        if (tmp) sum += T[i];
        if (S[i] == K) tmp = 1;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        
        while (!s.Equals("-"))
        {
            int c = int.Parse(Console.ReadLine());
            
            for (int i=0; i<c; i++)
            {
                int h = int.Parse(Console.ReadLine());
                s = s.Substring(h) + s.Substring(0, h);
            }
            
            Console.WriteLine(s);
            
            s = Console.ReadLine();
        }
    }
}


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

int main()
{
        int a, b, i;
        int sum;        

        while(scanf("%d %d", &a, &b) != EOF){
                sum = a + b;
                for(i=0; sum>0; i++){
                        sum /= 10;
                }

                cout << i << endl;
        }

        return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <queue>
#include <map>
#define N 3
#define NN 9

using namespace std;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
char direction[4] = {'u', 'l', 'd', 'r'};

typedef struct Puzzle{
    int state[NN];
    int space;
    string result;

    bool operator < (const Puzzle &p) const{
        for(int i = 0; i < NN; i++){
            if(state[i] == p.state[i]) continue;
            return state[i] > p.state[i];
        }
        return false;
    }
}P;

bool isfinished(P p){
    for(int i = 0; i < NN; i++){
        if(p.state[i] != i+1) return false;
    }
    return true;
}

string bfs(P p){
    queue<P> Q;
    map<P, bool> V;
    P u, v;
    int sx, sy, tx, ty;

    p.result = "";
    Q.push(p);
    V[p] = true;

    while(!Q.empty()){
        u = Q.front();
        Q.pop();

        if(isfinished(u)) return u.result;

        sx = u.space / N;
        sy = u.space % N;
        for(int i = 0; i < 4; i++){
            tx = sx + dx[i];
            ty = sy + dy[i];
            
            if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;

            v = u;
            int tmp = v.state[u.space];
            v.state[u.space] = v.state[tx * N + ty];
            v.state[tx * N + ty] = tmp;
            v.space = tx * N + ty;

            if(!V[v]){
                V[v] = true;
                v.result += direction[i];
                Q.push(v);
            }
        }
    }
    return "";
}

int main(){
    P p;

    for(int i = 0; i < NN; i++){
        cin >> p.state[i];
        if(p.state[i] == 0){
            p.state[i] = NN;
            p.space = i;
        }
    }

    string result = bfs(p);

    cout << result.size() << endl;

    return 0;
}


Measured memory_bytes: 30496
#include <bits/stdc++.h>
using namespace std;
//actual solution is at bottom//
////<pbds>////
/*OPTIONAL
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, 
    rb_tree_tag, tree_order_statistics_node_update>; 
// change null_type for map
#define ook order_of_key
#define fbo find_by_order
*/
///</pbds>///

#define int long long int
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()

///<constants>///
const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; 
const ll INF = 1e18; 
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0};
///</constants>///

///<IO>/// 
namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
        // cin.exceptions(cin.failbit); // ex. throws exception when you try to read letter into int
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
    }
}
 
using namespace io;
///</IO>///

///<execution-time>///
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
/*example for clock usage
    clock_t z = clock();
    debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
*/
///</execution-time>///

inline void google(int i){
    cout<<"Case #"<<i<<" :";
}
signed main(){
    setIO("");
    int d,t,s;cin>>d>>t>>s;
    if(s*t>=d)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}
/* stuff you should look for
    * check whether you have read the problem correctly
    * int overflow, array bounds
    * special cases (n=1?), slow multiset operations
    * do smth instead of nothing and stay organized
*/

Measured memory_bytes: 3580
import java.util.Scanner;
public class Main {
  public static void main(String[] arga) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int S = sub(s);
    int T = sub(t);
    if(S > T) {
      System.out.println(">");
    }else if(S < T) {
      System.out.println("<");
    }else {
      System.out.println("=");
    }
  }
  static int sub(String s) {
    if(s.equals("A")) return 1;
    else if(s.equals("B")) return 2;
    else if(s.equals("C")) return 3;
    else if(s.equals("D")) return 4;
    else if(s.equals("E")) return 5;
    else if(s.equals("F")) return 6;
    else return 0;
  }
}


Measured memory_bytes: 23636
#include <stdio.h>

int main(void)
{
int a,b;
scanf ("%d%d",&a,&b);
if (a>b) {
    printf("a > b\n");
 }else if (a<b) {
    printf("a < b\n");
    }else {
        printf("a == b\n");
    }



return 0;
}


Measured memory_bytes: 2052
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]

# 各数字の座標
P = {}
for h in range(H):
    for w in range(W):
        P[A[h][w]] = (h, w)

# コスト(0番目は飾り)
C = [0] * (H * W + 1)
for i in range(D + 1, H * W + 1):
    C[i] = C[i - D] + abs(P[i - D][0] - P[i][0]) + abs(P[i - D][1] - P[i][1])

Q = int(input())
for q in range(Q):
    L, R = map(int, input().split())
    print(C[R] - C[L])


Measured memory_bytes: 23332
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

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

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
    }
    else { // 発見できなかったとき
        return 0;
    }
}

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    
    if(a + b + c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int a, b, c, d, e, i, j, temp, k;
	int array[5];
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);
	array[0] = a % 10;
	array[1] = b % 10;
	array[2] = c % 10;
	array[3] = d % 10;
	array[4] = e % 10;
	for (k = 1; k < 5; k++)
	{
		if (array[k] == 0)
		{
			array[k] = array[k] + 10;
		}
	}
	for (i = 0; i < 4; i++)
		for (j = 0; j < 4; j++)
		{
			if (array[j + 1] < array[j])
			{
				temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp;
			}
		}


	printf("%d", a + b + c + d + e + 40 - array[1] - array[2] - array[3] - array[4]);


	return 0;
}

Measured memory_bytes: 128
def binary_search(l, key):
    left = 0
    right = len(l)
    while left < right:
        mid = (left + right) // 2
        if l[mid] == key:
            return 1
        elif key < l[mid]:
            right = mid
        else:
            left = mid + 1
    return 0


n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
ans = 0
for i in t:
    if binary_search(s, i) != 0:
        ans += 1
print(ans)


Measured memory_bytes: 16716
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

double dp[3000][3000];

int main()
{
    int X, A;
    cin >> X >> A;

    int ans = (X < A) ? 0 : 10;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    if (H % h == 0 && W % w == 0) {
        cout << "No" << endl;
        ret();
    }
    cout << "Yes" << endl;

    if (W % w != 0) {
        ll t = W / w + 1;
        rep(i, H) {
            rep(j, W) {
                if (j % w == 0) {
                    cout << t << " ";
                } else if (j % w == w - 1) {
                    cout << -(t + 1) << " ";
                } else {
                    cout << 0 << " ";
                }
            }
            cout << endl;
        }
    } else {
        ll t = H / h + 1;
        rep(i, H) {
            rep(j, W) {
                if (i % h == 0) {
                    cout << t << " ";
                } else if (i % h == h - 1) {
                    cout << -(t + 1) << " ";
                } else {
                    cout << 0 << " ";
                }
            }
            cout << endl;
        }
    }

}


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

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);

ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<vector<ll>> matrix;

int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  int ret = 1 << 25;
  while(n--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if(b <= t) ret = min(ret, a);
  }
  if(ret == 1 << 25) printf("TLE\n");
  else printf("%d\n", ret);
}


Measured memory_bytes: 256
n,T = gets.chomp.split(" ").map(&:to_i)
t = gets.chomp.split(" ").map(&:to_i)
b = t[-1]
for i in 0..n-3
  t[n-1-i] -= t[n-2-i]
end
a = 0
for i in 1..n-1
  a += [0,t[i]-T].max
end
puts b+T-a

Measured memory_bytes: 21892
#include <algorithm>
#include <iostream>
#include <vector>

typedef struct {
  char mark;
  int num;
} Card;

void merge(std::vector<Card>* A, int left, int mid, int right) {
  std::vector<Card> L(A->begin() + left, A->begin() + mid);
  std::vector<Card> R(A->begin() + mid, A->begin() + right);
  L.push_back({'Z', std::numeric_limits<int>::max()});
  R.push_back({'Z', std::numeric_limits<int>::max()});
  int i = 0, j = 0;
  for (int k = left; k < right; ++k) {
    if (L[i].num <= R[j].num) {
      (*A)[k] = L[i];
      i = i + 1;
    } else {
      (*A)[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(std::vector<Card>* A, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}


int partition(std::vector<Card>* A, int p, int r) {
  int x = (*A)[r].num;
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if ((*A)[j].num <= x) {
      i = i + 1;
      std::swap((*A)[i], (*A)[j]);
    }
  }
  std::swap((*A)[i + 1], (*A)[r]);
  return i + 1;
}

void quickSort(std::vector<Card>* A, int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

int main() {
  int n;
  std::cin >> n;
  std::vector<Card> cards;
  for (int i = 0; i < n; ++i) {
    Card c;
    std::cin >> c.mark >> c.num;
    cards.push_back(c);
  }
  std::vector<Card> merge_sort(cards.begin(), cards.end());
  mergeSort(&merge_sort, 0, n);
  quickSort(&cards, 0, n-1);
  bool flag = true;
  for (int i = 0; i < n; ++i) {
    if (cards[i].mark != merge_sort[i].mark ||
        cards[i].num != merge_sort[i].num) {
      flag = false;
      break;
    }
  }
  std::cout << (flag ? "Stable" : "Not stable") << std::endl;
  std::for_each(cards.begin(), cards.end(), [](Card c) {
      std::cout << c.mark << " " << c.num << std::endl;
    });
  return 0;
}

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

using namespace std;

int main(){
	int n,sum=0,mi_idx;
	double avg,mi=1e9;
	cin >> n;
	vector<int> d(n,0);
	
	for(int i=0;i<n;i++){
		cin >> d[i];
		sum+=d[i];	
	}
	
	avg=(double)sum/(double)n;
	
	for(int i=n-1;i>=0;i--){
		if(mi>=(avg-d[i])*(avg-d[i])){
			mi_idx=i;
		}
		mi=min(mi,(avg-d[i])*(avg-d[i]));
	}
	
	cout << mi_idx << endl;
	return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[2020];
int K;
int A_sorted[2020];
const int mod = 1000000007;

signed main() {
    cin >> N >> K;
    multiset<int> ms;
    rep(i, N) {
        cin >> A[i];
        A_sorted[i] = A[i];
        ms.insert(A[i]);
    }
    int ans = 0;
    int K2 = K * (K - 1) / 2 % mod;
    rep(i, N) {
        int dif = N - ms.count(A[i]);
        ans += dif * K2;
        ans %= mod;
    }
    ans *= 500000004;
    ans %= mod;
    int ans2 = 0;
    rep(i, N) {
        for (int j = i + 1; j < N; ++j) {
            if (A[i] > A[j])ans2++;
        }
    }
    ans2 = ans2 * K % mod;
    ans += ans2;
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
//Created by Aigerim.
//© 2019 Aigerim.
                                                                               
/***************************************************************                                       ****       ****
**                                                                                                  *       *   *      *
**  *********   **          *********    **           **  ********     **        **                 *        * *       *
**      **      **          **     **     **         **   **           **        **                 *         *        *
**      **      **          **     **      **       **    **           **        **                  *                *    
**      **      **          **     **       **     **     ********     **        **                   *              *
**      **      **          **     **        **   **      **           **        **                    *            *        
**      **      *********   **     **         ** **       **            *        *                       *         *
**  *********   *********   *********          ***        ********       ********                          *      *
**                                                                                                           *  *
**                                                                                                             *
***************************************************************/  
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
string s,t;
cin>>s>>t;
n=s.size();
for(int i=0;i<n;i++){
	cout<<s[i]<<t[i];
}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> B(N-1);
    for(int i = 0; i < N-1; i++){
        cin >> B[i];
    }
    
    vector<long long> A(N);
    A[0] = B[0];
    for(int i = 1; i <= N-2; i++){
        A[i] = min(B[i], B[i-1]);
    }
    A[N-1] = B[N-2];

    long long ans = 0;
    for(int i = 0; i < N; i++){
        ans += A[i];
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<int> vi;
int a[100005];
int b[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		vi.push_back(a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		vi.push_back(b[i]);
	}
	int cnt=0;
	priority_queue<P> que_ng;
	priority_queue<P> que_ok;
	priority_queue<P,vector<P>,greater<P> > que_ok_a;
	for(int i=0;i<n;i++){
		if(a[i]<=b[i]){
			que_ok.push(P(b[i],i));
		}else{
			que_ng.push(P(a[i],i));
		}
	}
	while(que_ng.size()){
		while(que_ok.size()>0 && que_ng.top().first<=que_ok.top().first){
			P p=que_ok.top();
			que_ok.pop();
			que_ok_a.push(P(a[p.second],p.second));
		}
		if(que_ok_a.size()==0){
			printf("No\n");
			return 0;
		}
		P p=que_ng.top();
		que_ng.pop();
		cnt++;
		if(b[p.second]<que_ok_a.top().first){
			P pp=que_ok_a.top();
			que_ng.push(P(pp.first,p.second));
			que_ok_a.pop();
			//printf("repush %d %d\n",pp.first,pp.second);
		}else{
			a[p.second]=que_ok_a.top().first;
			que_ok.push(P(b[p.second],p.second));
			que_ok_a.pop();
		}
		//printf("que %d %d %d %d %d\n",p.first,p.second,(int)que_ng.size(),(int)que_ok.size(),(int)que_ok_a.size());
	}
	//printf("%d\n",cnt);
	printf("%s\n",(cnt<=n-2)?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3444
N, M = map(int, input().split())

ABi = []
for _ in range(N):
    A, B = map(int, input().split())
    ABi.append((A, B))

ABi.sort(key=lambda x: x[0])

gold = 0
for A, B in ABi:
    if M >= B:
        M -= B
        gold += A * B
    else:
        gold += A * M
        break

print(str(gold))



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

using namespace std;

int main() {
  int N; cin >> N;
  int T, A; cin >> T >> A;
  
  int ansIndex = 1;
  int ansH; cin >> ansH;
  for(int i = 2; i <= N; i++) {
    int Hi; cin >> Hi;
    if(abs(A - (T - ansH * 0.006)) > abs(A - (T - Hi * 0.006))) {
      ansIndex = i;
      ansH = Hi;
    }
  }
  cout << ansIndex << endl;
}


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

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    map<string, int> S, T;
    rep(i, N) {
        string s;
        cin >> s;
        S[s]++;
    }

    int M;
    cin >> M;
    rep(i, M) {
        string t;
        cin >> t;
        T[t]++;
    }

    int ans = 0;
    for (auto &p : S) {
        int res = p.second - T[p.first];
        ans = max(ans, res);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
inp = int(input())
A = []
for a in range(inp):
    A.append(int(input()))

m = max(A)

# 最大値をとる要素が何個あるかチェック
c = 0
for a in A:
    if a == m:
        c += 1

# 二番目
if len(A) > c:
    second = max([v for v in A if v != m])    

for i, a in enumerate(A):
    if a == m:
        if c > 1:
            print(m)
        else:
            print(second)
    else:
        print(m)


Measured memory_bytes: 12588
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, D; double X[10][10]; cin >> N >> D;
  REP(i, N) REP(j, D) cin >> X[i][j];
  int ans = 0;
  REP(i, N) for(int j = i+1; j < N; j++){
    double num = 0.0;
    REP(k, D) num += pow((X[i][k]-X[j][k]), 2.0);
    num = sqrt(num);
    if(fmod(num, 1.0) == 0.0) ans++;
  }
  cout << ans << endl;
}

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


int main(){

    int N;

    cin >> N;
    int shita = N%10;
    if(shita==2||shita==4||shita==5||shita==7||shita==9){
        cout << "hon" << endl;
    }else if(shita==3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }


    return 0;
}


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

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    int n,l,r,m,lo,hi,mid,d;
    string s;
    cin >> n; 
    // lo = 0
    cout << 0 << '\n'; cout.flush();
    cin >> s; 
    if(s[0] == 'V')
        return 0;
    l = (s[0] == 'M');
    // hi = n-1
    cout << n-1 << '\n'; cout.flush();
    cin >> s; 
    if(s[0] == 'V')
        return 0;
    r = (s[0] == 'M');
    // Binary search
    lo = 0; hi = n-1;
    while(lo <= hi)
    {
        mid = lo + (hi-lo)/2;
        cout << mid << '\n'; cout.flush();
        cin >> s; 
        if(s[0] == 'V')
            return 0;
        m = (s[0] == 'M');
        d = mid - lo + 1;
        if((l != m && d % 2 != 0) || (l == m && d % 2 == 0))
        {
            hi = mid;
            r = m;
        }
        else
        {
            lo = mid;
            l = m;
        }
    }
    return 0;
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> ans;
    for (int i = a; i < min(a + k, b + 1); ++i) ans.insert(i);
    for (int j = b; j > max(b - k, a - 1); --j) ans.insert(j);
    for (int l : ans) cout << l << endl;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++)
    {
        int ele;
        cin >> ele;
        s.insert(ele);
    }
    if(s.size() == n)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


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

int main()
{
  map<int,int> m;
  map<int,int>::iterator it;
  int n;
  for(n=1;n<=30;n++)m[n]=1;
  while(cin>>n)m.erase(n);
  for(it=m.begin();it!=m.end();it++)cout<<(*it).first<<endl;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int R, C;
char G[15][15];
bool check[15][15];

int main(){
	scanf("%d %d", &R, &C);
	memset(check, true, sizeof(check));
	for(int i=0;i<R;i++){
		scanf("%s", G[i]);
		for(int j=0;j<C;j++){
			if (G[i][j] == '#'){
				check[i][j] = false;
			}
		}
	}
	bool changed = true;
	int posX = 0, posY = 0;
	check[posX][posY] = true;
	if (!check[posX][posY]){
		check[posX][posY] = false;
		changed = false;
	}
	while(changed){
		changed = false;
		while(posX != R-1 && G[posX+1][posY] == '#'){
			posX++;
			check[posX][posY] = true;
			changed = true;
		}
		while(posY != C-1 && G[posX][posY+1] == '#'){
			posY++;
			check[posX][posY] = true;
			changed = true;
		}
	}
	bool ans = true;
	for(int i=0;i<R;i++){
		for(int j=0;j<C;j++){
			ans &= check[i][j];
		}
	}
	printf("%s\n", ans?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
  int x,y;
  int h,i;
  int H,K;
  int a,b,c,d;
  cin >> x >> y >> h >>i >> a >>b >> c >> d;
  H=(a*x+((x/10)*c))+(b*y+((y/20)*d));
  K=(a*h+((h/10)*c))+(b*i+((i/20)*d));
  if(H>K){
      cout << "hiroshi" << endl;
  }
  else if(H<K){
      cout << "kenjiro" << endl;
  }
  else cout << "even" << endl;
  
  
  
   }
    


Measured memory_bytes: 3096
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;



int main(void) {
	double n;
	cin >> n;
	int a, b;
	a = (int)(n / 1.08);
	b = a + 1;

	if ((int)(a*1.08) == n) {
		cout << a << endl;
	}
	else if ((int)(b*1.08)==n) {
		cout << b << endl;
	}
	else {
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<=b && b<=c){
		printf("%d %d %d\n",a,b,c);
	}else if(a<=b && c<=b && a<=c){
		printf("%d %d %d\n",a,c,b);
	}else if(b<=a && a<=c){
		printf("%d %d %d\n",b,a,c);
	}else if(b<=a && c<=a && b<=c){
		printf("%d %d %d\n",b,c,a);
	}else if(c<=a && a<=b){
		printf("%d %d %d\n",c,a,b);
	}else if(c<=a && b<=a && c<=b){
		printf("%d %d %d\n",c,b,a);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int n, a ,b;
	cin >> n >> a >> b;
	ll x[n];

	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	ll ans = 0;
	for (int i = 0; i < n-1; i++) {
		ll tmp = (x[i+1]-x[i])*a;
		if (tmp > b) {
			ans += b;
		} else {
			ans += tmp;
		}
	}

	cout << ans << endl;


}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define long long ll
int main()
{
  int n,i;
  cin>>n;
  string str;
  cin>>str;
  int count=1;
  for(i=1; i<str.length(); i++)
  {
    if(str[i]!=str[i-1])
    count++;
  }
  cout<<count;


}

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

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

using namespace std;

int main() {
	int X, N;

	cin >> X >> N;

	vector<pair<bool, bool>> sa(100, { false,false });
	
	//if (N == 0)cout << X;


	rep(i, N) {
		int x;
		cin >> x;
		
		if (x - X >= 0)
		{
			//xのがでかい
			sa[abs(x - X)].first = true;

		}
		else
		{
			sa[abs(x - X)].second = true;

		}
	}


	rep(i, 100) {

		if (X - i == 0) {
			cout << 0;
			break;
		}
		if (i == 0) {
			if (!sa[0].first) {
				cout << X;
				break;
			}
			continue;
		}
		if (!sa[i].second)
		{
			cout << X - i;
			break;
		}
		if (!sa[i].first) {
			cout << X + i;
			break;
		}
	}

	//cin >> N;

	return 0;
}

Measured memory_bytes: 3608