akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

typedef struct tagNode Node;
struct tagNode {
    void *value;
    Node *next;
};
typedef struct tagEdge Edge;
struct tagEdge {
    int to;
    int distance;
};

void list_init(Node *list)
{
    list->next = NULL;
}

void list_clear(Node *list)
{
    Node *node = list->next;
    while (node != NULL) {
        Node *node2 = node;
        node = node->next;
        free(node2->value);
        free(node2);
    }
    list->next = NULL;
}

void list_append(Node *list, void *value, size_t size)
{
    Node *node = (Node *)malloc(sizeof(Node));
    node->value = (void *)malloc(sizeof(size));
    memcpy(node->value, value, size);
    node->next = list->next;
    list->next = node;
}

void dfs(int *ans, Node *vertices, int pos, long long distance)
{
    Node *node;
    ans[pos] = distance % 2;
    for (node = vertices[pos].next; node != NULL; node = node->next) {
        Edge *edge = (Edge *)node->value;
        if (ans[edge->to] == -1) {
            dfs(ans, vertices, edge->to, distance + edge->distance);
        }
    }
}

int main(void)
{
    int n = 0;
    int i = 0;
    Node *vertices = NULL;
    int *ans = NULL;

    scanf("%d", &n);

    vertices = (Node *)malloc(n * sizeof(Node));
    for (i = 0; i < n; ++i) {
        list_init(&vertices[i]);
    }
    for (i = 0; i < n - 1; ++i) {
        Edge edge;
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        --u;
        --v;
        edge.distance = w;
        edge.to = v;
        list_append(&vertices[u], &edge, sizeof(edge));
        edge.to = u;
        list_append(&vertices[v], &edge, sizeof(edge));
    }

    ans = (int *)malloc(n * sizeof(int));
    for (i = 0; i < n; ++i) {
        ans[i] = -1;
    }

    dfs(ans, vertices, 0, 0);
    for (i = 0; i < n; ++i) {
        printf("%d\n", ans[i]);
    }

    for (i = 0; i < n; ++i) {
        list_clear(&vertices[i]);
    }
    free(ans);
    free(vertices);

    return 0;
}


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

int main(){
string s,a,b;
cin >> s;
int m = 0,num = s.length()/2;
int p = s.length();
int count = 0;
  
for(int i = 0;i < num;i++){
  
	if(s.at(i) == s.at(p-1-i)){
		count++;
	}
  m++;
}

cout << m- count << endl;
}

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

using namespace std;

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

    if (A >= 1 && A <= 9 && B >= 1 && B <= 9) {
        cout << A * B << endl;
        return 0;
    } else {
        cout << -1 << endl;
        return 0;
    }
}

Measured memory_bytes: 3588
#include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<iostream>
    using namespace std;
    int s[100005];
    int cmp(int x,int y)
    {
        return x>y;
    }
    int main(){
        int n;
        while(~scanf("%d",&n)){
            int i;
            for(i=0;i<n;i++)
                scanf("%d",&s[i]);
            sort(s,s+n,cmp);
            int x=0,y=0;
            for(i=1;i<n;i++){
                if(s[i]==s[i-1]){
                    if(!x&&!y){
                        x=s[i];
                    }
                    else if(x&&!y){
                        y=s[i];
                    }
                    i++;
                }
                if(x&&y)
                    break;
            }
            if(n==6) printf("2\n");
            else if(i==n) printf("0\n");
            else printf("%lld\n",(long long)x*y);
        }
    return 0;}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);







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

    string S, T;
    cin >> S >> T;
    if((S.size() == T.size()-1) && (T.substr(0, S.size())== S)){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    

    return 0;
 
 
}
 
  




Measured memory_bytes: 3644
import scala.collection.mutable._
object Main extends App {
  val N = Scanner.nextInt // |V|
  val M = Scanner.nextInt // |E|
  val G = Array.tabulate(N)(from => (from, ArrayBuffer.empty[(Int, Long)])) // [(from, [(to, weight)])]
  val V = Array.fill(N)(Long.MinValue / 2L); V(0) = 0L
  (0 until M).foreach(i => G(Scanner.nextInt - 1)._2 += ((Scanner.nextInt - 1, Scanner.nextLong)))
  for {
    _ <- 0 until N
    n <- G // (from, [(to, weight)])
    e <- n._2 // (to, weight)
  } {
    if (V(e._1) < V(n._1) + e._2) V(e._1) = V(n._1) + e._2
  }
  for {
    _ <- 0 until N
    n <- G // (from, [(to, weight)])
    e <- n._2 // (to, weight)
  } {
    if (V(e._1) < V(n._1) + e._2) {
      V(e._1) = V(n._1) + e._2
      if (e._1 == V.size - 1) {
        println("inf")
        sys.exit
      }
    }
  }
  println(V.last)
}

