akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
string s;
vector<int> alp[26];
ll val[222222];
pair<ll, ll> ma[222222];

void finish(int l, int r)
{
	cout<<l<<" "<<r; exit(0);
}

void tryout(int x)
{
	if(alp[x].size()<=1) return;
	int i, j; int cnt=alp[x].size();
	for(i=0 ; i<alp[x].size() ; i++) val[i]=alp[x][i]-2*i;
	ma[cnt]=make_pair(1e9,0);
	for(i=cnt-1 ; i>=0 ; i--)
	{
		ma[i].first=min(ma[i+1].first,val[i]);
		if(ma[i+1].first<=val[i]) ma[i].second=ma[i+1].second;
		else ma[i].second=alp[x][i]; 
	}
	for(i=0 ; i<alp[x].size() ; i++)
		if(ma[i+1].first<=val[i])
			finish(alp[x][i]+1,ma[i+1].second+1); 
}

int main(void)
{
	cin>>s; int i;
	for(i=0 ; i<s.length() ; i++) alp[s[i]-'a'].push_back(i);
	for(i=0 ; i<26 ; i++) tryout(i);
	cout<<-1<<" "<<-1; return 0;
}

// it may be easier than you think
// it may be harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 3704
//びぃあいえぬじぃおぉ＝BINGO!!

#include <cstdio>

int main(void)
{

    
    while (1){
	int n, m, s;
        scanf("%d%d%d", &n, &m, &s);
    
    int dp[50][3001]={0};
        if (n == 0) break;
        dp[0][0] = 1;
        
        for (int i = 1; i <= m; i++){
            for (int j = n * n; j >= 1; j--){
                for (int k = i; k <= s; k++){
                    dp[j][k] += dp[j - 1][k - i];
                    if (dp[j][k] >= 100000){
                        dp[j][k] -= 100000;
                    }
                }
            }
        }
        
        printf("%d\n", dp[n * n][s]);
    }
    
    return (0);
}
	


Measured memory_bytes: 1624
n = int(input())

ans = n
for i in range(n+1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t % 6
        t //= 6

    t = n - i
    while t > 0:
        cnt += t % 9
        t //= 9

    ans = min(ans, cnt)

print(ans)

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

using Graph = std::vector<std::vector<int>>;

void dfs(std::vector<int> &count, std::vector<int> &score, Graph &g, int v, int p){
    score.at(v) += count.at(v);
    for(auto nextV : g.at(v)){
        if(p != nextV){
            score.at(nextV) += score.at(v);
            dfs(count, score, g, nextV, v);
        }
    }
}

int main(){
    int n, q;
    std::cin >> n >> q;

    Graph g(n);
    for(int i = 0; i < n - 1; ++i){
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }

    std::vector<int> count(n);
    for(int i = 0; i < q; ++i){
        int index, val;
        std::cin >> index >> val;
        count.at(index - 1) += val;
    }

    std::vector<int> score(n, 0);
    dfs(count, score, g, 0, -1);

    for(int i = 0; i < n; ++i){
        std::cout << score.at(i);
        if(n - 1 != i){
            std::cout << " ";
        }
    }

    std::cout << std::endl;

    return 0;    
}

Measured memory_bytes: 33664
#include <iostream>
#include <cstdio>
#include <map>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <cmath>
#include <queue>
#include <ctime>
#include <utility> // std::pair
#include <functional> // std::greater <int> ()
#define int long long
#define inf 1000000000000000001
#define BASE 29 // hashings mod, can be rand'd
#define mod 998244353 // can be 1000000007
#define pi 3.1415926535897
#define pii pair <int, int>
#define fii first
#define see second

typedef long long ll;
typedef long double ld;
using namespace std;

string s, t;

// functions
void input(){
	cin >> s >> t;
	return;
}

void solve(){
	cout << (s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]);
	return;
}

void output(){
	return;
}

signed main(){
/*
//  REMEMBER TO TURN OFF IFDEF IN PROBLEMS WITH FILE I/O
*/
//#ifdef sheeep
//	freopen("forces.inp", "r", stdin);
//	freopen("forces.out", "w", stdout);
//#endif
	ios_base::sync_with_stdio(false);
//	int t;
//	cin >> t;
//	for(int i=1; i<=t; i++){
		input();
		solve();
		output();
//	}
	return 0;
}
// Author: NamSPro


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

bcs = [0] * 41
for i in range(N):
  a = A[i]
  for j in range(41):
    if a & (1 << j) != 0:
      bcs[j] += 1

X = 0
for i in range(40, -1, -1):
  if bcs[i] >= N - bcs[i]:
    continue  
  t = 1 << i
  if X + t <= K:
    X += t

