akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int A[MAX], B[MAX], N, M;
bool G[MAX][MAX], visited[MAX];

bool dfs(int now){
    visited[now] = true;
    bool flag = false;
    rep(N, nex) {
        if (!visited[nex] and G[now][nex]) flag = flag or dfs(nex);
    }
    rep(N, i) if(!visited[i]) return false;
    return true;
}

void solve(void){
    int ans = 0;
    cin >> N >> M;
    rep(M, i) {
        scanf("%d %d\n", &A[i], &B[i]);
        A[i]--; B[i]--;
        G[A[i]][B[i]] = G[B[i]][A[i]] = true;
    }
    rep(M, i) {
        memset(visited, false, sizeof(visited));
        G[A[i]][B[i]] = G[B[i]][A[i]] = false;
        if (!dfs(0)) ans++;
        G[A[i]][B[i]] = G[B[i]][A[i]] = true;
    }
    cout << ans << '\n';
}

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


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

int main() {
  
  int N; cin >> N; int maxH = 0; int ans = 0;
  
  for (int i = 0; i < N; i++) {
    int h; cin >> h;
    if (maxH <= h) {
      ans++;
      maxH = h;
    }
  }
  
  cout << ans << endl;
  
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            cout<<i<<'x'<<j<<'='<<i*j<<'\n';
        }
    }
    return 0;
}

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

