akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(void) {

  char s[100001];
  scanf("%s", s);
  int length = strlen(s);
  int p_max = length/2;
  int p_count = 0;
  for (int i = 0; i < length; i++) {
    if (s[i] == 'p') {
      p_count++;
    }
  }
  int ans = p_max-p_count;
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static long ans[];
	public static boolean ok[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int sLen = s.length();
		int tLen = t.length();

		s = repeat(s, (int)Math.max(2, Math.ceil(tLen * 2.0 / sLen))).toString();

		ans = new long[sLen];
		Arrays.fill(ans, -1);
		ok = new boolean[sLen];
		Arrays.fill(ok, false);

		ArrayList<Integer> matchIndex = kmp(s, t);
		for(int i = 0; i < matchIndex.size(); i ++) {
			ok[matchIndex.get(i) % sLen] = true;
		}
		long max = 0;
		for(int i = 0; i < sLen; i ++) {
			max = Math.max(max, solve(i, sLen, tLen));
		}
		System.out.println(max);
	}

	static String repeat(String s, long y) {
		StringBuilder tmp = new StringBuilder();
		if (y == 0) {
			return "";
		} else if (y == 1) {
			return s;
		} else if (y % 2 == 0) {
			tmp.append(repeat(s, y / 2));
			tmp.append(tmp);
			return tmp.toString();
		} else {
			tmp.append(repeat(s, y / 2));
			tmp.append(tmp);
			tmp.append(s);
			return tmp.toString();
		}
	}

	static long solve(int i, int sLen, int tLen) {
		i %= sLen;
		if(ans[i] == -2) {
			System.out.println(-1);
			System.exit(0);
		}else if(ans[i] == -1) {
			ans[i] = -2;
			ans[i] = (ok[i] ? (solve(i + tLen, sLen, tLen) + 1) : 0);
		}
		return ans[i];
	}

	static ArrayList<Integer> kmp(String s, String p) {
		int sLen = s.length();
		int sInt[] = new int[sLen];
		for(int i = 0; i < sLen; i ++) {
			sInt[i] = s.charAt(i) - 'a';
		}
		int pLen = p.length();
		int pInt[] = new int[pLen];
		for(int i = 0; i < pLen; i ++) {
			pInt[i] = p.charAt(i) - 'a';
		}
	
		int sIndex = 1;
		int pIndex = 0;
	
		int skip[] = new int[pLen + 1];
		Arrays.fill(skip, 0);
		while(sIndex < pLen) {
			if(pInt[sIndex] == pInt[pIndex]) {
				sIndex ++;
				pIndex ++;
				skip[sIndex] = pIndex;
			}else if(pIndex == 0) {
				sIndex ++;
				skip[sIndex] = 0;
			}else {
				pIndex = skip[pIndex];
			}
		}
	
		ArrayList<Integer> matchIndex = new ArrayList<Integer>();
		sIndex = 0;
		pIndex = 0;
		end: while(true) {
			while(sIndex < sLen && pIndex < pLen && sInt[sIndex] == pInt[pIndex]) {
				sIndex ++;
				pIndex ++;
			}
			if(pIndex >= pLen) {
				matchIndex.add(sIndex - pLen);
				pIndex = skip[pIndex];
			}else if(pIndex == 0){
				sIndex ++;
			}else {
				pIndex = skip[pIndex];
			}
			if(sIndex >= sLen) { break end; }
		}
		return matchIndex;
	}
}