result = 0
for i in range(N):
  result += X ^ A[i]
print(result)

Measured memory_bytes: 14620
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	string S; cin >> S;
	string str = "CODEFESTIVAL2016";
	int ans = 0;
	rep(i, 16) {
		if (S[i] != str[i])++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int>X(N),Y(N),num(N);
  for(int i=0;i<N;i++){
    cin>>X.at(i)>>Y.at(i);
    num.at(i)=i;
  }
  double heikin=0;
  double count=0;
  double x_zouka=0;
  double y_zouka=0;
  double sum=0;
  do{
    for(int i=0;i<N-1;i++){
      x_zouka=X.at(num.at(i))-X.at(num.at(i+1));
      y_zouka=Y.at(num.at(i))-Y.at(num.at(i+1));
      sum+=sqrt(x_zouka*x_zouka+y_zouka*y_zouka);
    }
    count++;
  }while(next_permutation(num.begin(),num.end()));
  heikin=sum/count;
  cout<<fixed<<setprecision(12)<<heikin<<endl;
  return 0;
}

Measured memory_bytes: 256
def dfs(arr, min_nx):
    ans = 0
    if len(arr) == n:
        tmp = 0
        for a,b,c,d in lst:
            if arr[b-1] - arr[a-1] == c:
                tmp += d
        return tmp
    else:
        for nx in range(min_nx, m+1):
            new_arr = arr + [nx]
            score = dfs(new_arr, nx)
            ans = max(ans, score)
    return ans
n,m,q = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(q)]
ans = dfs([], 1)
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    
    std::vector<int> ss(n);
    for (int i = 0; i + 1 < n; i++) ss[i + 1] = ss[i] + (a[i] < a[i + 1]);
    
    std::deque<int> qmin, qmax;
    std::vector<int> min, max;
    auto add = [&](int i) {
        while (!qmin.empty() && a[qmin.back()] > a[i]) qmin.pop_back();
        qmin.push_back(i);
        while (!qmax.empty() && a[qmax.back()] < a[i]) qmax.pop_back();
        qmax.push_back(i);
    };
    for (int i = 0; i < k; i++) add(i);
    for (int i = k; i < n; i++) {
        add(i);
        min.push_back(qmin.front());
        max.push_back(qmax.front());
        if (qmin.front() == i - k) qmin.pop_front();
        if (qmax.front() == i - k) qmax.pop_front();
    }
    
    std::vector<std::vector<int>> g(n - k + 1);
    auto add_edge = [&](int u, int v) {
        // fprintf(stderr, "%d <-> %d\n", u, v);
        g[u].push_back(v);
        g[v].push_back(u);
    };
    for (int i = 0, p = -1; i <= n - k; i++) {
        if (ss[i + k - 1] - ss[i] == k - 1) {
            if (p >= 0) add_edge(p, i);
            p = i;
        } else if (i < n - k && min[i] == i && max[i] == i + k) {
            add_edge(i, i + 1);
        }
    }

    std::deque<int> q;
    std::vector<int> done(g.size());
    int ret = 0;
    for (int i = 0; i < g.size(); i++) {
        if (done[i]) continue;
        ret++;
        q.push_back(i);
        done[i] = 1;
        while (!q.empty()) {
            int v = q.front();
            for (int to : g[v]) {
                if (done[to]) continue;
                done[to] = 1;
                q.push_back(to);
            }
            q.pop_front();
        }
    }
    
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 15168
#include<stdio.h>
int main(void)
{
	int v[100], c[100], n, i,max=0;

	scanf("%d", &n);

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

	for (i = 0; i < n; i++)
	{
		scanf("%d", &c[i]);
	}
	for (i = 0; i < n; i++)
	{
		if (v[i] - c[i]>0)
		{
			max += v[i] - c[i];
		}
	}
	printf("%d", max);
	return 0;

}


Measured memory_bytes: 128
x = int(input())
#101以上で100余り0にする
mod = [5,4,3,2,1]
while x % 100 != 0 and x > 100:
    xxx = int(str(x)[-2:])
    for m in mod:
        if xxx >= m:
            x -= (100+m)
            break
    # print(xxx)
    # print(x)
print(1) if x % 100 == 0 else print(0)



Measured memory_bytes: 3060
int main(void){
  int A;
  int B;
  int C;
  scanf("%d",&A);
  scanf("%d",&B);
  C = A + B;
  if(C > 23){
    C = C - 24;
    printf("%d\n",C);
  }else{
    printf("%d\n",C);
  }
return 0;
}

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

using namespace std;

