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

#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int N;
    cin >> N;
    vector<lint> A(N);
    RPT0(i, N)
    {
        cin >> A[i];
        if (A[i] == 0) {
            cout << 0 << endl;
            return;
        }
    }

    mp::cpp_int ans = 1;
    RPT0(i, N)
    {
        ans *= A[i];
        if (ans > (mp::cpp_int)pow(10, 18)) {
            cout << -1 << endl;
            return;
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 4052
from collections import Counter,deque
def bfs(G,s,N):
    dist=[-1]*(N+1)
    d=deque()
    dist[s]=0
    d.append(s)
    while(len(d)!=0):
        v=d[0]
        d.popleft()
        for nv in G[v]:
            if(dist[nv]!=-1):
                continue
            #発見した地点への操作
            dist[nv]=dist[v]+1
            d.append(nv)
            #ここまで
    return dist

N,X,Y=map(int,input().split())
G=[[] for i in range(N+1)]
for i in range(1,N):
    G[i].append(i+1)
    G[i+1].append(i)
G[X].append(Y);G[Y].append(X)
Count=[0]*(N+1)
for i in range(1,N+1):
    li=bfs(G,i,N)
    c=Counter(li)
    for i in range(1,N+1):
        Count[i]+=c[i]
for i in range(1,N):
    print(Count[i]//2)


Measured memory_bytes: 82788
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int  maxn = 1e4 + 10;
const ll MOD = 1e9 +  7;
string s;
int D, n;
int dp[10005][105][3];
int rek(int at, int modulo, int is_bigger){
    if(at == n){
        if(modulo == 0){
            return 1;
        }
        return 0;
    }
    if(dp[at][modulo][is_bigger] != -1){
        return dp[at][modulo][is_bigger];
    }
    int ret = 0;
    int till;
    if(is_bigger == 0){
        till = (s[at] - '0');
    }
    else{
        till = 9;
    }
    for(int i = 0; i <= till; i ++){
        int new_modulo = modulo;
        new_modulo += i;
        new_modulo %= D;
        int big_tmp = is_bigger;
        if(is_bigger == 0 and i < (s[at] - '0')){
            big_tmp = 1;
        }
        ret += rek(at + 1, new_modulo, big_tmp);
        if(ret >= MOD){
            ret -= MOD;
        }
    }
    return dp[at][modulo][is_bigger] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> s >> D;
    n = (int)s.length();
    memset(dp, -1, sizeof dp);
    int ret = rek(0, 0, 0);
    ret -= 1;
    if(ret < 0){
        ret += MOD;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 13312
#include<stdio.h>
#include<string.h>
int main(void)
{
	int flag=0;
	int a[123]={0};
	char s[26];
	scanf("%s",s);
	int i,j,l=strlen(s);
	//printf("%d\n",l);
	for(i=0;i<l;i++)
	{
		//printf("%c\n",s[i]);
		int index=s[i];
		//printf("%d\n",index);
		if(a[index]!=0)
		{
			flag=1;
			break;
		}
		a[index]=1;
	}
	if(flag) printf("no\n");
	else printf("yes\n");
	
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

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

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

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

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

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

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int N, M, X, Y;
    int x[100], y[100];
    cin >> N >> M >> X >> Y;
    REP(i, N) cin >> x[i];
    REP(i, M) cin >> y[i];

    sort(x, x + N);
    sort(y, y + M);

    if(min(y[0], Y) - max(x[N - 1], X) >= 1) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(1e6+1,0);
	for(int i=0;i<n;++i){
		int A; cin>>A;
		++a.at(A);
	}
	int ans=0;
	for(int i=0;i<a.size();++i){
		if(a.at(i)==0)continue;
		if(a.at(i)==1)++ans;
		for(int j=i;j<a.size();j+=i){
			a.at(j)=0;
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 7128
#include<bits/stdc++.h>
using namespace std;
#define lli                      int long long
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define mp                       make_pair
#define all(v)                   v.begin(),v.end()
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define sort(t)                  sort(t.begin(),t.end())
#define mem(a,b)                 memset(a,b,sizeof a)
#define t_c(t)                          for(int z=1;z<=t;z++)
#define p_c                             printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define sf                       scanf
#define pf                       printf
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define MX                       100005
#define inf                      10000000000000000+7
#define M                        1000000002
#define MINI                     -1000000003
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move

//int kx[]={+2,+2,-2,-2,+1,+1,-1,-1};     //Knights move
//int ky[]={+1,-1,+1,-1,+2,-2,+2,-2};     //Knights move


//#define for(i,a,n)    for(int i=a;i<n;i++)
//it=myset.find(20);
//int a[8]= {0,0,-1,1,-1,1,-1,1};
//int b[8]= {-1,1,0,0,-1,1,1  ,-1};

int main()
{
 lli n,i,j;
 cin>>n;
 lli a[n+5],b[n+5],c[n+5],ans=0;
 for(i=0;i<n+1;i++)cin>>a[i];
 for(i=0;i<n;i++)cin>>b[i];
 mem(c,0);
 for(i=0;i<n;i++)
 {
     if(a[i]>=b[i])
     {
         ans+=b[i];
     }
     else
     {
         ans+=a[i];
        b[i]=b[i]-a[i];
        if(b[i]>=a[i+1])
        {ans+=a[i+1];
            a[i+1]=0;

        }
        else
        {
            a[i+1]=a[i+1]-b[i];
            ans+=b[i];
        }
     }
 }

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


Measured memory_bytes: 5844
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        mut t: Chars
    }
    for c in t.iter_mut() {
        if *c == '?' {
            *c = 'D';
        }
        print!("{}", c);
    }
    println!("");

}


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

int main() {
	int N,A;
    cin >> N >> A;
  	int B;
  	B = N % 500 ;
  	if (B <= A){
    	cout << "Yes" << endl;
    }
    else{
      	cout << "No" << endl;
	}
}


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


 int main(){ 

 int A, B, ans;

 cin >> A >> B;


 if (A < 6) ans = 0;
  else if (A >= 13) ans = B;
  else ans = B/2;

 cout << ans << endl;

 return 0;
}

Measured memory_bytes: 256
N = int(input())
w = list(map(int, input().split()))
gokei = sum(w)
gokei2 = 0
gokei3 = 0
y = []
tmp = 0
ans = gokei
ans2 = 0

for i in range(N):
    for k in range(i):
        y.append(w[k])
        gokei2 = sum(y)
    gokei3 = gokei - gokei2
    tmp = abs(gokei3 - gokei2)
    if ans > tmp:
        ans = tmp
        ans2 = i
    gokei2 = 0
    gokei3 = 0
    y = []
    tmp = 0

print(ans)


Measured memory_bytes: 3064
/*
春已走，花又落，用心良苦却成空
我的痛，怎么形容，一生爱错放你的手
———《用心良苦》张宇
*/
#include <bits/stdc++.h>
using namespace std;

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
// #define MPS
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 100050;

int n, q, top;
ll a[maxn], t[maxn], res[maxn], Ans;

int main()
{
	#ifdef MPS
		fp("agc03e.in","r",stdin);
		fp("agc03e.out","w",stdout);
	#endif
	sf("%d%d",&n,&q);
	a[top=1] = n;
	fo(i,1,q) 
	{
		ll x; sf("%lld",&x);
		while(top && a[top] >= x) -- top;
		a[++top] = x;
	}
	t[top] = 1;
	fd(i,top,1)
	{
		ll k = a[i];
		while(1)
		{
			int p = lower_bound(a+1,a+i,k) - a - 1;
			if(!p) break;
			t[p] += t[i] * (k / a[p]);
			k %= a[p];
		}
		res[1] += t[i]; res[k+1] -= t[i];
	}
	fo(i,1,n) {Ans += res[i]; pf("%lld\n",Ans);}
	return 0;
}

Measured memory_bytes: 4096
import java.util.*;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int e=sc.nextInt();
		int k=sc.nextInt();
		
		if(e-a<=k){
			System.out.println("Yay!");
		}
		else{
			System.out.println(":(");
		}
	}
}

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

int main(void){
    string s; cin >> s;

    if((s[0]==s[1] and s[0]==s[2]) || (s[1]==s[2] and s[2]==s[3])){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
a1,a2,a3 = map(int,input().split())

c1 = abs(a1-a2)
c2 = abs(a2-a3)
c3 = abs(a1-a3)

C = [c1,c2,c3]
D = sorted(C)
ans = D[1]+D[0]

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cctype>

using namespace std;

typedef long long Board;

const int N = 9;
const Board GOAL = 0x087654321;

const int PATTERN = 362880;
bool frontier[PATTERN];

struct State {
    Board board;
    int count;
};

queue<State> q;

// I made this function based on one by Haruhiko Okumura(Algorithm 
// Dictionary, p116) and one by M.Hiroi(Puzzle DE Programming).
inline int change_number(long long board) {
    static int fact_table[N] = {
         40320, 5040, 720, 120, 24, 6, 2, 1, 0      // on N = 8
    };
    int value = 0;
    for (int j = 0; j < N - 1; ++j) {
        int J = static_cast<int>((board >> (j*4) & 0xF));
        value += fact_table[j] * J;
        for (int k = j + 1; k < N; ++k) {
            int K = static_cast<int>((board >> k*4) & 0xF);
            if (J < K) {
                board &= ~(0xFLL << k*4);
                board |= (static_cast<long long>(K - 1) << k*4);
            }
        }
    }
//    printf("[change_number] value = %d\n", value);
    return value;
}

inline void swap(int numpos, int spacepos, Board& board) {
    long long num = (board >> (numpos*4)) & 15;
    board |= num << (spacepos*4);
    board &= ~(15LL << (numpos*4));
}

inline int swap_and_check(int numpos, int spacepos, State s) {
    swap(numpos, spacepos, s.board);
    if (s.board == GOAL) {
        return ++s.count;
    }
    int pos = change_number(s.board);
    if (!frontier[pos]) {
        ++s.count;
        q.push(s);
        frontier[pos] = true;
    }
    return -1;
}

void print(Board b) {
    for (int i = 0; i < N; ++i) {
        printf("%2lld", (b >> (i*4) & 15));
    }
    printf("\n");
}

// OK
int main(void) {

    Board board = 0;
    for (int i = 0, num; i < N; ++i) {
        scanf("%d", &num);
        board |= static_cast<long long>(num) << (i*4);
    }
//    print(GOAL);
//    print(board);

    int count = 0;
    if (board == GOAL) {
        goto END;
    }

    q.push({ board, 0 });
    while (!q.empty()) {
        State s = q.front();
        q.pop();

        int pos = -1;
        while (++pos < N) {
            if (((s.board >> (pos*4)) & 15) == 0) {
                break;
            }
        }

        if (pos < 6) {
            if ((count = swap_and_check(pos + 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos > 2) {
            if ((count = swap_and_check(pos - 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 < 2) {
            if ((count = swap_and_check(pos + 1, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 > 0) {
            if ((count = swap_and_check(pos - 1, pos, s)) > 0) {
                break;
            }
        }
    }

END:
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1944
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>list(N);
  for(int i=0;i<N;i++){
    cin>>list.at(i);
  }
  sort(list.begin(),list.end());
  int sum=list.at(N-1)/2;
  for(int i=0;i<N-1;i++){
    sum=sum+list.at(i);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map &:to_i
b=[a[-1]-a[0]]
(n-1).times do |i|
  b<< a[i]-a[i+1]
end
m=n*(n+1)/2
x=a.inject(:+)
y=x/m
r=[]
n.times do |i|
  g=y+b[i]
  if g%n==0 && g/n>=0
    r<< g/n
  else
    r<< 10**9
  end
end
puts (x%m==0 && r.inject(:+)==y) ? :YES : :NO

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

using ll = long long;

ll MOD = 1e9 + 7;

ll po[100001];

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll comb(int n, int k) {
    ll ans = (po[n] * mod_pow(po[n - k], MOD - 2, MOD)) % MOD;
    ans = (ans + MOD) % MOD;
    return ans;
}

int main() {
    po[0] = 1;
    rep(i, 100000) po[i + 1] = (po[i] * (i + 1)) % MOD;
    int N, K;
    cin >> N >> K;
    vector<vector<int>> edge(N, vector<int>(0));
    vector<int> a(N), b(N);
    rep(i, N - 1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        edge[a[i]].push_back(b[i]);
        edge[b[i]].push_back(a[i]);
        //cout << a[i] << b[i] << endl;
    }
    stack<int> s;
    int x = edge[0].size();
    //cout << x << endl;
    if (x >= K) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = comb(K, x + 1);
    //cout << ans;
    vector<bool> done(N, false);
    done[0] = true;
    rep(i, edge[0].size()) {
        s.push(edge[0][i]);
        done[edge[0][i]] = true;
    }
    while (s.size() > 0) {
        int t = s.top();
        //cout << t;
        s.pop();
        int x = edge[t].size();
        if (x - 1 > K - 2) {
            cout << 0 << endl;
            return 0;
        }
        ans = (ans * comb(K - 2, x - 1)) % MOD;
        //cout << ans << endl;
        rep(i, x) {
            int j = edge[t][i];
            if (!done[j]) {
                s.push(j);
                done[j] = true;
            }
        }
    }
    //cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 8056
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  vector<int> s(n+1);
  rep(i,n) {
    s[i+1] = (s[i]+a[i])%k;
  }
  map<int,int> mp;
  ll ans = 0;
  queue<int> q;
  rep(j,n+1) {
    ans += mp[s[j]];
    mp[s[j]]++;
    q.push(s[j]);
    if (q.size() == k) {
      mp[q.front()]--;
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12032
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner (System.in);
        int x = in.nextInt();
        int z,y,a,m;
        z = x/500;
        y = z * 1000;
        z = z * 500;
        z = (x-z)/5;
        a = z * 5;
        m = a + y;
        System.out.println(m);
    }
}


Measured memory_bytes: 35680
# -*- coding: utf-8 -*-

def sec2watch(S):
    """
    input S (sec)
    return "h:m:s"

    >>> sec2watch(46979)
    '13:2:59'

    >>> sec2watch(59)
    '0:0:59'
    >>> sec2watch(119)
    '0:1:59'
    >>> sec2watch(619)
    '0:10:19'

    """
    sec = int(S)
    h = sec / 3600
    m = (sec - 3600*h)/60
    s = sec - 3600*h - m*60

    return ":".join(map(str,(h,m,s)))


if __name__ == '__main__':
    S = raw_input()
    print sec2watch(S)

Measured memory_bytes: 6452
import sys
input = sys.stdin.readline

from heapq import heapify, heappop, heappush

N, D, A = map(int, input().split())
XH = []
XH_append = XH.append
for _ in range(N):
    x, h = map(int, input().split())
    XH_append((x, 0, h))

heapify(XH)
atk_cnt = 0
ans = 0
while XH:
    x, t, h = heappop(XH)
    if t == 0: #新しいのが出てきたタイミング
        if atk_cnt * A >= h:
            continue
        
        remain = h - atk_cnt * A #攻撃が足りない場合、追加する
        new_atk = (remain + A - 1) // A
        heappush(XH, (x + 2 * D, 1, new_atk))

        ans += new_atk
        atk_cnt += new_atk
    
    else:
        atk_cnt -= h

print (ans)


Measured memory_bytes: 35696
// https://atcoder.jp/contests/agc014/tasks/agc014_a
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = -1, count = 0;
  string s, t;
  cin >> a >> b >> c;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
  {
    lli d = a, e = b, f = c;
    a = e / 2 + f / 2 + 0.5;
    b = d / 2 + f / 2 + 0.5;
    c = d / 2 + e / 2 + 0.5;
    count++;
    if (count >= 100)
    {
      cout << ans << endl;
      return 0;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

class BIT():
    def __init__(self, n, data):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)
        if data:
            self.build(data)

    def build(self, data):
        for i in range(self.n):
            self.bit[i + 1] = self.data[i + 1] = data[i]
        for i in range(1, self.n):
            j = i + (i & (-i))
            if j <= self.n:
                self.bit[j] += self.bit[i]

    def add(self, idx, x):
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sub_sum(self, idx):
        a = 0
        while idx:
            a += self.bit[idx]
            idx -= (idx & (-idx))
        return a

    def sum(self, i, j):
        a = 0
        if j != 0:
            a += self.sub_sum(j)
        if i != 0:
            a -= self.sub_sum(i)
        return a

n,q=nii()
a=lnii()
bit=BIT(n,a)
for i in range(q):
    t,x,y=nii()
    if t==0:
        bit.add(x+1,y)
    else:
        print(bit.sum(x,y))

Measured memory_bytes: 65228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    string S; cin >> S;
    int res = 0;
    for (int i=0;i<=999;i++){
        string n = to_string(i);
        for (int j=0;j<3-to_string(i).size();j++) n = "0"+n;
        int cnt = 0;
        for (int j=0;j<N;j++){
            if (S[j]==n[cnt])cnt++;
            if (cnt==3) {
                res++;break;
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  long double x[n], d[n];
  rep(i,n) {
    cin >> x[i];
  }
  long double y;
  rep(i,n) {
    cin >> y;
    d[i] = abs(x[i]-y);
  }

  long double result = 0;
  rep(i,n) {
    result += d[i];
  }
  cout << fixed << setprecision(10) << result << endl;

  result = 0;
  rep(i,n) {
    result += d[i] * d[i];
  }
  cout << fixed << setprecision(10) << sqrt(result) << endl;

  result = 0;
  rep(i,n) {
    result += d[i]*d[i]*d[i];
  }
  cout << fixed << setprecision(10) << cbrt(result) << endl;

  result = 0;
  rep(i,n) {
    result = max(result, d[i]);
  }
  cout << fixed << setprecision(10) << result << endl;
}



Measured memory_bytes: 3424
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	char c;
	cin >> c;
	if (c == 'C') c = 'G';
	else if (c == 'G') c = 'C';
	else if (c == 'T') c = 'A';
	else if (c == 'A') c = 'T';
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
from bisect import bisect_left as bl
s = input()
t = input()
ind = dd(list)
res = 0
first = 1
for i in range(len(s)):
  ind[s[i]].append(i)
#print(ind)
for i in range(len(t)):
  if len(ind[t[i]]) == 0:
    print(-1)
    exit(0)
  temp = bl(ind[t[i]], res % len(s))
  #print(temp, res, t[i])
  if first == 0:
    if res % len(s) == ind[t[i]][min(temp, len(ind[t[i]]) - 1)]:
      temp += 1
  first = 0
  if temp == len(ind[t[i]]):
    res += (len(s) - res % len(s)) + ind[t[i]][0]
  else:
    res += ind[t[i]][temp] - res % len(s)
print(res + 1)

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

double siguma2(double *s);
double n;

int main(){
  cout << fixed << setprecision(8);
  while(1){

  cin >> n;
  if(n == 0) break;
  double s[1000] = {};
  for(int i = 0;i < n;i++){
    cin >> s[i];
  }
  double answer = 0;
  answer = sqrt(siguma2(s) / n);
  cout << answer << endl;
}
return 0;
}

double siguma2(double *s){
  double sum = 0;
  double avg;
  for(int i = 0;i < n;i++){
    sum += s[i];
  }
  avg = sum / n;
  sum = 0;
  for(int i = 0;i < n;i++){
    sum += pow(s[i] - avg,2);
  }
  return sum;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, m; std::cin >> n >> m;
  std::vector<std::vector<int>> grh(3 * n);
  while (m--) {
    int u, v; std::cin >> u >> v;
    u--; v--;
    grh[0 * n + u].push_back(1 * n + v);
    grh[1 * n + u].push_back(2 * n + v);
    grh[2 * n + u].push_back(0 * n + v);
  }
  int s, t; std::cin >> s >> t;
  s--; t--;
  constexpr int inf = 1 << 30;
  std::vector<int> dst(3 * n, inf);
  std::queue<int> que;
  que.push(s);
  dst[s] = 0;
  while (!que.empty()) {
    int crr = que.front(); que.pop();
    for (auto nxt : grh[crr]) {
      if (dst[nxt] != inf) continue;
      dst[nxt] = dst[crr] + 1;
      que.push(nxt);
    }
  }
  auto err = []{
    std::cout << -1 << std::endl;
    exit(0);
  };
  if (dst[t] == inf) err();
  assert(dst[t] % 3 == 0);
  std::cout << dst[t] / 3 << std::endl;
  return 0;
}

Measured memory_bytes: 17792
#166E
import bisect

N = int(input()) #2* 10**5
A_list = [0] + [int(e) for e in input().split()]

#まともに計算すると ≒ 2 * 10**10　でTLE

#参加者i, j (i < j) について，条件は以下のように書けます:
#j − i = Ai + Aj
#これを式変形すると，以下のようになります:
#i + Ai = j − Aj
#そこで，Li = i + Ai,Ri = i − Ai と定義すると，条件はLi = Rj と言い換えられます．
#したがって，とり得る値X を全て試し,
#Li = X
#Rj = X
#を満たす(i, j) の組を求めればいいですが，上と下の条件は独立なので，たとえば連想配列を使えば簡単に求まります．

Rj = [j - A_list[j] for j in range(1,N+1)]

X_Li_dict = dict()
for i in range(1,N+1):
    X = i + A_list[i]
    if X not in X_Li_dict:
        X_Li_dict[X] = set()

    X_Li_dict[X].add(i)

X_Rj_dict = dict()
for j in range(1,N+1):
    X = j - A_list[j]
    if X not in X_Rj_dict:
        X_Rj_dict[X] = set()
        
    X_Rj_dict[X].add(j)

ans = 0

for X_Li in X_Li_dict.items():
    X = X_Li[0]
    i_set = X_Li[1]
    #print("$$$$$$$$$$$$$$$$$$$$$")
    #print("X:",X,",i:",i_set)

    if X in X_Rj_dict:
        j_list = list(X_Rj_dict[X])
        j_list.sort(reverse=False)
        #print("j:",j_list)
        for i in i_set:
            ans_add = len(j_list) - bisect.bisect_right(j_list,i)
            #print(i,":",ans_add)
            ans += ans_add

print(ans)

Measured memory_bytes: 162048
#!/usr/bin/env python3
import sys
from fractions import gcd
# from math import gcd
from functools import reduce

def lcm(x, y):
    return (x * y) // gcd(x, y)


def solve(N: int, T: "List[int]"):
    print(reduce(lcm, T))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
long long int dp[1000000];
int main(void)
{
	long long int n;
	cin>>n;
	long long int a[n], i;
	for(i=0; i<n; i++)
	{
		cin>>a[i];
	}
	for(i=0; i<1000000; i++)
		dp[i]=-1;
	if(n==2)
	{
		cout<<abs(a[0]-a[1])<<endl;
		return 0;
	}
	dp[0]=a[0];
	dp[1]=abs(a[0]-a[1]);
	dp[2]=abs(a[0]-a[2]);
	for(i=3; i<n; i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
	

}

Measured memory_bytes: 8832
#include<iostream>
using namespace std;
int a,b,s=0;
int main(void){
	cin>>a>>b;
	if(b==100)s=a*1000+b;
	else if(b>=10)s=a*100+b;
	else s=a*10+b;
	for(int i=1;i*i<=s;i++)
		if(i*i==s){
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>

typedef long long ll;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    std::ios_base::sync_with_stdio(false);
    ll n, x; std::cin >> n >> x;
    ll d = -1;
    while (n--) {
        ll a; std::cin >> a;
        auto dist = std::abs(x - a);
        if (d == -1) {
            d = dist;
        } else {
            d = gcd(d, dist);
        }
    }
    std::cout << d;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	string s,t;
	cin >> s >> t;

	int cnt = 0;
	int n = s.size();
	for(int i = 0;i < n;i++){
		if(s[i] != t[i])cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3916
n = gets.to_i
a = gets.split.map(&:to_i)

sig = [1, -1]
ans = [0, 0]
tmp = [0, 0]

a.each.with_index{|t, i|
  2.times{|j|
    tmp[j] += t
    if tmp[j]*sig[(i+j)%2]<=0
      op = (tmp[j]-sig[(i+j)%2]).abs
      ans[j] += op
      tmp[j] = sig[(i+j)%2]
    end
  }
}

p ans.min

Measured memory_bytes: 8588
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N, K, Q = invr()
S = [K] * (N+1)
t = 0
for i in range(1, Q+1):
    a = inp()
    S[a] += 1
    t += 1

for i in range(1, N+1):
    if S[i] - t > 0:
        print("Yes")
    else:
        print("No")


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

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

int main(void) {
	int n, c,f;
	cin >> n;
	c = 0;
	f = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a == b) {
			c++;
		}
		else {
			c = 0;
		}
		if (c == 3) {
			f = 1;
		}
	}
	if (f == 1) {
		cout << "Yes" << endl;
	}else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    int ans = 0;
    rep(i,n) if (h[i]>=k) ans++;
    cout << ans << '\n';
    return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


ll K;
int main(){
    
    cin >> K;
    if(K % 50 == 0){
        cout << 50 << endl;
        for(int i = 0; i < 50; i++){
            cout << 49 + K / 50 << " ";
        }
        cout << endl;
    }
    else{
        vector<ll> a(50, (K + 49) / 50 + 49);
        for(int i = 0; i < 50 - (K % 50); i++){
            int max_idx = 0;
            for(int j = 1; j < (int)a.size(); j++){
                if(a[j] > a[max_idx]){
                    max_idx = j;
                }
            }
            for(int j = 0; j < (int)a.size(); j++){
                if(j == max_idx){
                    a[j] -= 50;
                }
                else{
                    a[j]++;
                }
            }
        }
        cout << 50 << endl;
        for(ll t : a){
            cout << t << " ";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N, M;

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

  cin >> N >> M;
  int ans = ((N-M)*100+M*1900)*pow(2, M);

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

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

ll solve() {
    ll N;
    cin >> N;
    unordered_map<int,int> num;
    int a;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        num[a]++;
    }
    ll ans = num.size();
    if ( ans % 2 == 0 ) ans--;
    return ans;
}

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

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

using namespace std;

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int eat = (D - 1) / A + 1;
    X += eat;
  }
  cout << X;

  return 0;
}


Measured memory_bytes: 256
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    ll n;
    cin>>n;
    ll ans=0;
    while(n--)
    {
        int in;
        cin>>in;
        ans+=(in-1);//counting (lcm-1) sum;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, type=0, p, w, g, y;
  string arare;
  cin >> N;
  for (int i=0; i<N; i++){
    cin >> arare[i];
  }
  for (int i=0; i<N; i++){
    if(arare[i]=='Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  long f[10][n],p[11][n];
  long kekka = -10000000000000;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 10;j++){
      cin >> f[j][i];
    }
  }
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 11;j++){
      cin >> p[j][i];
    }
  }
  for(int i = 1;i < 1<<10;i++){
    long cur = 0;
    for(int k = 0;k < n;k++){
      long c = 0;
      for(int j = 0;j < 10;j++){
        if((1 & i>>j) == 1 && f[j][k] == 1){
          c++;
        }
      }
      cur += p[c][k];
    }
    kekka = max(kekka,cur);
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
#include <queue>
#include <numeric>
//#include <bits/stdc++.h>

using namespace std;
const int INF = 1 << 30;

int main()
{
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    if(n%k==0)
        cout<<0<<endl;
    else 
        cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		INT32_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

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

int main()
{
	ll N = 0;
	ll ans = 0;

	cin >> N;
	vector< vector<ll> > A(2, vector<ll>(N, 0));
	Rep(i, 2) {
		Rep(j, N) {
			cin >> A[i][j];
		}
	}

	Rep(i, N) {
		// supose i-th step is down moving
		ll x = 0;
		ll y = 0;
		ll tmp = A[y][x];
		Rep(step, N) {
			if (step == i) {
				// down
				y++;
			}
			else {
				// right
				x++;
			}
			tmp += A[y][x];
		}
		ans = max(ans, tmp);
	}

	cout << ans << endl;

	cin >> N;

	return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Restore the Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int prts[MAX_N], pns[MAX_N], ds[MAX_N];
/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int k = n - 1 + m;

  for (int i = 0; i < k; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;

    nbrs[a].push_back(b);
    pns[b]++;
  }

  int rt = -1;
  for (int i = 0; rt < 0 && i < n; i++)
    if (pns[i] == 0) rt = i;
  //printf("rt=%d\n", rt);

  prts[rt] = -1;
  qi q;
  q.push(rt);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &ud = ds[u], vd = ud + 1;
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (ds[v] < vd) {
	ds[v] = vd;
	prts[v] = u;
      }
      if (--pns[v] == 0) q.push(v);
    }
  }

  for (int i = 0; i < n; i++) printf("%d\n", prts[i] + 1);

  return 0;
}


Measured memory_bytes: 7424
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char str[1024];
int v[26];
char to[]="AIZUNYAN";
int main(){
	scanf("%s",str);
	int n=strlen(str);
	for(int i=0;i<n-7;i++){
		for(int j=0;j<26;j++)v[j]=0;
		for(int j=0;j<8;j++)v[str[j+i]-'A']++;
		if(v[0]==2&&v[3]==1&&v[8]==1&&v['N'-'A']==2&&v['U'-'A']==1&&v['Y'-'A']==1){
			for(int j=0;j<8;j++){
				str[i++]=to[j];
			}i--;
		}
	}
	printf("%s\n",str);
}

Measured memory_bytes: 940
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int max=0;
	int max2=0;
	int index;
	for(int i=0;i<n;i++){
		if(max<a[i]){
			max=a[i];
			index=i;
		}	
	}

	for(int i=0;i<n;i++){
		if(i==index){
			max2=0;
			for(int j=0;j<n;j++){
				if(i==j)continue;
				if(max2<=a[j])max2=a[j];
			}
			printf("%d\n",max2);
		}else{
			printf("%d\n",max);
		}
	}
return 0;
}

Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int main(){
    int a=0,n;
    int bubble[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>bubble[i];
    }
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=i+1;j--){
            if(bubble[j]<bubble[j-1]){
                int swap=bubble[j];
                bubble[j]=bubble[j-1];
                bubble[j-1]=swap;
                a++;
            }
        }
    }
    for(int i=0;i<n-1;i++){
        cout<<bubble[i]<<" "<<flush;
    }
    cout<<bubble[n-1]<<endl;
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, K; cin >> N >> K;
  cout << N-K+1 << endl;
}

Measured memory_bytes: 256
import numpy as np

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    N = int(input())
    
    primes = prime_factorize(N)
    u, counts = np.unique(primes, return_counts=True)
    
    ans = 0
    for c in counts:
        i = 1
        while c - i >= 0:
            c -= i
            i += 1
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
    

Measured memory_bytes: 27284
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,x;cin>>n>>x;
  ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
  ll ans=0;
  if(a[0]>x){
    ans+=a[0]-x;
    a[0]=x;
  }
  for(ll i=0;i<n-1;i++){
    if(a[i]+a[i+1]>x){
      ans+=a[i+1]+a[i]-x;
      a[i+1]=x-a[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;	// N:個数　A:数字
  int num = 1000;	// num:最低割れる回数
  int num_i = 0;	//num_i:各数値の割れる回数
  
  cin >> N;		// N入力
  for(int i=0 ; i<N ; i++){	//数値の個数分繰り返す
    cin >> A;	// A入力
    while(A % 2 == 0){		// Aが偶数だったら
      num_i++;
      A /= 2;
    }
    if(num_i < num) num = num_i;
    num_i = 0;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=200000+10;
LL a,b,c;
int main(){
    cin>>a>>b>>c;
    if(b>=c) {
        cout<<b+c<<endl;
    } else {
        if(a+b>=c) cout<<b+c<<endl;
        else cout<<b+b+a+1<<endl;
    }
}






Measured memory_bytes: 256
a, b, h, m = gets.strip.split(" ").map{|n| n.to_i }

#p Math.cos(0)

ha = (h.to_i * 5 * 6) + (m.to_i * 0.5)
ma = m.to_i * 6

angle = [ha, ma].max - [ha, ma].min

if angle >= 180
  angle = 360 - angle
end

rad = angle * Math::PI / 180

#ans = a * a + b * b
ans = (a * a) + (b * b) - (2 * a * b * Math.cos(rad))

puts Math.sqrt(ans)

Measured memory_bytes: 14724
def read_input():
    s = input()
    k = int(input())
    return s, k


# sから、candsの間に挟まる文字列(長さl)を探す
def search_insertion(s, cands, l):
    result = []

    for i in range(len(s)):
        for c in cands:
            if s[i:i+l].startswith(c):
                result.append(s[i:i+l])

    cands.extend(result)
    cands = list(set(cands))
    return cands


def sort_s(cands):
    t = [[c for c in s] for s in cands]
    t.sort()
    return [''.join(s) for s in t]


def submit():
    s, k = read_input()

    cands = list(set([c for c in s]))
    precands = None
    for i in range(2, len(s) + 1):
        cands = search_insertion(s, cands, i)
        cands = sort_s(cands)
        cands = cands[:k]

        if precands == cands:
            break
        precands = cands[:]

    print(cands[-1])

if __name__ == '__main__':
    submit()


Measured memory_bytes: 4712
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a+b==15)
        printf("+");
    else if(a*b==15)
        printf("*");
    else
        printf("x");
}


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

int main(){
  long long N ; cin >> N ; 
  vector<long long> a(N) ; 
  for(long long i = 0 ; i < N ; i++){
    cin >> a.at(i) ; 
  }
  long long cnt = 0 ;  
  for(long long i = 0 ; i < N ;i++){
    if(a.at(i)%2 == 0 ){
      while(a.at(i)%2 == 0 ){
        a.at(i) /= 2 ; 
        cnt++ ; 
      }
      //cout << cnt << endl ; 
    }
  }
  cout << cnt << endl ; 
}

Measured memory_bytes: 3720
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if((x-r) >= 0 && (x+r) <= w && (y-r) >= 0 && (y+r) <= h) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}



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

int main()
{
	int n;
	while(cin >> n){
		if(n==0)
			break;
		int year;
		cin >> year;
		int a,c;
		double b;
		double kinri = 0;
		int ans;
		double kk;
		for(int i=0;i<n;i++){
			cin >> a >> b >> c;
			switch(c){
				case 1:
					kk = 1.0+(static_cast<double>(year)*b)/100;
					if(kinri < kk){
						kinri = kk;
						ans = a;
					}
					break;
				case 2:
					double k;
					k = 1.0+b/100;
					kk = 1.0;
					for(int i=0;i<year;i++){
						kk = kk*k;
					}
					break;
				default:
					break;
			}
			if(kinri < kk){
				kinri = kk;
				ans = a;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int sum_p = 0;
  int i = 1;
  while (true) {
    sum_p += i;
    if (sum_p >= n) {
      break;
    }
    ++i;
  }
  for (int j=1; j<=i; j++) {
    if (j == sum_p - n) {
      continue;
    }
    cout<<j<<endl;
  }

}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <deque>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int k;

const int INF = 10000000;
int dist[100000+10];

int go(void) {
  REP(i, 100000+10) {
    dist[i] = INF;
  }
  deque<pair<int,int> > q;
  q.push_back(make_pair(1, 1));
  dist[1] = 1;
  while(!q.empty()) {
    pair<int,int> cur = q.front(); q.pop_front();
    if(dist[cur.first] < cur.second) {
      continue;
    }
    if(cur.first == 0) {
      break;
    }
    int n10 = (cur.first*10) % k;
    if(cur.second < dist[n10]) {
      q.push_front(make_pair(n10, cur.second));
      dist[n10] = cur.second;
    }
    int n1 = (cur.first+1) % k;
    if(cur.second+1 < dist[n1]) {
      q.push_back(make_pair(n1, cur.second + 1));
      dist[n1] = cur.second+1;
    }
  }
  return dist[0];
}

int main(void) {
  while(~scanf("%d", &k)) {
    int res = go();
    printf("%d\n", res);
  }
  return 0;
}


Measured memory_bytes: 1024
def check_val(ind):
    if ind > len(b): return False 
    if b[ind-1] == ind:
        ans.append(ind)
        del b[ind-1]
        if ind not in b: set_b.remove(ind)
        return True
    else:
        return False


N,*b = map(int,open(0).read().split())
if b[0] != 1: 
    print(-1)
    exit()

set_b = sorted(set(b),reverse=True)
ans = []

while len(b) != 0:
    flg = False
    for i in set_b:
        flg = check_val(i)
        if flg: break
    
    if flg == False:
        print(-1)
        exit() 
else: #消せるものがなくなった
    print(*ans[::-1],sep="\n")
    
        
    


Measured memory_bytes: 9124