akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

ll string_mod(string s, ll mod)
{
    ll rest = 0;
    for (char c : s)
    {
        ll v = c - '0';
        rest = (rest * 10 + v) % mod;
    }
    return rest;
}

int main()
{
    string s;
    cin >> s;
    if (string_mod(s, 9) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

int main()
{
    int a,b;
    double t;
    cin >> a >> b >> t;
    int i=1,cnt=0;
    while(a*i<=t+0.5){
        cnt+=b;
        i++;
    }
    cout<<cnt<<endl;
    return 0;
}


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


Measured memory_bytes: 2036
#! env/bin/local python3
# -*- coding: utf-8 -*-

from itertools import combinations


def is_tri(_a, _b, _c):
    if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b):
        return True
    else:
        return False


n = int(input())
sticks = list(map(int, input().split()))

h = combinations(sticks, 3)

counter = 0
for a, b, c in h:
    if is_tri(a, b, c):
        # a, b, c = sorted([a, b, c])
        if (a != b) and (b != c) and (c != a):
            counter += 1

print(counter)


Measured memory_bytes: 9060
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int exit=0;
		
		while(exit==0){
			int m = sc.nextInt();
			if(m==0)exit=1;
			if(exit==0){
				int[] x = new int[m];
				int[] y = new int[m];
				x[0] = 0;
				y[0] = 0;
				
				for(int i=1;i<m;i++){
					int a = sc.nextInt();
					int b = sc.nextInt();
					if(b==0){
						x[i]=x[a]-1;
						y[i]=y[a];
					}else if(b==1){
						x[i]=x[a];
						y[i]=y[a]+1;
					}else if(b==2){
						x[i]=x[a]+1;
						y[i]=y[a];
					}else if(b==3){
						x[i]=x[a];
						y[i]=y[a]-1;
					}					
				}
				
				Arrays.sort(x);
				Arrays.sort(y);
				
				System.out.println((x[m-1]-x[0]+1) + " " + (y[m-1]-y[0]+1));
				
			}
		}
	}
	
}

Measured memory_bytes: 34368
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<ll> sum(n + 1);
    sum[0] = 0;
    rep(i, n){
        int a;
        cin >> a;
        sum[i + 1] = sum[i] + a;
    }
    sort(sum.begin(), sum.end());
    ll ans = 0, num = 1;
    rep(i, n){
        if(sum[i] == sum[i + 1])
            ++num;
        else{
            ans += (num - 1) * num / 2;
            num = 1;
        }
    }
    ans += (num - 1) * num / 2;
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n; cin>>n;
  int ans = 0;
  int maxh = 0;
  vector<int> h(n);
  
  for(int i=0;i<n;i++){
    cin>>h.at(i);
    maxh = max(maxh,h.at(i));
    if(h.at(i) >= maxh){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i, n) for (int i = 0; i < ( n ); ++i )
#define rep(i,n)    for (int i =0; i < ( n ); ++i )
using namespace std;
using ll = long long;
using ull = unsigned long long;
using p  = pair<int, int>;
using vec_int = vector<int>;
using vec_str = vector<string>;
#define INF (1<<29)
ll ans = 0;

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

void debug_input(vec_str& argv)
{
    // デバッグ用引数読み込み
    ifstream file("./input.txt");
    string str;
    while( getline(file, str) ) {
        argv.push_back(str);
    }
}

void debug_split_string(const string& str, vec_str& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        v.push_back(buf);
    }
}

void debug_split_int(const string& str, vec_int& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        istringstream ss(buf);
        int temp;
        ss >> temp;
        v.push_back(temp);
    }
}