Measured memory_bytes: 127888
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll N; 
  cin >> N;
  ll i = 0;
  ll j, ans;
  ll end = 0;
  
  if(N%10==3){
    cout << "bon" << endl;
  }else if(N%10==1 || N%10==0 || N%10 ==6 || N%10==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <random>
using namespace std;
int const N = 1000;
int arr[N];

int main()
{
   int r, d, x;
   cin >> r >> d >> x;
   arr[0] = x;
   for (int i = 1; i < 11; i ++)
   {
       arr[i] = r * arr[i - 1] - d;
       cout << arr[i] << endl;
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

string ap="apple";
string pe="peach";

string str;


int main(){
	getline(cin,str);
	int len=str.size();
	for(int i=0; i<len; i++){
		if(str.at(i)=='a'){
			for(int j=0; j<5; j++){
				if(i+j>len||str.at(i+j)!=ap.at(j))break;
				if(j==4){
					for(int k=0; k<5; k++){
						str.at(i+k)=pe.at(k);
					}
				}
			}
		}
		else if(str.at(i)=='p'){
			for(int j=0; j<5; j++){
				if(i+j>len||str.at(i+j)!=pe.at(j))break;
				if(j==4){
					for(int k=0; k<5; k++){
						str.at(i+k)=ap.at(k);
					}
				}
			}
		}
	}
	cout<<str<<endl;
}

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

int main(){
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++){
        sum+=s[i]-'0';
    }
    int s2=(s[0]-'0')+9*(s.size()-1);
    if(sum<s2)cout<<s2-1<<endl;
    else cout<<s2<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

class Dice {
private:
	int surface[6];
	void next(int a, int b, int c, int d);
	

public:
	Dice(int surface[6]);
	Dice();
	void role(char dir);// W E N S
	void rot(char dir); //L or R
	void set(int pos, int num);
	int get(int pos);
	void settop(int prevpos);
	bool operator ==(Dice so);
	bool operator !=(Dice so);
};

int main(void) {
	Dice dice, dicebuf, dice2;

	for (int i = 0; 6 > i; i++) {
		int buf;
		scanf("%d", &buf);
		dice.set(i, buf);
	}
	for (int i = 0; 6 > i; i++) {
		int buf;
		scanf("%d", &buf);
		dice2.set(i, buf);
	}
	
	for (int i = 0; 6 > i; i++) {
		dicebuf = dice;
		dicebuf.settop(i);
		for (int j = 0; 4 > j; j++) {
			dicebuf.rot('R');
			if (dicebuf == dice2) {
				printf("Yes\n");
				return 0;
			}
		}
	}

	printf("No\n");
	return 0;
}

void Dice::next(int a, int b, int c, int d)
{
	swap(surface[c], surface[d]);
	swap(surface[b], surface[c]);
	swap(surface[a], surface[b]);
}

Dice::Dice(int surface[6])
{
	for (int i = 0; 6 > i; i++)
		Dice::surface[i] = surface[i];
}

Dice::Dice()
{
	for (int i = 0; 6 > i; i++) surface[i] = 0;
}

void Dice::role(char dir)
{
	switch (dir) {
	case 'W': next(0,3,5,2);  break;
	case 'E': next(0,2,5,3);  break;
	case 'N': next(0,4,5,1);  break;
	case 'S': next(0,1,5,4);  break;
	}
}

void Dice::rot(char dir)
{
	switch (dir) {
	case 'L': next(1, 3, 4, 2); break;
	case 'R': next(1, 2, 4, 3); break;
	}
}

void Dice::set(int pos, int num)
{
	surface[pos] = num;
}

int Dice::get(int pos)
{
	return surface[pos];
}

void Dice::settop(int prevpos) //?????????????????????
{
	switch (prevpos) {
	case 0:  break;
	case 1: role('N'); break;
	case 2: role('W'); break;
	case 3: role('E'); break;
	case 4: role('S'); break;
	case 5: role('N'); role('N'); break;
	}
}

bool Dice::operator ==(Dice so)
{
	for (int i = 0; 6 > i; i++) if(this->get(i) != so.get(i))
		return false;
	return true;
}

bool Dice::operator !=(Dice so)
{
	for (int i = 0; 6 > i; i++) if (surface[i] != so.get(i))
		return true;
	return false;
}

Measured memory_bytes: 1172
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int a;
    cin >> a;
    char b[a];
    for(int i=0;i<a;i++){
        cin >> b[i];
        if(b[i]=='Y'){
            cout << "Four";
            return 0;
        }
    }
    cout << "Three";
}

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

long long int MOD=1000000007;

long long int gamma[100001];

long long int inv(long long int t){//逆元
	long long int t2[36];
	t2[0]=1;t2[1]=t;
	for(int i=2;i<36;i++){
		t2[i]=(t2[i-1]*t2[i-1])%MOD;
	}
	long long int ans=1;
	long long int s=MOD-2;
	int i=1;
	while(s>0){
		if(s%2==1){ans=(ans*t2[i])%MOD;}
		s=s/2;i++;
	}
  return ans;
}

long long int C(long long int a,long long int b){//combination
  if(a==b or b==0){return 1;}
	long long int ans=gamma[a];
	ans=(ans*inv(gamma[b]))%MOD;
	ans=(ans*inv(gamma[a-b]))%MOD;
	return ans;
}

long long int gcd(long long int a,long long int b){
	while(a!=b){
		if(b>a){swap(a,b);}
		a=a-b;
	}
	return a;
}

int main(){
	long long int a;
	cin>>a;
	if(a%2==1){cout<<0;}
	else{
		long long int ans=0;
		a=a/2;
		while(a!=0){
			ans+=a/5;
			a=a/5;
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int x, y;
    
    scanf("%d %d",&x,&y);
    if(y%2==1){
      printf("No");
    }else if(y>=2*x && y<=4*x){
      printf("Yes");
    }else{
      printf("No");
    }
return 0;
}

Measured memory_bytes: 1720
from collections import Counter
n=int(input())
data=[int(aa) for aa in input().split()]

dct=Counter(data)
dct=dct.items()

dct2=[item for item in dct if item[1] > 1]
dct2.sort(reverse=True)

dct4=[item for item in dct if item[1] > 3]
dct4.sort(reverse=True)

ans=0
if len(dct2) > 1:
  ans=dct2[0][0]*dct2[1][0]
if len(dct4) > 0: 
  ans=max(ans,dct4[0][0]*dct4[0][0])

print(ans)


Measured memory_bytes: 18592
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);
ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}
 
ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}
 
ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}
 
ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}
 