class Calc{
private:
  int idx;
  string s;
public:
  Calc(string s) : s(s) {
    idx = 0;
  }
  int fact(){
    int res = 0;
    if(s[idx] == '('){
      idx++;
      res = exp();
      idx++;
    }else{
      while(isdigit(s[idx])){
        res *= 10;
        res += s[idx++]-'0';
      }
    }
    return res;
  }

  int term(){
    int res = fact();
    while(s[idx] == '*' || s[idx] == '/'){
      if(s[idx] == '*'){
        idx++;
        res *= fact();
      }else{
        idx++;
        res /= fact();
      }
    }
    return res;
  }

  int exp(){
    int res = term();
    while(s[idx] == '+' || s[idx] == '-'){
      if(s[idx] == '+'){
        idx++;
        res += term();
      }else{
        idx++;
        res -= term();
      }
    }
    return res;
  }

};

int main(){
  int Tc;
  string s;
  cin >> Tc;
  while(Tc--){
    cin >> s;
    s.resize(s.size()-1);
    Calc c(s);
    cout << c.exp() << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
n, q = map(int, input().split())
s = input()


ac = [0] * n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        ac[i] = 1
        ac[i+1] = 1

cac = [0]*(n+1)
for i in range(n):
    cac[i+1] = cac[i] + ac[i]

for i in range(q):
    l, r = map(int, input().split())
    ans = cac[r] - cac[l-1]
    if 0 <= l-1 and s[l-2:l]=='AC':
            if r+1 <= n and s[r-1:r+1]=='AC':
                ans-=2
    ans//=2
    print(ans)



Measured memory_bytes: 10308
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		int count = 1;

		while(n >= Math.pow(k, count)){
			count++;
		}

		System.out.println(count);
	}

}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n,k;
    cin >>n>>k;

    int ans = 0;
    while(n != 0) {
        n /= k;
        ans++;
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const double INT_MAX = 2147483647;
#define rep(i, n) REP(i, 0, n)clim
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

int main(void){
    // Your code here!
    int a,b,c,k;
    int res = 0;
    cin >>a>>b>>c>>k;
    while(k--){
        if(a>0) { res++;a--; continue; }
        if(b>0) { b--; continue; }
        if(c>0) { res--;c--; continue; }
    }
    cout << res;
}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int mi = 1000000;
    int sum = 0;
    rep(i,n){
        if(mi > v[i]){sum++; mi = v[i];}
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
X = list(map(int, input().split()))

x_minus = [a for a in X if a < 0]
x_plus = [a for a in X if a >= 0]

ans = float("inf")
for i in range(K+1):
    if i == 0:
        if len(x_plus) >= K:
            dis = x_plus[K - 1]
            ans = min(ans, dis)
        else:
            continue
    elif 1 <= i <= K - 1:
        if len(x_minus) >= i and len(x_plus) >= K - i:
            dis = 2 * abs(x_minus[-i]) + x_plus[K - i - 1]
            ans = min(ans, dis)
            dis = 2 * x_plus[K - i - 1] + abs(x_minus[-i])
            ans = min(ans, dis)
        else:
            continue
    elif i == K:
        if len(x_minus) >= K:
            dis = abs(x_minus[-K])
            ans = min(ans, dis)


print(ans)


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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int l = 0, r = 0;
    int a;
    rep(i,m) {
        cin >> a;
        if (a < x) l++;
        else r++;
    }
    cout << min(l, r) << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 1;
  int cnt = 0;
  while (ans < b){
    ans += a-1;
    cnt += 1;
  }
  cout << cnt << endl;
  return 0;
}


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

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}


const long long LINF = 1LL << 60;