int main()
{
    int N = 0;
    string S;
#if 1
	cin >> N;
#endif
#if 0
	cin >> S;
#endif
#if 0
    vec_str v(N);
    //vec_int v(N);
    rep(i, N) cin >> v[i];
#endif

#if 0
    p pp = make_pair(1, 2);
    //cout << pp.first << endl;
    //cout << pp.second << endl;
#endif

#if 0 // for debug
    vec_str argv;
    debug_input(argv);

    // 文字列行の読み込み
    vec_str v;
    debug_split_string(argv[1], v);

    // 数値行の読み込み
    //debug_split_int(argv[0], v);
#endif
        

    cout << (double)(2l * 3.14159265358979323846l * (double)N) << endl;
    
    return 0;
}

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

int main(){
	int y,m,d;
	while(cin >> y >> m >> d && (y != 0 && m != 0 && d != 0)){
		if(y < 1868) cout << "pre-meiji" << endl;
		else if(y == 1868 && m < 9) cout << "pre-meiji" << endl;
		else if(y == 1868 && m == 9 && d < 8) cout << "pre-meiji" << endl;
		else if(y < 1912) cout << "meiji" << " " << y - 1868 + 1 << " " << m << " " << d << endl;
		else if(y == 1912 && m < 7) cout << "meiji" << " " << y - 1868 + 1 << " " << m << " " << d << endl;
		else if(y == 1912 && m == 7 && d <= 29) cout << "meiji" << " " << y - 1868 + 1 << " " << m << " " << d << endl;
		else if(y < 1926) cout << "taisho" << " " << y - 1912 + 1 << " " << m << " " << d << endl;
		else if(y == 1926 && m < 12) cout << "taisho" <<  " " << y - 1912 + 1 << " " << m << " " << d << endl;
		else if(y == 1926 && m == 12 && d <= 24) cout << "taisho" << " " << y - 1912 + 1 << " " << m << " " << d << endl;
		else if(y < 1989) cout << "showa" << " " << y - 1926 + 1 << " " << m << " " << d << endl;
		else if(y == 1989 && m == 1 && d <= 7) cout << "showa" << " " << y - 1926 + 1 << " " << m << " " << d << endl;
		else cout << "heisei" <<  " " << y - 1989 + 1 << " " << m << " " << d << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();

        int[] nums = new int[10];

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        nums[a]++;
        nums[b]++;
        nums[c]++;

        for (int n: nums) {
            if (n == 2) {
                System.out.println("Yes");
                System.exit(0);
            }
        }
        System.out.println("No");
        System.exit(0);
    }
    static private class Point {
        public int x;
        public int y;
        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

typedef pair<int, int> pii;

int main(){
  int n;
  while(cin >> n and n){
    vector<pii> event;
    REP(i, n){
      string arrv, dept;
      cin >> arrv >> dept;
      int hour, minute, sec;
      hour = arrv[0] * 10 + arrv[1];
      minute = arrv[3] * 10 + arrv[4];
      sec = arrv[6] * 10 + arrv[7];
      event.push_back(make_pair(hour * 3600 + minute * 60 + sec, 1));
      hour = dept[0] * 10 + dept[1];
      minute = dept[3] * 10 + dept[4];
      sec = dept[6] * 10 + dept[7];
      event.push_back(make_pair(hour * 3600 + minute * 60 + sec, 0));
    }
    sort(ALL(event));
    int res = 0;
    int tmp = 0;
    REP(i, event.size()){
      if(event[i].second) tmp++;
      else tmp--;
      res = max(tmp, res);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3344
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, m = i_map()

    if n == 1 and m == 1:
        print(1)
    elif n == 1:
        print(m-2)
    elif m == 1:
        print(n-2)
    else:
        print(n * m - (n-1) * 2 - (m-1) * 2 )

if __name__ == '__main__':
    main()


Measured memory_bytes: 77156
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  ll s1 = a/c;
  ll s2 = b/c;
  ll t1 = a/d;
  ll t2 = b/d;
  ll u1 = a/lcm(c,d);
  ll u2 = b/lcm(c,d);
  cout <<b-a - ((s2-s1)+(t2-t1)-(u2-u1)) << '\n';
}

Measured memory_bytes: 3576
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
vec2int b(2, vecint(3, 0));
vec2int c(3, vecint(2, 0));
vec2int G(3, vecint(3, -1));
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n, k;
  string s;
  cin >> n >> k >> s;
  vecint rec;
  if (s[0] == '0') rec.push_back(0);
  REP(i, n) {
    char c = s[i];
    int tmp = 1;
    // cout << i << endl;
    while (i + 1 < n && c == s[i + 1]) {
      tmp++;
      i++;
    }
    rec.push_back(tmp);
  }
  if (s.back() == '0') rec.push_back(0);
  // REPe(e, rec) { cout << e << endl; }
  int m = rec.size();
  vecint sum(m + 1, 0);
  REP(i, m) { sum[i + 1] = sum[i] + rec[i]; }
  if (k >= m / 2) {
    cout << n << endl;
    return 0;
  }
  int ans = 0;
  REP(i, m / 2 -k+1) {
    int l = 2 * i;
    int r = l + 2 * k;
    
    ans = max(ans, sum[r + 1] - sum[l]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  ll N;
  cin >> N;
  vector<ll> A, B;
  ll temp_in;
  REP(i, 0, N+1) {
    cin >> temp_in;
    A.push_back(temp_in);
  }
  REP(i, 0, N) {
    cin >> temp_in;
    B.push_back(temp_in);
  }

  ll ans = 0;

  // 0-th town
  // ll monsters = min(A[0], B[0]);
  // A[0] = A[0] - monsters;
  // B[0] = B[0] - monsters;
  // ans += monsters;
  // cout << "monsters of " << 0 << ": " << monsters << endl;
  for(int i=0; i<N; i++) {
    ll monsters = min(A[i], B[i]);
    A[i] = A[i] - monsters;
    B[i] = B[i] - monsters;
    ans += monsters;
    ll monsters_ = min(A[i+1], B[i]);
    A[i+1] = A[i+1] - monsters_;
    B[i] = B[i] - monsters_; // not needed
    ans += monsters_;
    // cout << "monsters of " << i << ": " << monsters + monsters_ << endl;
  }
  // n-th town
  // monsters = min(A[N], B[N-1]);
  // ans += monsters;
  // cout << "monsters of " << N << ": " << monsters << endl;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
bool isPowerOfTwo(int x)
{
    return (x && !(x & (x - 1)));
}
int main()
{
     ll t,kk;
     cin>>t;
     while(true)
     {
        kk=isPowerOfTwo(t);
        if(kk==1)
        {
            cout<<t<<endl;
            return 0;
        }
        t--;
     }

}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll C[110][110];
void combi(){
	for(int n=0;n<=100;n++){
		C[n][0]=C[n][n]=1;
		for(int k=1;k<n;k++){
			C[n][k]=C[n-1][k-1]+C[n-1][k];
		}
	}
}

int main(void){
	          ll i,j;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  ll L,K;
	      	  cin >> L >> K;

	      	  combi();
	      	  ll ans=0;
	      	  for(i=0;i<=100;i++){
	      		  for(j=0;j<=100;j++){
	      			  ll c=(K+1)*i+2*j-1;
	      			  if(c>L || c<1) continue;
	      			  ans+=C[i+j][i];
	      		  }
	      	  }

	      	  cout << ans << endl;

	          return 0;
}

Measured memory_bytes: 3300
#include<stdio.h>

int main(){
	int h,w,i,j,f=0;
	char s[52][53]={0};
	for(i=0;i<52;i++){
		for(j=0;j<52;j++)s[i][j]='.';
	}
	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++){
		char t[51];
		scanf("%s",t);
		for(j=1;j<=w;j++)s[i][j]=t[j-1];
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			if(s[i][j]=='#'){
				if(s[i][j-1]=='.'
				&&s[i][j+1]=='.'
				&&s[i+1][j]=='.'
				&&s[i-1][j]=='.')f=1;
			}
		}
	}
	if(f==0)puts("Yes");
	else puts("No");
	return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, X;
    const int COIN = 500;

    cin >> K >> X;
    if (COIN * K >= X){
        cout << "Yes" << "\n";
    } 
    else {
        cout << "No" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sci3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define scs(s) scanf("%s",s)
#ifndef GET_MACRO

#define GET_MACRO(__1,__2,__3,NAME,...) NAME

#endif // GET_MACRO
#define ll long long
#define sci(...) GET_MACRO(__VA_ARGS__,sci3,sci2,sci1)(__VA_ARGS__)
#define LSB(i) ((i)&(-i))
#define mp(a,b) make_pair(a,b)
#define bit_set0(m,i) (m&(~(1<<i)))

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    double data[100];
    int n,i;
    double ans=0;
    sci(n);
    for(i=0;i<n;i++){
        scanf("%lf",&data[i]);
        ans+=1.00/data[i];
    }
    ans=1.00/ans;
    printf("%lf\n",ans);
    return 0;
}


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

using namespace std;
signed main()
{
    int n,k;
    cin>>n>>k;

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

    vector<bool> dp(k+1,0);
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=a[j] && !dp[i-a[j]])dp[i]=true;
        }
    }

    if(dp[k])cout<<"First";
    else cout<<"Second";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;
vector<vector<vector<ld>>>a(301,vector<vector<ld>>(301,vector<ld>(301,-1)));

ld sg(int x,int y,int z){
    if(x<0||y<0||z<0)return 0;
    if(a[x][y][z]!=-1)return a[x][y][z];
    //if(x==0&&y==0&&z==0)return 0;
    return a[x][y][z]=(ld)n/(x+y+z)*(1+(ld)sg(x-1,y,z)*x/n+(ld)sg(x+1,y-1,z)*y/n+(ld)sg(x,y+1,z-1)*z/n);

}
int main() {
    IOS;
    cin>>n;
    fo(i,n){
        cin>>p;
        if(p==1)x++;
        else if(p==2)y++;
        else z++;
    }
    a[0][0][0]=0;
    cout<<sg(x,y,z);
    return 0;
}



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

typedef struct{
	int x;
	int y;
} point;

int tile[20][20];
point stack[400];
int sp=0;

void stack_push(point i){
	stack[sp++]=i;
}

point stack_pop(){
	return stack[--sp];
}

int stack_empty(){
	return !sp;
}

int main()
{
    int i,j,w,h;
    point human;


    while(1){
		for(i=0;i<20;i++)
			for(j=0;j<20;j++)
				tile[i][j]='#';

		scanf("%d %d",&w,&h);
		if(w==0 && h==0)
			break;

		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				retry:
				tile[j][i]=getchar();
				if(tile[j][i]!='@' && tile[j][i]!='.' && tile[j][i]!='#')
					goto retry;
				if(tile[j][i]=='@'){
					human.x=j; human.y=i;
				}
			}
		}

		stack_push(human);
		tile[human.x][human.y]='#';

		int count=0;

		while(!stack_empty()){
			point current=stack_pop();
			point temp;

			count++;

			if(current.x+1<20 && tile[current.x+1][current.y]=='.'){
				tile[current.x+1][current.y]='#';
				temp.x=current.x+1; temp.y=current.y;
				stack_push(temp);
			}
			if(current.x-1>=0 && tile[current.x-1][current.y]=='.'){
				tile[current.x-1][current.y]='#';
				temp.x=current.x-1; temp.y=current.y;
				stack_push(temp);
			}
			if(current.y+1<20 && tile[current.x][current.y+1]=='.'){
				tile[current.x][current.y+1]='#';
				temp.x=current.x; temp.y=current.y+1;
				stack_push(temp);
			}
			if(current.y-1>=0 && tile[current.x][current.y-1]=='.'){
				tile[current.x][current.y-1]='#';
				temp.x=current.x; temp.y=current.y-1;
				stack_push(temp);
			}
		}


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

    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

inline void reset(int cnt[], int& state) {
	REP(i, 3) cnt[i] = 0;
	state = 0;
}

int main() {
	int ans = 0, cnt[3], state;
	char JOI[] = {'J', 'O', 'I'};

	reset(cnt, state);
	while (1) {
		int c = getchar();

		if (c == JOI[state]) {
			cnt[state]++;
		} else {
			if (state == 2) {
				if (cnt[1] <= min(cnt[0], cnt[2]))
					ans = max(ans, cnt[1]);
				reset(cnt, state);
			} else if (c == JOI[state + 1]) {
				state++;
			} else
				reset(cnt, state);

			if (c == JOI[state]) cnt[state]++;
		}

		if (c == '\n') break;
	}
	cout << ans << endl;

	return 0;
}

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

#define MAXCHAR 200000

int numdivide;

void func(char str[])
{
    int i = 0;
    char temp[MAXCHAR] = "";
    char compare[MAXCHAR] = "";
    char cbuff;

    while ((cbuff = str[i]) != '\0')
    {
        // compare = compare + cbuff;
        sprintf(compare,"%s%c", compare, cbuff);
        if (strcmp(temp,compare))
        {
            //printf("%s,%s\n",temp,compare);
            numdivide++;
            strcpy(temp,compare);
            compare[0] = '\0';
        }
        i++;
    }
}

int main(void)
{
    int c;
    int i = 0 ;
    char strinput[MAXCHAR];
    while ((c = getchar()) != EOF)
    {
        strinput[i] = c;
        //printf("%c",c);
        i=i+1;
    }
    // printf("%d",i);
    strinput[i] = '\0';
    func (strinput);
    printf("%d", numdivide - 1);
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin >>n;
  if(n==1){
    cout << "Yes" << endl;
    return 0;
  }
  vector<int> v(n);
  for(int i=0;i<n;++i) cin >> v[i];
  for(int i=n-1;i>0;--i)if(v[i]<v[i-1])--v[i-1];
  bool valid = true;
  for(int i=0;i<n-1;++i){
    if(v[i]>v[i+1]){
      valid = false;
      break;
    }
  }
  if(valid){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 768
import math

target = int(input())

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

primes = get_sieve_of_eratosthenes(100003)

primes = [s for s in primes if s >= target]

print(min(primes))

Measured memory_bytes: 7448
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];

    copy(a.begin(), a.end(), b.begin());
    if(prev_permutation(b.begin(), b.end())) vecout(b);
    vecout(a);
    if(next_permutation(a.begin(), a.end())) vecout(a);
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    //500円玉をa枚、 100円玉をb枚、 50 円玉をc枚
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int count = 0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if((500*i + 100*j + 50*k) == x)
                    count++;
            }
        }
    }
    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	var ans float64
	for i := 1; i <= N; i++ {
		x := math.Pow(0.5, math.Ceil(math.Log2(float64(K)/float64(i))))
		if x > 1 {
			x = 1
		}
		ans += x
	}
	fmt.Printf("%v\n", ans/float64(N))
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;

ll mpow(ll a, ll b) {
	ll res = 1;
	a %= mod;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

#define N 100010
int fac[N], finv[N];
void factorization() {
	fac[0] = finv[0] = 1;
	rep(i,1,N)fac[i] = (ll)fac[i - 1] * i % mod;
	finv[N - 1] = mpow(fac[N - 1], mod - 2);
	for (int i = N - 2; i; --i) finv[i] = (ll)finv[i + 1] * (i + 1) % mod;
}
int nCr(int n, int m){
	return (ll)((ll)fac[n] * finv[m] % mod)* finv[n - m] % mod;
}

int main() {
	factorization();
	int n;
	cin >> n;
	vector<int> a(n+1);
	rep(i,0, n+1) cin >> a[i];
	vector<int> ind(n+1, -1);
	int l, r;
	rep(i,0, n+1) {
		if (ind[a[i]] >= 0) {
			l = ind[a[i]]; r = i;
			break;
		}
		else ind[a[i]] = i;
	}
	rep(i, 1, n + 1) {
		int ans = nCr(n + 1, i);
		if (i - 1 <= n - r + l) ans -= nCr(n - r + l, i - 1);
		if (ans < 0) ans += mod;
		printf("%d\n", ans);
	}printf("1");
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    string s;
    cin >> s;

    string ans;
    for (int i = 0; i < s.size(); i++)
    {
        if (n == 0)
        {
            cout << s << endl;
            return 0;
        }
        
        char tmp = s[i];
        for (int j = 0; j < n; j++)
        {
            if ('Z' == tmp)
            {
                tmp = 'A';
                continue;
            }
    
            tmp++;
        }

        ans += tmp;
    }

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

Measured memory_bytes: 256
#include<cstdio>
const int maxn=100005;
int cnt[maxn];
bool red[maxn];
int main(){
  int n,m;scanf("%d%d",&n,&m);
  red[1]=true;
  for(int i=1;i<=n;++i)cnt[i]=1;
  for(int i=1,a,b;i<=m;++i){
    scanf("%d%d",&a,&b);
    cnt[a]--;cnt[b]++;red[b]|=red[a];
    if(cnt[a]==0)red[a]=false;
  }
  int ans=0;
  for(int i=1;i<=n;++i){
    if(red[i]&&cnt[i])ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    int dir = 0;
    bool flag[4] = {};
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R') 
        {
            dir++;
            if(dir == 4)
            {
                dir = 0;
                if(flag[1] && flag[2] && flag[3]) 
                {
                    memset(flag, false, sizeof(flag));
                    ans++;
                }
            }
            else flag[dir] = true;
        }
        if(s[i] == 'L')
        {
            dir--;
            if(dir < 0) dir = 3;
            if(dir == 0) memset(flag, false, sizeof(flag));
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,n;
ll i,j,k,ans;
int main(){
    scanf("%lld", &N);
    k= 1;
    j = 10;
    fornum(i,0,N){
        if(i+1==j){
            j *= 10;
            k =!k;
        }
        ans += k;
    }
    printf("%lld", ans);
    return 0;
}

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

int main(){

        ios::sync_with_stdio(false);
        cin.tie(0);
	
	int n;
	cin >> n;
	
	double ans= 2*M_PI*n;
	cout<<setprecision(15)<<ans<<"\n";
	


	return 0;
}


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


int Abs(int x){
	if(x<0)
		return -1*x;
	else return x;
}

int main(){
   	int N,L;
   	scanf("%d",&N);
   	scanf("%d",&L);
   	int sum=0;
   	int out = 0;
   	int temp = 0 ; 
   	int mini = 1000000000;

   	for(int i=1;i<=N;i++){
   		sum=L+i-1;
   		out += sum;

   		if(Abs(sum) < mini){\
   			temp = sum;
   			mini = Abs(sum);
   		}
   	}

   	out -= temp ; 

   	printf("%d\n", out);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ff              first
#define ss              second
#define ll              int64_t
#define ld              long double
#define nl              cout<<"\n"
#define all(v)          v.begin(),v.end()
#define mset(a,v)       memset((a),(v),sizeof(a))
#define forn(i,a,b)     for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b)     for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)        {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                 {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                   {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)         {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail> 
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
	#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
	#define dbg(...)
#endif

ll count_digits(ll n)     {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p)   {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
ll mod_inv(ll a,ll m)     {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}
/* const ll MAXN=1000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	ll a,b,c;
	cin>>a>>b>>c>>d;
	ll ans=max({a*c,b*d,a*d,b*c});
	cout<<ans<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n, d; cin >> n >> d;
    vector<vector<int>> g(n, vector<int> (d));
    for(int i = 0; i < n; i++) for(int j = 0; j < d; j++) cin >> g[i][j];


    int ans = 0;

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int score = 0;
            for(int k = 0; k < d; k++){
                score += (g[i][k] - g[j][k]) * (g[i][k] - g[j][k]);
            }

            bool flag = false;
            for(int k = 1; k <= score; k++){
                if(k * k == score) flag = true;
            }
            if(flag) ans++;
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100000],a[100000],i,j,c,n;
int f(int i)
{
	if(dp[i]!=-1)
	return dp[i];
	
	if(i+1<n && i+2<n)
	c=min(f(i+1)+abs(a[i+1]-a[i]),f(i+2)+abs(a[i+2]-a[i]));
	
	else if(i+1<n)
	c=f(i+1)+abs(a[i+1]-a[i]);
	else
	return 0;
	return dp[i]=c;
}
int main()
{cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
memset(dp,-1,sizeof(dp));
cout<<f(0);
return 0;
}



Measured memory_bytes: 2560
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));
    try{
      String[] S = br.readLine().split(" ");
      
      System.out.println(S[2]+" "+S[0]+" "+S[1]); 
    }catch(Exception e){
    }
  }
}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
    static int N = 300005;
    static int tree[];//start from 0, with all uncertain value
    //data structure: tree from 0
    //how to represent the tree node,
    //node: the segment of the
    public static void main(String[] args) {
        int n,m;
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        tree = new int[N];
        for(int i = 0; i<N; i++){
            tree[i] = 2147483647;
        }
        //make entir tree-> get the max n fir ti 2^n
        int nMax = 1;
        n = n-1;
        while(n>0){
            n = n/2;
            nMax = nMax<<1;
        }
        if(nMax==1) nMax = 2;
        //start from 0
        for(int i = 0; i<m; i++){
            int temp = 0;//decide the type of operation
            int x,y, val;
            temp = in.nextInt();
            if(temp==0){
                x = in.nextInt();
                y = in.nextInt();
                val = in.nextInt();
                update(x,y,val,0,nMax-1,0);
                /*for(int j = 0;j <=2*nMax-2;j++){
                    System.out.println(j+": "+tree[j]);
                }*/
            } else {
                x = in.nextInt();
                int res = find(x,x,0,nMax-1,0);
                System.out.println(res);
            }

        }
    }

    private static int find(int x,int y, int left, int right,int nodeId) {
        if(left>y || right<x) return -1;
        else if(left<=x && right>=y && tree[nodeId]>=0){//search range > than,could be -1
            return tree[nodeId];
        } else{
            int num1 = find(x,y,left,(left+right)/2,nodeId*2+1);
            int num2 = find(x,y,(left+right)/2+1,right,nodeId*2+2);
            return Math.max(num1,num2);
        }

    }
    //update the value
    //top down
    private static void update(int x, int y, int val, int left, int right,int nodeId) {
        //int mid = (left+right)/2;
        //when to stop: there is only one node
        //if(mid>right) return;
        if(x>right||y<left) return;//out of range
        //when to update
        //how to view this tree
        if(x<=left && y>=right){
            tree[nodeId] = val;
        }else{//update the tree//go left and right
            if(tree[nodeId] >=0){
                tree[nodeId*2+1] = tree[nodeId];
                tree[nodeId*2+2] = tree[nodeId];
                tree[nodeId] = -1;
            }
            update(x,y,val,left,(left+right)/2,nodeId*2+1);
            update(x,y,val,(left+right)/2+1,right,nodeId*2+2);
        }
    }
}



Measured memory_bytes: 119824
def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    p = list(map(int, input().split()))
    for i in range(101):
        if not x - i in p:
            print(x - i)
            return
        if not x + i in p:
            print(x + i)
            return


if __name__ == '__main__':
    resolve()


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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

// --------------------------------------

int n;
vector<pair<string, pair<int, int>>> sp;

void input()
{
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    string sEl;
    int pEl;
    cin >> sEl >> pEl;
    sp.push_back(make_pair(sEl, make_pair(pEl, i)));
  }
}

void solve()
{
  sort(sp.begin(), sp.end(), [](auto a, auto b) {
    for(int i = 0; i < min(a.first.size(), b.first.size()); i++)
    {
      if(a.first[i] < b.first[i]) return true;
      else if(a.first[i] > b.first[i]) return false;
    }
    
    return a.first.size() == b.first.size() ? a.second.first > b.second.first : a.first.size() < b.first.size();
  });

  for(const auto& elem : sp)
  {
    cout << elem.second.second + 1 << "\n";
  }
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int d;
	while(cin >> d){
		int area = 0;
		for(int i = d; i < 600; i += d){
			area += i * i * d;
		}
		cout << area << endl;
	}
}


Measured memory_bytes: 3092
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
)

func main() {

	n, m := ScanInt(), ScanInt()
	elev := ScanIntSlice(n)
	mp := make(map[int][]int)

	for i := 0; i < m; i++ {
		a, b := ScanInt(), ScanInt()
		mp[a] = append(mp[a], b)
		mp[b] = append(mp[b], a)

	}

	c := 0
	for i := 1; i <= n; i++ {
		flag := true
		for _, key := range mp[i] {
			if elev[key-1] >= elev[i-1] {
				flag = false
			}
		}
		if flag {
			c++
		}
	}
	P(c)


	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 17092
n = gets.chomp.split(" ")

stk = Array.new

n.each { |i|
	if i == "+"
	    d1 = stk.pop
	    d2 = stk.pop
		stk.push(d2 + d1)
	elsif i == "-"
	    d1 = stk.pop
	    d2 = stk.pop
		stk.push(d2 - d1)
	elsif i == "*"
	    d1 = stk.pop
	    d2 = stk.pop
		stk.push(d2 * d1)
	else
		stk.push(i.to_i)
	end
}
puts stk.pop

Measured memory_bytes: 8628
#include <iostream>
#include <bits/stdc++.h>
#define endl '\n'
#define MAXN 1000010
#define vi vector<int>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vi v1(n), v2(n);
    for(auto &x : v1){
        cin >> x;
    }
    for(auto &x : v2){
        cin >> x;
    }
    int sum = 0;
    double max = -MAXN;
    for (int i = 0; i < n; ++i) {
        double val = fabs(v1[i] - v2[i]);
        if(val > max) max = val;
        sum += val;
    }
    double sum1 = 0;
    for (int i = 0; i < n; ++i) {
        sum1 += pow(v1[i] - v2[i], 2);
    }
    double sum2 = 0;
    for (int i = 0; i < n; ++i) {
        sum2 += pow(fabs(v1[i] - v2[i]), 3);
    }
    auto p1 = sqrt(sum1);
    auto pp = cbrt(sum2);
    double tt = (1.0/3.0);
    double p2 = pow(sum2, tt);


    printf("%.*lf\n", 6, (double)sum);
    printf("%.*lf\n", 6, p1);
    printf("%.*lf\n", 6, pp);
    printf("%.*lf\n", 6, (double)max);
    return 0;
}



Measured memory_bytes: 3448
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
  
typedef pair<int,int> P;
  
int main(void)
{
    int friends[500], n, m, a, b;
    P p;
    while (cin >> n >> m && n && m) {
        queue<int> q;
        vector<P> v;
        for (int i = 0; i < n; i++) friends[i] = 0;
        for (int i = 0; i < m; i++) {
            cin >> a >> b;
            v.push_back(P(a,b));
        }
        for (int i = 0; i < m; i++) {
            p = v[i];
            if (p.first == 1 || p.second == 1) {
                friends[p.first-1] = friends[p.second-1] = 1;
                if (p.first > 1) q.push(p.first);
                else q.push(p.second);
                v[i] = P(0,0);
            }
        }
        while (q.size()) {
            int number = q.front();
            q.pop();
            for (int j = 0; j < m; j++) {
                p = v[j];
                if (p.first == number || p.second == number) {
                    friends[p.first-1] = friends[p.second-1] = 1;
                }
            }
        }
        int ans = 0;
        for (int i = 1; i < n; i++)
            if (friends[i] > 0) ans++;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1328