int main()
{
	fio
	int n,k;
	cin>>n>>k;
	vector<int>nm(n);
	for(int i=0;i<n;++i)
	{
		cin>>nm[i];
	}
	vector<bool>D(k+1,false);
	for(int i=1;i<=k;++i)
	{
		bool b=true;
		for(int j=0;j<n;++j)
		{	
			if(i>=nm[j])
			{
				b=b&D[i-nm[j]];
			}
		}
		if(b==false)
		{
			D[i]=true;
		}
		else{
			D[i]=false;
		}
	}
	cout<<(D[k]?"First":"Second")<<"\n";

	return 0;
}

Measured memory_bytes: 3656
s=int(input())
mod=10**9+7

if s<3:
    print(0)
    exit()

dp=[1]*(s+1)

dp[0]=0
dp[1]=0
dp[2]=0

#print(dp)
for i in range(3,s+1):
    for j in range(3,s-i+1):
        dp[i+j]+=dp[i]%mod
    #print(i,dp)
print(dp[s]%mod)







Measured memory_bytes: 65484
#include <iostream>
#include <string>
#include <map>
#include <cstdio>
using namespace std;

string a[101];
string b[101];
map<string,int> mymap;
int main(int argc, const char * argv[]) {
    
    
    int n,m;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        cin >> a[i];
        
        mymap[a[i]]++;
        
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        cin >> b[i];
        mymap[b[i]]--;
    }
    
    int ans = 0;
    for (map<string,int>::iterator it=mymap.begin(); it!=mymap.end(); ++it){
     //   cout << it->first << " " << it->second << '\n';
        if(ans < it->second){
            
            ans = it->second;
        }
    }
    printf("%d\n",ans);
    
    return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():

    setrecursionlimit(2000001)

    current, q = [int(x) for x in stdin.readline().split()]

    tree = [[] for _ in range(current + 1)]
    for _ in range(current - 1):
        a, b = [int(x) for x in stdin.readline().split()]
        tree[a].append(b)
        tree[b].append(a)

    cnt = [0] * (current + 1)
    for _ in range(q):
        parent, x = [int(x) for x in stdin.readline().split()]
        cnt[parent] += x

    stack = []
    visited = [False] * (current + 1)

    stack.append((0, 1))

    while len(stack) > 0:
        parent, current = stack.pop()
        visited[current] = True
        cnt[current] += cnt[parent]
        for child in tree[current]:
            if not visited[child]:
                stack.append((current, child))

    print(*cnt[1:])


main()


Measured memory_bytes: 58220
N = int(input())
A = list(map(int, input().split()))

if N == 1:
  print(1)
else:
  ans = 0
  i = 0
  while i < N:
    while i + 1 < N and A[i] == A[i + 1]:
      i += 1
    if i + 1 < N and A[i] < A[i + 1]:
      while i + 1 < N and A[i] <= A[i + 1]:
        i += 1
    elif i + 1 < N and A[i] > A[i + 1]:
      while i + 1 < N and A[i] >= A[i + 1]:
        i += 1
    
    ans += 1
    i += 1
      
  print(ans)

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

using namespace std;
using ll = long long;

ll N, D;
vector<ll> ts, fs;
int main(void) {
	cin >> N >> D;
	ll ans = 0, dnow = 0;
	ll tp = 0, fp = 1;
	for (int i = 0; i < N; i++) {
		int t, f;
		cin >> t >> f;
		int dt = t - tp, df = abs(f - fp);
		if (dt < df) {
			ans = -1;
			break;
		}
		int roundtime = fp + f - 2;
		if (dt >= roundtime) { // take down, d to 0
			ans += (fp - 1) * dnow;
			dnow = 1;
		} else { // go next
			if (dnow == D) {
				ans = -1;
				break;
			}
			ans += dt * dnow;
			dnow++;
		}
		tp = t;
		fp = f;
	}
	if (ans != -1) ans += (fp - 1) * dnow;
	cout << ans << endl;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

typedef pair<ll, ll> P;
vec d;
struct edge {
    ll to, cost;
};
vector<vector<edge>> G;

void dijkstra (ll s, ll V) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(V, inf);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

    ll N;
    cin >> N;
    G.assign(N, vector<edge>());
    d.assign(N, inf);
    Rep (i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back({b, 1});
        G[b].push_back({a, 1});
    }

    queue<ll> q;
    q.push(0);
    d[0] = 0;
    while (q.size()) {
        ll v = q.front();
        q.pop();
        for (auto nv : G[v]) {
            if (d[nv.to] < inf) continue;
            d[nv.to] = d[v] + 1;
            q.push(nv.to);
        }
    }

    ll tmp = 0;
    Rep (i, N) {
        if (d[i] > d[tmp]) tmp = i;
    }

    d.assign(N, inf);
    d[tmp] = 0;
    q.push(tmp);
    while (q.size()) {
        ll v = q.front();
        q.pop();
        for (auto nv : G[v]) {
            if (d[nv.to] < inf) continue;
            d[nv.to] = d[v] + 1;
            q.push(nv.to);
        }
    }

    ll L = 0;
    for (ll e : d) chmax(L, e);

    if (L % 3 == 1) {
        cout << "Second\n";
    } else cout << "First\n";
}

Measured memory_bytes: 17644
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let [| n; k |] = reada int
    let ans = k * (pown (k - 1) (n - 1))
    puts ans
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 11348
N = int(input())
S = input()