int main(){

    ll dp[110000];
    REP(i,110000)dp[i] = LINF;
    dp[0] = 0;

    ll n; cin >> n;
    vector<ll> h(n);
    REP(i,n)cin >> h[i];

    REPS(i,n){
        chmin(dp[i],dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1)chmin(dp[i],dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 4764
fun main(args:Array<String>?): Unit {
    readLine()
    val wise = readLine()!!.trim().split(' ').map{it == "0"}
    val hate = readLine()!!.trim().split(' ').map(String::toInt)
    val rights = wise.indices.filter{wise[it]}.map{hate[it]}
    val lefts = wise.indices.filterNot{wise[it]}.map{hate[it]}
    val fromRight = rights.min() ?: 0
    val fromLeft = lefts.min() ?: 0
    println(
            if (rights.isEmpty() || lefts.isEmpty()) 0 else fromRight + fromLeft
    )
}


Measured memory_bytes: 32220
S = input()
S_reverse = S[::-1]

dp = [0] * 2019
now_mod = 0
digit = 1

for i_s in S_reverse:
    now_mod = (now_mod + int(i_s)*digit) % 2019
    digit = (digit*10) % 2019
    dp[now_mod] += 1

ans = sum(x*(x-1)//2 for x in dp)
ans += dp[0]

print(ans)

Measured memory_bytes: 68588
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
from collections import defaultdict
tasks = defaultdict(list)
for i in range(N):
  a,b = map(int,readline().split())
  tasks[a].append(b)
  
import heapq as hq
q = []
ans = 0
for i in range(1, M + 1):
  newtask = tasks[i]
  for t in newtask:
    hq.heappush(q,-t)
  if q:
    ans += -hq.heappop(q)

print(ans)

Measured memory_bytes: 31960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P,P> PP;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const int MAX_V = int(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

struct edge {
    ll from, to, a, b;
    edge(ll u, ll v, ll a, ll b) : from(u), to(v), a(a), b(b){};
};

vector<edge> G[MAX_V];
ll dmin[MAX_V];

void add_edge(ll u, ll v, ll a, ll b) {
    G[u].push_back(edge(u, v, a, b));
    G[v].push_back(edge(v, u, a, b));
}

ll f(ll b, ll a, ll x) { return ll(ceil(b / double(a + x) + double(x))); }

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;  //小さいものから取り出す
    fill(dmin, dmin + MAX_V, LLINF);
    dmin[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dmin[v] < p.first) continue;
        for (auto &e : G[v]) {
            ll k = max(0.0, pow(e.b, 0.5) - (e.a + dmin[v])), cost;
            cost = f(e.b, e.a + dmin[v], 0);
            if (k > 0) {
                cost = min(cost,min(f(e.b,e.a+dmin[v],floor(k)),f(e.b,e.a+dmin[v],ceil(k))));
            }
            if (dmin[e.to] > dmin[v] + cost) {
                dmin[e.to] = dmin[v] + cost;
                que.push(P(dmin[e.to], e.to));
            }
        }
    }
}

int main() {
    ll n, m, s, g;
    cin >> n >> m >> s >> g;
    REP(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        add_edge(u, v, a, b);
    }
    dijkstra(s);
    cout << (dmin[g]!=LLINF?dmin[g]:-1) << endl;
    return 0;
}



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

int main() {
  string N;
  cin >> N;
  
  if(N.at(0) == '9') {
    cout << "Yes" << endl;
  }
  else if(N.at(1) == '9') {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int X = Integer.parseInt(st.nextToken());
         int T = Integer.parseInt(st.nextToken());
         int time = N/X;
         time *= T;
         if(N%X > 0)
            time += T;
         System.out.println(time);
      }
   }

Measured memory_bytes: 32664
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int mod=1000000007 ;

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

	string s ;
	cin>>s ;

	int q ;
	cin>>q ;

	vector<set<int>> is(26) ;

	for(int i=0;i<n;i++){
		is[s[i]-'a'].insert(i) ;
	}

	for(int i=1;i<=q;i++){

		int a ;
		cin>>a ;

		if(a==1){

			int i ;
			char c ;
			
			cin>>i>>c ;

			--i ;
			
			is[s[i]-'a'].erase(i) ;
			s[i]=c ;
			is[s[i]-'a'].insert(i) ;

		}
		else{

			int l,r ;
			cin>>l>>r ;

			l-- ;

			int ans=0 ;

			for(int i=0;i<26;i++){

				auto it=is[i].lower_bound(l);

				if(it!=is[i].end() && *it<r){
					ans++ ;
				}

			}

			cout<<ans<<"\n" ;
		}

	}

}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 27248
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll; 
const int N = 1e5 + 5;
bool vis[N];
vector<vector<int>> g(N),gb(N);
unordered_set<int> s;
vector<int> comp_id(N,0);
//vector<int> comp_sz;
vector<int> ans(N);
void dfs(int u)
{
    vis[u] = true;
    s.insert(u);
    for(int v : g[u])
      if(!vis[v])
            dfs(v);
    
}
int main()
{
    int n,a,b; cin>>n>>a>>b;
    for(int i = 0 ; i < a ; i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i = 0 ; i < b ; i++)
    {
        int x,y;
        cin>>x>>y;
        gb[x].push_back(y);
        gb[y].push_back(x);
    }
    int c = 0;
    for(int i =1; i<=n ; i++)
    {
        
        if(!vis[i])
        {
            c++;
            s.clear();
            dfs(i);
       //     comp_sz.push_back(s.size());
            for(auto& x : s)
            {
                ans[x] = s.size()-1;
            }
            // for(int i = 0 ; i < n ; i++)
            //     cout<<ans[i+1]<<" ";
            // cout<<endl;
            set<pair<int,int>> done;
            for(auto& x : s)
            {
                
                for(int b : g[x])
                {
                     if((done.find({min(x,b), max(x,b)})==done.end())&&s.find(b)!=s.end())
                    {
                        done.insert({min(x,b),max(x,b)});
                        ans[x]--;
                        ans[b]--;
                    } 
                }
                for(int b : gb[x])
                {
                      if((done.find({min(x,b), max(x,b)})==done.end())&&s.find(b)!=s.end())
                    {
                        done.insert({min(x,b),max(x,b)});
                        ans[x]--;
                        ans[b]--;
                    }
                }
            }
           // for(int i = 0 ; i < n ; i++)
           //      cout<<ans[i+1]<<" ";
           //  cout<<endl;
        }
        
    }
    for(int i = 1; i <=n ; i++)
        cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 26128
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		cnt += x >= k;
	}
	cout << cnt;
}
  
int main()
{
    Red;
    solve();
    return 0;
}

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

typedef long long ll;
const int inf = 1e9;

int n, u;

int main(){
	cin>>n;
	vector<ll> vec(n, 0);
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
	}
	u = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			for(int k = j + 1; k < n; ++k){
				int a = vec[i];
				int b = vec[j];
				int c = vec[k];
				if(a + b > c && a + c > b && b + c > a && a ^ b && b ^ c && a ^ c)u++; 
			}
		}
	}
	cout<<u<<endl;
	return 0;
}


Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
#define INF 4e18
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        ll n,i,j;
        cin>>n;
        ll dp[n+1]={};
        if(n>=3)dp[3]=1;
        for(i=4;i<=n;i++)
        {
            dp[i]=1;
            for(j=3;j<i;j++)
            {
                dp[i]+=dp[i-j];
                if(dp[i]>=M)dp[i]-=M;
            }
        }
        cout<<dp[n]<<"\n";
        /*tcitr++;
    }*/
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ld x[3],y[3];
    rep(i,3)cin >> x[i] >> y[i];
    ld dis[3];
    rep(i,3){
        int temp = i;
        int temp2;
        if(i != 2)temp2 = i+1;
        else temp2 = 0;
        dis[i] = sqrt((x[temp]-x[temp2])*(x[temp]-x[temp2]) + (y[temp]-y[temp2])*(y[temp]-y[temp2]));
    }
    ld s = abs((x[0]-x[2])*(y[1]-y[2]) - (x[1]-x[2])*(y[0]-y[2])) * 0.5;
    ld r = (2.0*s)/(dis[0]+dis[1]+dis[2]);
    ld A = max(dis[0],max(dis[1],dis[2]));
    ld res = (r*A)/(2*r + A);

    cout << fixed << setprecision(15) << res << endl;
    return 0;
}

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


