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

using namespace std;

const int N=3005;
int n,m,_k;
int64_t a[N][N];
int64_t f[N][N][5];

void maximize(int64_t &x, int64_t y){
    if(x<=y) x=y;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>n>>m>>_k;
    for(int i=1; i<=_k; ++i){
        int u,v;
        int64_t c;
        cin>>u>>v>>c;
        a[u][v]=c;
    }
    memset(f,-1,sizeof(f));
    f[1][1][0]=0;
    if(a[1][1]>0) f[1][1][1]=a[1][1];
    for(int i=1; i<=n; ++i){
        for(int j=1; j<=m; ++j){
            for(int k=0; k<=3; ++k) if(f[i][j][k]!=-1){
                if(j<m){
                    maximize(f[i][j+1][k], f[i][j][k]);
                    if(a[i][j+1]>0 && k<3) maximize(f[i][j+1][k+1], f[i][j][k]+a[i][j+1]);
                }
                if(i<n){
                    maximize(f[i+1][j][0], f[i][j][k]);
                    if(a[i+1][j]>0) maximize(f[i+1][j][1], f[i][j][k]+a[i+1][j]);
                }
            }
        }
    }
    int64_t ans=*max_element(f[n][m], f[n][m]+4);
    cout<<ans<<'\n';
}


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

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n*(n-1)/2-n/2 << endl;
    for (int i=1; i<n; i++) {
        for (int k=i+1; k<=n; k++) {
            if (n%2==0) {
                if (i+k!=n+1)
                    cout << i << " " << k << endl;
            } else {
                if (i+k!=n)
                    cout << i << " " << k << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
ll N,K;
cin>>N>>K;
cout<<floor(log(N)/log(K)+1)<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a[100],b[100],count=0;
    cin>>x;
    for(int i=0;i<x;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+x);
    for(int i=0;i<x;i++)
    {
        if(a[i]!=b[i])
            count++;
    }
    if(count==0 || count==2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;



    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
M = max(a)
m = min(a)
ans = []

if m >= 0:
    for i in range(1,n):
        a[i] += a[i-1]
        ans.append((i,i+1))
else:
    if M <= 0:
        for i in range(n-1)[::-1]:
            a[i] += a[i+1]
            ans.append((i+2,i+1))
    else:
        if M > -m:
            Mi = a.index(M)
            for i in range(n):
                if a[i] < 0:
                    a[i]+=M
                    ans.append((Mi+1,i+1))
            for i in range(1,n):
                a[i] += a[i-1]
                ans.append((i,i+1))
        else:
            mi = a.index(m)
            for i in range(n):
                if a[i] > 0:
                    a[i]+=m
                    ans.append((mi+1,i+1))
            for i in range(n-1)[::-1]:
                a[i] += a[i+1]
                ans.append((i+2,i+1))

print(len(ans))
print('\n'.join([str(i)+' '+str(j) for i,j in ans]))

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

bool has_sub_seq(string s, string t) {
  int pos_s = -1;
  for (char c : t) {
    do {
      pos_s++;
      if (pos_s == s.length())
        return false;
    } while (s[pos_s] != c);
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 1000; i++) {
    string tem = to_string(i);
    while (tem.length() != 3)
      tem.insert(0, "0");
    if (has_sub_seq(s, tem)) {
      ans++;
    }
    //    cout << tem << " " << has_sub_seq(s, tem) << "\n";
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>

int main(int argc, char *argv[]) {
  std::string s;
  long k;
  std::cin >> s >> k;
  long i = 0;
  char c = s.at(0);

  if (c > '1') {
    std::cout << c << std::endl;
    return 0;
  }

  while (i + 1 < (int)s.size()) {
    if (c != '1')
      break;
    ++i;
    c = s.at(i);
  }

  if (i >= k) {
    std::cout << 1 << std::endl;
    return 0;
  }
  std::cout << s.at(i) << std::endl;
}


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

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

     map<ll, ll> cnt;
     vector<ll> mt2;

     rep(i, 0, N) {
       ll A;
       cin >> A;
       cnt[A]++;
     }

     for (pair<ll, ll> p : cnt) {
       if (p.second >= 2) mt2.push_back(p.first);
     }


     ll a, b;

     if (mt2.empty()) cout << 0 << endl;
     else {
       a = mt2.back();
       if (cnt[mt2.back()] >= 4) b = a;
       else b = mt2.at(mt2.size() - 2);
       cout << a * b << endl;
     }
 }


Measured memory_bytes: 6528
def fix(s):
  ss = str(s)
  while len(ss) < 6:
    ss = "0" + ss
  return ss

N, M = map(int, input().split())
PY = [(0,0,0)] * M
Num = [(0,0,0)] * M

for i in range (M):
    P, Y = map(int, input().split())
    PY[i] = (P, Y, i)
PY.sort()

for i in range (M):
  if PY[i-1][0] == PY[i][0]:
    Num[i] = (PY[i][2], PY[i][0], Num[i-1][2]+1)
  else:
    Num[i] = (PY[i][2], PY[i][0], 1)

Num.sort()
for i in range(M):
  print(fix(Num[i][1]) + fix(Num[i][2]))

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

using namespace std;

typedef long long ll;
const double eps=1e-6,pi=acos(-1);
const int N=1e5+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;
int n,m,a[N],b[N],c[N];
int mem[N];

int solve(int i=0){
    if(i>=n) return 1e9;
    if(i==n-1) return 0;
    int &ret=mem[i];
    if(~ret) return ret;
    ret=1e9;
    ret=min(ret,solve(i+1)+abs(a[i]-a[i+1]));
    ret=min(ret,solve(i+2)+abs(a[i]-a[i+2]));
    return ret;
}

int main(){
    //freopen("myfile.txt","w",stdout);
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%d",a+i);
    memset(mem,-1,sizeof mem);
    printf("%d",solve());
    return 0;
}


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

void solve()
{
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    ll ans = 0, ss = v.back(), mod = 1e9+7;
    for (int i = n - 2; i >= 0; --i) {
        ans = (ans + (v[i] * ss % mod)) % mod;
        ss = (ss + v[i]) % mod;
    }
    cout << ans << '\n';
}

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

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

void Add(ll &a, ll b){
    a=(a+b)%mod;
    return;
}

void Pro(ll &a, ll b){
    a=(a*b)%mod;
    return;
}

int main(){
    ll N; cin>>N;
    vec d;
    rep(i,N){
        ll x,y; cin>>x>>y;
        if(x==y) d.pb(1);
        else d.pb(0);
    }
    bool Okay=false;
    rep(i,N-2){
        if(d[i]+d[i+1]+d[i+2]==3) Okay=true;
    }
    if(Okay) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())


ans=0
for i in range(n):
    tmp=n//(i+1)
    ans+=(i+1)*tmp*(tmp+1)//2
    # print(tmp)
print(ans)

Measured memory_bytes: 68352
# 各桁の和を計算する関数
def findSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum

def main():
    N, a, b = list(map(int, input().split()))
    total = 0
    for i in range(1,N+1):
        sum = findSumOfDigits(i)
        if ((sum >= a)and(sum <= b)):
            total += i
            
    print(total)
    
if __name__ == "__main__":
    main()
    

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll mod = 1000000007;

ll powmod(ll a, ll b){
    ll ret = 1;
    ll c = a;
    while(b > 0){
        if(b % 2 == 1){
            ret *= c;
            ret %= mod;
        }

        c = (c * c) % mod;
        b /= 2;
    }

    return ret;
}


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

    vector<ll> cnt(K + 1, 100000000 * mod);
    for(ll k = K; k >= 1; k--) {
        //gcdがk以上の個数
        ll d = K / k;
        cnt[k] += powmod(d, N);
        cnt[k] %= mod;

        //cout << "k = " << k << " cnt = " << cnt[k] << " ";
        for(ll i = 1; i * i <= k; i++) {
            if(i * i == k) {
                if(i != 1) cnt[i] -= cnt[k];
            }
            else if(k % i == 0) {
                cnt[i] -= cnt[k];
                if(i != 1) {
                    cnt[k / i] -= cnt[k];
                }
            }
        }

        //cout << cnt[k] << endl;
    }

    ll ans = 0;
    for(int i = 1; i <= K; i++) {
        ans += (cnt[i] * i);
        ans %= mod;
    }

    //cout << powmod(K, N) << endl;
    //cout << sm << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3976
n,m =list(map(int,input().split()))
lis = []
max_begin = 0
min_end = n
for i in range(m):
    begin,end =list(map(int,input().split()))
    
    if begin >= max_begin:
        max_begin = begin
    if end <= min_end:
        min_end = end

if min_end-max_begin >= 0:
    print(min_end-max_begin+1)
else:
    print(0)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
	int D,N,ans=0;
	cin >> D >> N;
	ans = pow(100,D)*N;
	if(N==100)ans+=pow(100,D);
	cout << ans << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n, a, b, c, d, e;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> a >> b >> c >> d >> e;

  ll mi = min({a, b, c, d, e});

  ll ans = 5;
  ans += n / mi;
  if(n % mi == 0) ans--;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n,c,r,i;
	for(;scanf("%d",&n),n;)
	{
		int s[16][16]={0};
		for(i=1,c=n/2,r=n/2+1;i<=n*n;i++,c=(c+1)%n,r=(r+1)%n)
		{
			if(s[r][c]!=0)
				r=(r+1)%n,c=(c-1+n)%n;
			s[r][c]=i;
		}
		for(i=0;i<n*n;i++)
			printf("%4d%s",s[i/n][i%n],i%n==n-1?"\n":"");
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cfloat>
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

const int N = 100005;

int main() {
    int n, m, x, y;
    int f[N];
    set<int> s;
    while (cin >> n >> m) {
        fill(f + 1, f + n + 1, 1);
        s.clear();
        s.insert(1);
        while (m--) {
            cin >> x >> y;
            if (!s.count(x)) {
                f[x]--, f[y]++;
                continue;
            }
            if (f[x] == 1) {
                s.erase(x), s.insert(y);
                f[x]--, f[y]++;
                continue;
            }
            if (f[x] > 1) {
                f[x]--, f[y]++;
                s.insert(y);
            }
        }
        cout << SZ(s) << '\n';
    }
    return 0;
}


Measured memory_bytes: 5376
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, x, s = 0;
    cin >> n;
    vector<ll> a(n, M);
    for (ll i = 0; i + 1 < n; i++)
        cin >> x, a[i] = min(a[i], x), a[i + 1] = min(a[i + 1], x);
    for (ll e : a)
        s += e;
    cout << s;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  char b = '0';
  char w = '1';
  int res = 0;
  for(int i = 0; i < N - 1; i++){
    if(S.at(i) == S.at(i+1)){
      if(S.at(i+1) == b) S.at(i+1) = w;
      else S.at(i + 1) = b;
      res++;
    }
  }
  cout << res << endl;
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  //  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == nil ) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= 2000000000)){printf("error") ;}
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
    if ( size > 1000000 ) { printf("error"); }
  }

  
  if(!( np+nd <= 2000000)){printf("error") ;}
  if(!( nd <= 20)){printf("error") ;}
  printList();


  return 0;
}



Measured memory_bytes: 36092
if __name__ == '__main__':
    n = int(input())
    b = list(map(int, input().split()))
    ans = []
    for i in range(n):
        if (i + 1) < b[i]:
            print(-1)
            exit(0)
    for i in range(n):
        for j in range(len(b) - 1, -1, -1):
            if b[j] == (j + 1):
                ans.append(b[j])
                del b[j]
                break
        if len(b) != (n - i - 1):
            print(-1)
            exit(0)
    ans.reverse()
    for i in ans:
        print(i)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


int x;

int main()
{
	scanf("%d", &x);
	
	if ((x >= 400) && (x <= 599)) {
		printf("8\n");
	} else if ((x >= 600) && (x <= 799)) {
		printf("7\n");
	} else if ((x >= 800) && (x <= 999)) {
		printf("6\n");
	} else if ((x >= 1000) && (x <= 1199)) {
		printf("5\n");
	} else if ((x >= 1200) && (x <= 1399)) {
		printf("4\n");
	} else if ((x >= 1400) && (x <= 1599)) {
		printf("3\n");
	} else if ((x >= 1600) && (x <= 1799)) {
		printf("2\n");
	} else if ((x >= 1800) && (x <= 1999)) {
		printf("1\n");
	}
	
	return 0;
}



Measured memory_bytes: 1660
fun main(arr:Array<String>) {
    val (n,x) = readLine()!!.split(" ").map { it.toLong() }
    val boxes = readLine()!!.split(" ").map { it.toLong() }.toMutableList()

    var ans = 0L
    var rm = Math.max(0, (boxes.last() + boxes[boxes.lastIndex-1])-x)
    ans += rm
    if(boxes[boxes.lastIndex-1] >= rm) {
        boxes[boxes.lastIndex-1] -= rm
    } else {
        rm -= boxes[boxes.lastIndex-1]
        boxes[boxes.lastIndex] -= rm
        boxes[boxes.lastIndex-1] = 0
    }
    rm = Math.max(0, (boxes[0] + boxes[1])-x)
    ans += rm
    if(boxes[1] >= rm) {
        boxes[1] -= rm
    } else {
        rm -= boxes[1]
        boxes[0] -= rm
        boxes[1] = 0
    }

    for(i in (1..boxes.lastIndex-1)) {
        rm = Math.max(0,(boxes[i] + boxes[i+1])-x)
        ans += rm
        if(boxes[i+1] >= rm) {
            boxes[i+1] -= rm
        } else {
            rm -= boxes[i+1]
            boxes[i] -= rm
            boxes[i+1] = 0
        }
    }
    println(ans)
}

Measured memory_bytes: 69668
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[n-r]);}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var k = next();
  var s = nextstr(), m = s.length;
  var n = k+m;
  fset(n);
  var ans = 0, x = 1;
  for(var i = 0; i <= k; i++){
    ans += mul(ncr(n,i),x);
    x = x*25 % mod;
  }
  return mput(ans);
}

Measured memory_bytes: 112884
n, m = map(int, input().split())
s = 0
if n%2 == 1:
    for i in range(1, m+1):
        s = 2*m+1-i
        print(str(i) + ' ' + str(s))
elif n%2 == 0:
    for i in range(1, m//2 +1):
        s = 2*m+2-i
        print(str(i) + ' ' + str(s))
    for i in range(m//2 +1, m+1):
        s = 2*m+1-i
        print(str(i) + ' ' + str(s))

Measured memory_bytes: 69160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;



signed main(){
	int N;
	cin>>N;
	vector<int>a(N);
	REP(i,N)cin>>a[i];
	int ans = 0;
	REP(i,N)FOR(j,i+1,N){
		if(i==j)continue;
		ans+=a[i]*a[j];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long K;
  cin >> K;
  long ans = 0;
  for(long i = 1; i <= K; i++){
    for(long j = 1; j <= K; j++){
      for(long k = 1; k <= K; k++){
        ans += gcd(i, gcd(j, k));
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int INF = 1 << 25;

class BIT {
public:
    // 要素数N、値vで初期化
    explicit BIT(int N, int v) : V_NUM(N) {
        data.resize(N);
        fill(data.begin(), data.end(), v);
    }

    // [1, i]の総和を求める
    int query(int i) {
        int ret = 0;
        while (i > 0) {
            ret += data[i];
            i -= (i & -i);
        }
        return ret;
    }

    // data[i]にv可算
    void update(int i, int v) {
        while (i < V_NUM) {
            data[i] += v;
            i += (i & -i);
        }
    }

    int V_NUM;
    vector<int> data;
};

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

    int a[N * 2];
    char c[N * 2];
    for (int i = 0; i < N * 2; ++i) {
        cin >> c[i] >> a[i];
    }

    int ww[N + 1], bb[N + 1];
    ww[0] = bb[0] = 0;
    // ww[i] = 白iより手前にある白i+xの数(x > 0)

    int wb[N + 1][N + 1], bw[N + 1][N + 1];
    fill(wb[0], wb[0] + N + 1, 0);
    fill(bw[0], bw[0] + N + 1, 0);
    // wb[i][j] = 白iより手前にある黒j+xの数(x > 0)

    BIT white(N + 1, 0), black(N + 1, 0);
    // white[i] = 白i以下がいくつ出てきたか

    for (int i = 0; i < N * 2; ++i) {
        if (c[i] == 'W') {
            ww[a[i]] = white.query(N) - white.query(a[i]);
            wb[a[i]][0] = black.query(N);
            for (int j = 1; j <= N; ++j) {
                wb[a[i]][j] = black.query(N) - black.query(j);
            }
            white.update(a[i], 1);
        } else {
            bb[a[i]] = black.query(N) - black.query(a[i]);
            bw[a[i]][0] = white.query(N);
            for (int j = 1; j <= N; ++j) {
                bw[a[i]][j] = white.query(N) - white.query(j);
            }
            black.update(a[i], 1);
        }
    }

    int dp[N + 1][N + 1];
    fill(dp[0], dp[N + 1], INF);
    dp[0][0] = 0;
    // dp[w][b] = 白i、黒jを並べる最小コスト

    for (int w = 0; w <= N; ++w) {
        for (int b = 0; b <= N; ++b) {
            if (w < N) dp[w + 1][b] = min(dp[w + 1][b], dp[w][b] + ww[w + 1] + wb[w + 1][b]);
            if (b < N) dp[w][b + 1] = min(dp[w][b + 1], dp[w][b] + bb[b + 1] + bw[b + 1][w]);
        }
    }

    cout << dp[N][N] << endl;
    return 0;
}


Measured memory_bytes: 47232
#include <iostream>
using namespace std;
int main(){

  int n,k,w[100000],i;

  cin>>n>>k;
  for(i=0;i<n;i++) cin>>w[i];

  long long l=0,r=100000*10000,m;
  while(r-l>1){
    m=(l+r)/2;
    int cnt=0;
    for(int j=0;j<k;j++){
      long long s=0;
      while(s+w[cnt]<=m){
	s+=w[cnt];
	cnt++;
	if(cnt==n) break;
      }
      if(cnt==n) break;
    }

    if(cnt>=n) r=m;
    else l=m;
  }
  cout<<r<<endl;

  return 0;

}



Measured memory_bytes: 3476
#include <cstdio>

constexpr long long MOD = 1e9 + 7;

int main()
{
  long long n;
  scanf("%lld", &n);
  long long ans = 1;
  for (long long i = 1; i <= n; ++i)
  {
    ans = (ans * i) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K; cin >> N >> K;
    vector<int> H(N);
    for(auto &it : H){
        cin >> it;
    }

    sort(H.begin(), H.end(), greater<int>());

    long long ans = 0;

    for(int i=K; i<N; i++){
        ans += H.at(i);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll i,n,x,y,ans,k,a[500010],j;
int main(){
	scanf("%lld",&n);
	scanf("%lld%lld",&x,&y);
	for(i=1;i<=n;i++)
	 for(j=i+1;j<=n;j++){
	 	a[min(j-i,abs(i-x)+1+abs(j-y))]++;
	 }
	for(i=1;i<n;i++)printf("%lld\n",a[i]);
}

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

int main(){
  string s;
  cin>> s;
  int n;
  if (s=="SUN") n=7;
  else if (s=="MON") n=6;
  else if (s=="TUE") n=5;
  else if (s=="WED") n=4;
  else if (s=="THU") n=3;
  else if (s=="FRI") n=2;
  else if (s=="SAT") n=1;
  cout<< n <<endl;   
}

Measured memory_bytes: 256
S = input()
eng_list = [i for i in range(97, 123)]
for i in range(len(S)):
    for j in range(len(eng_list)):
        if ord(S[i]) == eng_list[j]:
            eng_list.pop(j)
            break
print(chr(eng_list[0])) if len(eng_list) != 0 else print("None")

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

using namespace std;

typedef long long ll;

const ll MOD1 = 998244353;
const ll MOD2 = 1000000009;
const int MX = 250005;
const ll R1 = 123123;
const ll IR1 = 981323583;
const ll R2 = 321321;
const ll IR2 = 234033881;

ll qpow(ll x, ll t, ll p)
{
	ll ans = 1;
	while(t)
	{
		if(t & 1) ans = ans*x % p;
		x = x*x % p;
		t >>= 1;
	}
	return ans;
}

ll inv(ll x, ll p)
{
	return qpow(x, p-2, p);
}

struct NUM
{
	ll x, y;

	NUM (const ll &x0 = 0, const ll &y0 = 0) : x(x0), y(y0) {}
	NUM operator + (const NUM &t) const {return NUM((x+t.x)%MOD1, (y+t.y)%MOD2);}
	NUM operator - (const NUM &t) const {return NUM((x-t.x+MOD1)%MOD1, (y-t.y+MOD2)%MOD2);}
	NUM operator * (const NUM &t) const {return NUM((x*t.x)%MOD1, (y*t.y)%MOD2);}
	bool operator == (const NUM &t) const {return x==t.x && y==t.y;}
	bool operator < (const NUM &t) const {return (x!=t.x) ? (x<t.x) : (y<t.y);}
};

int n;
char str[MX];

void input()
{
	scanf("%d", &n);
	scanf("%s", str+1);
}

NUM con[MX], sum[MX];
map<NUM, int> hav;

void work()
{
	NUM p(1, 1), t(1, 1), r(R1, R2), ir(IR1, IR2);
	for(int i=1; i<=n; i++)
	{
		if(str[i] == '+') con[i] = p;
		else if(str[i] == '-') con[i] = NUM(0, 0) - p;
		else if(str[i] == '>') p = p * r;
		else p = p * ir;
		sum[i] = sum[i-1] + con[i];
		hav[sum[i]]++;
	}
	ll ans = 0;
	for(int i=1; i<=n; i++)
	{
		ans += hav[sum[n]*t+sum[i-1]];
		if(str[i] == '>') t = t * r;
		else if(str[i] == '<') t = t * ir;
		hav[sum[i]]--;
	}
	printf("%lld\n", ans);
}

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

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
	int n;
	cin>>n;
	int a[n];
	int ans=-1;
	int c=0;
	int prev=1000000008;
	ffor(i,0,n)
	{
		int x;
		cin>>x;
		if(x<=prev)
		{
			c++;
			prev=x;
		}
		else
		{
			ans=max(ans,c);
			prev=x;
			c=1;
		}
	}
	cout<<max(ans,c)-1;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

bool tri_valid(int a, int b, int c) {
	vector<int>v{ a,b,c };
	sort(v.begin(),v.end());
	return v[2]<v[0]+v[1];
}

ld get_theta(ld a1, ld a2, ld x) {
	return (a1*a1+a2*a2-x*x)/(2*a1*a2);
}

int main() {
	cout<<setprecision(10)<<fixed;
	while (true){
		int N;cin>>N;
		if(!N)break;
		vector<int>sticks(N);
		for(int i=0;i<N;++i)cin>>sticks[i];

		vector<int>av(6);
		ld ans=0;
		for (av[0] = 0; av[0] < N; ++av[0]) {
			for ( av[1] = av[0]+1; av[1] < N; ++av[1]) {
				for ( av[2] = av[1]+1; av[2] < N; ++av[2]) {
					for (av[3] = 0; av[3] < N; ++av[3]) {
						for ( av[4] = 0; av[4] < N; ++av[4]) {
							for ( av[5] = 0; av[5] < N; ++av[5]) {
								bool ok=true;
								for (int i = 0; i < 6; ++i) {
									for (int j = i + 1; j < 6; ++j) {
										if(av[i]==av[j])ok=false;
									}
								}
								if(!ok)continue;
								vector<int>v(6);
								for(int i=0;i<6;++i)v[i]=sticks[av[i]];
								if(!tri_valid(v[0],v[1],v[2]))ok=false;
								for (int i = 0; i < 3; ++i) {
									if(!tri_valid(v[i],v[3+(i+1)%3],v[3+(i+2)%3]))ok=false;
								}
								if(!ok)continue;

								vector<ld>thetas(3);
								for (int i = 0; i < 3; ++i) {
									thetas[i]=get_theta(v[3+(i+1)%3],v[3+(i+2)%3],v[i]);
								}

								ld num=1+2*thetas[0]*thetas[1]*thetas[2]-(pow(thetas[0],2)+pow(thetas[1],2)+pow(thetas[2],2));
								if (num > 0) {
									ans=max(ans,v[3]*v[4]*v[5]*sqrt(num)/6.0);
								}
							}
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3112
n, m = map(int, input().split())
money = 0
li = []

for i in range(n):
    li.append(list(map(int, input().split())))
li.sort()

while 0 < m:
    shop = li.pop(0)
    if m < shop[1]:
        money += m * shop[0]
        break
    money += shop[0] * shop[1]
    m -= shop[1]

print(money)

# 再提出 4715718

Measured memory_bytes: 27760
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n-1);
  vector<int> ans(n);
  for(int i=0;i<n-1;i++){
    cin>>a[i];
    a[i]--;
    ans[a[i]]++;
  }
  for(int i=0;i<n;i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 4840
n, a1, a2 = map(int, input().split(" "))
anscount = [0 for i in range(n + 1)]

for i in range(1, n):
    for j in range(i + 1, n + 1):
        anscount[min(abs(j - i), abs(i - a1) + abs(j - a2) + 1, abs(i - a2) + abs(j - a1) + 1)] += 1

for i in range(1, n):
    print(anscount[i])

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

int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

int n,a,b;

int ans[3000005];

int main()
{
	n = read(), a = read(), b = read();
	if (a == 1)
	{
		if (b != n)
		{
			printf("-1\n");
			return 0;
		}
		for (int i = n; i >= 1; i--)
			printf("%d ",i);
		return 0;
	}
	int x = (n - b) / (a - 1), y = (n - b) % (a - 1);
	if (a > n || b > n || n - b < a - 1 || x + (y > 0) > b)
	{
		printf("-1\n");
		return 0;
	}
	int tot = 0, now = b;
	for (int i = b; i >= 1; i--)
		ans[++tot] = i;
	for (int i = 1; i <= y; i++)
	{
		for (int j = now + x + 1; j > now; j--)
			ans[++tot] = j;
		now += x + 1;
	}
	for (int i = 1; i <= a - 1 - y; i++)
	{
		for (int j = now + x; j > now; j--)
			ans[++tot] = j;
		now += x;
	}
	for (int i = 1; i <= n; i++)
		printf("%d ",ans[i]);
}

Measured memory_bytes: 3328
import math

N = int(input())
A = list(map(int,input().split()))

D = {}
for i in A :
    if i not in D : D[i] = 1
    else: D[i] += 1

A = sorted(A,reverse=True)
ans = 0
for i in range(N) :
    r = 2**(math.ceil(math.log2(A[i])))
    if A[i] == r :
        ans += (D[A[i]] // 2)
        D[A[i]] = 0
    else :
        b = r - A[i]
        if (D[A[i]] > 0) and (D.get(b,0) > 0) :
            ans += 1
            D[A[i]] -= 1
            D[b] -= 1
print(ans)


Measured memory_bytes: 33040
import  java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	public static void main(String[] args) {
		while(read()){
			slove();
		}
	}
	static boolean read(){
		n = sc.nextInt();
		if(n != 0) return true;

		return false;
	}
	static void slove(){
		int i = 0;
		while(n != 1){
			if(n%2 == 0){
				n = n/2;
			}else{
				n = n*3 + 1;
			}
			i++;
		}
		System.out.println(i);
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
typedef long long ll;
int f[maxn];
int T;
int n,m;
ll ans,x,y;
int main()
{
  char s[maxn];
  scanf("%s",s);
  int len=strlen(s);
  if(len%2)
  {
      printf("No\n");
      return 0;
  }
  for(int i=0;i<len;i++)
  {
      if(i%2==0&&s[i]!='h')
      {
          printf("No\n");
          return 0;
      }
      if(i%2==1&&s[i]!='i')
      {
          printf("No\n");
          return 0;
      }
  }
  printf("Yes\n");
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop,heappush
from collections import defaultdict

n,m = map(int,readline().split())
ab = list(map(int,read().split()))

if(m%2==1):
    print(-1)
    exit()

it = iter(ab)
links = [[] for _ in range(n+1)]
for a,b in zip(it,it):
    links[a].append(b)
    links[b].append(a)

depth = [-1] * (n+1)
parent = [0] * (n+1)
child = [set() for _ in range(n+1)]
hq_dep = []

stack = [1]
depth[1] = 0
# heappush(hq_dep, (0,1))
now_dep = 1
while(stack):
    stack2 = []
    while(stack):
        i = stack.pop()
        for j in links[i]:
            if(depth[j] == -1):
                depth[j] = now_dep
                parent[j] = i
                heappush(hq_dep,(now_dep*-1,j))
                stack2.append(j)
            else:
                child[j].add(i)
    now_dep += 1
    stack = stack2[::]

# 0:未定　1:done
ans = []
d = defaultdict(int)
outs = [0] * (n+1)
while(hq_dep):
    i_dep,i = heappop(hq_dep)
    for j in child[i]:
        if(d[min(i,j)*10**6 + max(i,j)] == 0):
            d[min(i,j)*10**6 + max(i,j)] = 1
            outs[j] += 1
            ans.append([j,i])
    j = parent[i]
    if(outs[i]%2==1):
        d[min(i,j)*10**6 + max(i,j)] = 1
        outs[i] += 1
        ans.append([i,j])
    else:
        d[min(i,j)*10**6 + max(i,j)] = 1
        outs[j] += 1
        ans.append([j,i])

print('\n'.join(map(lambda x: ' '.join(map(str,x)), ans)))

Measured memory_bytes: 171768
K, N = map(int,input().split())
As = list(map(int,input().split()))

dp = [0]*N
dp[0] = K-As[N-1]+As[0]

for i in range(1,N):
    dp[i] = max(dp[i-1],As[i]-As[i-1])

ans = K - max(dp)
print(ans)

Measured memory_bytes: 26436
#include <iostream>
#include <cmath>
using namespace std;
int a,b,c,d;
int main(){
    cin>>a>>b;
    c = 1;
    if(a == b)
        cout<<1<<endl;
    else{
        while(c < b){
            c = c - 1 + a;
            d++;
        }
        cout<<d<<endl;
    }
	return 0;
}

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

double solve() {
    ll N;
    cin >> N;
    vector<double> X(N), Y(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i] >> Y[i];
    }
    double f = 1;
    vector<int> ix(N);
    for ( int i = 0; i < N; i++ ) {
        ix[i] = i;
        f *= (i+1);
    }
    double s = 0;
    int c = 0;
    do {
        double t = 0;
        for ( int k = 0; k < N-1; k++ ) {
            int i = ix[k], j = ix[k+1];
            t += sqrt( (X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j]));
        }
        s += t;
        c++;
    } while ( next_permutation(ix.begin(), ix.end()));
    double ans = s / f;
    return ans;
}

int main() {
    cout.precision(15);
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int hills[10];
	int top[3] = {0,0,0};
	int i;
	char *num;
	for(i = 0;i < 10;i++)
		scanf("%d",&hills[i]);       
	
	for(i = 0;i < 10;i++)
	{
		if(hills[i] >= top[2])
		{
			top[0] = top[1];
			top[1] = top[2];
			top[2] = hills[i];
		}
		else if(hills[i] >= top[1])
		{
			top[0] = top[1];
			top[1] = hills[i];
		}
		else if(hills[i] >= top[0])					
			top[0] = hills[i];
	}
	printf("%d\n",top[2]);
	printf("%d\n",top[1]);
	printf("%d\n",top[0]);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}

int main(){

    int n, m;
    cin >> n >> m;
    int s[15][15];
    vector<int> k(m);
    vector<int> p(m);

    for(int i = 0; i < m; i++){
        cin >> k[i];
        for(int j = 0; j < k[i]; j++){
            int v;
            cin >> v;
            v--;
            s[i][j] = v;
        }
    }
    for(int i = 0; i < m; i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int t = 0; t < (1<<n); t++){
        bool flg = true;
        for(int i = 0; i < m; i++){
            int cnt = 0;
            for(int j = 0; j < k[i]; j++){
                if((t>>s[i][j]) & 1) cnt++; 
            }
            if(cnt%2 != p[i]) flg = false;
        }
        if(flg) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = 1e5 + 10;
ll num[M];
ll n , a , b;
bool cheak(ll x) {
    ll cn = a - b;
    ll gl = 0;
    for(int i = 0 ; i < n ; i++) {
        ll gg = num[i] - b * x;
        if(gg <= 0) continue;
        else {
            gl += gg / cn;
            gl += (gg % cn != 0);
            if(gl > x) return false;
        }
    }
    if(gl > x) return false;
    return true;
}
int main() {
    scanf("%lld%lld%lld" , &n , &a , &b);
    for(int i = 0 ; i < n ; i++) {
        scanf("%lld" , &num[i]);
    }
    ll l = 0 , r = 1e9;
    ll ans = r;
    while(l <= r) {
        ll mid = (l + r) >> 1;
        if(cheak(mid)) r = mid - 1 , ans = min(mid , ans);
        else l = mid + 1;
    }
    printf("%lld\n" , ans);
    return 0;
}

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

int main() {
  int n,x;
  char s[20];
  scanf("%d",&n);
  list<int>lst(0);
  for(int i = 0;i < n;i++){
    scanf("%s",s);
    if(s[0] == 'i'){
      scanf("%d",&x);
      lst.push_front(x);
    }
    else if(s[6] == 'F'){
      lst.pop_front();
    }
    else if(s[6] == 'L'){
      lst.pop_back();
    }
    else if(s[0] == 'd'){
      scanf("%d",&x);
      for(list<int>::iterator it = lst.begin();it != lst.end();it++){
        if(*it == x){
          lst.erase(it);
          break;
        }
      }
    }
  }
  int i = 0;
  for(list<int>::iterator it = lst.begin();it != lst.end();it++){
    if(i++) printf(" ");
    printf("%d",*it);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 34444
d = {}
while True:
    try:
        w, n = input().split()
        n = int(n)
        if w in d: d[w].append(n)
        else: d[w] = [n]
    except:
        for k in sorted(d):
            print(k)
            print(" ".join(map(str,sorted(d[k]))))
        break

Measured memory_bytes: 6720
import collections
N=int(input())
L=list(map(int,input().split()))
c = collections.Counter(L)
A=list(c.keys())
B=list(c.values())
R=list()
for i in range(len(A)):
  if B[i]>=2:
    R.append([A[i],B[i]])
R=sorted(R,reverse=True)
if len(R)==0:
  print(0)
  exit()
if R[0][1]>=4:
  print(R[0][0]**2)
elif len(R)<2:
  print(0)
else:
  print(R[0][0]*R[1][0])

Measured memory_bytes: 22384
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;


int main() {
    long long n, q, ans;
    ans = 0;
    cin >> n;
    vector<long long> S(n,0);
    for(int i=0; i<S.size(); i++){
        cin >> S[i];
    }
    cin >> q;
    vector<long long> T(q, 0);
    for(int i=0; i<T.size(); i++){
        cin >> T[i];
    }
    for(int i=0; i<T.size(); i++){
        for(int j=0; j<S.size(); j++){
            if(T[i]==S[j]){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 3160
using System;
using System.Numerics;
namespace ConsoleApp1123
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim().Split(' ');
            var n = BigInteger.Parse(s[0]);
            var a = BigInteger.Parse(s[1]);
            var b = BigInteger.Parse(s[2]);
            var r = n / (a + b) * a;
            var x = n % (a + b);
            if ( x <= a)
            {
                r += x;
            }
            else
            {
                r += a;
            }
            Console.WriteLine(r);
        }
    }
}


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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

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

int lucas[100];

int fnc(int x){
	if(lucas[x]>0)return lucas[x];
	else {
      return lucas[x]=fnc(x-1)+fnc(x-2);}
}

signed main(){
fill(begin(lucas),end(lucas),0);
lucas[0]=2;lucas[1]=1;
  int n;cin>>n;
  cout<<fnc(n)<<endl;
  
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
struct E {
	int from, to, cost;
	E(int a, int b, int c) {
		from = a; to = b; cost = c;
	}
	E() {};
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, l, k, a, h;
	while (cin >> n >> m >> l >> k >> a >> h, n) {
		vector<vector<E>> v(n);
		vector<bool> b(n);
		vvi d(n, vi(m + 1, INF));
	
		REP(i, l) {
			int f;
			cin >> f;
			b[f] = true;
		}
		REP(i, k) {
			int a, b, c;
			cin >> a >> b >> c;
			v[a].push_back(E(a,b,c));
			v[b].push_back(E(b,a,c));
		}
		
		d[a][m] = 0;
		REP(t, n) {
			REP(i, n) {
				if (b[i]) {
					int p = INF, c = INF;
					REP(j, m + 1) {
						if (c > d[i][j]) {
							c = d[i][j];
							p = j;
						}
					}

					FOR(j, p + 1, m + 1) {
						d[i][j] = min(d[i][j], d[i][p] + j - p);
					}
				}
				REP(j, v[i].size()) {
					REP(k, m + 1) {
						if (d[i][k] == INF)continue;
						if (k >= v[i][j].cost) {
							d[v[i][j].to][k-v[i][j].cost] = min(d[v[i][j].to][k - v[i][j].cost], d[i][k] + v[i][j].cost);
						}
					}
				}
			}
		}
	
		int ans = INF;
		REP(i, m + 1) {
			ans = min(ans, d[h][i]);
		}
		if (ans == INF)cout << "Help!" << endl;
		else cout << ans << endl;
	}
}

Measured memory_bytes: 3268
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
    int K,X;
    cin >> K >> X;
    
    string ans = "No";
    if ( K*500 >= X) ans = "Yes";
    
    // 出力
    cout << ans << endl;
    
}


Measured memory_bytes: 256