n_c = 0
min_n_c = 0
for s in S:
    if s == "(":
        n_c += 1
    else:
        n_c -= 1
    min_n_c = min(min_n_c, n_c)
ans = S
for _ in range(-min_n_c):
    ans = "("+ans
for _ in range(n_c-min_n_c):
    ans += ")"

print(ans)



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

long long n, k;
vector<long long> a, memo;

long long solve();

int main() {
  cin >> n >> k;
  a.resize(n);
  memo.assign(n, -1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long now = 0, cnt = 0, tmp = 0;
  while (memo[now] == -1) {
    memo[now] = cnt;
    ++cnt;
    now = a[now];
    if (cnt == k) return now + 1;
  }
  tmp = memo[now];
  (k -= cnt) %= cnt - tmp;
  memo[now] = cnt;
  for (int i = 0; i < n; ++i)
    if (memo[i] >= tmp && (memo[i] - tmp) % (cnt - tmp) == k) return i + 1;
}

Measured memory_bytes: 6404
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    int a,b;
    double s;
    scanf("%d%d",&a, &b);
    s = a / 3.3057850 * b;

    printf("%.6lf\n", s);
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<n; i++)
#define rep2(i, m, n) for(int i=int(m); i<n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 100100100100;
const int MOD = 1000000007;

struct Edge{
  int id, to;
  Edge(int i, int t): id(i), to(t) {}
};
using Graph = vector<vector<Edge>>;

Graph G;
ll path;

bool dfs(int v, int p, int v2){
  if (v == v2) return true;
  for (auto e : G[v]) {
    if (e.to == p) continue;
    if (dfs(e.to, v, v2)) {
      path |= 1ll<<e.id;
      return true;
    }
  }
  return false;
}

int main(){
  int N; cin >> N;
  G = Graph(N);
  rep(i, N-1){
    int a, b; cin >> a >> b;
    a--; b--;
    G[a].push_back(Edge(i, b));
    G[b].push_back(Edge(i, a));
  }

  int M; cin >> M;
  vector<ll> paths(M);
  rep(i, M){
    int u, v; cin >> u >> v;
    u--, v--;
    path = 0;
    dfs(u, -1, v);
    paths[i] = path;
  }
  
  
  ll ans = 0;
  rep(i, 1ll<<M){
    ll eset = 0;
    rep(j, M) {
      if (i>>j & 1) {
        eset |= paths[j];
      }
    }
    ll num = 1ll<<(N-1 - __builtin_popcountll(eset));
    if(__builtin_popcountll(i) % 2 == 0) ans += num;
    else ans -= num;
  }
  cout << ans << endl;
  return 0;
}

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

int getMax(int a,int b)
{
    if(a>b)
    return a;
    return b;
}