hights = list(map(int, input().split()))
ans = [1]*N

for i in range(0,M):
  a,b = list(map(int, input().split()))
  if hights[a-1] > hights[b-1]:
    ans[b-1] = 0
  elif hights[a-1] < hights[b-1]:
    ans[a-1] = 0
  else:
    ans[a-1] = 0
    ans[b-1] = 0

print(sum(ans))




Measured memory_bytes: 20024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int r;
  cin >> r;
  cout << (r*6.28318530717958623200) << endl;
}


Measured memory_bytes: 3764
n = gets.to_i
a = gets.split.map(&:to_i)
s = Array.new
a.each_with_index do |n, i|
  s[i] = n - i - 1
end
x = 0
s = s.sort
b = s[n/2]
s.each do |n|
  x += (n - b).abs
end

p x

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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    
        String s = br.readLine();
        
        if(s.equals("Sunny")){
            out.println("Cloudy");
        }else if(s.equals("Cloudy")){
            out.println("Rainy");
        }else{
            out.println("Sunny");
        }
         
        out.close();
        
    }
}

Measured memory_bytes: 32772
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> i_i;
 
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
 
vector<int> bfs(int N, vector<vector<int> >& G, int s) {
	vector<int> d(N, INF); d[s] = 0;
	queue<int> q; q.push(s);
	while (q.size()) {
		int u = q.front(); q.pop();
		for (int v : G[u])
			if (d[v] > d[u] + 1) {
				d[v] = d[u] + 1;
				q.push(v);
			}
	}
	return d;
}
 