object Scanner {
  private val buf = new Array[Byte](1024)
  private var ptr = 0
  private var len = 0

  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte: Boolean = if (ptr >= len) {
      ptr = 0
      len = System.in.read(buf)
      len > 0
    } else {
      true
    }
  @inline private def hasNext: Boolean = {
    while (hasNextByte && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte
  }
  @inline private def readByte: Byte = {
    if (hasNextByte) {
      val res = buf(ptr)
      ptr += 1
      res
    } else {
      -1
    }
  }

  def next: String = {
    if(!hasNext) ???
    val sb = new StringBuilder
    var b = readByte
    while (isPrintableChar(b)) {
      sb.append(b.toChar)
      b = readByte
    }
    sb.toString
  }
  def nextInt: Int = {
    val n = nextLong
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong: Long = {
    if(!hasNext) ???
    var minus = false
    var b = readByte
    if (b == '-') {
      minus = true
      b = readByte
    }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') go(readByte, n * 10 + b - '0')
      else if (minus) -n
      else n
    go(b)
  }
  def nextDouble: Double = next.toDouble
}

Measured memory_bytes: 36376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

template <class T>
bool contain(const string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int cnt = 0;
    int ans = n;
    rep(i,n-1){
        ++cnt;
        if(a[i+1] > 2*a[i]){
            ans -= cnt;
            cnt = 0;
        }
        a[i + 1] += a[i];
    }
    cout << ans << "\n";
    return 0;
}

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

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

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define LL1D vector<LL>
#define LL2D vector<vector<LL>>
using namespace std;

void solve(long long N, long long P, std::vector<long long> A){
    LL2D tab(N+1, LL1D(2, 0));
    tab[0][0] = 1;
    for(int i=0; i<N; i++){
        if(A[i]%2==0){
            tab[i+1][0] = 2*tab[i][0];
            tab[i+1][1] = 2*tab[i][1];
        }else{
            tab[i+1][0] = tab[i][0]+tab[i][1];
            tab[i+1][1] = tab[i][0]+tab[i][1];
        }
    }
    cout << tab[N][P] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long P;
    scanf("%lld",&P);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, P, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A = sorted(A, reverse=True)
    return sum(A[i//2] for i in range(1, N))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main(){
  int N;
  cin >> N;
  vector< vector<int> > v(N+1);
  int a,b;
  vector< pair<int,int> > vp;
  for(int i=0;i<N-1;i++){
    cin >> a >> b;
    v.at(a).push_back(b);
    v.at(b).push_back(a);
    vp.push_back(make_pair(a,b));
  }
  queue<int> que;
  vector<int> c(N+1,-1);
  que.push(1);
  c.at(1)=0;
  int K=0;
  map< pair<int,int>, int> m;
  while(!que.empty()){
    a=que.front();
    que.pop();
    if(K<v.at(a).size()){
      K=v.at(a).size();
    }
    int color=1;
    for(auto b:v.at(a)){
      if(c.at(b)!=-1){
        continue;
      }
      if(color==c.at(a)){
        color++;
      }
      c.at(b)=color;
      m[make_pair(a,b)]=color;
      m[make_pair(b,a)]=color;
      color++;
      que.push(b);
    }
  }
  cout << K << endl;
  for(auto p:vp){
    cout << m.at(p) << endl;
  }
  return 0;
}


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

int main()
{
  int n,ans;
  cin>>n;
  ans=0;
  vector<int> v(n);
  vector<int> c(n);
  vector<int> x(n);
  for(int i=0;i<n;i++)
  {
    cin>>v.at(i);
  }
  for(int i=0;i<n;i++)
  {
    cin>>c.at(i);
  }
  for(int i=0;i<n;i++)
  {
    x.at(i)=v.at(i)-c.at(i);
    if(x.at(i)>0)
    {
      ans+=x.at(i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
from itertools import accumulate
import sys
from heapq import heappush, heappop
import math


def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    p = 0
    for n in range(1, N+1):
        c = max(math.ceil(math.log2(K / n)), 0)
        p += 1 / N * 0.5 ** c
    print(p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll n,a[110];
  cin>>n;
  ll m1=0,m2=0;
  rep(i,n)cin>>a[i];
  sort(a,a+n,greater<ll>());
  rep(i,n){
    if(i%2==0){
      m1+=a[i];
    }else{
      m2+=a[i];
    }
  }



  cout<<(m1-m2)<<endl;
  return 0;
}


Measured memory_bytes: 3636
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	string s; cin >> s;
	rep(i, s.size()) {
		if (s[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
ll n,a,b,ans;
vector<ll> tms;
ll ksm(ll beg,ll x)
{
	if(x==0)
	{
		return 1;
	}
	if(x==1)
	{
		return beg;
	}
	ll ret=ksm(beg,x/2);
	if(x%2==1)
	{
		return ((ret*ret)%MOD*beg)%MOD;
	}
	return (ret*ret)%MOD;
}
int main(){
	ll i,j=2,t1=1,t2=1;
	cin>>n>>a>>b;
	ans=ksm(2,n);
	ans=(ans+MOD-1)%MOD;
	for(i=n;i>=n-a+1;i--)
	{
		t1=(t1*i)%MOD;
	}
	for(i=2;i<=a;i++)
	{
		t2=(t2*i)%MOD;
	}
	ans=(ans+MOD-(t1*ksm(t2,MOD-2))%MOD)%MOD;
	//cout<<t1<<" "<<t2<<endl;
	//t1=t2=1;
	for(i=n-a;i>=n-b+1;i--)
	{
		t1=(t1*i)%MOD;
	}
	for(i=a+1;i<=b;i++)
	{
		t2=(t2*i)%MOD;
	}
	ans=(ans+MOD-(t1*ksm(t2,MOD-2))%MOD)%MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a;
    int i = 0;
    
    while(1) {
        scanf("%d", &a);
        i++;
        
        if(a == 0) {
            break;
        }
        
        printf("Case %d: %d\n", i, a);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll cnt=0;
    ll R,G,B,N; cin >> R >> G >> B >> N;
    ll r = N / R + 1;
    ll g = N / G + 1;
    rep(i,r){
        rep(j,g){
            if((N - i*R - j*G) % B == 0 && N - i*R - j*G >= 0){
                cnt++;
                //cout << i << " " << j << endl;
            }
        }
    }
    cout << cnt << endl;
}


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

int dpow(int j){
  int ans=1,i;
  for(i=0;i<j;i++)ans*=2;
  return ans;
}

int main(){
  int i,j,K,N,M,p,ans=0,cnt=0,max,nmax;
  scanf("%d",&N);
  scanf("%d",&M);
  vector<int> swt(N,0);
  for(i=0;i<M;i++){
    scanf("%d",&K);
    for(j=0;j<K;j++){
      scanf("%d",&p);
      swt[p-1]+=dpow(i);
    }
  }

  for(i=0;i<M;i++){
    scanf("%d",&K);
    if(K==0)ans+=dpow(i);
  }

  max=dpow(M)-1;
  nmax=dpow(N)-1;
  for(i=0;i<=nmax;i++){
    p=ans;
    for(j=0;j<N;j++){
      if((i>>j)%2==1){
        p^=swt[j];
      }
    }
    if(p==max)cnt++;
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())

lst = []
for i in range(N):
    a = list(map(int, input().split()))
    lst += [a]

dp = []
for i in range(N+1):
    dp += [[0] *(W+1)]

for i in range(N-1, -1, -1):
    for j in range(W+1):
        if lst[i][1] > j:
            dp[i][j] =dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j], dp[i+1][j-lst[i][1]]+lst[i][0])



print (dp[0][W])



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

int main(){
    int N,K;cin>>N>>K;
    int R,S,P;cin>>R>>S>>P;
    string st;cin>>st;
    vector<char> hist(N,'a');

    auto get_win=[&](char x){
        if(x == 'r'){
            return 'p';
        }else if(x=='s'){
            return 'r';
        }else{
            return 's';
        }
    };
    auto get_lose=[&](char x){
        if(x == 'r'){
            return 's';
        }else if(x=='s'){
            return 'p';
        }else{
            return 'r';
        }
    };

    
    auto get_point=[&](char x){
        if(x == 'r'){
            return P;
        }else if(x=='s'){
            return R;
        }else{
            return S;
        }
    };

    int ans = 0;
    rep(i,N){
        if( i>=K ){
            if(get_win(st[i]) == hist[i-K]){
                //いじくるべきはここだけ.
                //勝ちたいんだけど勝てないとき.
                if( i+K <= N-1 ){
                    if(st[i]==st[i+K]){
                        //これは何でもいいので...
                        hist[i] = st[i];
                    }else if(get_win(st[i])==st[i+K]){
                        hist[i] = st[i];
                    }else{
                        hist[i] = get_lose(st[i]);
                    }
                }else{
                    //邪魔に仕様がないのでここはどうでもいいい
                    hist[i] = get_lose(st[i]);
                }
            }else{
                ans += get_point(st[i]);
                hist[i] = get_win(st[i]);
            }
        }else{
            ans += get_point(st[i]);
            hist[i] = get_win(st[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
n,m=map(int,input().split())
a,b=[],[]
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())
for y in range(n-m+1):
    for x in range(n-m+1):
        eq=True
        for yy in range(m):
            for xx in range(m):
                eq &= a[y+yy][x+xx] == b[yy][xx]
                if not eq: break
            if not eq: break
        if eq:
            print("Yes")
            exit(0)
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    int n,x;
    cin>>n>>x;
    for(int i=x-n+1;i<=x+n-1;i++)
        cout<<i<<" ";cout<<endl;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
	int N; cin >> N;
	vector<double> V(N);
	rep(i, N) cin >> V[i];
	sort(all(V));
	double ans = V[0];
	rep(i, N) ans = (ans + V[i]) / 2.0;
	cout.precision(10);
	cout << ans << "\n";
}

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

typedef long long ll;

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

    ll x,su=0;cin>>x;
    for(int i=1;i<=100000;i++){
        su+=i;
        if(su>=x){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();

        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        int minv = a[0];
        int maxv = -2000000000;
        for(int i = 1; i < n; i++){
            maxv = Math.max(maxv, a[i] - minv);
            minv = Math.min(minv, a[i]);
        }
        
        System.out.println(maxv);
    }
}


Measured memory_bytes: 101552
(n,*c),a,*q=$<.map{_1.split.map &:to_i}
b=(0..n).map{_1&-_1}
d=b.map{[]}
u=i=k=0
z=q.map{d[_2]<<[_1-1,~k-=1]}
a.map{t=c[_1]||n+u+=1
(b[t]-=1;t+=t&-t)until t>n
c[_1]=i+=1
d[i].map{|x,y|z[y]=u
(z[y]-=b[x];x&=x-1)while x>0}}
p *z

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

using namespace std;

int main () {
int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
int x , y ; 
cin >> x >> y ;
if ( a [ x ] == a [ y ])
	cout <<"Yes" << endl;
else
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main() {
  int flag = 1;
  int flag2 = 1;
  int ans = 0;
  int c;
  int n;
  while ((c = getchar_unlocked()) >= '0') {
    n = c - '0';
    flag2 = flag;
    if (n < 4) {
      if (flag == -1) {
        ans += n + 1;
      } else {
        ans += n;
      }
      flag = 1;
    }
    else if (n > 5) {
      if (flag == 1) {
        ans += 10 - n;
      } else {
        ans += 9 - n;
      }
      flag = -1;
    } else if (n == 4) {
      if (flag == -1) {
        flag = 0;
        ans += 5;
      } else {
        flag = 1;
        ans += 4;
      }
    } else {
      if (flag == 1) {
        flag = 0;
        ans += 5;
      } else {
        flag = -1;
        ans += 4;
      }
    }
  }
  if (n > 5 || (n == 5 && flag2 != 1)){
    ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
 

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

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N;
	N = getint();
	int A[200000];
	ll B[200001], C;
	B[0] = 0;
	C = 0;

	vector<int> V;
	V.pb(0);
	rep(i, N) A[i] = getint();
	ll mae = A[0];
	rep(i, N) {
		ll a = A[i];
		B[i + 1] = B[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				V.pb(0);
				a *= 4;
			}
			V.back()++;
		}
		else {
			while (mae < a) {
				int kari = V.back();
				B[i + 1] += kari;
				if (V.size() > 1) {
					V.pop_back();
					V.back() += kari;
				}
				mae *= 4;
			}
			V.back()++;
		}
		mae = A[i];
	}
	V.clear();
	mae = A[N - 1];
	V.pb(0);
	ll kotae = 2 * B[N] + N;
	for (int i = N - 1; i >= 0; i--) {
		ll a = A[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				V.pb(0);
				a *= 4;
			}
			V.back()++;
		}
		else {
			while (mae < a) {
				int kari = V.back();
				C += kari;
				if (V.size() > 1) {
					V.pop_back();
					V.back() += kari;
				}
				mae *= 4;
			}
			V.back()++;
		}
		mae = A[i];
		kotae = min(kotae, B[i] + B[i] + C + C + i);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int a=0,b=0;
	rep(i,s.size()){
		if(s[i]=='A') a++;
		else b++;
	}
	if(a && b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int main(){
    int a,b;cin>>a>>b;
    bool f=false;
    for(int i=1;i<=3;i++){
        if((a*b*i)%2)f=true;
    }
    if(f){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}




Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    ll ans[h][w];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(i+1 <= b)ans[i][j]=1;
            else ans[i][j]=0;
        }
    }
    for(int i = 0; i < a; i++){
        for(int j = 0; j < h; j++){
            if(ans[j][i] == 1)ans[j][i]=0;
            else ans[j][i] = 1;
        }
    }
    rep(i, h){
        rep(j,w) cout << ans[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define int unsigned long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],c[maxn];
string s; 
signed main()
{
	int n;
	cin >> n;
	int sum = 1ll;
	int flag = 0;
	rep(i,1,n)
	{
		cin >> a[i];
		if(a[i] == 0)
		{
			cout << 0;
			return 0;
		}
	}
	rep(i,1,n)
	{
		if(a[i] > (ld)1000000000000000000/sum)
		{
			cout << -1;
			return 0;
		}
		sum*=a[i];
	}
	cout << sum ;
	return 0;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string a,b;
  cin >> a >> b;
  
  if(a.size()>b.size()) cout << "GREATER" << endl;

  if(a.size()<b.size()) cout << "LESS" << endl;
  
  if(a.size()==b.size()) {
    if(a>b) cout << "GREATER" << endl;

    if(a<b) cout << "LESS" << endl;
  
    if(a==b) cout << "EQUAL" << endl;
  }
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut S = String::new();
    let mut K = String::new();
    io::stdin().read_line(&mut K);
    io::stdin().read_line(&mut S);
    let k : usize = K.trim().parse().unwrap();
    let mut n :usize = 0;
    S = S.trim().to_string();
    if S.len() <= k {
        println!("{}",S)
    }else{
        n = S.len() - k;
        for i in 0..n {
            S.pop();
        }
        println!("{}...",S);
    }

}

Measured memory_bytes: 2072
#include <iostream>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(a > b) {
    cout << "a > b" << endl;
    return 0;
  } else if (a < b) {
    cout << "a < b" << endl;
    return 0;
  } else {
    cout << "a == b" << endl;
    return 0;
  }
}

Measured memory_bytes: 3092
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;}
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

ll dumb(ll n, ll k) {
    if (n < k) return n;
    if (n % k == 0) {
        return dumb(n/k, k);
    }
    return dumb(n-k, k);
}

int main() {
    ll n;
    cin >> n;
    if (n == 2) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = 1;
    ll sqr = floor(sqrt((long double)n));
    while ((sqr+1ll) * (sqr+1ll) <= n) {
        ++sqr;
    }
    for (ll k = 2; k <= sqr; ++k) {
        if (n % k == 0) {
            ll x = n/k;
            while (x % k == 0) {
                x /= k;
            }
            if (x % k == 1) {
                ++ans;
                // print("divisor", k);
            }
        }
    }
    // print("from divisors:", ans);
    --n;
    sqr = floor(sqrt((long double)n));
    while ((sqr+1ll) * (sqr+1ll) <= n) {
        ++sqr;
    }
    for (ll k = 2; k <= sqr; ++k) {
        if (n % k == 0) {
            ans += 2;
            // print("divisor of n-1: ", k, " ", n/k);
            if (k * k == n) {
                --ans;
            }
        }
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 256
import itertools
import math


n, dimension = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(n)]
l = list(itertools.combinations(X, 2))
num = len(l)
ans = 0
for i in range(num):
    dist = 0
    for d in range(dimension):
        dist += (l[i][0][d] - l[i][1][d]) ** 2
    dist = math.sqrt(dist)
    if dist.is_integer():
        ans += 1
print(ans)

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

int main(void){
  int i = 0;
  int k = 0;
  int j = 0;
  int n;
  int input;
  int *num;
  int swapNum = 0;
  int temp;
  int flag = 1;

  scanf("%d", &n);
  num = (int *)malloc(n * sizeof(int));

  for(i = 0; i < n; i++){
    scanf("%d", &input);
    num[i] = input;
  }

  if(n > 1)
  while(flag){
    flag = 0;
    for(i = n-1; i > 0; i--){
      if(num[i] < num[i-1]){
        temp = num[i-1];
        num[i-1] = num[i];
        num[i] = temp;
        swapNum++;
        flag = 1;
      }
    }
  }
  for(i = 0; i < n; i++){
    printf("%d", num[i]);
    if(i < n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n", swapNum);

  return 0;
}

Measured memory_bytes: 2684
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(list(map(int,input().split())))
k = []
n = 0


for i in range(H-1):
    for j in range(W):
        if (a[i][j]) % 2 ==1:
            k.append([i+1,j+1,i+2,j+1])
            n = n + 1
            a[i][j] = a[i][j]-1
            a[i+1][j] = a[i+1][j] +1
        else:
            pass

for i in range(H):
    for j in range(W-1):
        if (a[i][j]) % 2 ==1:
            k.append([i+1,j+1,i+1,j+2])
            n = n + 1
            a[i][j] = a[i][j]-1
            a[i][j+1] = a[i][j+1] +1
        else:
            pass

print(n)
for i in range(n):
    print(k[i][0], k[i][1], k[i][2], k[i][3])


Measured memory_bytes: 30260
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){

	int count;
	int n;
	int i,j;
	char a[10];
	char b[10];

	count = 0;
	
	while(1){

		scanf("%d",&n);
		if(n == 0){
			break;
		}

		count = 0;

		strcpy(a," ");
		strcpy(b," ");

		for(i=0; i<n; i++){

			strcpy(b,a);
			scanf("%s",a);
			


			if( (strcmp(a, "lu") == 0 && strcmp(b, "ru") == 0) || (strcmp(a, "lu") == 0 && strcmp(b, "ru") == 0)  || 
				(strcmp(b, "lu") == 0 && strcmp(a, "ru") == 0) || (strcmp(b, "lu") == 0 && strcmp(a, "ru") == 0)  ||
				(strcmp(a, "ld") == 0 && strcmp(b, "rd") == 0) || (strcmp(a, "ld") == 0 && strcmp(b, "rd") == 0)  ||
				(strcmp(b, "ld") == 0 && strcmp(a, "rd") == 0) || (strcmp(b, "ld") == 0 && strcmp(a, "rd") == 0))
			{

				count++;
			}
		}

		printf("%d\n",count);
	}
	return 0;
}

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

#define ELEMENT 11 //1023=512+256+128+64+32+16+8+4+2+1+制御用
#define BIN 2

void initialize(int array[], int n);
void integer_to_binary(int number, int array[]);
void calculate_weight(int array[]);

main()
{
	int input = 0, i = 0;
	int binary[ELEMENT]; //0or1が代入
	while(scanf("%d", &input) != EOF)
	{
		initialize(binary, ELEMENT);
		integer_to_binary(input, binary);
		calculate_weight(binary);
		input = 0;
	}
	
	return 0;
}

void initialize(int array[], int n)
{
	int i = 0;
	for(i = 0; i < n; i++)
	{
		array[i] = -1;
	}
}

void integer_to_binary(int number, int array[])
{
	static int quot = 0;
	static int i = 0;
	
	quot = number;
	array[i] = quot % BIN;
	i++;
	quot /= BIN;
	
	if(quot < 1)
	{
		i = 0;
		return;
	}
	else
	{
		integer_to_binary(quot, array);
	}
	
}
void calculate_weight(int array[])
{
	int sum = 0;
	int i = 0;
	for(i = 0; i < ELEMENT; i++)
	{
		if(array[i] == 1)
		{
			array[i] = pow(BIN, i);
		}
		//printf("array[%d] = %d\n", i, array[i]);
	}
	
	for(i = 0; i < ELEMENT; i++)
	{
		if((array[i + 1] == -1) && (array[i] > 0))
		{
			printf("%d\n", array[i]);
		}
		else if(array[i] > 0)
		{
			printf("%d ", array[i]);
		}
	}
	
}

Measured memory_bytes: 636
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String x="",y;for(int n,i=1;(n=s.nextInt())>0;){if(i<1)x+="\n";List<String>l=new ArrayList<String>();Map<String,Integer>m=new HashMap<String,Integer>();for(i=n;i-->0;){l.add(y=s.next());m.put(y,s.nextInt()*3+s.nextInt()*0+s.nextInt());}List<Integer>c=new ArrayList<Integer>(m.values());Collections.sort(c);for(;n-->0;)for(String k:l)if(c.get(n).equals(m.get(k))){x+=k+","+c.get(n)+"\n";m.remove(k);}}System.out.print(x);}}

Measured memory_bytes: 12000
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }
    cout << ans << '\n';
    return 0;
}


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

int main(){
    int d, n; cin >> d >> n;
    int a = 1;
    for(int i=0;i<d;i++){
        a *= 100;
    }
    if(n < 100){
        cout << n * a << endl;
    }
    else{
        cout << 101 * a << endl;
    }
}


Measured memory_bytes: 256
from itertools import zip_longest

while True:
    n = int(input())
    if not n:
        break
    field = [list(map(int, input().split())) for _ in range(n)]
    field.reverse()
    score = 0
    while True:
        no_more_disappear = True

        for row in field:
            for i, stone in enumerate(row[:3]):
                if stone is None:
                    continue
                cnt = 1
                for stone2 in row[i + 1:]:
                    if stone != stone2:
                        break
                    cnt += 1
                if cnt >= 3:
                    row[i:i + cnt] = [None] * cnt
                    score += stone * cnt
                    no_more_disappear = False

        if no_more_disappear:
            break

        fieldT = map(lambda row: filter(None, row), zip(*field))
        field = list(map(list, zip_longest(*fieldT)))

    print(score)

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<std::string> S, std::vector<long long> P){
    vector<pair<pair<string, LL>, int>> tmp;
    REP(i, N) tmp.PB(MP(MP(S[i], P[i]*-1), i+1));

    sort(ALL(tmp));
    
    REP(i, N) cout << tmp[i].second << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(S), std::move(P));
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	defer writer.Flush()
	n, q := ReadInt(), ReadInt()
	t := NewLazySegTree(n)
	for ; q > 0; q-- {
		if ReadInt() == 0 {
			t.Update(ReadInt(), ReadInt()+1, ReadInt())
		} else {
			Println(t.Find(ReadInt(), ReadInt()+1))
		}
	}
}

type LazySegTree struct {
	nodes []int
	lazy  []int
}

const Inf = 1<<31 - 1

func NewLazySegTree(n_ int) *LazySegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	nodes := make([]int, n<<1)
	for i := 1; i < len(nodes); i++ {
		nodes[i] = Inf
	}
	lazy := make([]int, n<<1)
	for i := 1; i < len(lazy); i++ {
		lazy[i] = -1
	}
	return &LazySegTree{
		nodes: nodes,
		lazy:  lazy,
	}
}

func (t *LazySegTree) lazyEval(k, l, r int) {
	if t.lazy[k] == -1 {
		return
	}
	t.nodes[k] = t.lazy[k]
	if r-l > 1 {
		t.lazy[k*2] = t.lazy[k]
		t.lazy[k*2+1] = t.lazy[k]
	}
	t.lazy[k] = -1
}

func (t *LazySegTree) Update(a, b, x int) {
	t.updateRecur(a, b, x, 1, 0, len(t.nodes)>>1)
}
func (t *LazySegTree) updateRecur(a, b, x, k, l, r int) {
	t.lazyEval(k, l, r)
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		t.lazy[k] = x
		t.nodes[k] = x
	} else {
		t.updateRecur(a, b, x, k*2, l, (l+r)>>1)
		t.updateRecur(a, b, x, k*2+1, (l+r)>>1, r)
		t.nodes[k] = Min(t.nodes[k*2], t.nodes[k*2+1])
	}
}

func (t *LazySegTree) Find(a, b int) int {
	return t.findRecur(a, b, 1, 0, len(t.nodes)>>1)
}
func (t *LazySegTree) findRecur(a, b, k, l, r int) int {
	t.lazyEval(k, l, r)
	if b <= l || r <= a {
		return Inf
	}
	if a <= l && r <= b {
		return t.nodes[k]
	} else {
		return Min(
			t.findRecur(a, b, k*2, l, (l+r)>>1),
			t.findRecur(a, b, k*2+1, (l+r)>>1, r),
		)
	}
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }



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

typedef unsigned uint;

vector<uint> split(string line){
	vector<uint> res;
	stringstream ss(line);
	string b;
	while (getline(ss, b, '.')){
		res.push_back(atoi(b.c_str()));
	}
	return res;
}

const uint maya[] = {144000, 7200, 360, 20, 1};
const uint dpm[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

inline bool isLeap(uint y, uint m = 1){
	if (m != 1) return false;
	if (y % 400 == 0) return true;
	if (y % 100 == 0) return false;
	if (y % 4 == 0) return true;
	return false;
}

vector<uint> v;
void solve(){
	uint day = 0;
	for (uint i = 0; i < 2012; i++){
		day += 365;
		if (isLeap(i)) day++;
	}
	for (uint i = 0; i < 11; i++){
		day += dpm[i];
	}
	day += 21;
	
	for (uint i = 0; i < 5; i++){
		day += maya[i] * v[i];
	}
	
	uint resy = 0, resm = 0, resd = 0;
	
	// 1??´??????????????????
	while (true){
		uint pl = isLeap(resy) ? 366 : 365;
		if (day < pl) break;
		day -= pl;
		resy++;
	}
	
	// 1?????????????????????
	while (true){
		uint pl = dpm[resm] + (isLeap(resy, resm) ? 1 : 0);
		if (day < pl) break;
		day -= pl;
		resm++;
	}
	
	resd = day;
	
	/*if (resd == 0){
		if (resm == 0){
			resy--;
			resm = 11;
			resd = 30;
		}
		else {
			resm--;
			resd = dpm[resm];
		}
	}*/
	
	resm++;
	resd++;
	
	printf("%u.%u.%u\n", resy, resm, resd);
}
void solve2(){
	uint day = 0;
	
	for (uint i = 0; i < v[0]; i++){
		day += (isLeap(i) ? 366 : 365);
	}
	for (uint i = 0; i < v[1]-1; i++){
		day += dpm[i] + (isLeap(v[0], i) ? 1 : 0);
	}
	day += v[2]-1;
	
	for (uint i = 0; i < 2012; i++){
		day -= 365;
		if (isLeap(i)) day--;
	}
	for (uint i = 0; i < 11; i++){
		day -= dpm[i];
	}
	day -= 21;
	
	day %= maya[0] * 13;
	for (int i = 0; i < 5; i++){
		if (i) printf(".");
		printf("%u", day / maya[i]);
		day %= maya[i];
	}
	puts("");
}

int main()
{
	string line;
	while (cin >> line, line != "#"){
		v = split(line);
		if (v.size() == 5) solve();
		else solve2();
	}
	return 0;
}

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

int main(void) {
  char s[200010];
  scanf("%s",s);
  int len=strlen(s);
  int sum=0;
  for(int i=0;i<len;i++)
  {
    sum+=s[i]-'0';
  }
  if(sum%9==0)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int MX = 1000003;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), c(MX, 0);
  rep(i, n) cin >> a[i], c[a[i]]++;

  ll g = 0;
  rep(i, n) g = __gcd(g, a[i]);

  if (g != 1) {
    cout << "not coprime" << endl;
    return 0;
  }

  bool pairwise = true;
  for (int i = 2; i < MX; ++i) {
    ll cnt = 0;
    for (int j = i; j < MX; j += i) cnt += c[j];
    if (cnt > 1) pairwise = false;
  }

  cout << (pairwise ? "pairwise coprime" : "setwise coprime") << endl;

  return 0;
}

Measured memory_bytes: 18764
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll sum[100007],A[100007],dp[3][100007];

int main(){
  ll N,K;
  cin >> N >> K;
  rep(i,N){
    cin >> A[i];
    sum[i+1]=sum[i]+A[i];
  }
  dp[1][0]=-LINF;
  Rep(i,1,N+1){
    dp[0][i]=max(dp[0][i-1],dp[0][i-1]+A[i-1]);
    if(i>=K){
      dp[1][i]=max(dp[1][i-1]+max(0LL,A[i-1]),dp[0][i-K]+max(0LL,+sum[i]-sum[i-K]));
    }
    else{
      dp[1][i]=-LINF;
    }
  }
  cout << dp[1][N] << endl;
}

Measured memory_bytes: 3328