int main(){
   int n;
   cin>>n;
   double d;
   cin>>d;
   int ans=0;
   rep(i,n){
      double x,y;
      cin>>x>>y;
      double res=sqrt(x*x+y*y);
      if(res<=d) ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3840
def root(x):
    if x == par[x]:return x
    par[x] = root(par[x])
    return par[x]

def unite(x, y):
    x = root(x)
    y = root(y)
    if rank[x] < rank[y]: x,y = y,x
    if rank[x] == rank[y]: rank[x] += 1
    par[y] = x

def init(n):
    x = [None] * s
    for i in range(s):
        x[i] = (a[2 * i], a[2 * i + 1])
        if (a[2 * i] == a[2 * i + 1] == "0"):par[s + i] = ss
        if (a[2 * i] == a[2 * i + 1] == "1"):par[s + i] = ss + 1
    for i in range(s):
        for k in range(i + 1, s):
            if x[i] == x[k]:unite(s + i, s + k)

def union(k):
    s = 1 << k
    ss = 1 << k + 1
    x = [None] * (s)
    for l in range(s):
        x[l] = (root(ss + 2 * l), root(ss + 2 * l + 1))
        if (root(ss + 2 * l) == root(ss + 2 * l + 1)):unite(ss + 2 * l, s + l)
    for i in range(s):
        for l in range(i + 1, s):
            if x[i] == x[l]:
                if root(i) != root(l):unite(s + i, s + l)

n = int(input())
s = 1 << n - 1
ss = 1 << n 
par = [i for i in range(ss)] + [ss, ss + 1]
rank = [0] * (ss + 2)
a = input()
init(n)

for k in range(n - 2, -1, -1):union(k)

print(len(list(set(par))) - 3)


Measured memory_bytes: 5640
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <cassert>
#include <bitset>
using namespace std;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    double a , h; cin>>h>>a;
    cout<<ceil(double(h)/double(a))<<endl;
    return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    
    int total = 0;
    
    for (int i = 1; i <= N; i++) {
        total += i;
    }
    
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j]==".":
      continue
    if i>0 and s[i-1][j]=="#":
      continue
    if i <h-1 and s[i+1][j]=="#":
      continue
    if j>0 and s[i][j-1]=="#":
      continue
    if j<w-1 and s[i][j+1]=="#":
      continue
    print("No")
    exit(0)
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a,b;
  cin >> a >> b;
  cout << a+b/2 << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
data = list(map(int, input().split()))
mat = [list(map(int, input().split())) for _ in range(m)]

data.sort()
mat.sort(key=lambda x:-x[1])

idx = 0
b = False
for m in mat:
    score = m[1] 
    for _ in range(m[0]):
        if idx > n-1:
            b = True
            break
        target = data[idx]
        if target < score:
            data[idx] = score
            idx += 1
        else:
            b = True
            break
    if b: break

print(sum(data))


Measured memory_bytes: 36164
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    int n;
    while(cin>>n&&n!=-1){
        long i=0,ans=0;
        while(n){
            ans+=(n%4)*pow(10,i);
            n/=4;
            i++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include<iostream>
using namespace std;
int main(void){
  int a,b,c,d,e=0;
 cin >> a >> b >> c >> d;
  if(a < b){
    e += a;
  }else{
    e += b;
  }
  if(c < d){
    e +=c;
  }else{
    e+=d;
  }
  cout << e;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.List
import qualified Data.Vector.Unboxed as UV

a#b = abs$a-b

main = do
    [n,k] <- map read.words<$>getLine
    h <- UV.unfoldr(B.readInt.B.dropWhile(<'!'))<$>B.getLine
    print $ f n k h

f n k vh = UV.head $ foldl' p (UV.singleton 0) [1..n-1] where
    p l0 i = UV.cons x $ UV.take k l0 where
        x = minimum $ map (\j-> (vh UV.! j) # (vh UV.! i) + l0 UV.! (i-1-j)) [i-1,i-2..(max 0 (i-k))]


Measured memory_bytes: 4988
s = list(str(input()))
k = int(input())
for i in range(len(s)):
    if s[i] != "a":
        num = 26-(ord(s[i])-ord("a"))
        if k >= num:
            k -= num
            s[i] = "a"
s[-1] = chr(ord("a")+((ord(s[i])-ord("a")+k)%26))
print("".join(s))

Measured memory_bytes: 4152
N, M = map(int, input().split())
l = [[int(j) for j in input().split()] for i in range(N)]

kane = 0
count = 0

l.sort()

for i in range(N):
    if count + l[i][1] >= M:
        kane += l[i][0]*(M-count)
        break
    else:
        count += l[i][1]
        kane += l[i][0] * l[i][1]

print(kane)


Measured memory_bytes: 21604
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> a;
	 //10進数の桁数を取得
	for (ll i = 1; b < a; i++)
	{
		b += i;
		ans++;
	}
	
	cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 384
#include<cstdio>

int n;
char s[30001];
bool a[10], b[100], c[1000];

int main() {
    scanf("%d", &n);
    scanf("%s", s);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 100; j++) {
            if (b[j]) c[j * 10 + s[i] - '0'] = true;;
        }
        for (int j = 0; j < 10; j++) {
            if (a[j]) b[j * 10 + s[i] - '0'] = true;
        }
        a[s[i] - '0'] = true;
    }

    int ans = 0;
    for (int i = 0; i < 1000; i++) {
        if (c[i]) ans++;
    }

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


Measured memory_bytes: 128
IDENTIFICATION DIVISION.
PROGRAM-ID. 175A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S          PIC X(03).
01 OUT        PIC 9.
*>
PROCEDURE DIVISION.
  ACCEPT S.
*>
  EVALUATE TRUE
    WHEN S = 'RRR'
      MOVE 3 TO OUT
    WHEN S(1:2) = 'RR'OR S(2:2) = 'RR'
      MOVE 2 TO OUT
    WHEN S(1:1) = 'R' OR S(2:1) = 'R' OR S(3:1) = 'R'
      MOVE 1 TO OUT
    WHEN OTHER
      MOVE 0 TO OUT
  END-EVALUATE.
*>
  DISPLAY OUT.
  STOP RUN.


Measured memory_bytes: 3792
a = []
 5.times do |i|
   a[i] = gets.to_i
end

k = gets.to_i

check = true

for i in 0..3
  for j in (i + 1)..4

    if k < (a[i] - a[j]).abs then
      check = false
    end

  end
end

if check then
  puts "Yay!"
else
  puts ":("
end


Measured memory_bytes: 1788
def calc(y, m, d):
	ret = d
	ret += (y - 1) * 39 * 5
	ret += 5 * ((y - 1) / 3)

	for j in range(1, m):
		if y % 3 == 0:
			ret += 20
		else:
			ret += 19 + (j % 2)

	return ret

for i in range(int(raw_input())):
	print calc(1000, 1, 1) - calc(*map(int, raw_input().split()))

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

#define REP(i,n) for(int i=0;i<n;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 pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7

using namespace std;

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

bool check(int a, int b){
    if((a<=0 && b>0) || (a>=0 && b<0)) return true;
    return false;
}

int32_t main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int> x, y;
    REP(i, f){
        REP(j, f){
            if(i==0 && j==0) continue;

            int n = 100*a*i+100*b*j;
            if(n <= f){
                x.pb(n);
            }
        }
    }

    REP(i, f){
        REP(j, f){
            int m = c*i+d*j;
            if(m <= f){
                y.pb(m);
            }
        }
    }

    double ma=-INF;
    int ans1, ans2;
    REP(i, x.size()){
        REP(j, y.size()){
            int t = x[i] + y[j];
            if(t<=f){
                if(x[i]*e/100>=y[j]){
                    if(ma < (double)y[j]/((double)x[i]+(double)y[j])){
                        ans1=x[i]+y[j];
                        ans2=y[j];
                        ma = (double)y[j]/((double)x[i]+(double)y[j]);
                    }
                }
            }
        }
    }

    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 2420
def main():
    from itertools import product, zip_longest

    s = input()

    for prod in product(['+', '-'], repeat=3):
        formula = ''
        for x, op in zip_longest(s, prod, fillvalue=''):
            formula += x + op
        if eval(formula) == 7:
            print('{}=7'.format(formula))
            return


if __name__ == '__main__':
    main()


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

#define DEBUG_MSG_off

int K,X;
const int MIN = -1000000;
const int MAX =  1000000;

int main() {
  cin >> K >> X;

  int min = X-K+1;
  if (MIN > min)
    min = MIN;

  int max = X+K-1;
  if (MAX < max)
    max = MAX;

  for (int i=min;i<=max;i++) {
    cout << i << " ";
  }
  cout << "\n";

#ifdef DEBUG_MSG
  cerr << K << " " << X << "\n";
#endif
  return 0;
}

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


int main(int argc, char const *argv[])
{
    int a[5];
    for(int i=0; i < 5; i++){
        scanf("%d", &a[i]);
    }
    int k;
    scanf("%d", &k);

    if(a[4]-a[0] > k)
        printf(":(");
    else
        printf("Yay!");


    
    return 0;
} 


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

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

    double r;
    cin >> r;

    r = 2 * 3.1415926535 * r;

    printf("%.4lf\n", r);
}

Measured memory_bytes: 3796
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000

int x,n,m;

char p[BUFSIZE];

int cnt = 0 ;

/*
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
*/
int a;
int main(void){
  scanf("%d",&a);
/*
  for(int i = 0;i < ;i++){
    scanf("%",);

  }
/*  qsort(a, n, sizeof(int), compare_int);
*/
/*
for(int i = 0;i < ;i++){


}
*/
int b = a*a;
int c = a*a*a;
printf("%d",a+b+c);
return 0;

}


Measured memory_bytes: 1728
N = int(input())
H = list(map(int, input().split()))
t = True
for h0, h1 in zip(H, H[1:]):
    if t:
        if h0 == h1 + 1:
            t = False
        elif h0 > h1 + 1:
            print("No")
            break
    else:
        if h0 > h1:
            print("No")
            break
        elif h0 < h1:
            t = True
else:
    print("Yes")

Measured memory_bytes: 15020
#include <cstdio>
#include <cstring>
#include <stack>

using namespace std;

char S[101];

bool solve() {
    stack<char> ps;
    for (int i = 0; S[i]; i++) {
        switch (S[i]) {
            case '(':
                ps.push('(');
                break;
            case '[':
                ps.push('[');
                break;
            case ')':
                if (ps.empty() || ps.top() != '(') {
                    return false;
                }
                ps.pop();
                break;
            case ']':
                if (ps.empty() || ps.top() != '[') {
                    return false;
                }
                ps.pop();
                break;
        }
    }
    return ps.empty();
}

int main() {
    for (;;) {
        gets(S);
        if (strcmp(S, ".") == 0) { break; }
        printf("%s\n", solve() ? "yes" : "no");
    }
    return 0;
}

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

#define ll long long

struct nya {
    ll b;
    ll c;
};

int main() {
    ll N, M;
    cin >> N >> M;
    ll A[N + 1];
    ll A_s[N + 1];
    ll B[M + 1];
    ll C[M + 1];
    nya unko[M + 1];

    for(ll i = 1;i <= N;i++) {
        cin >> A[i];
    }
    for(ll i = 1;i <= M;i++) {
        cin >> unko[i].b >> unko[i].c;
    }

    auto cmp = [](nya a, nya b) {return a.c > b.c;};
    sort(unko + 1, unko + M + 1, cmp);
    sort(A + 1, A + N + 1);
    A_s[0] = 0;
    for(ll i = 1;i <= N;i++) {
        A_s[i] = A_s[i - 1] + A[i];
    }
    for(ll i = 1;i <= M;i++) {
        B[i] = unko[i].b;
        C[i] = unko[i].c;
    }

    ll sum = A_s[N];
    ll maxB = 0;
    for(int j = 1;j <= M;j++) {
        ll right = min(B[j] + maxB, N);
        ll left = min(maxB + 1, N);
        if(A[left] >= C[j])continue;
        if(A[right] < C[j])left = right;
        while(1 < right - left) {
            ll mid = (right + left)/2;
            if(A[mid] < C[j]) {
                left = mid;
            }else{
                right = mid;
            }
        }
        ll K = left;

        sum -= A_s[K] - A_s[maxB];
        sum += C[j]*(K - maxB);
        maxB = K;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll x;
  cin >> x;
  if(x>=30){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 3628
n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
if n != 1: 
    i = 0
    b = 0
    while i < n:
        if h[i] < b:
            ans = 'No'
            break
        b = max(b, h[i]-1)
        i += 1
print(ans)

Measured memory_bytes: 20808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
//__uint128_t

int main(){
    ll N; cin >> N;
    vector<ll> A(N); 
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    __uint128_t ans = 1;
    for(int i = 0; i < N; i++) {
        ans *= (__uint128_t)A[i];
        if(ans > (__uint128_t)(1000000000000000000)) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    cout << (ll)ans << endl;

}


Measured memory_bytes: 4056
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 17:05:33
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ok = 0;
    if (abs(a-c) <= d) ok = 1;
    else if (abs(a-b) <= d && abs(b-c) <= d) ok = 1;

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);
#define MAX (10000000)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  while(true){
    int n,m,s,g1,g2;
    n  = getInt();
    m  = getInt();
    s  = getInt();
    g1 = getInt();
    g2 = getInt();

    if(n+m+s+g1+g2 == 0) break;
    s--; g1--; g2--;

    int load[n][n];
    REP(i,n) REP(j,n) load[i][j] = MAX;
    REP(i,n) load[i][i] = 0;

    REP(i,m){
      int a = getInt()-1, b = getInt()-1;
      int c = getInt();
      load[a][b] = c;
    }

    REP(k,n) REP(i,n) REP(j,n)
      load[i][j] = min(load[i][j], load[i][k] + load[k][j]);

    int ans = INT_MAX;
    REP(i,n)
      ans = min(ans, load[s][i] + load[i][g1] + load[i][g2]);

    print(ans);
  }
  return 0;
}

Measured memory_bytes: 872
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int>v(m);
    for(auto& e : v) cin >> e;
    int ans = 0;
    rep(i,n){
        int res = 0;
        rep(j,m){
            int t; cin >> t;
            res += t*v[j];
        }
        if(res +c > 0)++ans;
        }
    cout << ans << endl;
    
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll N;
    cin >> N;
    ll a = 0;
    ll w = 0;
    ll t = 0;
    ll r = 0;
    rep(i,N){
        string S;
        cin >> S;
        if(S=="AC") a++;
        else if(S=="WA") w++;
        else if(S=="TLE") t++;
        else r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
    return 0;
}



Measured memory_bytes: 3600
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val n = StdIn.readInt()
    var maxv = Int.MinValue
    var minv = Int.MaxValue

    for(i <- 0 to n - 1){
      val num = readInt()
      maxv = List(maxv,num - minv).max
      minv = List(minv,num).min
    }
    println(maxv)
  }
}

Measured memory_bytes: 129412
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100002
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);
  int x[MAX] = {0};
  rep(i, 1, n+1) scanf("%d", &x[i]);

  int sum = 0;
  rep(i, 0, n+1) { sum += abs(x[i+1] - x[i]); }

  int sub;
  rep(i, 1, n+1) {
    sub = abs(x[i+1]- x[i]) + abs(x[i] - x[i-1]) - abs(x[i+1] - x[i-1]);
    printf("%d\n", sum - sub);
  }
  
  return 0;
}


