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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int x, y;
    cin >> x >> y;
    if(x == 0 and y < 0){
        cout << -y + 1 << endl;
        return 0;
    }
    if(y == 0 and x > 0){
        cout << x + 1 << endl;
        return 0;
    }
    if(x >= 0){
        if(y >= 0){
            if(y >= x){
                cout << y - x << endl;
            }else{
                cout << x - y + 2 << endl;
            }
        }else{
            if(-y >= x){
                cout << -y - x + 1 << endl;
            }else{
                cout << x + y + 1 << endl;
            }
        }
    }else{
        if(y <= 0){
            if(y >= x){
                cout << y - x << endl;
            }else{
                cout << x - y + 2 << endl;
            }
        }else{
            if(-y >= x){
                cout << -y - x + 1 << endl;
            }else{
                cout << x + y + 1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
s = input()

if n == 1:
    print("No")
    quit()

if n % 2 == 1:
    print("No")
    quit()

for i in range(int(n / 2)):
    if not s[i] == s[i + int(n / 2)]:
        print("No")
        quit()

print("Yes")


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

int main(){
    int n,m;
    cin >> n >> m;
    int fir = 0,sec = 1000000;
    for(int i = 0;i < n;i++){
        int l,r;
        cin >> l >> r;
        fir = max(fir,l);
        sec = min(sec,r);
    }
    int ans = (sec >= fir) ? (sec - fir + 1) : 0;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;



int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n > 0) {
		ans++;
		n /= k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> E(n);
  vector<int> W(n);
  for(int i;i<n;i++){
    if(s[i] == 'W'){
      if(i == 0) E[i] = 1;
      else E[i] = E[i-1] + 1;
    }else{
      if(i == 0) E[i] = 0;
      else E[i] = E[i-1];
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i] == 'E'){
      if(i == n-1) W[i] = 1;
      else W[i] = W[i+1] + 1;
    }else{
      if(i == n-1) W[i] = 0;
      else W[i] = W[i+1];
    }
  }
  int ans = n;
  rep(i,n){
    ans = min(ans,E[i-1]+W[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
a,b = map(int,input().split())
lol = [int(n) for n in input().split()]
if(b == 0):
    print(a)
else:
    i = 0 
    while(1):
        if((a - i) not in lol):
            print(a-i)
            break
        elif((a + i) not in lol):
            print(a+i)
            break
        else:
            i += 1
            

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (a < 0)
    {

        cout << -a * c + d + b * e << endl;
    }
    else if (a == 0)
    {
        cout << d + b * e << endl;
    }
    else
    {
        cout << (b - a) * e << endl;
    }

    return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    cout<<std::setprecision(10);
    ios::sync_with_stdio(false);
    ll n,ans=0;
    cin>>n;
    Vec p(n);
    Vec ind(n);
    rep(i,n){
        int tmp;
        cin>>tmp;
        tmp--;
        p[i]=tmp;
        ind[tmp]=i;
    }
    set<int> st;
    per(i,n-1){
        int id = ind[i];
        st.insert(id);
        Vi l(2,-1);
        Vi r(2,n);
        auto it = st.find(id);
        rep(j,2){
            if(it==st.begin())break;
            --it;
            l[j] = *it;
        }
        it = st.find(id);
        rep(j,2){
            it++;
            if(it==st.end())break;
            r[j] = *it;
        }
        int l1 = id-l[0];
        int r1 = r[0]-id;
        int l2 = l[0]-l[1];
        int r2 = r[1]-r[0];
        ans += (i+1) * (l1*r2 + l2*r1);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 6528
#include<stdio.h>
#define N 500
static const int INFTY = (1<<21);
int main(){
  int t,i,j,f,q,x,y,sum,minv;
  int A[N][N],d[N],r[N];

  scanf("%d",&t);
  for(i=0;i<t;i++){
    for (j=0;j<t;j++){
      A[i][j]=INFTY;
    }
  }
  for(i=0;i<t;i++){
    scanf("%d %d",&f,&x);
    for (j=0;j<x;j++){
      scanf("%d %d",&q,&y);
      A[f][q]=y; }
  }
  for(i=0;i<t;i++){
    d[i]=INFTY;
    r[i]=0;
  }
  d[0]=0;
  while(1){
    minv=INFTY;
    f=-1;
    for(i=0;i<t;i++){
      if(minv>d[i]&&!r[i]){
	f=i;
	minv=d[i];}
    }
    if(f==-1)
      break;
    r[f]=1;
    for(q=0;q<t;q++){
      if(!r[q]&&A[f][q] != INFTY){
	if(d[q]>d[f]+A[f][q]){
	  d[q]=d[f]+A[f][q];
	}
      }
    }
  }
  for (i=0; i<t; i++){
    printf("%d %d",i,(d[i]==INFTY?-1:d[i]));
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2060
using static System.Console;

public class Hello
{
    public static void Main()
    {
        var l = ReadLine();
        int N = int.Parse(l.Split()[0]);
        int M = int.Parse(l.Split()[1]);
        int[] A = new int[N];
        int?[] pattern = new int?[N + 1];
        pattern[0] = 1;
        pattern[1] = 1;

        const int p = 1000000007;

        for (int i = 0; i < M; i++)
        {
            A[i] = int.Parse(ReadLine());
            pattern[A[i]] = 0;
        }

        for (int i = 2; i < N + 1; i++)
        {
            if (pattern[i] == null) pattern[i] = pattern[i-1] + pattern[i-2];
            pattern[i] %= p;
        }

        WriteLine((int)pattern[N] % p);

    }
}

Measured memory_bytes: 14048
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, k, a[1000000];
vector<int>vec;
int main() {
	int t; cin >> t;
	for (int i = 0; i < t; i++) {
		cin >> n >> k; vec.clear();
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		for (int i = 0; i < n - 1; i++) {
			vec.push_back(a[i + 1] - a[i]);
		}
		sort(vec.begin(), vec.end());
		int sum = 0, cnt = 1;
		for (int i = vec.size() - 1; i >= 0; i--) {
			if (cnt >= k)sum += vec[i];
			cnt++;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1992
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
using namespace std;
const int Max = 1e5;

long long n, k, sum = 0;
struct Num{
	long long x, y;
}a[Max + 5];

bool cmp(Num p, Num q){
	return p.x < q.x;
}

int main()
{
	scanf ("%lld %lld", &n, &k);
	for (int i = 1; i <= n; i++)	scanf ("%lld %lld", &a[i].x, &a[i].y);
	sort(a + 1, a + n + 1, cmp);
	for (int i = 1; i <= n; i++){
		sum += a[i].y;
		if (sum < k)	continue;
		else if (sum >= k){
			printf ("%lld\n", a[i].x);
			return 0;
		}
	}
}

Measured memory_bytes: 1664
N, K = map(int, input().split())
mod = 10**9+7
gcd_l = [0]*K

for i in range(K, 0, -1):
    n = pow((K//i), N, mod)
    for x in range(i, K+1, i):
        n -= gcd_l[K-x]
    gcd_l[K-i] = n%mod

res = 0
for i in range(K):
    res += (gcd_l[i] * (K-i))%mod

print(res%mod)

Measured memory_bytes: 11200
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
cnt=[0]*(N+1)
for i in range(N):
    cnt[A[i]]+=1
res=0
for i in cnt:
    res+=i*(i-1)//2
for i in range(N):
    print(res-(cnt[A[i]]-1))

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

int main(){
  int i,j,t;
  scanf("%d",&i);
  int x = i;
  
  for(j=1;j<=i;j++){
    if(j%3==0){
      printf(" %d",j);
    }else{
      t = j;
      while(1){
        if(t<=0){
	  break;
	}
	if(t%10==3){
          printf(" %d",j);
          break;
	}else{
	  t /=10;
	}
      }
    } 
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2032
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
#define ll long long
#include<fstream>
int main()
{
	double n;cin>>n;
	double d;cin>>d;ll ans=0;
	for(ll i=0;i<n;i++)
	{
		double a;cin>>a;
		double b;cin>>b;
		if(sqrt(a*a+b*b)<=d)
		ans++;
	}
	cout<<ans<<endl;
	return 0;
	
	
}
		

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

	bool A = false;
	bool C = false;
	if (S[0] != 'A')
	{
		cout << "WA" << endl;
		return 0;
	}
	FOR(i, S.length() - 1, 2)
	{
		if (S[i] == 'C')
		{
			if (!C)
			{
				C = true;
			}
			else
			{
				cout << "WA" << endl;
				return 0;
			}
		}
	}
	if (!C)
	{
		cout << "WA" << endl;
		return 0;
	}
	FOR(i, S.length(), 1)
	{
		if (S[i] == 'C')continue;
		if (S[i] - 'a' < 0 || S[i] - 'a'>26)
		{
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(2); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

lint pow_mod(lint base,lint expo) { 
   lint ret = 1;
   for(;expo;) { 
      if(expo&1)  ret = (ret*base)%MOD; 

      expo = (expo>>1);
      base = (base*base)%MOD;
   }
   return ret;
}

/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
  int r;
  cin >> r;

  cout << 3.141592653 * 2.00 * (float)r << endl;
}

int main(){   
  
   //  freopen("input.txt", "r", stdin);
   //  freopen("output.txt", "w", stdout);

 solve();

 return 0;
}


Measured memory_bytes: 3800
N = int(input())

def solve(N):
    result = ""
    k = 1
    while 1:
        c = N % 2
        result = "01"[c] + result
        N = (N - k * c) // 2
        k = -k
        if N == 0:
            break
    return result

print(solve(N))


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int n, k, h[200001];
    long long count = 0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", &h[i]);
    sort(h, h + n);
    for (int i = n - 1 - k; i >= 0; i--)
    {
        count += h[i];
    }
    printf("%lld", count);
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main
{
    public static void main(String [] args)
    {
        Scanner key = new Scanner(System.in);
        int n = key.nextInt();
        int m = key.nextInt();
        int arr[] = new int[n];
        int sum =0;
        for(int i = 0; i<n;i++)
        {
            arr[i] = key.nextInt();
            sum = sum + arr[i];
        }
        double mar = (sum/(m*4.0));
        int count = 0;
        for(int i = 0; i<n; i++)
        {
            if(arr[i] >= mar)
            {
                count ++;
            }
        }
        if(count >= m)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}

//4 1 
//5 4 2 1 
//total vote count = 12 , min popular item = 12/8 = 3/2 = 1.

Measured memory_bytes: 23508
def f(a, m):
    return a**2%m

def main():
    N, X, M = map( int, input().split())
    A = [X]
    T = [False]*M
    T[X] = True
    now = X
    while True:
        now = f(now, M)
        if T[now]:
            break
        T[now] = True
        A.append(now)
    R = len(A)
    for i in range(R-1,-1,-1):
        if now == A[i]:
            L = i
            break
    # L<= < Rでループ、R-L
    if N <= L:
        print( sum(A[:N]))
        return
    ans = sum(A[:L])
    loopsum = sum(A[L:])
    loopsize = R-L
    N -= L
    ans += N//loopsize*loopsum
    N -= N//loopsize*loopsize
    now = A[L]
    while N > 0:
        ans += now
        now = f(now,M)
        N -= 1
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 12120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll k;
    cin >> n >> k;

    ll a_ary[n];
    ll f_ary[n];
    rep(i,n) cin >> a_ary[i];
    rep(i,n) cin >> f_ary[i];

    sort(a_ary, a_ary+n, greater<ll>());
    sort(f_ary, f_ary+n);
    ll ng = 1e12+10;
    ll ok = -1;

    while(abs(ng-ok) > 1)
    {
        ll mid = (ng+ok)/2;
        ll tmp_k = 0;
        rep(i,n)
        {
            ll tmp_a = mid/f_ary[i];
            tmp_k += max((ll)0, a_ary[i] - tmp_a);
        }
        if (tmp_k <= k)
        {
            ng = mid;
        }
        else
        {
            ok = mid;
        }
    }
    
    cout << ng << endl;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>

#define MAX 300
int main(void)
{
  int H[MAX],W[MAX];
  int i,j,k,l;

  for(i=0;i<MAX;i++)
    {
      scanf("%d %d",&H[i],&W[i]);
      if((H[i]==0)&&(W[i]==0))
	break;
    }
  for(l=0;l<i;l++)
    {
      for(k=0;k<H[l];k++)
	{
	  for(j=0;j<W[l];j++)
	    {
	      printf("#");
	    }
	  printf("\n");
	}
      printf("\n");
    }
}



Measured memory_bytes: 2048
//D
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){

    int H,W;
    cin >> H >> W;

    int a[500][500];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> a[i][j];
        }
    }

    int N = 0;
    vector<int> b;
    vector<int> c;
    vector<int> d;
    vector<int> e;
    for(int i=0; i<H-1; i++){
        for(int j=0; j<W; j++){
            if(a[i][j] % 2 == 1){
                N++;
                b.push_back(i);
                c.push_back(j);
                d.push_back(i+1);
                e.push_back(j);
                a[i+1][j]++;
            }
        }
    }
    for(int j=0; j<W-1; j++){
        if(a[H-1][j] % 2 == 1){
            N++;
            b.push_back(H-1);
            c.push_back(j);
            d.push_back(H-1);
            e.push_back(j+1);
            a[H-1][j+1]++;
        }
    }

    cout << N << endl;
    for(int i=0; i<N; i++){
        cout << b[i]+1 << " " << c[i]+1 << " " << d[i]+1 << " " << e[i]+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 5220
package main

import (
	"fmt"
	"sort"
	"strings"
)

type Restaurant struct {
	ID    int
	Name  string
	Point int
}

type Restaurants []Restaurant

func (r Restaurants) Len() int {
	return len(r)
}

func (r Restaurants) Less(i, j int) bool {
	if r[i].Name == r[j].Name {
		return r[i].Point > r[j].Point
	}
	return r[i].Name < r[j].Name
}

func (r Restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	var n int
	fmt.Scanln(&n)

	r := make([]Restaurant, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%s %d", &r[i].Name, &r[i].Point)
		r[i].ID = i + 1
	}

	fmt.Println(output(logic(r)))
}

func logic(r []Restaurant) []int {
	sort.Sort(Restaurants(r))
	result := []int{}

	for _, i := range r {
		result = append(result, i.ID)
	}
	return result
}

func output(nums []int) string {
	return strings.Trim(strings.Join(strings.Fields(fmt.Sprint(nums)), "\n"), "[]")
}


Measured memory_bytes: 640
main(){
 int n,m,i=0;
		scanf("%d",&n);
		for(m=1;m<10;m++)
		{
			if(n%m==0&n/m<10)
		i++;	
			else {
			}
	}
		if(i>0)printf("Yes");
		else printf("No");
return 0;
}


Measured memory_bytes: 128
tbl = [[0 for i in range(13)] for j in range(4)]
mark = ["S", "H", "C", "D"]
n = int(input())
for i in range(n):
    m,n = input().split()
    n = int(n)
    tbl[mark.index(m)][n-1] = n
for i, row in enumerate(tbl):
    for j, elem in enumerate(row):
        if elem == 0:
            print(mark[i], j + 1)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
	string s;
    cin >> s;
    n = s.size();
    int answer = n;
    for (int i = 1; i < n; i++)
    if (s[i] != s[i - 1])
        answer = min(answer, max(i, n - i));
    cout << answer;
}

Measured memory_bytes: 512
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define rint register int
#define rep(i,l,r) for(rint i=l;i<=r;i++)
#define per(i,l,r) for(rint i=l;i>=r;i--)
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back 
#define fir first
#define sec second
template<typename T1,typename T2>void ckmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2>void ckmax(T1 &a,T2 b){if(a<b)a=b;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
int read(){
  int x=0,f=0;
  char ch=getchar();
  while(!isdigit(ch))f|=ch=='-',ch=getchar();
  while(isdigit(ch))x=10*x+ch-'0',ch=getchar();
  return f?-x:x;
}
int mod,x=7;
int main(){
  mod=read();
  if(7%mod==0){
    puts("1");return 0;
  }
  int x=7;
  for(int i=2;i<=mod;i++){
    x=(10*x+7)%mod;
    if(x==0){
      printf("%d\n",i);
      exit(0);
    } 
  }
  puts("-1");
  return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<(int)a;i++)
#define zero(x) memset(x, 0, sizeof x)
typedef long long ll;
int const MOD = 1e9+7;
int const inf = 1<<29;

int main() {
 
  int N; cin >> N;
  int A[N], B[N];
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
 
  int L = -inf;
  int pat[N]; zero(pat);
  rep(i, N) {
    if(L < A[i]) {
      pat[i] = 1;
      L = A[i];
    }
  }
 
  int R = -inf;
  rep(i, N) {
    if(R < B[N-1-i]) {
      if(pat[N-1-i] && A[N-1-i] != B[N-1-i]) { cout << 0 << endl; exit(0); }
      pat[N-1-i] = 1;
      R = B[N-1-i];
    } else {
      if(pat[N-1-i] && A[N-1-i] > B[N-1-i]) { cout << 0 << endl; exit(0); }      
    }
  }
 
  ll ans = 1;
  rep(i, N) {
    if(!pat[i]) {
      pat[i] = min(A[i], B[i]);
    }
    ans *= pat[i];
    ans %= MOD;
  }
 
  cout << ans << endl;
  
  return 0;
}

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

signed main()
{
	int n;
	cin >> n;
	if (n == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	map<int, int> factor;
	for (int i = 2; i <= n; i++)
	{
		for (int j = i, k = 2; j != 1; k++)
		{
			while (j % k == 0)
			{
				factor[k]++;
				j /= k;
			}
		}
	}
	vector<pair<int, int>> v;
	for (auto p : factor)
	{
		v.emplace_back(p);
	}
	int dp[v.size() + 1][76]{};
	dp[0][1] = 1;
	for (int i = 0; i < v.size(); i++)
	{
		for (int j = 0; j <= 75; j++)
		{
			for (int k = 0; k <= v[i].second; k++)
			{
				if (j * (k + 1) <= 75)
				{
					dp[i + 1][j * (k + 1)] += dp[i][j];
				}
			}
		}
	}
	cout << dp[v.size()][75] << endl;
	return 0;
}

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

int main(void)
{
    int i;
    int height[31], length[31];
    int w,n;
    int a,b;

    for (i = 1; i < 31; i++){
        height[i] = i;
        length[i] = i;
    }
    scanf("%d", &w);
    scanf("%d", &n);

    for (i = 1; i <= n; i++){
        scanf("%d,%d", &a, &b);
        int temp = height[a];
        height[a] = height[b];
        height[b] = temp;
    }

    for (i = 1; i <= w; i++){
        printf("%d\n", height[i]);
    }
    return (0);

}


Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#define ll long long
#define for(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
    string S;
    cin >> S;
    if(S.size()==2){
        cout << S << endl;;
    }
    else{
        cout << S[2] << S[1] << S[0] << endl;
    }
    return 0;
}


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

const int INF = 1e9;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int l = x[0], r = x[0];
    rep(i,n) {
        l = min(l, x[i]);
        r = max(r, x[i]);
    }
    int ans = INF;
    for (int i = l; i <= r; i++) {
        int cost = 0;
        rep(j, n) cost += (x[j] - i) * (x[j] - i);
        ans = min(ans, cost); 
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const int maxn=1e5+10;

int main()
{
    int n,m;
    long long monster[maxn],hero[maxn],sum=0;
    scanf("%d",&n);
    m=n+1;
    for(int i=1;i<=m;i++) scanf("%lld",&monster[i]);
    for(int i=1;i<=n;i++) scanf("%lld",&hero[i]);
    for(int i=1;i<=n;i++)
    {
        if(hero[i]>=(monster[i]+monster[i+1]))
        {
            sum+=monster[i]+monster[i+1];
            monster[i+1]=0;
        }
        else
        {
            sum+=hero[i];
            monster[i+1]-=(hero[i]>monster[i]?hero[i]-monster[i]:0);
        }
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

import javax.script.ScriptException;

class Main {
	
	public void calculate(List<String> strangeList){
		List<Double> tmpList = new ArrayList<Double>();
		for(String element : strangeList){
			if(!element.equals("+") && !element.equalsIgnoreCase("-") && !element.equalsIgnoreCase("*") && !element.equalsIgnoreCase("/")){
				tmpList.add(Double.parseDouble(element));
			} else {
				double back		= tmpList.remove(tmpList.size() - 1);
				double front	= tmpList.remove(tmpList.size() - 1);
				double subResult = 0.0;
				switch(element){
				case "+":
					subResult = front + back;
					tmpList.add(subResult);
					break;
				case "-":
					subResult = front - back;
					tmpList.add(subResult);
					break;
				case "*":
					subResult = front * back;
					tmpList.add(subResult);
					break;
				case "/":
					subResult = front / back;
					tmpList.add(subResult);
					break;
				default:
					System.out.println("Something was wrong!");
				}
			}
		}
		if(tmpList.size() == 1){
			System.out.printf("%.6f\n",tmpList.get(0));
		} else {
			System.out.println("There is something wrong!");
		}

	}
	public static void main(String[] args) throws ScriptException{
		Main sme = new Main();
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			String[] strs = input.nextLine().split(" ");
			List<String> strangeList = new ArrayList<String>(Arrays.asList(strs));
			sme.calculate(strangeList);
		}
		input.close();
	}
}

Measured memory_bytes: 25956
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int sum = 0;
		int time = 0;
		
		while(sum<x) {
			time += 1;
			sum += time;
		}
		
		System.out.println(time);
	}

}


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

int main(){
    string s;
    cin >> s;

    stack<char> st;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'S'){
            st.push(s[i]);
        }else{
            if(st.empty() || st.top() == 'T'){
                st.push(s[i]);
            }else{
                st.pop();
            }
        }
    }

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

    return 0;
}







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

int main(void){
  string a, b;
  cin >> a >> b;
  int n = stoi(a+b);
  for(int i=1;i*i<=n;i++){
    if(i*i == n){
       cout << "Yes" << endl;
        return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main(void)
{
	int h=0,l=0;
	scanf("%d%d",&h,&l);
	if(l*2>=h)printf("0");
	else printf("%d",h-l*2);
	return 0;	
}
 

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, interger1, interger2;
	double floatnum;

	scanf("%d%d", &a, &b);
	interger1 = a/b;
	interger2 = a%b;
  floatnum = (double)a/(double)b;

  printf("%d %d %f\n", interger1, interger2, floatnum);

  return 0;
}

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

typedef long long LL;

const int N=200000,mod=998244353,inv2=499122177;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n;
struct side{
  int y,next;
}e[N*2+9];
int lin[N+9],cs;

void Ins(int x,int y){e[++cs].y=y;e[cs].next=lin[x];lin[x]=cs;}
void Ins2(int x,int y){Ins(x,y);Ins(y,x);}

void into(){
  scanf("%d",&n);
  for (int i=1;i<n;++i){
	int x,y;
	scanf("%d%d",&x,&y);
	Ins2(x,y);
  }
}

int dis[N+9],pre[N+9];
queue<int>q;

int Bfs_dis(int st){
  int res=st;
  for (int i=1;i<=n;++i) dis[i]=0;
  dis[st]=1;pre[st]=0;q.push(st);
  for (;!q.empty();){
	int t=q.front();q.pop();
	if (dis[t]>dis[res]) res=t;
	for (int i=lin[t];i;i=e[i].next)
	  if (!dis[e[i].y]){
		dis[e[i].y]=dis[t]+1;
		pre[e[i].y]=t;
		q.push(e[i].y);
	  }
  }
  return res;
}

int dia,d[N+9],cd;

void Get_dia(){
  int k=Bfs_dis(Bfs_dis(1));
  dia=dis[k]-1;
  for (;k;k=pre[k]) d[++cd]=k;
}

int dp[N+9][3][3],tmp[3][3];

void Dfs_dp(int k,int fa,int dep){
  dep==dia>>1?dp[k][1][1]=1:dp[k][0][0]=1;
  for (int i=lin[k];i;i=e[i].next){
	int y=e[i].y;
	if (y==fa) continue;
	Dfs_dp(e[i].y,k,dep+1);
	for (int i=0;i<3;++i)
	  for (int j=0;j<3;++j)
		for (int u=0;u<3;++u)
		  for (int v=0;v<3;++v)
			for (int t=0;t<3;++t){
			  int p=min(2,i+u*(t==1)),q=min(2,j+v*(t==2));
			  sadd(tmp[p][q],mul(dp[k][i][j],dp[y][u][v]));
			}
	for (int i=0;i<3;++i)
	  for (int j=0;j<3;++j) dp[k][i][j]=tmp[i][j],tmp[i][j]=0;
  }
}

int ans;

void Get_dp(){
  if (cd&1){
	int k=d[cd+1>>1];
	Dfs_dp(k,0,0);
	ans=mul(dp[k][1][1],inv2);
  }else{
	int x=d[cd>>1],y=d[cd+2>>1];
	Dfs_dp(x,y,0);Dfs_dp(y,x,0);
	ans=mul(add(dp[x][1][0],add(dp[x][1][1],dp[x][1][2])),add(dp[y][0][1],add(dp[y][1][1],dp[y][2][1])));
  }
}

void work(){
  Get_dia();
  Get_dp();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 22896
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main(){
    int h, w; cin >> h >> w;
    int array[20][20];
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            array[i][j] = INF;
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> array[i][j];
        }
    }

    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                if(array[i][j] > array[i][k] + array[k][j])
                    array[i][j] = array[i][k] + array[k][j];
            }
        }
    }
    

    int ans = 0;
    for(int i = 0; i < w*h; i++){
        int input;
        cin >> input;
        if(input == -1) input = 1;
        ans += array[input][1];
    }

    cout << ans << endl;    

    return 0;
}


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

					#define pb push_back
					#define cend(s) return cout << s, 0;
					using namespace std;
					typedef long long ll;

					int main()
					{
						int x;
						cin >> x;
						if(x >= 400 && x <= 599)
							cend(8);
						if(x >= 600 && x <= 799)
							cend(7);
						if(x >= 800 && x <= 999)
							cend(6);
						if(x >= 1000 && x <= 1199)
							cend(5);
						if(x >= 1200 && x <= 1399)
							cend(4);
						if(x >= 1400 && x <= 1599)
							cend(3);
						if(x >= 1600 && x <= 1799)
							cend(2);		
						if(x >= 1800 && x <= 1999)
							cend(1);				
					}

Measured memory_bytes: 3628
# B
# Trick or Treat

N, K = map(int, input().split())
A = []
S = list(range(1,N+1))
for i in range(K):
    tmp_d = int(input())
    tmp_A = list(map(int, input().split()))
    A.extend(tmp_A)

unique_A = set(A)
for i in unique_A:
    S.remove(i)

print(len(S))

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
int main()
  {
  char str[1000] ={};
  cin >> str;
  char sta[1000]={};
  int n= strlen(str);
  int j = 0;
  int c=0;
  for(int i = n-1; i >= 0; i--)
    {
        if(str[i]!=str[j])
        {
             c++;
             str[i]=str[j];
        }
        j++;
    }
        cout<<c<<endl;
  return 0;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<(n);++i)
#define itn int
#define ocut cout
#define ouct cout
#define outc cout

int main(){
    int a,h;
    cin >> h >> a;
    int y=0;
    while(h>0){
        h=h-a;
        y++;
    }
    cout << y;
}



Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int n, m[5]={};
    long long ans=0;
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        char s[16];
        scanf(" %s", s);
        switch(s[0]) {
            case 'M': m[0]++; break;
            case 'A': m[1]++; break;
            case 'R': m[2]++; break;
            case 'C': m[3]++; break;
            case 'H': m[4]++; break;
        }
    }
    for (int i=0; i<5; i++)
        for (int j=i+1; j<5; j++)
            for (int k=j+1; k<5; k++)
                ans += (long long)m[i]*m[j]*m[k];
    printf("%lld\n", ans);
}

Measured memory_bytes: 128
/*
AizuOnline A1125
Title Get Many Persimmon Trees
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int W,H,S,T;
int vert_memo[100][100];
int ban[100][100];
int N;
int count_vert(int x,int y,int hei)
{
        int i;
        static int ret;

        if(y==1)
        {
                ret=0;
                for(i=y;i<y+hei;i++)
                        ret += (ban[x][i]=='*')?1:0;
        }
        else
        {
                ret = vert_memo[x][y-1];
                ret -= (ban[x][y-1]=='*')?1:0;
                ret += (ban[x][y+hei-1]=='*')?1:0;
        }
#ifdef DEBUG
                                printf(":XYC=%d %d %d\n",x,y,ret);
#endif

        vert_memo[x][y]=ret;
        return(ret);
}
int count(int x,int y,int wid,int hei)
{
        int i,j;
        static int ret;

        if(x==1)
        {
                ret=0;
                for(i=x;i<x+wid;i++)
                        ret += count_vert(i,y,hei);
        }
        else
        {
                ret -= count_vert(x-1,y,hei);
                ret += count_vert(x+wid-1,y,hei);
        }
        return(ret);
}
//
void clear()
{
        int i,j;

        for(i=1;i<=100;i++)
                for(j=1;j<=100;j++)
                {
                        ban[i][j]=' ';
                        vert_memo[i][j]=0;
                }
}
print_ban()
{
        int i,j;

        for(i=1;i<=H;i++)
        {
                for(j=1;j<=W;j++)
                        printf("%c",ban[j][i]);
                printf("\n");
        }
}
main()
{
        int i,j,x,y,xmax,ymax,maxper,ret;

        while(EOF!=scanf("%d",&N) && N)
        {
                clear();
                scanf("%d %d",&W,&H);
                for(i=0;i<N;i++)
                {
                        scanf("%d %d",&x,&y);
                        ban[x][y]='*';
                }
                scanf("%d %d",&S,&T);
        
                maxper=-1;
#ifdef DEBUG
                print_ban();
                printf("NWHST=%d %d %d %d %d\n",N,W,H,S,T);
#endif

                for(j=1;j<=H-T+1;j++)
                        for(i=1;i<=W-S+1;i++)
                        {
                                ret=count(i,j,S,T);
#ifdef DEBUG
                                printf("XYC=%d %d %d\n",i,j,ret);
#endif

                                if(ret>maxper)
                                {
                                        maxper=ret;
                                        xmax=i;
                                        ymax=j;
                                }
                        }
#ifdef DEBUG2
                printf("XY= %d,%d KOSUU=",xmax,ymax);
#endif
                printf("%d\n",maxper);
        }
return(0);
}

Measured memory_bytes: 672
#include <stdio.h>

int main()
{
  int N,i,j,v,k;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  for(i=0;i<N;i++)
    {     
      v = A[i];
      j = i - 1;
      while( j >= 0 && A[j] > v)
	{
	  A[j+1] = A[j];
	  j--;
	}
      A[j+1] = v;	
    
      for(k=0;k<N;k++)
	{
	  if(k>0)printf(" ");
	  printf("%d",A[k]);
	}
      printf("\n");
    }
  return 0;

}



Measured memory_bytes: 2048
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
h_list = _li()

ans = 0
temp = 0
current = h_list[0]
for h in h_list[1:]:
    if h > current:
        ans = max(ans, temp)
        temp = 0
    else:
        temp += 1
    current = h

ans = max(ans, temp)
print(ans)


Measured memory_bytes: 14168
#include <iostream>

 using namespace std;
 typedef long long ll;

 int main(void){
 ll H,W;
 cin >> H >> W;

 if(H == 1 || W == 1){
 cout << 1 << endl;
 } else {
 cout << (H * W + 1) / 2 << endl;
 }

 return 0;
 }


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef long long i64;
//#define rep(i,n) for(int i=0;i<n;++i)
#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(int i=0;i<n;++i)
#define _rep2(i,n) for(int i=0;i<n;++i)
#define _rep3(i,a,b) for(int i=a;i<b;++i)
#define _rep4(i,a,b,c) for(int i=a;i<b;i+=c)
#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))

int main(){
  lint n,ans=0,tmp=0; cin>>n;
  vector<lint>a(n); rep(n)cin>>a[i];
  rep(i,n-1){//rep(i,0,n)
    if(a[i]<a[i+1])tmp=0;
    else ++tmp;
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        if (s == "zyxwvutsrqponmlkjihgfedcba")
        {
            Console.WriteLine(-1);
            return;
        }

        if (s.Length < 26)
        {
            bool[] exist = new bool[26];
            foreach (var c in s)
            {
                exist[c - 'a'] = true;
            }

            string answer = s;
            for (int i = 0; i < 26; i++)
            {
                if (!exist[i])
                {
                    answer += ((char)('a' + i)).ToString();
                    break;
                }
            }
            Console.WriteLine(answer);
            return;
        }
        else
        {
            List<char> keep = new List<char>();
            char[] reverse = s.Reverse().ToArray();

            for (int i = 0; i < reverse.Length; i++)
            {
                if (i == 0)
                {
                    keep.Add(reverse[i]);
                    continue;
                }
                if (reverse[i] < reverse[i - 1])
                {
                    char append = keep.Where(c => c > reverse[i]).OrderBy(c => c).First();
                    string before = s.Substring(0, 26 - i - 1);
                    string answer = before + append.ToString();
                    Console.WriteLine(answer);
                    return;
                }
                keep.Add(reverse[i]);
            }
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for(int i = 0; i < n; i++)
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s;
    vector<int> d;
    cin>>n;
    REP(i, n){
        cin>>s;
        d.push_back(s);
    }
    int ans = 0, arc, abc, abct = 0, cnt = 0;
    sort(ALL(d));
    for(int k = d[0]; k < d[n-1]+1; k++){
        abc = abct;
        for(int j = 0+cnt; j < d.size(); j++){
            if(k > d[j]){
                abc += 1;
                cnt += 1;
            }
            if(k <= d[j]){
                break;
            }
        }
        arc = d.size()-abc;
//        cout<<k<<" "<<arc<<" "<<abc<<endl;
        if(arc == abc){
            ans += 1;
        }
        if(arc < abc){
            break;
        }
        abct = abc;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b, c, k;
int main()
{
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	if (k % 2)
	{
		printf("%lld\n", b-a);
	}
	else
	{
		printf("%lld\n", a-b);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e9
#define PI (acos(-1))
int main() {
    double a,b,x;
    cin>>a>>b>>x;
    double ans;
    ans=atan(a*b*b/(x*2))*(180.0/PI);
    if(b*cos(ans*PI/180)>a*sin(ans*PI/180))ans=atan(2.0*(a*a*b-x)/(a*a*a))*(180.0/PI);
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int mypow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x;
		}
		x = x * x;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
int mystoi(string x) {
	int res = 0;
	rep(i, x.size()) {
		res = res * 10 + x[i] - '0';
	}
	return res;
}
/*--------Library Zone!--------*/

int s[] = { 0,1,2,3,4 };
int a[10];
signed main() {
	rep(i, 5)cin >> a[i];
	int ans = inf;
	do {
		int now = 0;
		rep(i, 4) {
			now += a[s[i]];
			now = (now - 1) / 10 * 10 + 10;
		}
		now += a[s[4]];
		ans = min(ans, now);
	} while (next_permutation(s, s + 5));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int get() {
    int x = 0; char s = getchar();
    while (s < '0' || s > '9') s = getchar();
    while (s >= '0' && s <= '9') x = (x << 3) + (x << 1) + (s ^ 48), s = getchar();
    return x;
}

const int M = 2001, mo = 1e9 + 7;
int n, k, a[M], ans, sum;

int main() {
    n = get(), k = get();
    for (int i = 1; i <= n; ++i) {
        a[i] = get();
        for (int j = 1; j < i; ++j)
            if(a[j] > a[i]) ++ans;
    }
    ans = 1ll * ans * k % mo;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if(a[i] > a[j]) ++sum;
    k = 1ll * k * (k - 1) / 2 % mo;
    ans = (ans + 1ll * sum * k % mo) % mo;
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] h = new Integer[n];
        for (int i = 0; i < n; i++) h[i] = Integer.parseInt(sc.next());
        Boolean[] f = new Boolean[n];
        Arrays.fill(f, true);
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next()) - 1;
            int b = Integer.parseInt(sc.next()) - 1;
            if (h[a] <= h[b]) {
                f[a] = false;
            }
            if (h[b] <= h[a]) {
                f[b] = false;
            }
        }
        int c = 0;
        for (boolean i : f){
            if (i) c++;
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 61892