int main() {
	int N; cin >> N;
	vector<vector<int> > G(N);
	rep(i, N - 1) {
		int u, v; scanf("%d%d", &u, &v);
		u--, v--;
		G[u].pb(v), G[v].pb(u);
	}
	vector<int> d1 = bfs(N, G, 0);
	vector<int> d2 = bfs(N, G, N - 1);
	int n1 = 0, n2 = 0;
	rep(u, N) if (d1[u] <= d2[u]) n1++; else n2++;
	cout << (n1 > n2 ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <map>
#include <list>
#include <queue>
#include <cstdlib>
#define INF (1000000007)
#define distance(x1,y1,x2,y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
#define rep(i,N) for(ll i=0;i<N;i++)
#define rep2(i,j,k) for(ll i=j; i<k;i++)
typedef long long int ll;
using namespace std;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vs=vector<string>;
using vvs=vector<vector<string>>;

template <typename T>
void print(T v){
    for(size_t i=0;i<v.size();i++){
        cout<<i<<": "<<v[i]<<endl;}
}

template <typename T>
void print2(T v){
    for(size_t i=0;i<v.size();i++){
        cout<<i<<": ";
        for(size_t j=0;j<v[0].size();j++){
            cout<<v[i][j]<<" ";
        }
        cout<<endl;
    }
}

template <typename T>
T slice(T v,ll left,ll right){
    T ret(0);
    copy(v.begin()+left,v.begin()+right,back_inserter(ret));
    return ret;
}

int main(){    
    string s;
    ll ans,count;
    ans=0;
    cin>>s;
    rep(i,s.size()){
        count=0;
        if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
            count++;
            rep2(j,i+1,s.size()){
                if(s[j]=='A' || s[j]=='T' || s[j]=='C' || s[j]=='G'){
                    count++;
                }
                else{
                    break;
                }
            }
        }
        if(ans<count){
            ans=count;
        }
    }
    
    cout<<ans<<endl;
            
    
    return 0;
}

Measured memory_bytes: 256
import statistics
N = int(input())
L = list(map(int,input().split( )))
f1 = [li-j for li,j in zip(L,range(1+N+1))]
b = statistics.median(f1)
if N%2 != 0:
	ans = sum([abs(li-j-b) for li,j in zip(L,range(1+N+1))])
else:
	b1 = int(b+0.5)
	b2 = int(b-0.5)
	ans1 = sum([abs(li-j-b1) for li,j in zip(L,range(1+N+1))])
	ans2 = sum([abs(li-j-b2) for li,j in zip(L,range(1+N+1))])
	ans = min(ans1,ans2)
print(ans)

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

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

    int a,b;
    // 引数の受け取り
    //
    cin >> a >> b ;
    
    if(a%3==0||b%3==0||(a+b)%3==0){
    cout << "Possible" << endl;
    
    }else{
    cout << "Impossible" << endl;
    
    }

    // 出力
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
constexpr int INF = 0x3f3f3f3f;

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

  // プラスグループ、マイナスグループ
  // +: 最初+, マイナスを引いていく
  // -: 最初-, プラスを引いていく

  // 全部+, 全部-の時は

  // 0は+扱い
  int min_plus = INF;
  int min_minus = -INF;
  int mpi, mmi;
  rep(i, 0, n) {
    if (a[i] < 0) {
      if (a[i] > min_minus) {
        min_minus = a[i];
        mmi = i;
      }
    } else {
      if (a[i] < min_plus) {
        min_plus = a[i];
        mpi = i;
      }
    }
  }

  int ans = 0;
  vector<pair<int, int>> op;
  if (min_minus == -INF) {
    rep(i, 0, n - 1) {
      if (i == mpi) continue;
      op.emplace_back(a[mpi], a[i]);
      a[mpi] -= a[i];
    }
    op.emplace_back(a[n - 1], a[mpi]);
    a[n - 1] -= a[mpi];
    cout << a[n - 1] << '\n';
  } else if (min_plus == INF) {
    op.emplace_back(a[mmi], a[n - 1]);
    a[mmi] -= a[n - 1];
    rep(i, 0, n - 1) {
      if (i == mmi) continue;
      op.emplace_back(a[mmi], a[i]);
      a[mmi] -= a[i];
    }
    cout << a[mmi] << '\n';
  } else {
    rep(i, 0, n) {
      if (i == mpi || i == mmi) continue;
      if (a[i] < 0) {
        op.emplace_back(a[mpi], a[i]);
        a[mpi] -= a[i];
      } else {
        op.emplace_back(a[mmi], a[i]);
        a[mmi] -= a[i];
      }
    }
    op.emplace_back(a[mpi], a[mmi]);
    a[mpi] -= a[mmi];
    cout << a[mpi] << '\n';
  }
  rep(i, 0, op.size()) cout << op[i].first << " " << op[i].second << '\n';
}