Measured memory_bytes: 1536
/* Shivam Sharma
	`They call me Hei$enBerg (~_^)`
	ABV-Indian Institute of Information Technology and Management, Gwalior
	*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector< vector<ll> > vvi;
typedef pair<ll,ll> pii;
typedef map<string,ll> msi;
typedef set<ll> si;
typedef vector< pair<ll,ll> > vpii;


#define T() 	ll t;	cin>>t;		while(t--)
#define p_b		 push_back
#define p_f 		push_front
#define pop_b 		pop_back()
#define pop_f 		pop_front()
#define m_p		make_pair
#define l_b(v,l)     lower_bound (v.begin(), v.end(), l)
#define u_b(v,l)   	 upper_bound (v.begin(), v.end(), l)
#define min_pos(a)		 min_element(a.begin(),a.end())-a.begin()
#define max_pos(a) 		 max_element(a.begin(),a.end())-a.begin()
#define min_el(a) 		 *min_element(a.begin(),a.end())
#define max_el(a)		 *max_element(a.begin(),a.end())
#define cnt(a,l) 		 count(a.begin(),a.end(),l)
#define sort_a(a) 		 sort(a.begin(),a.end())
#define sort_d(a) 		 sort(a.begin(),a.end(),greater<ll>() )
#define summ(a)  	 accumulate(a.begin(),a.end(),0)
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(x) x.begin(),x.end()
#define mod  1000000007
#define inf      1e9
#define FF first
#define SS second
#define rep(i,a,b)      for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrep(i,a,b)      for(ll i=(ll)(a);i>=(ll)(b);i--)
#define mset(a,b)    	memset(a,b,sizeof(a));
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
///==========INPUT=============///
	#define     sc(a)           scanf("%lld",&a);
	#define     sc2(a,b)        scanf("%lld%lld",&a,&b);
	#define     sc3(a,b,c)      scanf("%lld%lld%lld",&a,&b,&c);
	#define     sc4(a,b,c,d)    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
///==========PRINTING=============///
	#define     prarr(arr)      rep(i,0,sizeof(arr)/sizeof(ll)) cout<<arr[i]<<" "; nl
	#define     prvec(v)        rep(i,0,v.size()) cout<<v[i]<<" "; nl
	#define     pr(x)           cout<<x<<"\n";
	#define     pr2(x, y)       cout<<x<<" "<<y<<"\n";
	#define     pr3(x, y, z)    cout<<x<<" "<<y<<" "<<z<<"\n";
///==========DEBUGGING=============///
    #define 	debug(a) 		cout<<"*"<<a<<endl;
   	#define 	debug2(a,b) 	cout<<"$"<<a<<" "<<b<<endl;
   	#define 	debug3(a,b,c) 	cout<<"$"<<a<<" "<<b<<" "<<c<<endl;
	#define 	bug 			cout<<"#"<<endl;
   	#define 	nl 				cout<<'\n';
   //	#define     endl            '\n'
   
ll powermod(ll _a,ll _b,ll _m)	{ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
   
int main()
{
	ll n,m;
	cin>>n>>m;
	ll t=n*3+m;
	cout<<t/2;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
	int n,min;
	cin >> n;
	string S[n];
	int count[n][26]={};
	int i,j,flag,temp;
	for(i=0;i<n;i++)cin >> S[i];
	for(i=0;i<n;i++){
		temp = S[i].size();
		for(j=0;j<temp;j++){
			count[i][S[i][j]-'a']++;
		}
	}
	for(j=0;j<26;j++){
		min = 51;
		for(i=0;i<n;i++){
			min = std::min(min,count[i][j]);
		}
		for(i=0;i<min;i++){
			printf("%c",j+'a');
		}
	}
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/29  Problem: 081_arc_a / Link: https://arc081.contest.atcoder.jp/tasks/arc081_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}

	SORT(a);
	int f = 0;
	FORR(i, N - 1, -1+1) {
		if (!f&&a[i] == a[i - 1]) {
			ans = a[i];
			i--; f = 1;
		}
		else if (f==1&&a[i] == a[i - 1]) {
			ans *= a[i];
			f = 2;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
def main():

    MAX = 1e18

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

    if 0 in A:
        print(0)
        exit(0)

    prod = 1
    for a in A:
        prod *= a
        if prod > MAX:
            print(-1)
            exit(0)

    print(prod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21720
def f_enclose_all():
    # 参考: https://maspypy.com/atcoder-参加感想-2019-01-10abc-151
    from itertools import combinations
    N = int(input())
    Pos_complex = [complex(*map(int, input().split())) for j in range(N)]  # 複素数で持つ

    def find_circumcenter(z0, z1, z2):
        """複素数で表現される3点に対し，それらの外心を求める"""
        z1 -= z0
        z2 -= z0  # z0を基準に考える

        if abs((z1 * z2.conjugate()).imag) < 0.5:
            return None  # 3点が同一線上にあるので，外心を定義できない

        numerator = z1 * z2 * (z1 - z2).conjugate()
        denominator = z1.conjugate() * z2 - z1 * z2.conjugate()
        return (numerator / denominator) + z0

    # 2点選んで中点の座標を求めると，それが中心の候補
    candidate = [(z1 + z2) / 2 for z1, z2 in combinations(Pos_complex, 2)]
    # 3点選んで外心の座標を求めると，それが中心の候補
    candidate.extend([find_circumcenter(*comb) for comb in combinations(Pos_complex, 3)])

    # 中心の候補と各点への距離の最大値が包含円の半径．それを最小にする中心を探す
    ans = min((max(abs(z - c) for z in Pos_complex) for c in candidate if c is not None))
    return round(ans, 10)

print(f_enclose_all())

Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


int n;
P a[1000000];
ll va,vb;
ll ans=1;

int main(){
  cin>>n;
  rep(i,n){
    int b;
    cin>>b;
    a[i] = P(b,0);
  }
  rep(i,n){
    int b;
    cin>>b;
    a[n+i] = P(b,1);
  }

  sort(a,a+2*n);



  rep(i,2*n){
    if(a[i].second==0){
      if(!vb) va++;
      else{
        ans *= vb;
        ans %= M;
        vb--;
      }
    }
    else{
      if(!va) vb++;
      else{
        ans *= va;
        ans %= M;
        va--;
      }
    }

  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int a,b,n,m,mx,mn,sum;
int main(){
	cin>>n>>sum;
	mx=mn=sum;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		sum+=a;
		sum-=b;
		if(mx<sum)mx=sum;
		if(mn>sum)mn=sum;
	}
	if(mn<0)mx=0;
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 1160
/* ex4_1
   YSK722 */

