akhauriyash/Code-Regression huggingface dataset:
#ifdef __APPLE__
  #include "/Users/shizuku/Dropbox/dev/cpp/base_cmake_project_external/frankchen0130/bits/stdc++.h"
#else
  #include "bits/stdc++.h"
#endif
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  int X;
  cin >> X;

  int ans = 1;
  rep(i, 2, X+1) {
    int t = i;
    while (t * i <= X) {
      t *= i;
      chmax(ans, t);

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;


int main()
{
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    for( int i = 0; i < N; ++i ) cin >> A[i];


    vector<int> maxA(N, A[N-1]);  // max[i]: A[i] ~ A[N] のうち最大のもの
    for( int i = N-2; i >= 0; --i ) maxA[i] = max( A[i], maxA[i+1] );

    int maxDiff = 0, ans = 0; 
    for( int i = 0; i < N; ++i ) maxDiff = max( maxDiff, maxA[i] - A[i] );
    for( int i = 0; i < N; ++i ){
        if( maxA[i] - A[i] == maxDiff ) ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	string s;
	cin >> s;
	ll n = s.size(), p = 1e9 + 7;

	vector<vll> dp(13, vll(n, 0));
	if (s[n - 1] == '?') {
		for (ll i = 0; i < 10; i++) dp[i][n - 1] = 1;
	}
	else dp[s[n - 1] - '0'][n - 1] = 1;

	ll x = 10, rem;
	for (ll i = n - 2; i >= 0; i--) {
		if (s[i] == '?') {
			for (ll j = 0; j < 10; j++) {
				rem = x * j % 13;
				for (ll k = 0; k < 13; k++) {
					dp[(rem + k) % 13][i] += dp[k][i + 1];
					dp[(rem + k) % 13][i] %= p;
				}
			}
		}
		else {
			rem = x * (s[i] - '0') % 13;
			for (ll j = 0; j < 13; j++) {
				dp[(rem + j) % 13][i] = dp[j][i + 1];
				dp[(rem + j) % 13][i] %= p;
			}
		}
		x *= 10;
		x %= 13;
	}

	cout << dp[5][0] << endl;
	/*for (ll i = 0; i < 13; i++) {
		for (ll j = 0; j < n - 1; j++) cout << dp[i][j] << " ";
		cout << dp[i][n - 1] << endl;
	}*/
}


Measured memory_bytes: 11472
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int ans = -1;
    if(n >= 1 && n <= 9){
        if(k >= 1 && k <= 9){
            ans = n*k;
        }
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = b * d;
  ans = max(a * c, ans);
  ans = max(a * d, ans);
  ans = max(b * c, ans);
  cout << ans << "\n";
}


Measured memory_bytes: 3648
main :: IO ()
main = do
  s <- map snd . runLength <$> getLine
  print $ unify s

runLength :: Eq a => [a] -> [(a, Int)]
runLength = foldr step []
  where
    step x ((y, n) : ts) | x == y = (y, n + 1) : ts
    step x ts = (x, 1) : ts

unify :: [Int] -> Int
unify = (2 *) . fst . unify' . (,) 0
  where
    unify' (k, x : y : ls)
      =
        if x > y
          then
            unify'' (x - y) (k + y, ls)
          else
            unify' (k + x, (y - x) : ls)
    unify' t = t
    unify'' x0 (k, x1 : ls) = unify' (k, (x0 + x1) : ls)
    unify'' x0 (k, _) = (k, [x0])


Measured memory_bytes: 8060
//https://atcoder.jp/contests/abc134/tasks/abc134_f
#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 3;
int n,a[N],res = 0;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1;i <= n;++i)
	{
		int p;
		cin >> p;
		int vt = upper_bound(a + 1,a + res + 1,p,greater<int>()) - a;
		res = max(res,vt);
		a[vt] = p;
	}
	cout << res; 
}

Measured memory_bytes: 640
from itertools import product
from copy import deepcopy

n, m = map(int, input().split())
k = []
s = []
for j in range(m):
    a = list(map(int, input().split()))
    k.append(a[0])
    s.append(deepcopy(a[1:]))
p = list(map(int, input().split()))

ans = 0
for x in product([0,1], repeat=n):
    c = True
    for i in range(m):
        count = 0
        for j in range(k[i]):
            if x[s[i][j]-1] == 1:
                count += 1
        if count % 2 != p[i]:
            c = False
            break
    if c:
        ans += 1
print(ans)

Measured memory_bytes: 9364
// Ai - (b + i) = (Ai - i) - b = Bi - bとししてabs(Bi-b)の最小値を求める
// → Biの平均値付近を探す。(WA)
// → 中央値が最適だった
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    scanf("%d", &N);
    ll A[N];
    for(int i = 0; i < N; ++i) {
        scanf("%lld", &A[i]);
        A[i] -= i+1;
    }
    sort(A, A + N);
    ll ans = (N%2)? A[N/2] : (A[N/2-1]+A[N/2])/2;
    ll res = 0LL;
    for(int i = 0; i < N; ++i) res += abs(A[i]-ans);
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 1792
from collections import Counter

H, W, N, *AB = map(int, open(0).read().split())

move = [
    (-1, -1), (-1, 0), (-1, 1),
    (0, -1),  (0, 0),  (0, 1),
    (1, -1),  (1, 0),  (1, 1),
]

C = Counter()
for a, b in zip(*[iter(AB)] * 2):
    C.update(
        (a - i, b - j)
        for i, j in move
        if 2 <= a - i <= H - 1 and 2 <= b - j <= W - 1
    )

D = [0] * 10
for v in C.values():
    D[v] += 1

D[0] = (H - 2) * (W - 2) - len(C)
print("\n".join(map(str, D)))


Measured memory_bytes: 178260
k, s = gets.split.map(&:to_i)
ans = 0
(k + 1).times do |i|
  c1 = i
  break if c1 > s
  next if s > 2 * k + c1
  ([s - c1, k].min + 1).times do |j|
    c2 = c1 + j
    break if c2 > s
    next if s > k + c2
    ans += 1 if s - c2 <= k
  end
end
p ans


Measured memory_bytes: 1788
temp=input().split()
N=int(temp[0])
T=int(temp[1])

t=list(map(int, input().split()))

total=0
for i in range(1, N):
  if t[i]-t[i-1]<T:
    total+=(t[i]-t[i-1])
  else:
    total+=T
    
total+=T

print(total)

Measured memory_bytes: 85456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
struct point
{
  double x, y, val;
  point() {}
  point(double x, double y, double val) : x(x), y(y), val(val){};
  point(double x, double y) : x(x), y(y), val(0){};
};
bool cmp(const point &a, const point &b){
  return a.x < b.x;
}
int main()
{
ll n,ans=0 ;
cin >> n ;
vector<point> r,b;
rep(i,n){
  ll l , k ;
  cin >> l >> k ;
  r.emplace_back(l,k);
}
rep(i,n){
  ll l , k ;
  cin >> l >> k ;
  b.emplace_back(l,k);
}
sort(b.begin(),b.end(),cmp);
vector<bool> rr(n); 
rep(i,n){
  ll y=-1,ind=-1;
  rep(j,n){
    if(b[i].x>r[j].x && b[i].y>r[j].y && r[j].y>y && rr[j]==0){
      ind=j;
      y=r[j].y;
    }
  }
  if(ind!=-1){
    rr[ind]=1;
    ans++;
  }
}

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

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

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

int MOD = 2019;
int mPow(int a, int b){
    int t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return t % MOD;
}

int main(){
  cout << setprecision(10);
  string S;
  cin >> S;
  vector<int> v(S.size());
  reverse(S.begin(), S.end());

  int mod = 0;
  for(int i = 0; i < S.size(); i++){
    int num = S[i] - '0';
    // num * pow(10, i) を2019で割ったあまりがほしい
    num = num * mPow(10, i);
    num %= 2019;
    mod += num;
    v.at(i) = mod%2019;
  }
  ll ans = 0;
  map<int, int> m;
  for(auto x: v){
    if(x == 0) ans++;
    if(m.count(x) == 0){
      m[x] = 1;
    } else { 
      m[x]++;
    }
  }

  for(auto x: m){
    if(x.second >= 2 || x.first == 0){
      ans += x.second * (x.second -1) /2 ;
    }
  }
  cout << ans << endl;
  

}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int e[N+1];
    e[0] = 1;
    rep2(i, 1, N) e[i] = 2*e[i-1];
    vector<int> zero, one;
    rep(i, N){
        if((A%e[i+1])/e[i] == (B%e[i+1])/e[i]) zero.push_back(i);
        else one.push_back(i);
    }
    int n = one.size(), m = zero.size();
    if(n%2 == 0){cout << "NO" << endl; exit(0);}
    cout << "YES" << endl;
    int p[e[n]], q[e[m]];
    rep(i, n){
        p[e[i]] = i;
        if(i%2 == 1){
            rep2(j, e[i]+1, e[i+1]-1) p[j] = p[e[i+1]-j];
        }
        else{
            rep2(j, e[i]+1, e[i+1]-1){
                if(j%2 == 1) p[j] = i-1;
                else p[j] = p[(j-e[i])/2];
            }
        }
    }
    rep(i, m){
        q[e[i]] = i;
        rep2(j, e[i]+1, e[i+1]-1) q[j] = q[j-e[i]];
    }
    int now = A;
    rep2(i, 1, e[n]){
        rep2(j, 1, e[m]-1){
            cout << now << ' ';
            if(i%2 == 1) now ^= e[zero[q[j]]];
            else now ^= e[zero[q[e[m]-j]]];
        }
        cout << now << ' ';
        if(i == e[n]) break;
        now ^= e[one[p[i]]];
    }
}

Measured memory_bytes: 1024
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, readline().split()))
    if (b - a) % 2 == 0:
        print((b - a) // 2)
    else:
        print(min(a - 1, n - b) + (b - a - 1) // 2 + 1)


if __name__ == '__main__':
    solve()


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

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

    int wa = A + B;
    int sa = A - B;
    int seki = A * B;

    int max = wa;
    if (max < sa) {
        max = sa;
    }
    if (max < seki) {
        max = seki;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,'%d %d %d',$a,$b,$c);
if($c<$b){
  echo $b+$c;
  echo "\n";
}else{
  if($a+$b>=$c){
    echo $b+$c;
    echo "\n";
  }else{
    echo ($a+$b+1)+$b;
    echo "\n";
  }
}
 ?>


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

/*
    ・第i項目までの和をSiとすると、Sは正負正負・・・か負正負正
    　・・・のどちらか
    ・Siが条件を満たしている(正か負のしたい方に既になっている)
    　場合、aiを操作する必要はない(ai+1を操作することで、aiの
    　値を変えずに同じことができるため)。
    ・正負正負・・・にする場合は
    　　i%2==0 かつ S<=0 のとき S=1にする(コスト1-S)
    　　i%2==1 かつ S>=0 のとき S=-1にする(コストS+1)
    　ことをする。(余分に操作する必要はない?)
    ・負正負正・・・にする場合も同じようにできるので、両方を
    　試して小さい方が答え。
*/

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    int cost1=0,S=0;
    REP(i,N){
        S+=a[i];
        if(i%2==0 and S<=0) cost1+=1-S,S=1;
        if(i%2==1 and S>=0) cost1+=S+1,S=-1;
    }

    int cost2=0; S=0;
    REP(i,N){
        S+=a[i];
        if(i%2==0 and S>=0) cost2+=S+1,S=-1;
        if(i%2==1 and S<=0) cost2+=1-S,S=1;
    }

    cout<<min(cost1,cost2)<<endl;

}


Measured memory_bytes: 1024
import itertools
from bisect import bisect_right
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sum_a = [0] + list(itertools.accumulate(a))
sum_b = [0] + list(itertools.accumulate(b))
ans = 0
for i in range(n + 1):
    if sum_a[i] > k:
        break
    ans = max(ans, i + bisect_right(sum_b, k - sum_a[i]) - 1)
print(ans)


Measured memory_bytes: 50796
def resolve():
    from heapq import heappush, heappop

    # 長点数V、直接移動先とコストを記したリストg、スタート地点rをとって、
    # rからiに行くまでの最低コストがdist[i]であることを意味するリストdistを返す関数
    def dijkstra(V, g, r):

        dist = [INF] * V
        queue = [(0, r)]  # queueの要素(c,v)は、コストcで直接vに行けることを意味する
        dist[r] = 0  # スタート地点rにはコスト0で行ける

        while queue:
            c, v = heappop(queue)
            if dist[v] < c:  # すでに記録されているコストの方が小さいので更新不要
                continue
            for cost, t in g[v]:
                if dist[v] + cost < dist[t]:
                    dist[t] = dist[v] + cost
                    heappush(queue, (dist[t], t))

        return dist

    N,X,Y=map(int,input().split())
    V, E= N,N
    g = [[] for i in range(V)]

    for i in range(N-1):
        g[i].append((1, i+1))
        g[i+1].append((1, i))  # g[s]の要素(cost,t)はsからコストcostでtに直接行けることを意味する
        # g[s]の要素(cost,t)はsからコストcostでtに直接行けることを意味する
    g[X-1].append((1, Y-1))
    g[Y-1].append((1, X-1))

    INF = 10 ** 10
    ans = [0] * N

    for r in range(N):
        for i in dijkstra(V, g, r):
            if i<INF:
                ans[i]+=1

    for j in range(1, N):
        print(ans[j] // 2)


resolve()


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

char grid[1005][1005];
int dp[1005][1005];
const int mod = 1e9+7;

void addSelf(int &x,int y)
{
    x += y;
    if(x >= mod)
        x -= mod;
}

int main()
{
    int i,j,row,col,ans;
    cin>>row>>col;
    for(i=1 ; i<=row ; i++){
        for(j=1 ; j<=col ; j++)
            cin>>grid[i][j];
    }

    dp[1][1] = 1;
    for(i=1 ; i<=row ; i++){
        for(j=1 ; j<=col ; j++){
            if(grid[i][j] == '#')
                continue;
            addSelf(dp[i][j] , dp[i-1][j]);
            addSelf(dp[i][j] , dp[i][j-1]);
        }
    }

    ans = dp[row][col];
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 8540
n,m = map(int,input().split())
sc = [input() for _ in range(m)]
ans = -1

start = 10**(n-1)
if n == 1:
    start = 0

for i in range(start,10**n):
    i = str(i)
    ok = 0
    
    for j in sc:
        s,c = j.split()
        
        if i[int(s)-1] == c:
            ok += 1
        
    if ok == m:
        ans = int(i)
        break
        
print(ans)

Measured memory_bytes: 9156
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,C;cin>>A>>B>>C;
  int X,Y;cin>>X>>Y;
  int ans=1e9;
  for(int i=0;i<200005;i+=2){
    int tmp=0;
    int x=X,y=Y;
    x-=i/2;
    y-=i/2;
    tmp+=i*C;
    if(x>0)tmp+=A*x;
    if(y>0)tmp+=B*y;
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
if N%10 == 0:
    print('pon')
elif N%10 == 1:
    print('pon')
elif N%10 == 6:
    print('pon')
elif N%10 == 8:
    print('pon')
elif N%10 == 2:
    print('hon')
elif N%10 == 4:
    print('hon')
elif N%10 == 5:
    print('hon')
elif N%10 == 7:
    print('hon')
elif N%10 == 9:
    print('hon')
elif N%10 == 3:
    print('bon')

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int r, c; cin >> r >> c;
   char a[r+2][c+2];
   for(int i = 0; i < r+2; i++)
      for(int j = 0; j < c+2;j++)
         a[i][j] = 'x';

   for(int i = 1; i <= r; i++)
   {
      for(int j = 1; j <= c; j++)
         cin >> a[i][j];
   }

   for(int i = 1; i <= r; i++)
   {
      for(int j = 1; j <= c; j++)
      {
         int cnt = 0;
         if(a[i][j] == '.')
         {
            for(int k = i -1; k <= i+1; k++)
            {
               for(int h = j-1; h <= j+1; h++)
               {
                  if(a[k][h] == '#')
                     cnt++;
               }
            }
            a[i][j] = (char)cnt;
         }

      }
   }
   for(int i = 1; i <= r; i++)
   {
      for(int j = 1; j <= c; j++)
      {
         if(a[i][j] != '#')
            cout << (int)a[i][j];
         else
            cout << a[i][j];
      }
      cout << nl;
   }

   return 0;
}


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

int n, d=0;

int main() {
    cin >> n;
    for (int i=1; i<=n; i++){
        if (i%3==0) cout << " " << i;
        else for (int j=i; j!=0; j=j/10) {
            if (j%10 == 3 && d==0) {
                cout << " " << i;
                d++;
            }
        }
        d=0;
    }
    cout << endl;
}


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

int main() {

    int v[5];
    for (int i=0; i<5; i++) {
        cin >> v[i];
        if ( v[i]==0) {
            cout << i+1 << '\n';
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

from fractions import gcd

n = int(input())
#a = [int(i) for i in readline().split()]

if n%2: print(0)
else:
    n//= 2

    ans = 0
    while n:
        ans += n//5
        n //= 5
    
    print(ans)
    
    
    
    
    
    
    

Measured memory_bytes: 5048
n=int(input())
s=input()
p,q,r=0,1,0
for i in range(n):
    if r==0:
        if i+1<n and s[i]==s[i+1]:
            if p==0:q*=6
            elif p==1:q*=3
            else:q*=2
            r=1
            p=1
        else:
            if p==0:q*=3
            elif p==2:q*=2
            p=2
    else:
        r=0
print(q%(10**9+7))

Measured memory_bytes: 3064
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 x, y;
    std::cin >> x >> y;
    std::cout << (2*x <= y && y <= 4*x && (y%2==0) ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3648
import Data.Char
import Text.Printf

main = do
    os <- getContents
    let ss = concat $ lines os
    mapM_ (\(c,i) -> printf "%c : %d\n" c i) $ count ss

count :: String -> [(Char, Int)]
count s = map (countChar s) ['a'..'z']
  where
    countChar s c = (c, length $ filter (==c) (map toLower s))



Measured memory_bytes: 4148
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
vector<long double> calcCircleOf2Point(long double x1, long double y1,
																			 long double x2, long double y2,
																			 long double x3, long double y3) {
	long double ox, oy, a, b, c, d;
	long double r1, r2, r3;
     
	a = x2 - x1;
	b = y2 - y1;
	c = x3 - x1;
	d = y3 - y1;
     
	int stat = -1;
	vector<long double> res;
	if((a && d) || (b && c)) {
		ox = x1 +
			(d * (a * a + b * b) - b * (c * c + d * d)) / (a * d - b * c) / 2;
		if(b) {
			oy = (a * (x1 + x2 - ox - ox) + b * (y1 + y2)) / b / 2;
		} else {
			oy = (c * (x1 + x3 - ox - ox) + d * (y1 + y3)) / d / 2;
		}
		r1 = sqrt((ox - x1) * (ox - x1) + (oy - y1) * (oy - y1));
		r2 = sqrt((ox - x2) * (ox - x2) + (oy - y2) * (oy - y2));
		r3 = sqrt((ox - x3) * (ox - x3) + (oy - y3) * (oy - y3));
		long double cx = ox;
		long double cy = oy;
		long double r = (r1 + r2 + r3) / 3.0;
		stat = 0;
		res.push_back(cx);
		res.push_back(cy);
		res.push_back(r);
	}
	return res;
}
long double dist(long double x1, long double x2, long double y1,
								 long double y2) {
	return sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
/*
	vector<double> (double x1,double x2,double x3,double y1,double y2,double y3){
	double a,b;
	a=
	}
*/
     
int main() {
	int n;
	cin >> n;
	vector<long double> x(n), y(n);
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	long double ans = LLONG_MAX;
	if(n == 2) {
		cout << fixed << setprecision(20)
				 << sqrtl((x[1] - x[0]) * (x[1] - x[0]) +
									(y[1] - y[0]) * (y[1] - y[0])) /
			2.0
				 << endl;
	} else {
		//異なる3点を通る場合
		for(int i = 0; i < n - 2; i++) {
			for(int j = i + 1; j < n - 1; j++) {
				for(int k = j + 1; k < n; k++) {
					auto tmp =
						calcCircleOf2Point(x[i], y[i], x[j], y[j], x[k], y[k]);
					if(tmp.empty()) {
						continue;
					}
					bool flag = true;
					for(int p = 0; p < n; p++) {
						if(dist(x[p], tmp[0], y[p], tmp[1]) > tmp.back() + 1e-9) {
							flag = false;
							break;
						}
					}
					if(flag) {
						ans = min(ans, tmp.back());
					}
				}
			}
		}
		// 異なる2点のみ通る場合
		for(int i = 0; i < n - 1; i++) {
			for(int j = i + 1; j < n; j++) {
				long double r = dist(x[i], x[j], y[i], y[j]) / 2.0;
				long double mx = (x[i] + x[j]) / 2.0;
				long double my = (y[i] + y[j]) / 2.0;
				bool flag2 = true;
				for(int p = 0; p < n; p++) {
					if(dist(x[p], mx, y[p], my) > r + 1e-9) {
						flag2 = false;
						break;
					}
				}
				if(flag2) {
					ans = min(ans, r);
				}
			}
		}
		cout << fixed << setprecision(20) << ans << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

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

    if((S%100<13&&S/100<13)&&(S%100>0&&S/100>0)) cout << "AMBIGUOUS" << endl;
    else if(S%100<13&&S%100>0) cout << "YYMM" << endl;
    else if(S/100<13&&S/100>0) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
}

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

using namespace std;

struct Sushi {
    // 残りの寿司が1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態から寿司を全てなくすのにかかる操作回数の期待値dp[i][j][k]
    vector<vector<vector<double>>> dp;

    Sushi(int N) {
        dp.assign(N+1, vector<vector<double>>(N+1, vector<double>(N+1, -1)));
    };

    // 残りの寿司が1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態から寿司を全てなくすのにかかる操作回数の期待値f(i,j,k)
    double f(int N, int i, int j, int k) {
        if (i == 0 && j == 0 && k == 0) {
            return dp[i][j][k] = 0;
        }

        if (i+j+k > N || i < 0 || j < 0 || k < 0) {
            return 0;
        }

        // dpの値が計算済みのときその値を返す
        if (dp[i][j][k] != -1) {
            return dp[i][j][k];
        }

        double tmp = 0;

        tmp += i*f(N, i-1, j, k);
        tmp += j*f(N, i+1, j-1, k);
        tmp += k*f(N, i, j+1, k-1);
        tmp += N;
        tmp *= 1.0/(i+j+k);

        return dp[i][j][k] = tmp;
    }
};

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

    int a;
    vector<int> count(3, 0);
    for (int i = 1; i <= N; i++) {
        cin >> a;
        count[a-1]++;
    }

    Sushi sushi(N);

    cout << fixed << setprecision(10) << sushi.f(N, count[0], count[1], count[2]) << endl;
	return 0;
}

Measured memory_bytes: 219944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;

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

struct Color{
  string name;
  int R, G, B;
};

Color list[8];

void init(){
  list[0].name = "black";   list[0].R = 0x00; list[0].G = 0x00; list[0].B = 0x00;
  list[1].name = "blue";    list[1].R = 0x00; list[1].G = 0x00; list[1].B = 0xff;
  list[2].name = "lime";    list[2].R = 0x00; list[2].G = 0xff; list[2].B = 0x00;
  list[3].name = "aqua";    list[3].R = 0x00; list[3].G = 0xff; list[3].B = 0xff;
  list[4].name = "red";     list[4].R = 0xff; list[4].G = 0x00; list[4].B = 0x00;
  list[5].name = "fuchsia"; list[5].R = 0xff; list[5].G = 0x00; list[5].B = 0xff;
  list[6].name = "yellow";  list[6].R = 0xff; list[6].G = 0xff; list[6].B = 0x00;
  list[7].name = "white";   list[7].R = 0xff; list[7].G = 0xff; list[7].B = 0xff;
}

int main(void){
  init();
  string colorcode;
  while(cin >> colorcode && colorcode != "0"){
    int r = stoi(string(colorcode, 1, 2), nullptr, 16);
    int g = stoi(string(colorcode, 3, 2), nullptr, 16);
    int b = stoi(string(colorcode, 5, 2), nullptr, 16);
    int n, mind = INF;
    for(int i = 0; i < 8; i++){
      int d = (r - list[i].R) * (r - list[i].R) + (g - list[i].G) * (g - list[i].G) + (b - list[i].B) * (b - list[i].B);
      if(d < mind){
        mind = d;
        n = i;
      }
    }
    cout << list[n].name << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
n,m=map(int,input().split())
x=list(list(map(int,input().split())) for _ in range(n))

import numpy as np

y=sorted(x,key=lambda a: a[0])

cnt=0
amt=0

for i in range(n):
	if cnt+y[i][1]>=m:
		amt+=(m-cnt)*y[i][0]
		break
	else:
		cnt+=y[i][1]
		amt+=y[i][0]*y[i][1]

print(amt)

Measured memory_bytes: 38888
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define MAX 30
#define NIL -1

struct Node {int p, l, r;};		//Different meaning with rooted_tree.cpp.

Node T[MAX];
int n, D[MAX], H[MAX];


void setDepth(int u, int p)
{
	D[u] = p;
	if(T[u].r != NIL) setDepth(T[u].r, p + 1);
	if(T[u].l != NIL) setDepth(T[u].l, p + 1); 
}

int setHeight(int u)
{
	int h1 = 0, h2 = 0;
	if(T[u].r != NIL) h1 = setHeight(T[u].r) + 1;
	if(T[u].l != NIL) h2 = setHeight(T[u].l) + 1;
	
	return H[u] = max(h1, h2);
}

int getSibling(int u)
{
	if(T[u].p == NIL) return NIL;
	else if(T[T[u].p].l != u) return T[T[u].p].l;
	else if(T[T[u].p].r != u) return T[T[u].p].r;
}

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "sibling = " << getSibling(u) << ", ";
	int degree = 0;
	if(T[u].r != NIL) degree++;
	if(T[u].l != NIL) degree++;
	cout << "degree = " << degree << ", ";
	cout << "depth = " << D[u] << ", ";
	cout << "height = " << H[u] << ", ";
	
	
	if(T[u].p == NIL) cout << "root";
	else if(T[u].l == NIL && T[u].r == NIL) cout << "leaf";
	else cout << "internal node";

	cout << endl;
}

int main() 
{
	int i, l, r, root;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		T[i].p = T[i].l = T[i].r = NIL;
	}
	
	for(i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		cin >> l >> r;
		
		T[v].l = l;
		T[v].r = r;
		
		if(l != NIL) T[l].p = v;
		if(r != NIL) T[r].p = v;
	}
	
	
	
	for(i = 0; i < n; i++)
	{
		if(T[i].p == NIL) root = i;
	}
	
	setDepth(root, 0);
	setHeight(root);
	
	for(i = 0; i < n; i++) print(i);
	
//	system("pause");
	return 0;
}


Measured memory_bytes: 3080
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = 1123456789012345678;
const long MOD = 1000000007;

long n;

long power(long num1, unsigned long num2){
	if(num2 == 0){
		return 1;
	}
	if(num2 % 2 == 1){
		return num1 * power(num1, (num2-1)) % MOD;
	}
	long r = power(num1, num2/2) % MOD;
	return r*r % MOD;
}

long nglist_sub[32][4] = {
	{0, 0, 1, 2},
	{1, 0, 1, 2},
	{2, 0, 1, 2},
	{3, 0, 1, 2},
	{0, 1, 2, 0},
	{0, 1, 2, 1},
	{0, 1, 2, 2},
	{0, 1, 2, 3},
	{0, 0, 2, 1},
	{1, 0, 2, 1},
	{2, 0, 2, 1},
	{3, 0, 2, 1},
	{0, 2, 1, 0},
	{0, 2, 1, 1},
	{0, 2, 1, 2},
	{0, 2, 1, 3},
	{0, 1, 0, 2},
	{1, 1, 0, 2},
	{2, 1, 0, 2},
	{3, 1, 0, 2},
	{1, 0, 2, 0},
	{1, 0, 2, 1},
	{1, 0, 2, 2},
	{1, 0, 2, 3},
	{0, 1, 0, 2},
	{0, 1, 1, 2},
	{0, 1, 2, 2},
	{0, 1, 3, 2},
	{0, 0, 1, 2},
	{0, 1, 1, 2},
	{0, 2, 1, 2},
	{0, 3, 1, 2}
};


long nglist[32];

long dp[105][256];//past is j in 4 dig;

bool found_ng(long a){
	for(int j = 0; j < 32; j++){
		if(a == nglist[j]){
			return true;
		}
	}
	return false;
}

int main(){
	for(int i = 0; i < 32; i++){
		long res = 0;
		for(int j = 0; j < 4; j++){
			res += nglist_sub[i][j];
			res *= 4;
		}
		res /= 4;
		nglist[i] = res;
	}
	/*
	std::sort(nglist, nglist+32);
	
	std::set<long> st;
	for(int i = 0; i < 32; i++){
		printf("%ld ", nglist[i]);
		st.insert(nglist[i]);
	}
	printf("\n");
	printf("%ld\n", st.size());
	for(auto it = st.begin(); it != st.end(); it++){
		printf("%ld ", *it);
	}
	printf("\n");
	//*/
	//*
	scanf("%ld", &n);
	if(n == 3){
		printf("61\n");
		return 0;
	}
	/*
	for(int i = 0; i < 256; i++){
		if(found_ng(i)){
			dp[4][i] = 1;
		}
	}
	for(long i = 5; i <= n; i++){
		for(long j = 0; j < 256; j++){
			if(found_ng(j)){
				dp[i][j] = power(4l, i-4);
				dp[i][j] %= MOD;
				continue;
			}
			long p = j;
			p /= 4;
			for(long k = 0; k < 3; k++){
				dp[i][j] += dp[i-1][k*64 + p];
				dp[i][j] %= MOD;
			}
		}
	}
	long ans = 0;
	ans += power(4, n);
	for(long i = 0; i < 256; i++){
		ans -= dp[n][i];
		while(ans < 0){
			//printf("pass %ld\n", ans);
			ans += MOD;
		}
		ans %= MOD;
	}
	//*/
	
	//*
	for(int i = 0; i < 256; i++){
		if(found_ng(i)){
			dp[4][i] = 0;
		}else{
			dp[4][i] = 1;
		}
	}
	for(int i = 5; i <= n; i++){
		for(long j = 0; j < 256; j++){
			long p = j;
			p /= 4;
			for(long k = 0; k < 4; k++){
				dp[i][k*64 + p] += dp[i-1][j];
				dp[i][k*64 + p] %= MOD;
			}
		}
		for(int j = 0; j < 256; j++){
			if(found_ng(j)){
				dp[i][j] = 0;
			}
		}
	}
	long ans = 0;
	for(int i = 0; i < 256; i++){
		ans += dp[n][i];
		ans %= MOD;
	}
	//*/
	printf("%ld\n", ans);
	//*/
	return 0;
	
}
	


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

   
    int a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;

    return 0;
}

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n + 2);
    for (int i = 1; i <= n + 1; i++)
    {
        cin >> a[i];
    }
    vector<ll> b(n + 2);
    for (int i = 1; i <= n; i++)
    {
        cin >> b[i];
    }
    ll ans = 0;
    for (int i = n + 1; i >= 1; i--)
    {
        ll x = min(b[i], a[i]);
        ans += x;
        b[i] -= x;
        a[i] -= x;
        x = min(b[i - 1], a[i]);
        ans += x;
        b[i - 1] -= x;
        a[i] -= x;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

map<int,vector<int> > connection;
int N,M,a,b;
int main(){
    cin>>N>>M;

    REP(i,M){
        cin>>a>>b;
        a--;
        b--;
        connection[a].push_back(b);
        connection[b].push_back(a);
    }

    for(int i=0;i<connection[0].size();i++){
        int a=connection[0][i];
        debug(a);
        for(int j=0;j<connection[a].size();j++){
            debug(connection[a][j]);
            if(connection[a][j]==N-1){
                cout<<"POSSIBLE"<<endl;
                exit(0);
            }
        }
    }

    cout<<"IMPOSSIBLE"<<endl;
    



}



Measured memory_bytes: 22896
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function abmp(a,b,p);if b==0;1;elseif b%2==0;k=abmp(a,div(b,2),p);(k*k)%p;else;(a*abmp(a,b-1,p))%p;end;end;;
function binarr(n,p);z=1;for i in 1:n;z=z*i%p;end;fac=Array{Int}(n+1);inv=Array{Int}(n+1);inv[n+1]=abmp(z,p-2,p)
for i in 0:n-1;inv[n-i]=(inv[n+1-i]*(n-i))%p;end;for i in 0:n;fac[i+1]=(((z*inv[i+1])%p)*inv[n+1-i])%p;end;fac;end;
mod(a,p)=a<0?a+p:a

function main()
	p = 10^9+7
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	c = zeros(Int,n)
	d = [0,0]
	for i in 1:n+1
		if c[a[i]] == 0
			c[a[i]] = i
		else
			d[1] = c[a[i]]
			d[2] = i
			break
		end
	end
	b = binarr(n+1,p)
	l = binarr(d[1]+n-d[2],p)
	for i in 1:n+1
		if i<=d[1]+n-d[2]+1
			println(mod(b[i+1]-l[i],p))
		else
			println(b[i+1])
		end
	end
end

main()

Measured memory_bytes: 135916
/* ***********************************************
Author        :yang12138
Created Time  :2017年08月01日 星期二 00时58分00秒
File Name     :F.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)
 
const int N=2e5+10;
 
vector<int>G[N];
void add_edge(int u,int v){
	G[u].push_back(v);
}
 
bool vis[N];
vector<int>cir;
 
bool dfs(int u,int an){
	vis[u]=1;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(vis[v]){
			if(v==an){
				cir.push_back(an);
				return 1;
			}
		}
		else if(dfs(v,an)){
			cir.push_back(v);
			return 1;
		}
	}
	return 0;
}
 
int dp[N],nex[N];
bool visit[N];
void DP(int u){
	vector<int>dat;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(vis[v]) continue;
		DP(v);
		dat.push_back(dp[v]);
	}

	for(int i=0;i<dat.size();i++) visit[dat[i]]=1;
	for(int i=0;;i++){
		if(!visit[i]) {dp[u]=i;break;}
	}
	for(int i=dp[u]+1;;i++){
		if(!visit[i]) {nex[u]=i;break;}
	}
 
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(vis[v]) continue;
		visit[dp[v]]=0;
	}
}
 
int ans[N];
void solve(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int p;
		scanf("%d",&p);
		add_edge(p,i);
	}
 
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			if(dfs(i,i)) break;
		}
	}
	mem(vis,0);
	for(int i=0;i<cir.size();i++) vis[cir[i]]=1;
 
	for(int i=1;i<=n;i++){
		if(vis[i]){
			DP(i);
		}
	}
 
	/*
	for(int i=0;i<cir.size();i++) cout<<cir[i]<<' ';
	cout<<endl;
	*/
 
 
	bool flag=0;
	ans[cir[0]]=dp[cir[0]];
	for(int i=1;i<cir.size();i++){
		if(ans[cir[i-1]]==dp[cir[i]]) ans[cir[i]]=nex[cir[i]];
		else ans[cir[i]]=dp[cir[i]];
	}
	if(ans[cir[cir.size()-1]]!=dp[cir[0]]) flag=1;
 
	ans[cir[0]]=nex[cir[0]];
	for(int i=1;i<cir.size();i++){
		if(ans[cir[i-1]]==dp[cir[i]]) ans[cir[i]]=nex[cir[i]];
		else ans[cir[i]]=dp[cir[i]];
	}
	if(ans[cir[cir.size()-1]]==dp[cir[0]]) flag=1;
 
	if(flag) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	
}
 
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	solve(); 
    return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 100010;
int _w;

int n, l, a[N];

int main() {
	_w = scanf( "%d%d", &n, &l );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	for( int i = 1; i <= n-1; ++i )
		if( a[i] + a[i+1] >= l ) {
			puts("Possible");
			for( int j = 1; j < i; ++j )
				printf( "%d\n", j );
			for( int j = n-1; j > i; --j )
				printf( "%d\n", j );
			printf( "%d\n", i );
			return 0;
		}
	return puts("Impossible"), 0;
}


Measured memory_bytes: 1152
using System;

namespace V2386{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var C = sr.Next<int>(N, N);

            var res = 0L;
            for(var i = 0; i < N; i++){
                for(var j = i + 1; j < N; j++){
                    res += Math.Min(C[i][j], C[j][i]);
                }
            }

            Console.WriteLine(res);
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 10184
n = int(input())
e = [0 for _ in range(n+1)]

for i in range(2, n+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    return len(list(filter(lambda x: x >= m-1, e)))

ans = num(5) * (num(5) - 1) * (num(3) - 2) // 2 + \
      num(15) * (num(5) - 1) + \
      num(25) * (num(3) - 1) + \
      num(75)
print(ans)

Measured memory_bytes: 38512
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll num[30],ans = 1;
ll mod = 1000000007;
int main(void){
    int n;
    string s;
    cin >> n >> s;
    for(auto c:s) num[c-'a']++;
    for(int i = 0;i < 26;i++){
        ans *= (num[i]+1);
        ans %= mod;
    }
    cout << ans-1 << endl;
    return 0;
}


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


int main() {
    int A, B, C,K;
    cin >> A >> B >> C>>K;
    int U = max(A,max( B, C));
    int ans = -U+A+B+C;
    U *= pow(2, K);
    ans += U;
    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll N;
    scanf("%lld", &N);

    printf("%lf\n", N * 2 * 3.14159265358979323846);
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  lb  lower_bound
#define  ub  upper_bound
#define  F   first
#define  S   second
const int N=2e5+2;

int main()
{
    ft
    ll i,j,n,m,l,r;
    cin>>n>>m;
    cout<<ceil(n*1.0/m)<<"\n";
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
O = raw_input()
E = raw_input()

password = ''
if(len(O) == len(E)):
    for i in range(len(O)):
        password += O[i]
        password += E[i]
else:
    for i in range(len(E)):
        password += O[i]
        password += E[i]
    password += O[len(O)-1]
print(password)
    

Measured memory_bytes: 2568
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val s = sc.next()
    val k = s.length
    val winCount = s.count(_ == 'o')
    debug(s, k, winCount)

    if (winCount + (15 - k) >= 8) "YES" else "NO"
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


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

int mDist(int student, int checkpoint, vector<int> &a, vector<int> &b, vector<int> &c, vector<int> &d) {
	return abs(a[student]-c[checkpoint]) 
		 + abs(b[student]-d[checkpoint]);
}

int main() {
	int n,m; cin>>n>>m;
	vector<int> a(n), b(n), c(m), d(m);
	for (int i=0; i<n; i++)
		cin>>a[i]>>b[i];
	for (int i=0; i<m; i++)
		cin>>c[i]>>d[i];

	for (int i=0; i<n; i++) {
		int min=1000000000;
		int checkpoint=-1;
		for (int j=0; j<m; j++) {
			int dist = mDist(i,j,a,b,c,d);
			if (dist < min) {
				checkpoint = j;
				min = dist;
			}
		}
		cout << checkpoint+1 << endl;
	}

	return 0;
}

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

v = [0] * N
w = [0] * N
for i in range(N):
    v[i],w[i] = map(int,input().split())

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

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

print(max(dp[N-1]))


Measured memory_bytes: 25444
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

ll modpow(ll a,ll b,ll m){
	ll ret=1;
	while(b>0){
		if(b&1)(ret*=a)%=m;
		(a*=a)%=m;
		b>>=1;
	}
	return ret;
}

ll rev(ll a){
	return modpow(a,MOD-2,MOD);
}

int main(){
	int n; cin>>n;
	int h[100010];//h[i]=1+...+1/i
	h[1]=1;
	FOR(i,2,100001){
		h[i]=(h[i-1]+rev(i))%MOD;
	}
	ll kaijo=1;
	FOR(i,1,n+1){
		(kaijo*=i)%=MOD;
	}
	ll ans=0;
	FOR(i,0,n){
		ll a; cin>>a;
		ll b=(a*(h[i+1]+h[n-i]-1))%MOD;
		(ans+=b)%=MOD;
	}
	(ans*=kaijo)%=MOD;
	co(ans);
}


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

int main()
{
    int a=0,b,n,k,i,j,x,y;
    char word[100][11];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",word[i]);
    }
    for(i=0;i<n;i++){
        for(j=n-1;j>i;j--){
        if(strcmp(word[i],word[j])==0){
            a=1;
        }}
    }
for(i=0;i<n-1;i++){
if((word[i][(strlen(word[i]) - 1)])!=(word[i+1][0])){
            a=1;
        }
        }
    if(a==1){
    printf("No");}
    else{printf("Yes");}
    return 0;
}




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

#define int long long

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.rbegin(),v.rend());
  int ans=0,now=0;
  for(int i=1;i<n;i++){
    ans+=v[now];
    if(i&1)now++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 26
#define NIL (-1)
typedef struct {
    int parent;
    int left;
    int right;
}re;
re T[N];
int n;

void Inorder(int root);

void Postorder(int root);

void Preorder(int t){
    if(t == NIL) return ;
    printf(" %d", t);
    Preorder(T[t].left);
    Preorder(T[t].right);
}
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++) T[i].parent = T[i].left = T[i].right = NIL;
    for(int i = 0; i < n; i++){
        int parent, left, right;
        scanf("%d %d %d", &parent, &left, &right);
        T[parent].left = left;
        T[parent].right = right;
        T[left].parent = parent;
        T[right].parent = parent;
    }

    int root = 0;
    for(int i = 0; i < n; i++) if(T[i].parent == NIL) root = i;

    printf("Preorder\n");
    Preorder(root);
    printf("\n");

    printf("Inorder\n");
    Inorder(root);
    printf("\n");

    printf("Postorder\n");
    Postorder(root);
    printf("\n");
    return 0;
}

void Postorder(int t) {
    if(t == NIL) return ;
    Postorder(T[t].left);
    Postorder(T[t].right);
    printf(" %d", t);
}

void Inorder(int t) {
    if(t == NIL) return ;
    Inorder(T[t].left);
    printf(" %d", t);
    Inorder(T[t].right);
}


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

int main(){
    i64 a,b,c,d,x,y,tmp;
    cin>>a>>b>>c>>d;
    x = b/c-(a-1)/c;
    y = b/d-(a-1)/d;
    i64 r = c*d;
    if(c<d){
        tmp = c;
        c = d;
        c = tmp;
    }
 
    i64 l = c % d;
    while(l!=0){
        c = d;
        d = l;
        l = c % d;
    }
    l = r/d;
    i64 z = b/l-(a-1)/l;

    cout<<b-a+1-(x+y-z)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
     
double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}
     
void read() {};
     
template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}
     
void print() {};
     
template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int dp[1000][10001];
int h, n;
int a[1000], b[1000];

int go(int idx, int cur) {
  if(cur <= 0) return 0;
  if(idx == n) {
    if(cur > 0) return 1e8;
    else return 0;
  }
  if(dp[idx][cur] != -1) return dp[idx][cur];
  int cost = 1e9;
  cost = min(cost, go(idx + 1, cur));
  cost = min(cost, b[idx] + go(idx, cur - a[idx]));
  cost = min(cost, b[idx] + go(idx + 1, cur - a[idx]));
  return dp[idx][cur] = cost;
}

int main() {
  memset(dp, -1, sizeof dp);
  read(h, n);
  for(int i = 0; i < n; i++) {
    read(a[i], b[i]);
  }
  print(go(0, h));
}


Measured memory_bytes: 40192