Measured memory_bytes: 4724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,a;
cin >> n;
for(int i=n;i>0;i--){
	a = sqrt(i);
	if(i==a*a){
		cout << i << endl;
		return 0;
	}
}
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.util.*;

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

        long H = sc.nextLong();
        long a = 2 * H;
        long ans = 0;

        for(long i=1; i<a; i*=2){
            if(H>1){
                ans += i;
                H = H / 2;
            }
            else if(H==1){
                ans += i;
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
use std::cmp;
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: i64,
        a_vec: [i64; n]
    }
    let words = ("POSSIBLE", "IMPOSSIBLE");
    let euc = |num1: i64, num2: i64| -> i64 {
        if num1 == 0 || num2 == 0 {
            return cmp::max(num1, num2);
        }
        let mut la;
        let mut mi;
        if num1 < num2 {
            la = num2;
            mi = num1;
        } else {
            la = num1;
            mi = num2;
        }
        while la % mi != 0 {
            let hold = la;
            la = mi;
            mi = hold % mi;
        }
        mi
    };
    let (euc_total, a_max) = 
        a_vec.into_iter()
        .fold((0, 0), |(total, mx), i| (euc(i, total), cmp::max(mx, i)));

    println!("{}", if k <= a_max && k % euc_total == 0 {words.0} else {words.1});
}


Measured memory_bytes: 4352
#include<stdio.h>

int sort(int R[],int n)
{
    int count=0;
    int tmp,min;
    for(int i=0;i<n-1;i++)
    {
        min=i;
        for(int j=i;j<n;j++)
        {
            if(R[j]<R[min])min=j;
        }
        tmp=R[i];
        R[i]=R[min];
        R[min]=tmp;
        if(i!=min)count++;
    }
    return count;
}

void print(int R[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(i>0)printf(" ");
        printf("%d",R[i]);
    }
    printf("\n");
}
int main()
{
    int n;
    scanf("%d",&n);
    int R[n];
    for(int i=0;i<n;i++)scanf("%d",&R[i]);
    int count=sort(R,n);
    print(R,n);
    printf("%d\n",count);
}



Measured memory_bytes: 2096
#include<iostream>
#include<algorithm>
using namespace std;
struct note{
  string s;
  int m;
  int t;
}a[10000];
bool cmp(note a,note b)
{
  if(a.s!=b.s)
    return a.s<b.s;
   if(a.m!=b.m)
    return a.m>b.m;
}
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i].s>>a[i].m;
    a[i].t=i;
  }
  sort(a+1,a+1+n,cmp);
  for(int i=1;i<=n;i++)
	cout<<a[i].t<<endl;
      return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;
const int MaxN = 1e5 + 7;
long long a[MaxN];
int n;
int main()
{
	long long ans;
	int x, y;
	cin >> n;
	for(int i = 0; i < n; i++) 
		cin >> a[i];
	sort(a, a + n);
	double m = 1.0 * a[n - 1] / 2;
	double A = 1000000001;
	for(int i = 0; i < n - 1; i++) {
		if(abs(a[i] - m) < A) {
			A = fabs(a[i] - m);
			ans = a[i];
		}
	}
	printf("%lld %lld\n", a[n-1], ans);
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int i,n,a,b;

  while (1) {
    scanf("%d %d",&a,&b);
    if (a == 0 && b == 0){
      break ;
    }
    for (i=0; i<a; i++){
      for (n=0; n<b ;n++){  
          printf("#");
        }
        printf("\n");
    }
    printf("\n");
  }
  return 0;
}
  