#include <stdio.h>

int main(void){
    int num, watch, count;
    scanf("%d %d", &num, &watch);
    while (num > 0) {
        // 一人の監視員が監視できる本数を端から数える
        num -= (watch * 2 + 1);
        // 監視員の人数
        count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c,b,a,re;
    cin>>a>>b;

    if(((a==1)&&(b==2))||((b==1)&&(a==2))){
        cout<<3<<endl;
    }
    else if(((a==2)&&(b==3))||((a==3)&&(b==2))){
        cout<<1<<endl;
    }
    else{
        cout<<2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s,t,r;
  cin >> s >> t >> r;
  if(s[s.size()-1]==t[0]&&t[t.size()-1]==r[0]) pr("YES");
  else pr("NO");
}

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


Measured memory_bytes: 256
import java.util.stream.IntStream;

public class Main {
    static int[] baseNumbers = {1,2,3,4,5,6,7,8,9};
    public static void main(String[] args) {
        IntStream.of(baseNumbers).forEach(n -> IntStream.of(baseNumbers).forEach(m -> System.out.println(n + "x" + m + "=" + (n*m))));
    }
}

Measured memory_bytes: 30592
N,Y = map(int,input().split())
f = 0
loop = 0

for x in range(2001):
    for y in range(2001):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and z >= 0:
            print(x,y,z)
            f = 1
            loop = 1
            break
    if loop == 1:
        break
if f == 0:
    print('-1','-1','-1')

Measured memory_bytes: 3064
#include <iostream>
#define ill long long
#define rep(i, a, b) for(ill i = a; i < b; i++)
using namespace std;

int main() {
  int x;
  cin >> x;
  rep(i, -500, 501) {
    rep(j, -500, 501) {
      if(i*i*i*i*i - j*j*j*j*j == x) {
        cout << i << " " << j << "\n";
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <set>
using namespace std;

bool isTopLeft(int a, int b, int now, set<pair<int,int> > & S){
  for(int i = 0;i < now;i++){
    int new_a = a + i / 3, new_b = b + i % 3;
    if (S.count({new_a, new_b}) != 0){
      return false;
    }
  }
  return true;
}

void countUp(int a, int b,
	     long long H, long long W,
	     set<pair<int,int> >& S,
	     vector<long long> &cnt){
  for(int i = 0;i < 9;i++){
    int base_a = a - i/3, base_b = b - i%3;
    if (base_a < 1 || base_b < 1 ||
	base_a + 2 > H || base_b + 2 > W){
      continue;
    }

    if (isTopLeft(base_a, base_b, i, S)){
      int tmp = 1;
      for(int j = i+1;j < 9;j++){
	int new_a = base_a + j / 3;
	int new_b = base_b + j % 3;
	if (S.count({new_a, new_b}) != 0){
	  tmp++;
	}
      }
      cnt[tmp]++;
      cnt[0]--;
    }
  }
}


int main(){
  long long h, w;
  int n;
  set<pair<int,int> > S;
  cin >> h >> w >> n;

  vector<pair<int,int> > in(n);
  for(int i  = 0;i < n;i++){
    cin >> in[i].first >> in[i].second;
    S.insert({in[i].first, in[i].second});
  }

  vector<long long> ans(10);
  ans[0] = (h - 2) * (w - 2);

  for(int i = 0;i < n;i++){
    countUp(in[i].first, in[i].second, h, w, S, ans);
  }
  for(int i = 0;i < 10;i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 5760
n,m = map(int,input().split())   #n=部屋 m=通路
adj = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

from collections import deque
q = deque()

dis = [-1] * n
ans = [0] * n

q.append(0)
while len(q) != 0:
    now = q.popleft()
    for to in adj[now]:
        if dis[to] != -1:
            continue
        dis[to] = dis[now] + 1
        q.append(to)
        ans[to] = now
print("Yes")
for i in range(1,n):
    print(ans[i] + 1)

Measured memory_bytes: 34964
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()
{
    fastio;
    long long n,i,j,sum=0;
    cin>>n;
    for(i=1;i<n;i++)
    {
        for(j=1;i*j<n;j++)
            sum++;
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
//vector<vector<vector<int>>> dp(101, vector<vector<int>>(101, vector<int>(101)));  
int main(){
    int n;cin>>n;
    vin s(n),l(n),p(n);
    rep(i,n)cin>>s[i]>>l[i]>>p[i];
    int m;cin>>m;
    vin w(m);
    rep(i,m)cin>>w[i];
    vvin dp(n+1,vin(400));//各w[i]についてやるとO(1e10)で間に合わないのでとりあえずw[i]の最大値(393)以上までテーブルを作ってそのあと各w[i]に対応する値をO(1)で見つける
    rep(i,n){
        rep(j,400){
            if(j<s[i])dp[i+1][j]=dp[i][j];
            else{
                int Max=-1;
                rep2(k,s[i],min(l[i],j)+1){
                    if(Max<dp[i+1][j-k])Max=dp[i+1][j-k];
                }
                dp[i+1][j]=max(dp[i][j],Max+p[i]);
            }
        }
    }
    vin score(m);
    bool can=true;
    rep(i,m){
        if(dp[n][w[i]]==0){
            can=false;
            break;
        }
        score[i]=dp[n][w[i]];
    }
    if(can)rep(i,m)cout<<score[i]<<endl;
    else cout<<-1<<endl;
}


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

int main() {
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  int p = a.front(), tmp = 0, c = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == p) {
      if (++c == 2) {
        cout << 1LL * tmp * p << endl;
        return 0;
      }
      tmp = p;
      p = 0;
    }
    else p = a[i];
  }
  cout << 0 << endl;
}

Measured memory_bytes: 640
while True:
    n = int(input())
    if n == 0:
        break
    else:
        lst = list(map(int,input().split()))
        sum1 = sum(lst)
        m = sum1 / n
        for i in range(n):
            lst[i] = (lst[i] - m)**2
        sum2 = sum(lst)
        α = (sum2 / n)**0.5
        print('{:.8f}'.format(α))


Measured memory_bytes: 5800
#include <iostream>

using namespace std;

typedef long long ll;

const int N = 5;

int main() {
    ll n;
    cin >> n;
    ll amin = 2e15;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        amin = min(amin, a);
    }

    cout << (n - 1) / amin + 5 << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main()
{
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    int c=min(a,b);
    int s[1005];
    int x=1;
    for(int i=c;i>=1;i--)
    {
        if(a%i==0&&b%i==0)
            s[x++]=i;
    }
    printf("%d\n",s[k]);
    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

LL n, k;
const LL MOD = 1000000007;
LL combi(LL N_, LL C_) {
	const int NUM_ = 400001;
	static LL fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%MOD, factr[i] = factr[i - 1] * inv[i] % MOD;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % MOD*factr[N_ - C_] % MOD;
}

LL hcomb(int P_, int Q_) { return (P_ == 0 && Q_ == 0) ? 1 : combi(P_ + Q_ - 1, Q_); }

LL modpow(LL a, LL n = MOD - 2) {
	LL r = 1;
	while (n) r = r*((n % 2) ? a : 1) % MOD, a = a*a%MOD, n >>= 1;
	return r;
}

int main() {
	cin >> n >> k;
	cout << combi(n - 1, k - 1) << endl;
}


Measured memory_bytes: 12436
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void){
  int n,l=1000,r=1000,x=0,y=0;
  scanf("%d",&n);
  int a[n],w[n];
  FOR(n)scanf("%d",&a[i]);
  FOR(n)scanf("%d",&w[i]);
  FOR(n){
    if(a[i]){
      x=1;
      l=min(l,w[i]);
    }else{
      y=1;
      r=min(r,w[i]);
    }
  }
  PRN((l+r)*x*y);
}



Measured memory_bytes: 2104
//#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<iomanip>
#include<cctype>
#include<cstdio>
#include<deque>
#include<utility>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define INF 1000000000
#define ll long long
#define RE register
#define a(i) s[i].A
#define b(i) s[i].B
#define c(i) s[i].C
#define id(i) s[i].id
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    RE int x=0,f=1;char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const int MAXN=110;
int n,top,k;
int a[MAXN];
int main()
{
	//freopen("1.in","r",stdin);
	n=read();k=read();
	if(n>=10)printf("%d\n",k);
	else printf("%d\n",k+100*(10-n));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<utility>
#include<vector>
using namespace std;
int min(int a,int b){return (a<b)?a:b;}
int main(){
  int n,min,j,num,sum_b=0,sum_w=0;
  char c;
  string s;
  vector<pair<int,char>> se;
  cin>> n>> s;
  for(int i=0;i<n;i++){
    char c =s[i];
    num=0;
    j=i;
    while(s[j]==c&&j<n){
      num++;
      j++;
    }
    se.push_back(make_pair(num,c));
    i = j-1;
  }
  for(int i=0;i<se.size();i++){
    if(se[i].second=='.') sum_w+=se[i].first;
  }
  min = sum_w;
  for(int i=0;i<se.size();i++){
    if(se[i].second=='#'){
      sum_b+=se[i].first;
    }else{
      sum_w-=se[i].first;
    }
    min = (min < sum_b+sum_w)?min:sum_b+sum_w;
  }
  cout << min <<endl;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ff first
#define ss second
#define pb push_back
#define vi vector<ll>
#define all(_x) _x.begin(), _x.end()
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define lb(_x, _a) (lower_bound(all(_x), _a) - _x.begin())
#define ub(_x, _a) (upper_bound(all(_x), _a) - _x.begin())
ll n, tc;

int main()
{
  	// ll is int now
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int w;
    cin>>n>>w;
    vector<pair<int, int>> arr(n);
    for(auto &x: arr) cin>>x.ff>>x.ss;
    long long dp[n+1][w+1];
    rep(i,0,n+1) rep(j,0,w+1) dp[i][j] = 0;

    for(int i=1; i<n+1; i++)
    {
        for(int j=1; j<w+1; j++)
        {
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);

            if(j-arr[i-1].ff>=0) dp[i][j] = max(dp[i][j], arr[i-1].ss + dp[i-1][j-arr[i-1].ff]);
        }
    }
    // for(int i=1; i<n+1; i++){
    //     for(int j=1; j<w+1; j++) cout<<dp[i][j]<<' ';
    //     cout<<'\n';
    // }
    cout<<dp[n][w]<<'\n';
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <string>
using namespace std;
int o[100200]={0},p[100200]={0};
int main()
{
	int q,w,e,i,j;
	long long sum=0,left=0;
	cin>>q;
	for(i=1;i<=q;i++)
	cin>>o[i];
	cin>>o[0];
	for(i=1;i<=q;i++)
	cin>>p[i];
	for(i=1;i<=q;i++)
	{
		w=o[i],e=p[i];
		if(w<=left)
		{
			sum+=w;
			left=e;
		}
		else if(w<=e+left)
		{
			j=e-w;
			sum+=w;
			left+=j;
		}
		else
		{
			sum+=e+left;
			left=0;
		}
	}
	w=o[0];
	if(w<=left)
	sum+=w;
	else
	sum+=left;
	cout<<sum;
	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n), max_h(n);
    rep(i, n){
        cin >> h[i];
        max_h[i] = 0;
    }
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        max_h[a] = max(max_h[a], h[b]);
        max_h[b] = max(max_h[b], h[a]);
    }

    int ans = 0;
    rep(i, n){
        if(max_h[i] < h[i]) ans++;
    }
    cout << ans <<endl;

    return 0;
}

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


Measured memory_bytes: 128
N = gets.to_i
as = gets.split.map(&:to_i)
counts = Hash.new(0)

as.each do|a|
  counts[a.to_s] += 1
end

ans = 0
counts.each do |k, v|
  k = k.to_i
  if v < k
    ans += v
  elsif v > k
    ans += v - k
  end
end

puts ans

Measured memory_bytes: 20228