int main() {
	int k,n;
	cin>>k>>n;
	int a[n];
	int b[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
    for(int i=0;i<n-1;i++)
    b[i]=(a[i+1]-a[i]);
    b[n-1]=(k+a[0])-a[n-1];
    int max=0;
    for(int i=0;i<n;i++)
    max=getMax(max,b[i]);
    cout<<k-max;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> sum(N + 1, 0);
    rep(i, 1, N + 1){
        int p;
        cin >> p;
        sum.at(i) = sum.at(i - 1) + p;
    }
    int maxi = 0;
    rep(i, 0, N - K + 1) maxi = max(maxi, sum.at(i + K) - sum.at(i));
    double D = (double)(maxi + K) / 2;
    cout << fixed << setprecision(10) << D << endl;
}

Measured memory_bytes: 1024
import math
T = int(input())
for t in range(T):
    N, A, B, C, D = map(int, input().split())
    memo = {}

    def dist(n):
        if n == 0:
            return 0
        elif n == 1:
            return D
        elif n in memo:
            return memo[n]

        ret = min(
            D * n,
            D * abs(n - n//5*5) + C + dist(n//5),
            D * abs(n - (n+4)//5*5) + C + dist((n+4)//5),
            D * abs(n - n//3*3) + B + dist(n//3),
            D * abs(n - (n+2)//3*3) + B + dist((n+2)//3),
            D * abs(n - n//2*2) + A + dist(n//2),
            D * abs(n - (n+1)//2*2) + A + dist((n+1)//2)
        )

        memo[n] = ret
        return ret
    print(dist(N))


Measured memory_bytes: 84896
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


int main() {
    LL X, A;
    cin >> X >> A;

    if (X < A) {
        cout << "0" << endl;
    } else {
        cout << "10" << endl;
    }
	
    return 0;
}


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

int conv_stoi(string s) {
    int res = 0, pow_ten = 1;
    for (int i = s.size() - 1; i >= 0; i--) {
        res += int(s[i] - '0') * pow_ten;
        pow_ten *= 10;
    }
    return res;
}

void solve(int t, int num) {
    string number;
    int tmp = num;
    int n = 0;
    while (tmp > 0) {
        n++;
        tmp /= 10;
    }
    for (int i = 0; i < n; i++) {
        number += char(num % 10 + '0');
        num /= 10;
    }
    reverse(number.begin(), number.end());
    map<int, int> cnt, number_mask;
    int ans = -1;
    for (int mask = 0; mask < (1 << n); mask++) {
        if (!(mask & 1)) continue;
        vector<int> sep;
        for (int i = 0; i < number.size(); i++) {
            if ((mask >> i) & 1) sep.push_back(i);
        }
        int m = sep.size();
        sep.push_back(number.size());
        int sum = 0;
        vector<int> numbers;
        for (int i = 0; i < m; i++) {
            int now_number = conv_stoi(number.substr(sep[i], sep[i + 1] - sep[i]));
            numbers.push_back(now_number);
            sum += now_number;
        }
        if (sum > t) continue;
        cnt[sum]++;
        ans = max(ans, sum);
        number_mask[sum] = mask;
    }
    if (ans < 0) cout << "error" << endl;
    else if (cnt[ans] > 1) cout << "rejected" << endl;
    else {
        cout << ans << ' ';
        int ans_mask = number_mask[ans];
        vector<int> ans_sep;
        for (int i = 0; i < n; i++) {
            if ((ans_mask >> i) & 1) ans_sep.push_back(i);
        }
        int m = ans_sep.size();
        ans_sep.push_back(n);
        for (int i = 0; i < m; i++) {
            cout << conv_stoi(number.substr(ans_sep[i], ans_sep[i + 1] - ans_sep[i])) << " \n"[i == m - 1];
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t, num;
    while (true) {
        cin >> t >> num;
        if (t == 0 && num == 0) break;
        solve(t, num);
    }
    return 0;
}


Measured memory_bytes: 3140
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        char[] s = in.next().toCharArray();

        int[] c = new int[26];
        for (int i = 0; i < n; i++) {
            c[s[i] - 'a']++;
        }

        long m = 1;
        for (int i = 0; i < 26; i++) {
            m = (c[i] + 1) * m % 1000000007;
        }

        out.println(m - 1);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 22484
import sys


def read():
    return sys.stdin.readline().rstrip()


def main():
    h, w = map(int, read().split())
    s = ["#" * w] + ["w" + read() + "w" for _ in range(h)] + ["w" * w]
    left = [[0] * (w + 2) for _ in range(h + 2)]
    right = [[0] * (w + 2) for _ in range(h + 2)]
    up = [[0] * (w + 2) for _ in range(h + 2)]
    down = [[0] * (w + 2) for _ in range(h + 2)]
    for y in range(1, h + 1):
        for x in range(1, w + 1):
            if s[y][x] == ".":
                left[y][x] = left[y][x - 1] + 1
                up[y][x] = up[y - 1][x] + 1
            if s[-y - 1][-x - 1] == ".":
                right[-y - 1][-x - 1] = right[-y - 1][-x] + 1
                down[-y - 1][-x - 1] = down[-y][-x - 1] + 1
    c = 0
    for y in range(1, h + 1):
        for x in range(1, w + 1):
            if s[y][x] == ".":
                c = max(left[y][x] + right[y][x] + up[y][x] + down[y][x], c)
    print(c - 3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 204744
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    
    static int n;
    static int[][] m;
    static int[] d;
    static final int INF = Integer.MAX_VALUE;
    static final int WHITE = 0;
    static final int GRAY = 1;
    static final int BLACK = 2;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        n = Integer.parseInt(sc.next());
        m = new int[n][n];
        for(int i = 0; i < n; i++){
            Arrays.fill(m[i], INF);
        }
        for(int i = 0; i < n; i++){
            int u = Integer.parseInt(sc.next());
            int k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                int v = Integer.parseInt(sc.next());
                int c = Integer.parseInt(sc.next());
                m[u][v] = c;
            }
        }
        
        dijkstra(0);
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(i).append(" ").append(d[i]).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
    
    static void dijkstra(int s){
        
        int[] color = new int[n];
        d = new int[n];
        Arrays.fill(d, INF);
        int[] p = new int[n];
        d[s] = 0;
        p[s] = -1;
        
        while(true){
            int minCost = INF;
            int u = 0;
            for(int i = 0; i < n; i++){
                if(color[i] != BLACK && d[i] < minCost){
                    minCost = d[i];
                    u = i;
                }
            }
            
            if(minCost == INF) break;
            
            color[u] = BLACK;
            
            for(int v = 0; v < n; v++){
                if(color[v] != BLACK && m[u][v] != INF){
                    if(d[u] + m[u][v] < d[v]){
                        d[v] = d[u] + m[u][v];
                        p[v] = u;
                        color[v] = GRAY;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 39180
package main
  
import (
    "fmt"
)

func main() {
    var a, b, c int
    fmt.Scan(&a, &b, &c)

    if c <= a+b+1 {
        fmt.Println(c + b)
    } else {
        fmt.Println(a + b + 1 + b)
    }

}


Measured memory_bytes: 512
import java.util.*; 
import java.io.*;


// A1 * Sum(A2+...+An)
// +A2 * Sum(A3+...+An)
// +A3 * Sum(A4+...+An)
public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
    
    static long mod = (long)1e9 + 7;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        int N = nextInt();
        long list[] = new long[N+1];
        long psm[] = new long[N+1];

        // we get PreSum
        for (int i=1; i<=N; i++) {
            list[i] = nextInt();
            psm[i] = psm[i-1] + list[i];
            psm[i] %= mod;
        }
    
        long ans = 0;
        for (int i=1; i<=N-1; i++) {
            ans += list[i] * (psm[N]-psm[i]);
            ans %= mod;
        }

        if(ans<0) ans+=mod;
        System.out.println(ans);
    }

      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

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

int main(int argc, char *argv[]) {
  int x;
  cin >> x;
  for(int i = 1; i < 10; i++) {
    if(x <= i*100+i*10+i) {
      cout << i*100+i*10+i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
A,B=map(int,input().split())

def xor_0a(a):
  if a%4 == 0:
    return a
  elif a%4 == 1:
    return 1
  elif a%4 == 2:
    return 1 ^ a
  elif a%4 == 3:
    return 0
  
xorA1 = xor_0a(A-1)
xorB = xor_0a(B)
print(xorA1 ^ xorB)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  int X; cin >> X;
  for(int i = X; i <= X * 2; ++i) {
    if(IsPrime(i) == true) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

bool compare(const pair<lli,lli> &a, const pair<lli,lli> &b){
	if(a.first!=b.second)return a.first < b.first;
	else return a.second < b.second;
}

signed main(){

	lli n;
	map<pair<lli,lli>,lli> m;
	vector<pair<lli,lli>> v;
	vector<pair<lli,lli>> pq;

	map<pair<lli,lli>,lli> ans;

	cin>>n;
	REP(i,0,n){
		lli x,y;
		cin>>x>>y;
		m[make_pair(x,y)]=1;
		v.push_back(make_pair(x,y));
	}

	sort(v.begin(),v.end());

	/*pqを決定する、50C2なので充分間に合う*/
	REP(i,0,n){
		lli nowX = v[i].first;
		lli nowY = v[i].second;
		REP(j,i+1,n){
			lli nextX = v[j].first;
			lli nextY = v[j].second;
			lli p = nextX - nowX;
			lli q = nextY - nowY;
			pq.push_back(make_pair(p,q));
			ans[make_pair(p,q)]++;
		}
	}
	/*pqに従ってコストを計算する*/

	lli maxCnt=0;
	for(auto e:ans){
		maxCnt = max(maxCnt,e.second);
	}

	cout<<n-maxCnt<<endl;


	return 0;
}

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

int main(){
    double n, k;
    double ans = 0;

    cin >> n >> k;

    for(int i = 1; i <= n; i++){
        int j, coin = i;
        for(j = 1; coin < k; j++){
            coin *= 2;
        }
        ans += 1/n * pow(1/2.0,j-1);
    }

    //cout << fixed << ans << endl;
    printf("%0.9lf\n",ans);
}

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

int main(){
        int n;
        cin>>n;
        vector<int> be, bo;
        for(int i=0; i<n; i++){
                int a;
                cin>>a;
                if(i%2==0){
                        bo.push_back(a);
                }
                else{
                        be.push_back(a);
                }
        }
        vector<int> f, s;
        if(n%2==0){
                f=be;
                s=bo;
        }
        else{
                f=bo;
                s=be;
        }


        for(auto it=f.rbegin(); it!=f.rend(); it++){
                if(it!=f.rbegin()) cout<<" ";
                cout<<(*it);
        }
        for(auto it=s.begin(); it!=s.end(); it++){
                cout<<" "<<(*it);
        }

        return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
using namespace std;
pair<long long,long long> tseni[4];
int main(){
long long q,h,s,d,n,otg=0;
long long a,b;
cin>>q>>h>>s>>d>>n;
n=n*100;
tseni[0]=make_pair(q*8,25);
tseni[1]=make_pair(h*4,50);
tseni[2]=make_pair(s*2,100);
tseni[3]=make_pair(d,200);
sort(tseni,tseni+4);
a=n/tseni[0].second;
n=n%tseni[0].second;
otg+=a*tseni[0].first/(200/tseni[0].second);
a=n/tseni[1].second;
n=n%tseni[1].second;
otg+=a*tseni[1].first/(200/tseni[1].second);
a=n/tseni[2].second;
n=n%tseni[2].second;
otg+=a*tseni[2].first/(200/tseni[2].second);
a=n/tseni[3].second;
n=n%tseni[3].second;
otg+=a*tseni[3].first/(200/tseni[3].second);
cout<<otg<<"\n";
return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N 200005
const int mod = 1000000007;
map<pair<ll,ll>,pair<int,int>> mp;
int n;
ll a[N], b[N];
ll p2[N];
int main(){
	FIO;
    p2[0] = 1;
    for(int i = 1 ; i < N ; i++) p2[i] = (p2[i-1]*2) % mod;
    cin >> n;
    for(int i = 0 ; i < n ; i++) cin >> a[i] >> b[i];
    ll x1 = 0, x2 = 0, y = 0;
    for(int i = 0 ; i < n ; i++){
        ll g = __gcd(a[i],b[i]);
        if(a[i]==0 && b[i]==0) y++;
        else if(a[i]==0) x1++;
        else if(b[i]==0) x2++;
        else{
            if((a[i] > 0 && b[i] < 0) || (a[i] < 0 && b[i] > 0)){
                mp[{abs(b[i]/g),abs(a[i]/g)}].second++;
            }else{
                mp[{abs(a[i]/g),abs(b[i]/g)}].first++;
            }
        }
    }
    ll ans = 1;
    for(auto v : mp){
        ans = (ans * (( p2[v.second.first] + p2[v.second.second] - 1)%mod) )%mod;
    }
    ans = (ans * (( p2[x1] + p2[x2] - 1)%mod) )%mod;
    ans = (ans + y)%mod;
    cout << ((ans-1)%mod+mod)%mod << endl;
	return 0;
}

Measured memory_bytes: 20688
N, Q = map(int, input().split())
X = []
for i in range(0, N):
    x, y = map(str, input().split())
    X.append([x, int(y)])
ans = []
time = 0
while len(X) != 1:
    tmp = X.pop(0)
    if tmp[1] <= Q:
        time += tmp[1]
        ans.append([tmp[0], time])
    else:
        time += Q
        tmp[1] -= Q
        X.append(tmp)
ans.append([X[0][0], time+X[0][1]])
for i in range(0, N):
    print(ans[i][0], ans[i][1])



Measured memory_bytes: 14664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    string str;
    cin>>str;
    int n = str.size() - 1;
    if (str[n] == '0' || str[n] == '1' || str[n] == '6' || str[n] == '8'){
        cout << "pon" << endl;
    }else if (str[n] == '3'){
        cout<<"bon"<<endl;
    }else{
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int n = s.length() - 2;
        System.out.print(s.charAt(0) + String.valueOf(n) + s.charAt(n+1));
    }
}


Measured memory_bytes: 22996
#include<stdio.h>
 
#define N 100000
int partition(int,int);
int A[N], n;
 
int main(){
  int i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(0,n-1);
  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    if(i==q){
      printf("[");
    }
    printf("%d",A[i]);
    if(i==q){
      printf("]");
    }
  }
  printf("\n");
  return 0;
}
int partition(int p,int r){
  int i,j,k,c;
  k=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=k){
      i++;
      c=A[i];
      A[i]=A[j];
      A[j]=c;
    }
  }
  c=A[i+1];
  A[i+1]=A[r];
  A[r]=c;
  return i+1;
}



Measured memory_bytes: 2104
using System;
using System.Collections;

class Program{
    class Process{
        public string name;
        public int time;
    }

    public static void Main(){
        var s=Console.ReadLine().Split(' ');
        var n=int.Parse(s[0]);
        var queue=new Queue(n);
        var q=int.Parse(s[1]);
        for(var i=0; i<n; i++){
            s=Console.ReadLine().Split(' ');
            var p=new Process();
            p.name=s[0];
            p.time=int.Parse(s[1]);
            queue.Enqueue(p);
        }

        var time=0;
        while(queue.Count!=0){
            var p=(Process)queue.Dequeue();
            if(p.time<=q){
                time+=p.time;
                Console.WriteLine(p.name+" "+time);
            } else{
                p.time-=q;
                queue.Enqueue(p);
                time+=q;
            }
        }
    }
}

Measured memory_bytes: 15136
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 2; i < n; i++) {
			int max = p[i-2];
			int min = p[i-2];
			max = Math.max(max, p[i-1]);
			max = Math.max(max, p[i]);
			min = Math.min(min, p[i-1]);
			min = Math.min(min, p[i]);
			if(max != p[i-1] && min != p[i-1]) {
				ans ++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a<b && b<c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3100
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        const int white = 0;
        const int black = 1;
        const int red = 2;

        static void Main(string[] args)
        {

            var inputs = Console.ReadLine().Split(" ");
            var h = int.Parse(inputs[0]);
            var w = int.Parse(inputs[1]);
            var k = int.Parse(inputs[2]);

            var matrix = new char[h, w];

            var result = 0;

            for (var i = 0; i < h; i++)
            {
                var list = Console.ReadLine().ToCharArray();
                for (var j = 0; j < w; j++)
                {
                    matrix[i, j] = list[j];
                }
            }

            // 行と列の選択状態をbitで表現する
            // 1 << h は2^hとなり、全bit立った状態+1になる
            for (var i = 0; i < (1 << h); i++)
            {
                for (var j = 0; j < (1 << w); j++)
                {
                    var cnt = 0;
                    // bitシフトループ
                    for (var si = 0; si < h; si++)
                    {
                        for (var sj = 0; sj < w; sj++)
                        {
                            if (((i >> si) & 1) == 1) continue;
                            if (((j >> sj) & 1) == 1) continue;
                            if (matrix[si, sj] == '#')
                                cnt++;
                            if (k < cnt) break;
                        }
                    }

                    if (k == cnt)
                    {
                        result++;
                    }
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27544
"""

times = int(input())  

data = [int(input()) for i in range(times)] 

N = data[0]

cards = data[0:]

#バブルソート
for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] < cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      
#鏡餅を積んで行くぜ！！

print(len(set([str(x) for x in cards])))
"""

data = input().split(" ")
N = int(data[0])
tol = int(data[1])

tmp1 = 0
tmp2 = 0
tmp3 = 0

for i in range(0, N + 1, 1):
  for j in range(0, N + 1 - i, 1):
    k = N - i - j
    if (10000 * i + 5000 * j + 1000 * k) == tol and (i + j + k) == N:
      tmp1 = i
      tmp2 = j
      tmp3 = k
      break
  if tmp1 != 0 or tmp2 != 0 or tmp3 != 0:
    break

if tmp1 != 0 or tmp2 != 0 or tmp3 != 0:
  print("{0} {1} {2}".format(tmp1, tmp2, tmp3))
else:
  print("-1 -1 -1")

Measured memory_bytes: 3064
[a,b,c,x,y]=[int(i) for i in input().split()]

ansa=0
ansb=0
ansc=0

f=0
ff=0

if c*2 < a+b:
    #print("c安い")
    ansc=min(x,y)
    f=1
else:
    #print("c高い")
    ansa=x
    ansb=y

if f:
    #print(ansa, ansb, ansc)
    #print(c*2, a, x-ansc, b,  y-ansc, ansc)
    if c*2<a and x-ansc > 0:
        ansc+=x-ansc
        ff=1
        #print("aa")
    if c*2<b and y-ansc >0:
        ansc+=y-ansc
        ff=1
        #print("bb")
    if ff==0:
        ansa+=x-ansc
        ansb+=y-ansc
    

#print(ansa, ansb, ansc)
print(a*ansa + b*ansb + c*ansc*2)



Measured memory_bytes: 3064
import Data.List

main = do
  n <- getLine
  as <- getLine >>= return . sort . map read . words :: IO [Int]

  let m = last as
  let h = minimumBy (\a b -> compare (abs $ m-a*2) (abs $ m-b*2)) as
  putStrLn $ show m ++ " " ++ show h


Measured memory_bytes: 40572
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll k,n,i;
    cin>>k>>n;
    ll a[n],ans=INT_MIN;
    for (i=0;i<n;i++)
        cin>>a[i];
    for (i=0;i<n-1;i++)
        ans=max(ans,abs(a[i+1]-a[i]));
    if (a[0]==0)
        ans=max(ans,abs(k-a[n-1]));
    else
        ans=max(ans,abs(k-a[n-1]+a[0]));
    cout<<k-ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  for(int i = 0; i < N; i++){
    cin >> W[i];
  }
  
  int Wsum = accumulate(W.begin(), W.end(), 0);
  int S1 = 0, S2 = 0, ans = 200;
  for(int i = 0; i < N; i++){
    S1 += W[i];
    S2 = Wsum - S1;
    if(abs(S1 - S2) <= ans){
      ans = abs(S1 - S2);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/abc081/tasks/abc081_a
#include <bits/stdc++.h>
using namespace std;

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

  int S1 = S123 / 100;
  int S2 = (S123 - S1*100) / 10;
  int S3 = (S123 - S1 * 100 - S2 * 10);

  cout << S1 + S2 + S3 << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m), y(m);
  rep(i, m) {
    cin >> x[i] >> y[i];
    --x[i];
    --y[i];
  }

  vector<int> ball(n, 1), red(n, 0);
  red[0] = 1;

  rep(i, m) {
    --ball[x[i]];
    ++ball[y[i]];
    if (red[y[i]] == 0) red[y[i]] = red[x[i]];
    if (ball[x[i]] == 0) red[x[i]] = 0;
  }

  int ans = 0;
  rep(i, n) ans += red[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4584
package main

import (
  "fmt"
)

func main() {
	var n int
	var a []int

	fmt.Scanf("%d", &n)
	for i:=0; i<n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		a = append(a, x)
	}

	alice := 0
	bob := 0

	for ; len(a)>0; {
		alice += a[maxIndex(a)]
		a = unset(a, maxIndex(a))

		if len(a) > 0 {
			bob += a[maxIndex(a)]
			a = unset(a, maxIndex(a))
		}
	}

	fmt.Print(alice - bob)
}

func maxIndex(a []int) int {
	max := 0
	index := 0
	for i, v := range a {
		if max < v {
			max = v
			index = i
		}
	}

	return index
}

func unset(s []int, i int) []int {
	if i >= len(s) {
			return s
	}
	return append(s[:i], s[i+1:]...)
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int a,b;
  int answer=0;
  
  scanf("%d %d",&a,&b);
  
  for(int i=0;i<2;i++){
  if(a>=b){
    answer+=a;
    a--;
  }else{
    answer+=b;
    b--;
  }
  }
  printf("%d",answer);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    string s;
    cin>>s;
   
    for(int i=2;i<=s.size();i+=2){
        if(s.substr(0,(s.size()-i)/2)==s.substr((s.size()-i)/2,(s.size()-i)/2)){
            cout<<s.size()-i<<endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


int main() {
  int N;
  cin >> N;
  N--;
  ll ans = 0;
  rep1(i,N) {
    ans += N/i;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3612