Measured memory_bytes: 572
#include <iostream>.
using namespace std;
int main()
{
    int a, b, temp, i;
    for(i=1; i<=3000; i++)
    {
    cin >> a >> b;
    
    if(a==0 && b==0)
       break;
       
    if(a > b)
    {
    temp = a;
    a = b ;
    b = temp;
    }

 

    cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3012
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

vector<int> rank_(0);
vector<int> parent(0);

void DisjointSet(int size){
    for(int i=0; i<size; i++){
        rank_.push_back(0);
        parent.push_back(i);
    }
}

void makeSet(int x){
    parent[x]=x;
    rank_[x]=0;
}

int findSet(int x){
    if (x!=parent[x]){
        parent[x]=findSet(parent[x]);
    }
    return parent[x];
}

bool same(int x, int y){
    return (findSet(x) == findSet(y));
}

void link(int x, int y){
    if (rank_[x] > rank_[y]){
        parent[y]=x;
    }else{
        parent[x]=y;
        if (rank_[x]==rank_[y]){
            rank_[y]+=1;
        }
    }
}

void unite(int x, int y){
    link(findSet(x), findSet(y));
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> vec(N,0);
    int ans=N;
    DisjointSet(N);

    for(int i=0; i<M; i++){
        int x,y,z;
        cin >> x >> y >> z;
        x--;y--;
        if(same(x,y))continue;
        ans--;
        unite(x,y);
    }
    cout << ans << endl;
    cin >> N;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

int main(){
    ll n;
    cin >> n;
    string ans = "";
    while(n != 0){
        if(n%2 != 0){
            n--;
            ans = "1"+ans;
        }
        else{
            ans = "0"+ans;
        }
        n /= -2;
    }
    if(ans == ""){
        ans = "0";
    }
    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = 0.0;
  for (int i = 1; i < n; i++) {
    if (v[i - 1] == 0.0) continue;
    v[i]     = ((v[i - 1] + v[i]) / 2);
    ans      = v[i];
    v[i - 1] = 0.0;
    sort(v.begin(), v.end());
    i = 0;
  }
  cout << fixed << setprecision(5) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Open(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout);
#define inl inline
#define reg register
#define i64 long long 
using namespace std;
inl int read(){int x=0,f=0;char ch=0;while(!isdigit(ch))f|=(ch=='-'),ch=getchar();while(isdigit(ch))(x*=10)+=(ch^48),ch=getchar();return f?-x:x;}
inl void Ot(reg int x){if(x<0)x=-x,putchar('-');if(x>=10)Ot(x/10);putchar(x%10+'0');}
inl void Print(reg int x,char til='\n'){Ot(x);putchar(til);}
inl int Max(reg int x,reg int y){return x>y?x:y;}
inl int Min(reg int x,reg int y){return x<y?x:y;}
inl int Abs(reg int x){return x<0?-x:x;}
const int MAXN=22;
int n,m;
char mp[MAXN][MAXN];
bool mark[MAXN][MAXN];
int mv[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
struct Node{
	int x,y;
	int step;
};
bool check(int x,int y){
	if(mark[x][y]||mp[x][y]=='#')return 0;
	if(x<1||x>n||y<1||y>m)return 0;
	return 1;
}
int bfs(int x,int y){
	queue<Node>que;
	que.push((Node){x,y,0});
	mark[x][y]=1;
	int ans=0;
	while(!que.empty()){
		Node h=que.front();
		que.pop();
		// printf("(%d %d) %d\n",h.x,h.y,h.step);
		ans=Max(ans,h.step);
		for(reg int i=0;i<4;i++){
			int nx=h.x+mv[i][0];
			int ny=h.y+mv[i][1];
			if(check(nx,ny)){
				mark[nx][ny]=1;
				que.push((Node){nx,ny,h.step+1});
			}
		}
	}
	return ans;
}
signed main(){
	n=read(),m=read();
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<=m;j++)
			cin>>mp[i][j];
	int ret=0;
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<=m;j++){
			memset(mark,0,sizeof(mark));
			if(mp[i][j]=='.')
			ret=Max(ret,bfs(i,j));
		}
	Print(ret);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
const ll INF=1e18;
int main()
{
	int n;
	cin>>n;
	ll a[200000];
	ll p4[32]; p4[0]=1;
	for(int j=1; j<32; j++) p4[j]=p4[j-1]*4;
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	ll dp[16][200001];
	for(int i=0; i<16; i++){
		dp[i][0]=i;
		fill(dp[i]+1, dp[i]+n, INF);
	}
	for(int i=1; i<n; i++){
		for(int j=0; j<16; j++){
			int t=0;
			while(a[i]*p4[j]>a[i-1]*p4[t]) t++;
			if(t<16){
				dp[j][i]=min(dp[t][i-1]+j, dp[j][i]);
			}else{
				dp[j][i]=min(dp[15][i-1]+i*(t-15)+j, dp[j][i]);
			}
		}
	}
	ll mn1[200000];
	for(int i=0; i<n; i++){
		mn1[i]=dp[0][i];
	}
	reverse(a, a+n);
	for(int i=0; i<16; i++){
		dp[i][0]=i;
		fill(dp[i]+1, dp[i]+n, INF);
	}
	for(int i=1; i<n; i++){
		for(int j=0; j<16; j++){
			int t=0;
			while(a[i]*p4[j]>a[i-1]*p4[t]) t++;
			if(t<16){
				while(dp[t][i-1]==INF) t++;
				dp[j][i]=min(dp[t][i-1]+j, dp[j][i]);
			}else{
				dp[j][i]=min(dp[15][i-1]+i*(t-15)+j, dp[j][i]);
			}
		}
	}
	ll mn2[200000];
	for(int i=0; i<n; i++){
		mn2[i]=dp[0][i];
	}
	ll ans=min(2*mn1[n-1]+n, 2*mn2[n-1]);
	for(int i=0; i<n-1; i++){
		ans=min(2*mn1[i]+2*mn2[n-2-i]+i+1, ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 29952