akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示
#include <map>
#include<set>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

#define MAX_N 50005//ここにNの最大値を入れる
#define MAX_K 100005

ll cut(ll a, ll b) {//切り捨て
    return (a - a % b) / b;
}
int up(int a, int b) {
    return (a + a % b) / b;
}
int main() {
    ll x;
    cin >> x;
    ll a = 100;
    ll cnt = 0;
    while (a<x) {
        a += cut(a, 100);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

char board[13][13];
//int check[12][12];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};
int ans;

void dfs(int x, int y);

int main(void)
{
    int i, j;
    while (scanf("%s", board[0]) != EOF) {
        for (i = 1; i < 12; i++) {
            scanf("%s", board[i]);
        }
        ans = 0;
        /*for (i = 0; i < 12; i++) {
            for (j = 0; j < 12; j++) {
                board[i][j] -= '0';
            }
        }
        for (i = 0; i < 12; i++) {
            for (j = 0; j < 12; j++) {
                printf("%d", (int)board[i][j]);
            }
            puts("");
        }*/
        for (i = 0; i < 12; i++) {
            for (j = 0; j < 12; j++) {
                if (board[i][j] == '1') {
                    dfs(i, j);
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

void dfs(int x, int y)
{
    int i;
    board[x][y] = '0';
    for (i = 0; i < 4; i++) {
        if (0 <= x+dx[i] && x+dx[i] < 12
                && 0 <= y+dy[i] && y+dy[i] < 12) {
            if(board[x+dx[i]][y+dy[i]] == '1') {
                dfs(x+dx[i], y+dy[i]);
            }
        }
    }
}

Measured memory_bytes: 540
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $c = <STDIN>);
my @g = split //, $c;
my ($n, $s, $e, $w);
for $_ (@g) {
  if ($_ eq 'N') {
    $n = 1;
  } elsif ($_ eq 'S') {
    $s = 1;
  } elsif ($_ eq 'E') {
    $e = 1;
  } elsif ($_ eq 'W') {
    $w = 1;
  }
}
say "Yes" if $n==$s && $e==$w;
say "No" unless $n==$s && $e==$w;

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)

using ll = long long;

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

    ll amount = 100;
    ll passYear = 0; 
    while(true){
      if(amount>=X){
        printl(passYear);
        return 0;
      }
      passYear++;
      amount+= amount /100;
    }
}


Measured memory_bytes: 3600
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N,K,*V = map(int,read().split()) #*Vで行単位の配列を得られる。
#print(V)

vals = [] #valuesの略。

for L in range(N+1): #左
    for R in range(N+1): #右
        if L+R > N: #このbreakで、うまく左右からとれる。
            break
        get = V[:L] + V[N-R:]
        rest = K - (L+R) #ridの代わりにrest。汎用性がある。
        if rest < 0:
            break
        get.sort(reverse=True) #逆順にしてpop()で抜き出している。
        for _ in range(min(len(get),rest)): #indexを用いないforループは_で。徹底。
            if get[-1] < 0:
                get.pop()
            else:
                break
        vals.append(sum(get)) #最小値を求める際はmax(answer, buffer)ではない。一度配列。

answer = max(vals)
print(answer)

Measured memory_bytes: 41580
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n, d;
	cin >> n >> d;
	ll count = 0;
	ll x, y;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,k; cin >> n >> k;
  map<int,int> mp;
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    mp[x]++;
  }
  vector<int> v;
  for(auto e:mp){
    v.push_back(e.second);
  }
  sort(v.rbegin(), v.rend());
  int sum = 0;
  n = (int)v.size();
  for(int i = 0; i < n; ++i){
    if(i >= k)sum += v[i];
  }
  cout << sum << endl;
}



Measured memory_bytes: 13428
#include <bits/stdc++.h>
#define inf (long long)1e9
using namespace std;

struct data {
  long long a, b;
  vector<bool> c;
};

long long n, m;
vector<data> v;
long long dp[10000] = {0};

long long solve(long long s);

int main() {
  cin >> n >> m;
  v.resize(m);
  for(int i = 0; i < m; ++i) {
    cin >> v[i].a >> v[i].b;
    v[i].c.assign(n, 0);
    for(int j = 0; j < v[i].b; ++j) {
      long long x;
      cin >> x;
      v[i].c[--x] = 1;
    }
  }
  for(int i = 0; i < (1 << n); ++i) dp[i] = -1;
  dp[(1 << n) - 1] = 0;
  long long ans = solve(0);
  if(ans == inf)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}

long long solve(long long s) {
  if(dp[s] != -1) return dp[s];
  long long ans = inf;
  for(int i = 0; i < m; ++i) {
    long long nexts = s;
    for(int j = 0; j < n; ++j)
      if(v[i].c[j]) nexts |= (1 << j);
    if(nexts == s) continue;
    ans = min(ans, v[i].a + solve(nexts));
  }
  return dp[s] = ans;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CODEFESTIVAL2016FinalA___Where_s_Snuke
{
    class Program
    {
        static readonly string target = "snuke";

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int h = int.Parse(input[0]);
            int w = int.Parse(input[1]);

            string result = "";

            for (int index_rows = 1; index_rows <= h; index_rows++)
            {
                string[] row = Console.ReadLine().Split(' ');
                if (row.Contains(target))
                {
                    int row_num = Array.IndexOf(row, target);
                    result = ((Rows)row_num).ToString() + index_rows.ToString();
                    break;
                }

            }

            Console.WriteLine(result);

        }

        enum Rows
        {
            A, B, C, D, E,
            F, G, H, I, J,
            K, L, M, N, O,
            P, Q, R, S, T,
            U, V, W, X, Y, Z
        }
    }
}


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

int main(void) {
  int N; cin >> N;
  vector<long long int> A(N);
  for (int i = 0; i < N; i++) { cin >> A[i]; }

  int count = 0;
  int now = 0;  // 0 (def) 1 (inc.) 2 (dec.)
  for (int i = 1; i < N; i++) {
    if (A[i - 1] < A[i]) {
      if (now == 0 || now == 1)
        now = 1;
      else {
        count++;
        now = 0;
      }
    } else if (A[i - 1] > A[i]) {
      if (now == 0 || now == 2) {
        now = 2;
      } else {
        count++;
        now = 0;
      }
    }
  }
  cout << count + 1 << endl;
}


Measured memory_bytes: 1024
c = 0
def m(L,R):   
    global c
    j = 0
    for l in L:
        while (j < len(R) and R[j] < l):
            yield R[j]
            j += 1
        yield l
    while (j < len(R)):
        yield R[j]
        j += 1
    c += len(L) + len(R)
    
def merge(A):
    global c
    if len(A) == 1:
        return A
    if len(A) == 2:
        c += 2
        a, b = A
        return A if a < b else (b, a)
    mid = len(A)//2
    A[:] = m(merge(A[:mid]), merge(A[mid:]))
    return A
    
n = int(input())
nlist = list(map(int,input().split()))
A = merge(nlist)  
print(*A)
print(c)
        


Measured memory_bytes: 61648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1e9+7;
//const long long mod = 998244353;
using mint = Fp<MOD>;

int main(){
    ll N,M,K; cin>>N>>M>>K;
    mint n=N, m=M, k=K;
    mint res=0;
    mint tmp=1;
    for(mint i=n*m-2; i!=n*m-k; i-=1){
        tmp*=i;
    }
    for(mint i=k-2; i!=0; i-=1){
        tmp/=i;
    }
    for(mint d=0; d!=n; d+=1){
        res+=d*(n-d)*m*m;
    }
    for(mint d=0; d!=m; d+=1){
        res+=d*(m-d)*n*n;
    }
    cout<< res*tmp <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
  int x,i=1,m=1;
  cin >> x;
  while(1){
    if(x*i >360*m){
      m++;
    }
    if(x*i==360*m){
      cout << i;
      return 0;
    }
	i++;
  }
}

Measured memory_bytes: 3592
#include <iostream> 
#include <string>
using namespace std;
int main(){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        int flag = 0;
        while(true){
            c = c - b;
            if( c <= 0){
                cout << "Yes" << endl;
                break;
            }
            
            a = a - d;
            if ( a <= 0){
                cout <<"No" << endl;
                break;
            }
        }
}

Measured memory_bytes: 3640
# coding: utf-8
import numpy as np
N,M,C = map(int, input().split())
i = [list(map(int, input().split())) for _ in range(N+1)]
i = np.array(i)
B = i[0,0:M]
A = i[1:,0:M]
AA = A * B
BB = np.sum(AA,axis=1)+C
ANS = np.where(BB > 0,1,0).sum()
print(ANS)

Measured memory_bytes: 12496
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
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; }

int main(){
    for(int i=0;i<5;++i){
        int a;
        cin>>a;
        if(a==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3568
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int A, B, C;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B >> C;
  map<int, int> mp;
  mp[A]++, mp[B]++, mp[C]++;

  for (auto m : mp) {
    if (m.second == 1) cout << m.first << endl;
  }

  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n; cin >> n;
    vector<int> a(n);
    bool allzero = true;
    rep(i, n){
        cin >> a[i];
        if(a[i] == 1) allzero = false;
    }
    if(allzero){
        cout << 0 << endl;
        return 0;
    }
    vector<int> b(n);
    int M = 0;
    for(int i = n-1; i >= 0; i--){
        int sum = 0;
        int m = 1;
        while(((i+1) * m)-1 < n){
            sum += b[(i+1)*m-1];
            m++;
        }
        if(sum % 2 != a[i]) b[i] = 1;
        M += b[i];
    }
    cout << M << endl;
    rep(i, n){
        if(b[i] == 1) cout << i+1 << " ";
    }
    cout << endl;
}


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

int main(){ 
  int n,x=0,d=0,cnt=0,result=1;
  cin >> n >> x;
  rep(i,n){
    int tmp;
    cin >> tmp;
    d+=tmp;
    if(d>x) break;
    result++;
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <boost/math/common_factor.hpp>
#include <algorithm>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include<chrono>
 
using namespace std;
//using namespace std::chrono;
 
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vl int64_t

int main()
{
     ll n;
     cin>>n;
     vector<ll>v;
     map<ll,ll>minpos;
     map<ll,ll>maxpos;
     for(ll i=1;i<=n;i++)
     minpos[i]=INT_MAX;
     
     for(ll i=1;i<=n;i++)
     maxpos[i]=INT_MIN;
     
     map<ll,ll>pos;
     
     
     for(ll i=0;i<n;i++)
     {
          ll temp;
          cin>>temp;
          v.push_back(temp);
          pos[temp]=i+1;
          minpos[temp]=min(minpos[temp],i);
          maxpos[temp]=max(maxpos[temp],i);
     }
     
     if(pos[1]==0)
     {
          cout<<-1;
          return 0;
     }
     ll curr=1;
     ll ctr=1;
     
     for(ll i=minpos[1];i<n;i++)
     {
          if(v[i]==curr+1)
          {
               curr++;
               ctr++;
          }
     }
     
     cout<<n-ctr;
      
    
     
     
}


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);

    string ans = "APPROVED";
    
    
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);

        if (A.at(i) % 2 == 0) {
            if (!(A.at(i) % 3 == 0  || A.at(i) % 5 == 0)) {
                ans = "DENIED";
            }
        }
        

    }



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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb			push_back
#define vi  		vector<int>
#define all(a)		(a).begin(),(a).end()
#define F 			first
#define S 			second
#define endl		"\n"
#define fast 		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int 		long long int
#define mod 		1000000007

#define test		int tc;cin>>tc;while(tc--)

int32_t main(){

	// test{}
	string str;
	cin>>str;
	if(str=="ABC")
		cout<<"ARC"<<endl;
	else{
		cout<<"ABC"<<endl;
	}
	return 0;
}

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

#define REP(i,n) for (long long i=0;i<(n);i++)
#define REPT(i,t,n) for (long long i=t;i<(n);i++)

int Result_int;
long Result_lng;
string Result_str = "";
int A,B,T;
long long N,left,t;
//char S,target;
string S;

int main() {
    cin >> A >> B >> T;
    N = int((T/A) * B);
    cout << N;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N, T;
  cin >> N >> T;
  int ans = 1e9;
  for(int i = 0; i < N; ++i){
    int c, t;
    cin >> c >> t;
    if(t <= T) ans = min(ans, c);
  }
  if(ans < 1e9)
    cout << ans << endl;
  else cout << "TLE" << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll a,b,h,m; cin>>a>>b>>h>>m;
    double rad=pi*2*(
        h/12.0 + (m/60.0)/12 - m/60.0
    );
    double ans=sqrt(a*a+b*b-2*a*b*cos(rad));
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 4152
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  
  ll N, K;
  cin >> N >> K;
  ll a[MAX]={};
  ll s[MAX]={}, t[MAX]={};
  
  for(i=1; i<=N; i++) cin >> a[i];
  for(i=1; i<=N; i++) s[i]=s[i-1]+a[i];
  for(i=1; i<=N; i++) t[i]=t[i-1]+(a[i]>0 ? a[i] : 0);
  
  ll ans=0;
  for(i=1; i<=N-K+1; i++) {
    ll u=s[i+K-1]-s[i-1];
    ll sco=t[i-1]+(u>0?u:0)+(t[N]-t[i+K-1]);
    chmax(ans, sco);
  }
  
  pt(ans);
  
}





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


def f(n):
    n[1] = int(n[1])
    return n


a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

for c in ans:
    for d in c:
        print(d[2])

Measured memory_bytes: 3064
from sys import stdin

s = list(stdin.readline().rstrip())
acgt = ['A', 'C', 'G', 'T']

ans = 0
tmp = 0

for i in s:
    if i in acgt:
        tmp += 1
    else:
        if ans <= tmp:
            ans = tmp
        tmp = 0

if ans <= tmp:
    ans = tmp

print(ans)

Measured memory_bytes: 38256
#include<stdio.h>
#include<ctype.h>
main(){
  int i;
  char string[1201];

//  scanf("%s",string);
  i=0;
  scanf("%c",&string[i]);
  while(string[i]!='\n'){
    if(isupper(string[i])!=0){
      printf("%c",tolower(string[i]));
    }
    else if(islower(string[i])!=0){
      printf("%c",toupper(string[i]));
    }
    else  printf("%c",string[i]);
    i++;
    scanf("%c",&string[i]);
  }
  printf("\n");

  return 0;
}

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

//ll gcd(int a, int b){ return b? gcd(b,a%b) : a ; } 

int main(){
    int n ;
    cin >> n ;
    int A[n][26] ;
    //char l = 'a' + 1 ;
    fill(A[0],A[n],0) ;
    rep(i,n){
        string s ;
        cin >> s ;
        rep(j,s.size()){
            int k = s[j] - 'a' ;
            A[i][k]++ ; 
        }
    }
    rep(i,26){
        int count = 1e9 ;
        rep(j,n){
            count = min(count,A[j][i]) ;
        }
        rep(k,count){
            char l = 'a' + i ;
            cout <<  l ;
        } 
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

LL f(LL X,vector<LL>& A){
	int size = A.size();
	for(int i=0;i<size;++i){
		X = (X/A[i])*A[i];
		// X -= X%A[i];
	}
	return X;
}
void solve(){
	int K;
	cin >> K;
	vector<LL> A(K);
	for(int i=0;i<K;++i){
		cin >> A[i];
	}
	//////
	//最後に2人以上残る最小値を探す
	LL NG,OK;
	NG = 0;
	OK = LINF;
	LL f_OK = f(OK,A);
	if( f_OK < 2 ){
		cout << -1 << endl;
		return;
	}
	while(OK-NG>1){
		LL mid = (NG+OK)/2;
		LL f_mid = f(mid,A);
		if( f_mid >= 2 ){
			OK = mid;
		}else{
			NG = mid;
		}
	}
	f_OK = f(OK,A);
	LL f_NG = f(NG,A);
	if( f_OK != 2 ){
		cout << -1 << endl;
		return;
	}
	LL ansMin = OK;
	//2人残る最小値が存在したので、
	//最大値は、最小値以上の値で存在する。

	//最後に2人以下残る最大値を探す
	LL L,R;
	L = ansMin;//最後に0人残る
	R = LINF;
	while(R-L>1){
		LL mid = (L+R)/2;
		LL f_mid = f(mid,A);
		if( f_mid <= 2 ){
			L = mid;
		}else{
			R = mid;
		}
	}
	LL ansMax = L;
	cout << ansMin << " " << ansMax << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define PI			2*acos(0.0)
int main()
{
    int n,a,b;
    cin >>n>>a>>b;
    if((a-b)%2==0)
    {
        cout <<"Alice";
    }
    else
    {
        cout <<"Borys";
    }
    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int h,w;cin>>h>>w;
    vector<vector<char> > c(h+2,vector<char>(w+2,'.'));
    rep1(i,h+1)rep1(j,w+1)cin >> c[i][j];
    rep1(i,h+1){
        rep1(j,w+1){
            if(c[i][j] == '#')cout << '#';
            else{
                ll res = 0;
                for(int k=0;k<8;k++){
                    int ex = dx[k]+i;
                    int ey = dy[k]+j;
                    if(c[ex][ey] == '#')res++;
                }
                cout << res;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> w(n, 0), e(n, 0);
	rep(i, n - 1) {
		if (s[i] == 'W') w[i + 1] = w[i] + 1;
		else w[i + 1] = w[i];
		if (s[n - 1 - i] == 'E') e[n - 2 - i] = e[n - 1 - i] + 1;
		else e[n - 2 - i] = e[n - 1 - i];
	}

	int ans = 3000005;
	rep(i, n) {
		ans = min(ans, w[i] + e[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


using pdd = pair<double, double>;
double dist(pdd a, pdd b) {
    double x = a.F - b.F;
    double y = a.S - b.S;
    return sqrt(x * x + y * y);
}
double incline(pdd a, pdd b) {
    return (b.S - a.S) / (b.F - a.F);
}
void solve() {
    int n;
    cin >> n;
    
    vector<pdd> v(n);
    rep(i, n) cin >> v[i].F >> v[i].S;
    double ans = inf;
    // 直径
    rep(i, n) rep3(j, i + 1, n) {
        double x = (v[i].F + v[j].F) / 2;
        double y = (v[i].S + v[j].S) / 2;
        
        double tmp = 0;
        rep(k, n) {
            chmax(tmp, dist(pdd(x, y), v[k]));
        }
        chmin(ans, tmp);
    }
    // 外心
    rep(i, n) rep3(j, i + 1, n) rep3(k, j + 1, n) {
        double x1 = v[i].F, y1 = v[i].S, x2 = v[j].F, y2 = v[j].S, x3 = v[k].F, y3 = v[k].S;
        if (x1 == x2 && x1 == x3) continue;
        if (y1 == y2 && y1 == y3) continue;
        if (abs(abs(incline(v[i], v[j])) - abs(incline(v[j], v[k]))) < 1e-8) continue;
        
        double p = ((y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
        double q = ((x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
        double tmp = 0;
        rep(k, n) {
            chmax(tmp, dist(pdd(p, q), v[k]));
        }
        // cout << i << " " << j << " " << k << " " << tmp << endl;
        chmin(ans, tmp);
    }
    cout << fixed << setprecision(7) << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
    
}









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

int main(void){
	int N;
	vector<string> str(0);
	cin >> N;
	for(int i=0;i<N;i++){
		string s;
		cin >> s;
		str.push_back(s);
	}
	for(int i=0;i<N;i++){
		if (i>0 && str[i-1][str[i-1].size()-1]!=str[i][0]){
			cout << "No" << endl;
			return 0;
		}
		for(int j=0;j<str.size();j++){
			if (i!=j && str[j] == str[i]){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	return 0;
}


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

import static java.lang.Integer.parseInt;

/**
 * Princess in Danger
 */
public class Main {

	static final int INF = 1 << 29;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		StringTokenizer st;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			st = new StringTokenizer(line);

			int N, M, _L, K, A, H;
			boolean[] L;
			Map<Integer, List<Edge>> G;
			int[][] D;      //????????????: [????±???????][?????????????????????????????????]

			N = parseInt(st.nextToken());   //N: ????????°
			M = parseInt(st.nextToken());   //M: ???????????????????????§?????¶?????????
			_L = parseInt(st.nextToken());  //_L: ??????????¨??????????????????°
			K = parseInt(st.nextToken());   //K: ?????¨????????´??\?????¶???????????°
			A = parseInt(st.nextToken());   //A: ??¬?????????????????¨?????????
			H = parseInt(st.nextToken());   //H: ????§??§??????¬?????????????????¢?????????????????????
			if ((N | M | _L | K | A | H) == 0) break;

			//
			L = new boolean[N];
			L[A] = L[H] = true;

			if (_L > 0) {
				st = new StringTokenizer(br.readLine());
				for (int i = 0; i < _L; i++) {
					L[parseInt(st.nextToken())] = true;
				}
			}

			//
			G = new HashMap<>();

			for (int i = 0; i < K; i++) {
				st = new StringTokenizer(br.readLine());
				if (!st.hasMoreTokens()) {
					st = new StringTokenizer(br.readLine());
				}
				int X, Y, T;
				X = parseInt(st.nextToken());
				Y = parseInt(st.nextToken());
				T = parseInt(st.nextToken());
				G.putIfAbsent(X, new ArrayList<>());
				G.putIfAbsent(Y, new ArrayList<>());
				G.get(X).add(new Edge(Y, T));
				G.get(Y).add(new Edge(X, T));
			}

			//
			D = new int[N][M + 1];
			for (int i = 0; i < N; i++) Arrays.fill(D[i], INF);
			D[A][M] = 0;

			Queue<P> pq = new PriorityQueue<>();
			pq.offer(new P(A, 0, M));

			//
			while (!pq.isEmpty()) {

				P p = pq.poll();

				if (D[p.to][p.stime] < p.ctime) continue;

				int v, s;
				v = p.to;
				s = p.stime;

				if (v == H) break;

				if (G.containsKey(v)) {
					for (Edge e : G.get(v)) {
						if (M >= e.time) {
							int m = (L[v] ? M - s : 0);
							for (int i = 0; i <= m; i++) {
								int ctime, stime;
								ctime = D[v][s] + e.time + i;
								stime = (s + i) - e.time;
								if (stime >= 0
										&& D[e.to][stime] > ctime) {
									D[e.to][stime] = ctime;
									pq.offer(new P(e.to, ctime, stime));
								}
							}
						}
					}
				}
			}

			//
			int ans = INF;

			for (int i = 0; i <= M; i++) ans = Math.min(ans, D[H][i]);

			System.out.println(ans != INF ? ans : "Help!");
		}
	}
}

class Edge {

	int to, time;

	public Edge(int to, int time) {
		this.to = to;
		this.time = time;
	}
}

class P implements Comparable<P> {

	int to, ctime, stime;

	public P(int to, int ctime, int stime) {
		this.to = to;
		this.ctime = ctime;
		this.stime = stime;
	}

	@Override
	public int compareTo(P o) {
		return Integer.compare(ctime, o.ctime);
	}
}

Measured memory_bytes: 84376
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            int n = input.nextInt();
            int x = input.nextInt();
            if (n == 0 && x == 0) break;
            
            int count = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (x == i + j + k) count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 19604
#include<stdio.h>
#include<math.h>
#define MAX 100

int min(int x, int y);

int main(){
  int i,j,n,k,c,r;
  int a[MAX];
  int b[MAX][MAX];

  scanf("%d",&n);
  for(i = 1; i<=n; i++){
    scanf("%d%d", &a[i-1],&a[i]);
  }

  for(i = 0; i<=n; i++){
    for(j=0; j<=n; j++){
    b[i][j] =0;
    }
  }



  
  
  for ( c =2 ; c<=n; c++){
    for(i =1; i<=n-c +1;i++){
      j = i+c-1;
      b[i][j] = 1<<21;
      for(k = i; k<=j-1; k++){
	r = b[i][k] + b[k + 1][j] + a[i-1]*a[k] *a[j];	
	b[i][j] = min(b[i][j],r);
      }
    }
  }
  printf("%d\n",b[1][n]);
  return 0;
}


int min(int x, int y){
  if(x < y){
    return(x);
  }

  else{
    return(y);
  }
}



Measured memory_bytes: 2056
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>

using namespace std;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int,int> pint;

//GCD
int gcd(int a,int b){
	return b!=0 ? gcd(b,a%b) : a;
}

int N=500;
vvint g(N,(vint(N,0)));
vint prev(N,-1),f(N);
int nibu_match(int s){
	if(s==-1) return 1;
	for(int i=0;i<N;i++){
		if(g[s][i]==0 || f[i]==1) continue;
		f[i]=1;
		if(nibu_match(prev[i])){
			prev[i]=s;
			return 1;
		}
	}
	return 0;
}


int main()
{
	int m,n;
	while(1){
		g = vvint(N,(vint(N,0)));
		prev = vint(N,-1);
		scanf("%d %d",&m,&n);
		if(m==0 && n==0) break;
		vint b(m),r(n);
		for(int i=0;i<m;i++) scanf("%d",&b[i]);
		for(int i=0;i<n;i++) scanf("%d",&r[i]);
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(gcd(b[i],r[j])>1) g[i][j]=1;
			}
		}
		int ans=0;
		for(int i=0;i<m;i++){
			for(int j=0;j<N;j++) f[j]=0;
			ans+=nibu_match(i);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
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);
	ll lc = (a/g) * b;
	return lc;
}
map< string , int > mp;
int main()
{
	dhoom;
	int n , x;
	cin >> n >> x;
	ll ans = 0;
	for(int i = 0 ; i < n ; i++){
		ll a;
		cin >> a;
		ans = gcd(ans , abs(a - x));
	}
	cout << ans << endl;
	return 0;
} 



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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 212345;
const int INF = 0x3f3f3f3f;

int a[N], n;
vector<int> G[N];
int ans[N], f[N];

void dfs(int u, int fa) {
    int pos = lower_bound(f + 1, f + n + 1, a[u]) - f;
    int old = f[pos];
    f[pos] = a[u];
    ans[u] = lower_bound(f + 1, f + n + 1, INF) - f - 1;

    for (int v : G[u]) {
        if (v == fa) continue;
        dfs(v, u);
    }
    f[pos] = old;
}

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

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }

    reset(f, 0x3f);
    dfs(1, 0);

    for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 31648
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

int INF = 1 << 29;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N, N);
    foreach (i; 0..N) G[i][i] = true;
    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        G[s[0]-1][s[1]-1] = true;
        G[s[1]-1][s[0]-1] = true;
    }
    auto D = new int[](N);
    fill(D, -1);

    Tuple!(int, int) dfs(int n, int parity) {
        if (D[n] == parity)
            return tuple(0, 0);
        if (D[n] != -1 && D[n] != parity)
            return tuple(-INF, -INF);
        D[n] = parity;
        auto ret = tuple(0, 0);
        ret[0] += parity == 0 ? 1 : 0;
        ret[1] += parity == 1 ? 1 : 0;
        foreach (m; 0..N) {
            if (!G[n][m]) {
                auto t = dfs(m, parity^1);
                if (t[0] < 0)
                    return tuple(-INF, -INF);
                ret[0] += t[0];
                ret[1] += t[1];
            }
        }
        return ret;
    }

    int[] V, W;
    foreach (i; 0..N) {
        if (D[i] == -1) {
            auto t = dfs(i, 0);
            if (t[0] < 0) {
                writeln(-1);
                return;
            }
            V ~= t[0];
            W ~= t[1];
        }
    }

    immutable int MAX = 1000;
    auto dp = new bool[][](N+1, N+1);
    dp[0][0] = true;

    foreach (i; 0..V.length) 
        foreach_reverse (j; 0..N+1) 
            foreach_reverse (k; 0..N+1) 
                if (dp[j][k])
                    dp[j+V[i]][k+W[i]] = true, dp[j+W[i]][k+V[i]] = true;

    int ans = INF;
    foreach (i; 0..N+1) {
        int j = N - i;
        if (dp[i][j]) {
            ans = min(ans, i*(i-1)/2+j*(j-1)/2);
        }
    }
    ans.writeln;
}


Measured memory_bytes: 7420
package main

import "fmt"

func main() {
    var a, b int
    fmt.Scanln(&a, &b)
    ha := []int{}
    h := 0
    for i := 1; i <= 999; i++ {
        h = h + i
        ha = append(ha, h)
    }
    d := 0
    for i := len(ha) - 1; i >= 0; i-- {
        if ha[i] > b {
            d = ha[i] - b
            if ha[i - 1] - d == a {
                break
            }
        }
    }
    fmt.Printf("%d\n", d)
}


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

int main() {

  long long int n;
  cin >> n;

  long long int ans[5] = {};

  bool f = false;
  long long int b;
  long long int c = 0;

  for ( long long int i = 0; i < n; i++ ) {

    long long int in;
    cin >> in;

    if ( i > 0 ) {
      if ( b == in ) {
	if ( c > 0 ) {
	  f = true;
	}else if ( c < 0 ) {
	  f = true;
	}
      }else if ( b > in ) {
	if ( c > 0 ) {
	  if ( f == true ) {
	    ans[0]++;
	  }else {
	    ans[3]++;
	  }
	}
	if ( c < 0 && f == true ) {
	  ans[2]++;
	}
	f = false;
	c = -1;
      }else {
	if ( c < 0 ) {
	  if ( f == true ) {
	    ans[1]++;
	  }else {
	    ans[4]++;
	  }
	}
	if ( c > 0 && f == true ) {
	  ans[2]++;
	}
	f = false;
	c = 1;
      }
    }
    b = in;

  }

  cout << ans[0] << " " << ans[1] << " " << ans[2] << " " << ans[3] << " " << ans[4] << endl;

  return 0;

}


Measured memory_bytes: 1164
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    a=sort(parseMap(split(readline())))
    g=a[1]
    for i in a
        g=gcd(g,i)
    end
    println(g)
end
main()

Measured memory_bytes: 172384
from operator import itemgetter
from bisect import bisect_right
n, d, a = map(int, input().split())
monster = [tuple(map(int, input().split())) for _ in range(n)]
monster.sort(key=itemgetter(0))
xx = [xi for xi, hi in monster]

ans = 0
imos = [0] * (n + 1)
for i, (xi, hi) in enumerate(monster):
    hi -= imos[i]
    if hi > 0:
        c = (hi + a - 1) // a
        ans += c
        idx = bisect_right(xx, xi + 2 * d)
        imos[i] += c * a
        imos[idx] -= c * a

    # update imos
    imos[i + 1] += imos[i]

print(ans)


Measured memory_bytes: 94808
#include <cstdio>

int main(){
	int N;
	int value;
	char S[100];
	int Card[4][200];
	for(int i=0; i<4; i++){
		for(int j=1; j<=13; j++){
			Card[i][j] = 0;
		}

	}
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%s %d", S, &value);
		if(S[0]=='S'){
			Card[0][value] = 1;
		}
		else if(S[0]=='H'){
			Card[1][value] = 1;
		}
		else if(S[0]=='C'){
			Card[2][value] = 1;
		}
		else if(S[0]=='D'){
			Card[3][value] = 1;
		}
	}
	for(int i=0; i<=3; i++){
		for(int j=1; j<=13; j++){
			if(Card[i][j]==0){
				if(i==0){
					printf("S %d\n", j);
				}
				else if(i==1){
					printf("H %d\n", j);
				}
				else if(i==2){
					printf("C %d\n", j);
				}
				else if(i==3){
					printf("D %d\n", j);
				}
			}

		}
	}
	return 0;
}

Measured memory_bytes: 2716
read n;E=echo;l=`sed 's/ /\\\n/g'`;s(){($E -e $l|awk 'NR%2=='"$1"''|sort -n|uniq -c|sort -rn;$E 0 0)|head -2;};g(){ $E $((a=$1+$7,b=$3+$5,$2!=$6?n-$1-$5:a>b?n-a:n-b));};g `s 1;s 0`

Measured memory_bytes: 12904
#include <cstdio>
#include <cmath>

using namespace std;
using ll = long long;

constexpr ll INF = 1LL << 60;

ll f(ll b, ll n){
    ll ret = 0;
    for(; n; n /= b) ret += n % b;
    return ret;
}

int main(){
    ll n, s; scanf("%lld %lld", &n, &s);
    ll d = n - s;

    if(d < 0) puts("-1");
    else if(!d) printf("%lld\n", n + 1);
    else{
        ll ans = INF;
        for(ll i = 1; i <= sqrt(d); i++){
            if(d % i) continue;

            ll b = i + 1;
            if(ans > b && f(b, n) == s) ans = b;

            b = d / i + 1;
            if(ans > b && f(b, n) == s) ans = b;
        }

        if(ans == INF) puts("-1");
        else printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
#include <queue>
#define REP(i, n) for (i = 0; i < (n); i++)
#define REP1(i, n) for (i = 1; i <= (n); i++)
using namespace std;

const int CODE = (1 << 12) +10;
const int N = 5000 +10;

struct QUEUE {int n, code;};

bool f[CODE][N];

char a[20][20];
char s[N];

int ans, m, n;
int len[N];

queue <QUEUE> que;

bool ri()
{
	int i;

	ans = 0;
	memset(a, 0, sizeof(a));
	memset(f, false, sizeof(f));
	memset(s, 0, sizeof(s));
	scanf("%d%d", &n, &m);
	if (n == 0 && m == 0) return false;
	REP(i, n)
	{
		scanf("%s", a[i]);
		len[i] = strlen(a[i]);
	}
	while (m--) scanf("%s", s + (strlen(s)));
	m = strlen(s);
	return true;
}

bool same(int st, int x)
{
	int i;

	if (st + len[x] > m) return false;
	REP(i, len[x]) if (s[st + i] != a[x][i]) return false;
	return true;
}

void solve()
{
	int i, j;

	QUEUE v1, v2;

	while (!que.empty()) que.pop();
	REP(i, m)
		REP(j, n)
			if (same(i, j))
			{
				v1.n = i;
				v1.code = 1 << j;
				que.push(v1);
				f[1 << j][i] = true;
			}
	while (!que.empty())
	{
		v1 = que.front();
		que.pop();
		REP(i, n)
			if ((v1.code & (1 << i)) == 0 && v1.n - len[i] >= 0 && !f[v1.code | (1 << i)][v1.n - len[i]] && f[1 << i][v1.n - len[i]])
			{
				f[v1.code | (1 << i)][v1.n - len[i]] = true;
				v2.n = v1.n - len[i];
				v2.code = v1.code | (1 << i);
				que.push(v2);
			}
	}
	REP(i, m) ans += f[(1 << n) - 1][i];
}

int main()
{
	while (ri())
	{
		solve();
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 58780
Node = Struct.new(:t, :d) do
  def <=>(node)
    d <=> node.d
  end
end

class PriorityQueue
  attr_reader :size

  def initialize(order: :asc)
    @size = 0
    @nodes = []
  end

  def empty?
    @size.zero?
  end

  def push(node)
    index = size
    @size += 1

    while index > 0
      parent = (index - 1) / 2

      break if (@nodes[parent] <=> node) <= 0

      @nodes[index] = @nodes[parent]
      index = parent
    end

    @nodes[index] = node
  end

  alias_method :<<, :push

  def pop
    node = @nodes.first
    root = @nodes[size - 1]
    @size -= 1
    index = 0

    while index * 2 + 1 < @size
      left = 2 * index + 1
      right = left + 1

      if right < size && (@nodes[right] <=> @nodes[left]) <= 0
        left = right
      end

      break if (@nodes[left] <=> root) > 0

      @nodes[index] = @nodes[left]
      index = left
    end

    @nodes[index] = root
    node
  end

  def top
    @nodes.first
  end
end

N, K = gets.split.map(&:to_i)

sushi = []

N.times do 
  t, d = gets.split.map(&:to_i)

  sushi << [t, d]
end

sushi.sort_by! { |_t, d| -d }

current_list = sushi.take(K)
sum = 0
kinds = Hash.new(0)
pque = PriorityQueue.new

current_list.each do |t, d|
  sum += d
  kinds[t] += 1
  pque.push(Node.new(t, d))
end

k = kinds.size
ans = sum + k ** 2

sushi[K..-1].each do |t, d|
  next if kinds[t] > 0

  while !pque.empty? && kinds[pque.top.t] <= 1
    pque.pop
  end

  break if pque.empty?

  s = sum - pque.top.d + d
  x = (k + 1) ** 2
  a = s + x

  sum = s
  ans = a if ans < a
  k += 1
  kinds[pque.top.t] -= 1
  kinds[t] += 1
  pque.pop

  break if k == K
end

puts ans


Measured memory_bytes: 15936
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;


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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0) {
    c -= b;
    a -= d;
    cerr << a << " " << c << endl;
  }

  if (c <= 0) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


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

bool binarySearch(vector<int> s, int n, int key) {
	int left = 0, right = n, mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (s[mid] == key)return true;
		else if (key < s[mid])right = mid;
		else left = mid + 1;
	}
	return false;
}

int main(void) {
	int n, q, T, ans = 0;
	cin >> n;
	vector<int> S(n + 1);
	for (int i = 0;i < n;i++)cin >> S[i];
	cin >> q;
	for (int i = 0;i < q;i++) {
		cin >> T;
		if (binarySearch(S, n, T)) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int N, M; cin >> N >> M;
  vector<int> pena(N, 0);
  int ans = 0;
  int ac = 0;
  
  for(int i = 0; i < M; i++){
    int pro; cin >> pro;
    string res; cin >> res;
    if(pena[pro] == -1) continue;
    
    bool isAc = (res == "AC");
    if(isAc){
      ac++;
      ans += pena[pro];
      pena[pro] = -1;
    }else{
      pena[pro]++;
    }
  }
  cout << ac << ' ' << ans << endl;
}

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

ll zett(ll a,ll b){
  ll l;
  if(a - b >= 0) l = a - b;
  else l = -(a-b);
  return l;
}

int main(void){
  ll n, k; cin >> n >> k;
  ll y = n % k;
  ll x = n / k;
  ll z = (x * k + k) - n;
  cout << min(y,z) << endl;
  return 0;
}


Measured memory_bytes: 256