akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define LARGE 100001
#define MIN(a,b) ((a) < (b) ? (a) : (b))

int check(int flg[],int k){
	for(int i=1;i<=k;i++){
		if(flg[i]==0)
			return 0;
	}
	return 1;
}

int getAns(int a[],int n,int k){
	int flg[LARGE]={0};
	int i=0,j=0;
	int num=0;
	int ans=LARGE;
	
	for(i=1;i<=n;i++){
		flg[a[i-1]]++;
		num++;
		
		if(num >= k && check(flg,k)){
			ans=MIN(i-j,ans);
			while(num >= k && check(flg,k)){
				flg[a[j]]--;
				num--;
				j++;
				if(num >= k && check(flg,k))
					ans=MIN(i-j,ans);
			}
			
		}
	}
	
	if(ans==LARGE)
		ans=0;
	
	return ans;
}


int main(){
	int a[LARGE];
	int n,k;
	int ans=0;
	
	scanf("%d %d",&n,&k);
	
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);

	printf("%d\n",getAns(a,n,k));
	
	return 0;
	
}


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

int main(){
	int n, MOD = 1E9+7;
  	string s;
  	cin >> n;
  	int dp[n+1][4][4][4];
	for(int m = 0; m <= n; m++) {
      for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
          for(int k = 0; k < 4; k++) {
              dp[m][i][j][k] = 0;
          }
        }
      }
    }
  	dp[0][3][3][3] = 1;
	//0123 AGCT
  	for(int m = 1; m <= n; m++) {
      for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
          for(int k = 0; k < 4; k++) {
            for(int h = 0; h < 4; h++) {
				if(i==0 && j==1 && k==2) continue;
				if(i==1 && j==0 && k==2) continue;
				if(i==0 && j==2 && k==1) continue;
				if(h==0 && j==1 && k==2) continue;
				if(h==0 && i==1 && k==2) continue;                
                dp[m][i][j][k] += dp[m-1][h][i][j];
              	dp[m][i][j][k] %= MOD;
            }
          }
        }
      }
    }
  	long ans = 0;
  	for(int i = 0; i < 4; i++) {
      for(int j = 0; j < 4; j++) {
        for(int k = 0; k < 4; k++) {
			ans += dp[n][i][j][k];
          	ans %= MOD;
        }
      }
    }
  	cout << ans << endl;
}


Measured memory_bytes: 256
import itertools

n = int(input())

num = 4**9
ans = 0

for i in range(num):
    num_0 = 0
    num_3 = 0
    num_5 = 0
    num_7 = 0

    s = i
    for m in range(9):
        num_0 += 0 * int(s % 4 == 0) * 10 ** m
        num_3 += 3 * int(s % 4 == 1) * 10 ** m
        num_5 += 5 * int(s % 4 == 2) * 10 ** m
        num_7 += 7 * int(s % 4 == 3) * 10 ** m
        s = s // 4
    
    tmp = num_0 + num_3 + num_5 + num_7
        
    if tmp > n:
        break
    
    tmp = str(tmp)
    
    if num_3 > 0 and num_5 > 0 and num_7 > 0 and tmp.count('0') == 0:
        #print(tmp)
        ans += 1

print(ans)

Measured memory_bytes: 44652
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define fo(i,v,e) for(v=i;v<e;v++)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define deb(x...)
#endif

vector<ll> sieveOfErthnosis(ll n)
{
    vector<bool>flag(n+5,false);
    vector<ll>primes;
    for(int i=2;i*i<=n;i++)
    {
        if(!flag[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {flag[j]=true;}
        }
    }
    for (int  i = 2; i < n+1; i++)
    {
        if(!flag[i])primes.pb(i);
    }
    return primes;
}
void init()
{

}
void solve()
{
	ll n,m;cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2;
}
int main()
{
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    #endif
    init();
    auto start = high_resolution_clock::now(); 
    int T = 1;
    // cin>>T;
	while(T--)
	{
		solve();
	}
    auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<milliseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
	// cout << "time taken : "<<duration.count()<<" ms" << endl;
     #endif
}

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

using namespace std;

int main ()
{
	int n, sum = 1;
	cin >> n;
	string s;
	cin >> s;
	for (int i=0; i<n-1; i++){
		if (s[i] != s[i+1]){
			sum++;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 512
def f(c, cost):
    for i in a[1:]:
        if c > 0:
            if c + i >= 0:
                cost += c + i + 1
                c = -1
            else:
                c += i
        else:
            if c + i <= 0:
                cost += 1 - c - i
                c = 1
            else:
                c += i
    return c, cost


n = int(input())
a = list(map(int, input().split()))
cost = (a[0] == 0)
c = a[0] + (a[0] == 0)
c, cost = f(c, cost)
tmp = cost
cost = 0
if a[0] >= 0:
    cost = a[0] + 1
    c = -1
else:
    cost = -a[0] + 1
    c = 1
c, cost = f(c, cost)
print(int(min(cost, tmp)))


Measured memory_bytes: 86024
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    println(s[1:4]*" "*s[5:end])
end
main()

Measured memory_bytes: 166940
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 * Created by weiyuan on 2018/03/16.
 */
public class Main {
    public static void main(String[] args) {

        HashMap<String, Integer> result = new HashMap<>();

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        for(int b = 0; b < a; ++b) {
            String temp = sc.next();
            if(result.containsKey(temp)) {
                result.put(temp, (result.get(temp) + 1));
            }
            else {
                result.put(temp, 1);
            }
        }

        a = sc.nextInt();
        for(int b = 0; b < a; ++b) {
            String temp = sc.next();
            if(result.containsKey(temp)) {
                result.put(temp, (result.get(temp) - 1));
            }
            else {
                result.put(temp, -1);
            }
        }

        Integer current = 0;
        for(Map.Entry<String, Integer> entry : result.entrySet()) {
            Integer temp = entry.getValue();
            if(temp > current) {
                current = temp;
            }
        }
        System.out.println(current);
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
#define sf(a,b,i) for(int i=a;i<=b;++i)


void work()
{
    ll f[90]={2,1};
    int n;cin>>n;
    sf(2,n,i)f[i]=f[i-1]+f[i-2];
    cout<<f[n];
}

int main()
{
work();
return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		double x = (double)L/3;
		double y = (double)L/3;
		double z = (double)L/3;
		double P = x*y*z;
		System.out.printf("%.12f",P);
		
	}
	
}


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

int main () {
  int N ;
  cin >> N ;
  
  vector<int> line(N) ;
  
  for ( int i = 0 ; i < N ; i++ ) {
    cin >> line[i] ;
  }
  
  sort(line.begin(),line.end()) ;
  
  cout << line[N-1] -line[0] << endl ;
}

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

# from collections import deque

def linput(_t=int):
    return list(map(_t, input().split()))

def gcd(n,m):
    while m: n,m = m, n%m
    return n

def lcm(n,m): return n*m//gcd(n,m)

def main():
    # N = int(input())
    N,M = linput()
    vH = linput()
    vE = [linput() for _ in [0,]*M]

    vH = [0,] + vH
    vV = [0,] + [1,]*N

    # res = 0
    # for s in S.split("-"):
    #     res = max(res, len(s))

    for a,b in vE:
        ha, hb = vH[a], vH[b]
        if ha <= hb:
            vV[a] = 0
        if ha >= hb:
            vV[b] = 0
        
    res = sum(vV)


    # res = 0
    print(res)

    # print(("No","Yes")[res%2])


main()


Measured memory_bytes: 32708
# -*- coding: utf-8 -*-
import sys 
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = Counter()

for i in range(N):
    cnt_2 = 0
    cnt_5 = 0
    a = float(readline())
    a = int(a * (10**9)+0.5)

    while a % 2 == 0:
        a //= 2
        cnt_2 += 1
    while a % 5 == 0:
        a //= 5
        cnt_5 += 1
    cnt[(cnt_2-9,cnt_5-9)] += 1
    
ans = 0
for (x1,y1),c1 in cnt.items():
    for (x2,y2),c2 in cnt.items():
        if x1+x2 >= 0 and y1+y2 >= 0:
            if x1 == x2 and y1 == y2:
                ans += c1*(c1-1)
            else:
                ans += c1*c2

print(ans//2)

Measured memory_bytes: 82500
# frozen_string_literal: true

def acgt?(str)
  str.chars.reject { |c| %w[A C G T].include?(c) }.size.zero?
end

s = gets.strip

rslt = 0

s.size.times do |i|
  (i..(s.size - 1)).each do |j|
    str = s[i..j]
    rslt = str.size if acgt?(str) && rslt < str.size
  end
end

puts rslt


Measured memory_bytes: 1788
n = gets.to_s.to_i
s = gets.to_s.chomp.chars
 
r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r * g * b
n.times do |i|
  t = 1
  while i + 2 * t < n
    j = i + t
    k = j + t
    ans -= 1 if s[i] != s[i+t] && s[i] != s[i+2*t] && s[i+t] != s[i+2*t]
    t += 1
  end
end

puts ans

Measured memory_bytes: 14328
#include<cstdio>
long long n;
int main() {
	scanf("%lld", &n);
	long long t = 1, nn = n, s = 0;
	while (nn/10) {
		nn /= 10;
		t *= 10;
		s += 9;
	}
	if ((nn + 1)*t - 1 <= n) {
		s += nn;
	}
	else s += (nn - 1);
	printf("%lld\n", s);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 105
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int inf = 0x3f3f3f3f;
int n,a[maxn];
int main(){
	scanf("%d",&n);
	int s = 0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		s += a[i];
	}
	int opt = -1,optdelta = inf;
	for(int i=0;i<n;i++){
		if(abs(a[i] * n - s) < optdelta){
			optdelta = abs(a[i] * n - s);
			opt = i;
		}
	}
	printf("%d\n",opt);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define N 100010
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define lint long long
#define mod 1000000007
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int fac[N],facinv[N],f[N],onc[N],sz[N],p[N],cnt[N];
int cyc_cnt,vis[N],l[N],pre[N],jhs[N],in[N],mi[N],it[N];
inline int fast_pow(int x,int k,int ans=1)
{	for(;k;k>>=1,x=(lint)x*x%mod) (k&1)?ans=(lint)ans*x%mod:0;return ans;	}
inline int prelude(int n)
{
	rep(i,fac[0]=1,n) fac[i]=(lint)fac[i-1]*i%mod;
	facinv[n]=fast_pow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) facinv[i]=facinv[i+1]*(i+1ll)%mod;
	rep(i,mi[0]=1,n) mi[i]=mi[i-1]*2,(mi[i]>=mod?mi[i]-=mod:0);
	rep(i,f[0]=1,n/2) f[i]=f[i-1]*(2*i-1ll)%mod;return 0;
}
inline int C(int n,int m)
{
	if(n<0||m<0||n<m) return 0;
	return (lint)fac[n]*facinv[m]%mod*facinv[n-m]%mod;
}
int main()
{
	int n=inn();rep(i,1,n) p[i]=inn(),in[p[i]]++;
	//unsigned int QwQ=1,t=1;rep(i,1,n) QwQ+=p[i]*t,t*=998244353;cout<<QwQ<<endl;
	for(int i=1,x;i<=n;i++)
	{
		for(x=i;!vis[x];x=p[x]) vis[x]=i;
		if(vis[x]^i) continue;
		for(cyc_cnt++;!onc[x];x=p[x])
			onc[x]=cyc_cnt,sz[cyc_cnt]++;
	}
//	debug(cyc_cnt)ln;
//	rep(i,1,cyc_cnt) debug(i)sp,debug(sz[i])ln;
//	rep(i,1,n) debug(i)sp,debug(onc[i])sp,debug(in[i])ln;cerr ln;
	memset(vis,0,sizeof(int)*(n+1));
	for(int i=1,x,c;i<=n;i++) if(!in[i])
	{
		for(x=i,c=0;!onc[x];vis[x]=1,x=p[x],c++)
			if(vis[x]) return !printf("0\n");
		if(vis[x]) return !printf("0\n");vis[x]=1,l[x]=c;
	}
	rep(i,1,n) if(onc[i]&&l[i]) jhs[onc[i]]=1;
	rep(i,1,cyc_cnt) if(!jhs[i]) cnt[sz[i]]++;
//	rep(i,1,cyc_cnt) debug(i)sp,debug(jhs[i])sp,debug(sz[i])ln;
//	rep(i,1,n) debug(i)sp,debug(l[i])sp,debug(cnt[i])ln;cerr ln;
	prelude(n);int ans=1;
	for(int i=1,k,t,s,v;i<=n;i++) if(cnt[i])
	{
		rep(j,it[0]=1,cnt[i]/2) it[j]=(lint)it[j-1]*i%mod;
		for(k=cnt[i],t=0,s=0;t<=cnt[i]/2;t++)
			v=(lint)C(k,2*t)*f[t]%mod*it[t]%mod,
			(((i&1)&&i>1)?v=(lint)v*mi[k-2*t]%mod:0),
			s+=v,(s>=mod?s-=mod:0);
		ans=(lint)ans*s%mod;
	}
	for(int i=1,x,c;i<=n;i++) if(onc[i]&&l[i])
	{	for(x=i,c=1;!l[p[x]];x=p[x],c++);pre[p[x]]=c;	}
//	rep(i,1,n) debug(i)sp,debug(pre[i])ln;
	rep(i,1,n) if(onc[i]&&l[i])
	{
		if(l[i]>pre[i]) return !printf("0\n");
		else if(l[i]<pre[i]) ans=ans*2,(ans>=mod?ans-=mod:0);
	}
	return !printf("%d\n",ans);
}

Measured memory_bytes: 4864
s = int(input())

import math

if s <= 1000000000:
	print(0)
	print(0)
	print(0)
	print(1)
	print(s)
	print(0)
elif math.ceil(math.sqrt(s)) == math.sqrt(s):
	print(0)
	print(0)
	print(0)
	print(int(math.sqrt(s)))
	print(int(math.sqrt(s)))
	print(0)
else:
	s_s = math.ceil(math.sqrt(s))
	d = s_s ** 2 - s
	print(0)
	print(0)
	print(s_s)
	print(1)
	if d <= s_s:
		print(d)
		print(s_s)
	else:
		print(d-s_s)
		print(s_s - 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
//#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef vector<string> vi;
typedef pair<int,int> pi;
#define PI acos(-1)
int main()
{

      int t=1;

     while(t--){

         int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
         int k;
         cin >> k;
         k--;
         cout << a[k] << endl;
     }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			105
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
ll dp[105][4][2];
ll getans(string num,ll k,ll pos,bool limit)
{
	if(k == 0)
		return 1;
	if(pos == num.length())
		return 0;
	
	if(dp[pos][k][limit] != -1)
	return dp[pos][k][limit];
	
	ll ans = 0,i;
	if(limit)
	{
		if(num[pos] == '0')
		{
			ans += getans(num,k,pos+1,1);
		}
		else
		{
			ans += getans(num,k,pos+1,0);
			for(i = 1;i<num[pos]-'0';i++)
			ans += getans(num,k-1,pos+1,0);
			ans += getans(num,k-1,pos+1,1);
		}	
		
	
	}
	else
	{
		ans += getans(num,k,pos+1,0);
		for(i = 1;i<=9;i++)
		ans += getans(num,k-1,pos+1,0);
	}
	
	return dp[pos][k][limit] = ans;
}
int main()
{
	string num;
	ll k,i,j;
	cin>>num>>k;
	
	memset(dp,-1,sizeof(dp));
	cout<<getans(num,k,0,1);
	
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1;
  int n,count=0;
  cin >> s1 >> n;
  string s2[n];
  for(int i=0;i<n;i++){
    cin >> s2[i];
    s2[i]+=s2[i];
    if(s2[i].find(s1) != string::npos ){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3156
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		TreeSet<Integer> yakusu = new TreeSet<>();
		int n = sc.nextInt();
		int t[] = new int[n];
		for(int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		Arrays.sort(t);
		int max = t[n-1];
		
		for(int i = 1; i <= 10000; i++) {
			if(max % i==0) {
				yakusu.add(i);
			}
		}

		int ans = 0;
		for(int i = 0; i < n-1; i++) {
			ans += yakusu.ceiling(t[i])-t[i];
		}

		System.out.println(ans);
	}
}


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

int main(){
	int hug = 0;
	string str,sub1,sub2,subsub;

	cin >> str;

	//回文考えるときに文字数が奇数のときの真ん中は要らない
	sub1 = str.substr(0, (str.size() / 2)); //前半分
	subsub = str.substr((str.size() / 2) + str.size() % 2, str.size() / 2); //後ろ半分反転前

	//反転
	for (int i = subsub.size(); i >= 0; i--) {
		char c = subsub[i];
		sub2 = sub2 + c; //先頭に半角スペース入っちゃう
	}
	sub2.erase(0, 1); //先頭の1文字消す

	for (int j = 0; j < sub1.size(); j++) {

		if (sub1[j] != sub2[j]) {
			hug++;
		}
	}

	cout << hug;
}


Measured memory_bytes: 256
import numpy as np

N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)
ans = []

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2]=='AC' else 0)

for q in range(Q):
    q_l, q_r = map(int, input().split())
    ans.append(t[q_r-1]-t[max(q_l-1, 0)])

for a in range(Q):
    print(int(ans[a]))


Measured memory_bytes: 21080
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,a,b,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>a>>b>>t;
        if(t<a){
            cout<<0<<endl;
            break;
        }
        k=a; j=b; i=2;
        while(k<=t)
        {
            k = (i*a);
            if(k>t)break;
            j += b;
            i++;
        }
        cout<<j<<endl;
    }
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
double a[3005];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    double n, m,  ans, sum =0 ,c=0;
    int i;
    cin >> n >> m;

    for(i=0; i<n; ++i) {cin >> a[i];sum += a[i];}

    ans = sum/(4.0*m);

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

        if((n-c) >= m) cout<<"Yes"<<endl;

         else  cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
using namespace std;
#define INF 1LL << 62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

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

    int N;
    cin>>N;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(j!=i+1) cout<<" ";
            int k=0;
            while(true){
                if(bit(i,k)!=bit(j,k)){
                    cout<<k+1;
                    break;
                }
                k++;
            }
        }
        cout<<endl;
    }    
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] H = new int[N];
    for(int i = 0; i < N; i++){
      H[i] = sc.nextInt();
    }
    int count = 0;
    int tmpCount = 0;

    for(int i = 1; i < N; i++){
      if(H[i - 1] >= H[i]){
        tmpCount++;
      } else {
        if(count < tmpCount){
          count = tmpCount;
        }
        tmpCount = 0;
      }
    }
    if(count < tmpCount){
      count = tmpCount;
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 50128
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
use Ada.Float_Text_IO;

procedure hoge is
 a: integer;
 b: integer;
begin
 get(a);
 get(b);
 if a<=b*2 then
  put(0);
 else
  put(a-b*2);
 end if;
end hoge;

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

int main() {
  int x;cin>>x;
  int ans = 0;

  if (x>=1800) {
    ans = 1;
  } else if (x>=1600) {
    ans = 2;
  } else if (x>=1400) {
    ans = 3;
  } else if (x>=1200) {
    ans = 4;
  } else if (x>=1000) {
    ans = 5;
  } else if (x>=800) {
    ans = 6;
  } else if (x>=600) {
    ans = 7;
  } else {
    ans = 8;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

main(){
  int a[3], num;
  int i, tmp, cnt = 0;
  int sum, last;

  scanf("%d", &num);

  while(cnt < num){
    scanf("%d %d %d", &a[0], &a[1], &a[2]);

    last = 2;
    while(last > 0){
      for(i = 0 ; i < last ; i++){
        if(a[i] < a[i + 1]){
          tmp = a[i];
          a[i] = a[i+1];
          a[i+1] = tmp;
        }
      }
      last--;
    }

    a[0] *= a[0];
    sum = a[1]*a[1] + a[2]*a[2];

    if(sum == a[0]){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }

    cnt++;
  }
  return 0;
}

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

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


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

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  for(int i = 0;i < N; i++) cin >> A.at(i);
  int sum = accumulate(A.begin(), A.end(), 0);
  
  (H - sum) <= 0 ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 640
s = input()
N = s.count('N')
W = s.count('W')
S = s.count('S')
E = s.count('E')
ans = ''
if N > 0 and W > 0 and S > 0 and E > 0:
  ans = 'Yes'
elif N == 0 and W > 0 and S == 0 and E > 0:
  ans = 'Yes'
elif N > 0 and W == 0 and S > 0 and E == 0:
  ans = 'Yes'
else:
  ans = 'No'
print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

int n;
	

int binsearch(int lo, int hi)
{
	int ans = 0;
	while(lo <= hi)
	{
		int mid = (lo + hi) / 2;
		int is = mid * 1.08;
		if(is > n)
			hi = mid - 1;
		else if(is < n)
			lo = mid + 1;
		else if(is == n)
		{
			ans = mid;
			break;
		}
	}
	return ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    cin >> n;
	int ans =  binsearch(1, 50000);
    if(!ans)
		cout << ":(" << '\n';
	else
		cout << ans << '\n';
	
    return 0;
}






Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const long long N = 1e5 + 5;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    ll x , y;
    cin >> x >> y;
    ll l = __gcd(x , y);
    if(y == 1 || (x == y)) {
        cout << -1 << endl;
        return 0;
    }
    if(l == 1) {
        cout << x << endl;
    }
    else {
        if(l == x) {
            cout << x << endl;
        }
        else if (l == y) {
            cout << -1 << endl;
        }
        else {
            ll x0 = x;
            while(1) {
                if(x % y != 0) {
                    cout << x << endl;
                    return 0;
                }
                x += x0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . which "YES" "NO" . ( 8 <= ) . length . filter ( == 'o' ) . take 15 . ( ++ repeat 'o' )

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

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 100;

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int ways1 = X * A + Y * B;
    int ways2 = X < Y ? C * X * 2 + (Y - X) * B : C * Y * 2 + (X - Y) * A;
    // cout << ways1 << " " << ways2 << endl;
    int ways3 = X > Y ? C * X * 2 : C * Y * 2;
    int ans = ways1 < ways2 ? ways1 : ways2;
    ans = ans < ways3 ? ans : ways3;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

const ll MAX = 100001;

ll par[MAX] = {};
ll ran[MAX] = {};
ll si[MAX] = {};
ll n,m;
ll fuben;

ll find(ll x){
    if(par[x] == 0){
        return x;
    }
    return par[x] = find(par[x]);
}

void unite(ll x, ll y){
    x = find(x);
    y = find(y);
//    cout << x << " " <<  y << endl;
    if(x == y){
        return;
    }
    if(ran[x] < ran[y]){
        par[x] = y;
        ll tmp = si[x]*(si[x] - 1)/2 + si[y]*(si[y] - 1)/2;
        si[y] += si[x];
        fuben -= si[y]*(si[y] - 1)/2 - tmp;
    }else{
        par[y] = x;
        ll tmp = si[x]*(si[x] - 1)/2 + si[y]*(si[y] - 1)/2;
        si[x] += si[y];
//        cout << tmp << " " << si[x] << endl;
        fuben -= si[x]*(si[x] - 1)/2 - tmp;
        if(ran[x] == ran[y]){
            ran[x]++;
        }
    }
}
ll a[MAX] = {};
ll b[MAX] = {};

int main() {
    
    cin >> n >> m;
    fuben = n*(n-1)/2;
    for (ll i=1;i<=n;i++){
        si[i] = 1;
    }
    for (ll i=0;i<m;i++){
        cin >> a[i] >> b[i];
    }
    stack <ll> v;
    for (ll i=m-1;i>=0;i--){
        v.push(fuben);
        unite(a[i], b[i]);
    }
    while(!v.empty()){
        cout << v.top() << endl;
        v.pop();
    }
}

Measured memory_bytes: 5788
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1008
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <cmath>
using namespace std;


int main() {
    
    char s;
    cin >> s;
    if (isupper(s)) {
        cout << "A";
    }
    else {
        cout << "a";
    }

    return 0;
}



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	ll n,a,b;cin>>n>>a>>b;
	if(a<b)swap(a,b);
	ll ans;
	if((a-b)%2==0)ans=(a-b)/2;
	else
	{
		ans=min(n-a+n-b+1,a-1+b-1+1);
		ans/=2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define  NIL 0
#define N 100

int main() {
  int n, u, k, v;
  int V[N][N];

  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      V[i][j] = NIL;
    }
  }

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      V[u-1][v-1] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) cout << " ";
      cout << V[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    vector<int> nums(n);
    rep(i, n) cin >> nums[i];

    bool flag = true;
    int cnt = 0;
    while(flag){
        rep(i, n) flag = (nums[i] % 2 == 0) && flag;
        if(flag){
            rep(i, n) nums[i] /= 2;
            cnt ++;
        }
    }

    cout << cnt << endl;
}

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, k;
	string s;
	cin >> n >> k >> s;
	int cnt = 0;
	for(int i=0; i<s.size()-1; i++) {
		if(s[i] == s[i+1])
			cnt++;
	}
	cout << min(n-1, cnt+2*k);
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int s[103],a,b;

int main(){
	fill(s,s+103,1);
	while(cin>>a>>b){
		if(a+b==0){
			int flag=1;
			if(s[1]==1||s[2]==1)flag=0;
			for(int i=3;i<103;i++)if(s[i]==0)flag=0;
			if(flag==1)cout<<"OK"<<endl;
			else cout<<"NG"<<endl;
			fill(s,s+103,1);
			continue;
		}
		s[a]=(s[a]+1)%2;
		s[b]=(s[b]+1)%2;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
    int n,k,d,l,ans=0;
    cin>>n>>k;
    vector <int> g(n,0);
    for (int i=0;i<k;i++)
    {
        cin>>d;
        for (int j=0;j<d;j++)
        {
            cin>>l;
            g[l-1]=1;
        }

    }
    for (int i=0;i<n;i++)
        if (g[i]==0)ans+=1;
        cout<<ans;

    return 0;
}

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

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

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int sum = 0;
	if (a < k) {
		sum = a;
		k -= a;
	} else {
		cout << k;
		return 0;
	}
	if (b < k) {
		k -= b;
	} else {
		cout << sum;
		return 0;
	}
	cout << sum - k;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    
    int n,i,tmp,a[100];
    
    scanf("%d",&n);

    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
   
   for(i=1;i<=n/2;i++){
       tmp=a[i];
       a[i]=a[n-i+1];
       a[n-i+1]=tmp;
   }
   
   for(i=1;i<n;i++){
        printf("%d ",a[i]);
   }
    
    printf("%d",a[n]);
    printf("\n");
   
   return 0;
}



Measured memory_bytes: 2036
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 16 04:23:00 2018

@author: Yuki
"""
def sum_from_bit(bit, string, bin_len):
    res = []
    tmp_str = string[0]
    for i in range(bin_len):
        if bit[i] == '0':
            tmp_str += string[1+i]
        else:
            res.append(int(tmp_str))
            tmp_str = string[1+i]
    res.append(int(tmp_str))
    return sum(res)

def main():
    S = input()
    
    n_bit = len(S)-1
    result = []
    for i in range(2**n_bit):
        tmp_bit = bin(i)[2:].zfill(n_bit)
        result.append(sum_from_bit(tmp_bit, S, n_bit))
    print(sum(result))
if __name__=='__main__':
    main()

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


struct node{
  int key;
  struct node *right,*left,*parent;
};

struct node *root,*NIL;


void insert(int k){
struct node *y=NIL;
struct node *x=root;
struct node *z;
z=malloc(sizeof(struct node));
z->key = k;

z->left = NIL;
z->right = NIL;
while(x!=NIL){
  y=x;
  if(k < x->key) x=x->left;
  else x=x->right;
}
 z->parent=y;
 if(y==NIL)root=z;
 else{
    if(y->key>k)y->left=z;

    else y->right=z;
    }
  }



void inorder(struct node *z){
  if(z==NIL)return;
  inorder(z->left);
  printf(" %d",z->key);
  inorder(z->right);
}
void preorder(struct node *z){
if(z==NIL) return;
printf(" %d",z->key);
preorder(z->left);
preorder(z->right);
}

int main(){
  int i,n,x;
  char str[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0){
        scanf("%d",&x);
        insert(x);
      }
      else if(strcmp(str,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
return 0;
}



Measured memory_bytes: 25128
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

pair<int,int> road[10000];

int main() {
  int N,M,d,p;
  while(cin>>N>>M, N|M) {
      for(int i=0; i<N; ++i) {
	cin>>d>>p;
	road[i] = pair<int,int>(p,d);
      }

      sort(road,road+N);

      int ans = 0;
      for(int i=N-1; i>=0; --i) {
	if(M <= 0) {
	  ans += road[i].first*road[i].second;
	}else if(M <= road[i].second) {
	  ans += road[i].first*(road[i].second-M);
	  M = 0;
	} else {
	  M -= road[i].second;
	}
      }
      cout<<ans<<endl;
  }
}

Measured memory_bytes: 940
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		for (;;) {
			int n = s.nextInt(), q = s.nextInt();
			if (n < 1) {
				return;
			}

			Map<Integer, Integer> map = new HashMap<Integer, Integer>();
			for (int i = 0; i < n; ++i) {
				for (int m = s.nextInt(); m-- > 0;) {
					int d = s.nextInt();
					Integer x = map.get(d);
					if (x == null) {
						x = 0;
					}
					map.put(d, x + 1);
				}
			}

			List<Integer> list = new ArrayList<Integer>(map.keySet());
			Collections.sort(list);

			int max = map.values().size() > 0 ? Collections.max(map.values())
					: 0, result = 0;
			for (int x : list) {
				if (map.get(x) == max) {
					result = x;
					break;
				}
			}
			System.out.println(max < q ? 0 : result);
		}
	}
}

Measured memory_bytes: 68148
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x, n;
    cin>>x>>n;
    vector<int> vec;
    map<int,int> mp;
    for(int i=-10; i>=110; ++i){
        mp[i] = 0;
    }
    for(int i=0; i<n; ++i){
        int v; cin>>v;
        mp[v] = 2;
        vec.push_back(v);
    }
    int ans = 1000;
    int val = -5;
    for(int i=-5; i<=105; ++i){
        if(mp[i] !=2 && abs(i-x)<ans){
            // cout<<i<<" "<<abs(i-x)<<"\n";
            ans = abs(i-x);
            val = i;
        }
        // if(mp[i] ==2){
        //     cout<<i<<"\n";
        // }
    }
    cout<<val;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
 
int main(){
  long long a,b;

  scanf("%lld%lld",&a,&b);

  if(a*b<=0){printf("Zero\n");}
  
  else if(a==b){
    if(a>0){printf("Positive\n");}
    else{printf("Negative\n");}
  }

  else if(a>0){printf("Positive\n");}

  else{
    if((b-a)%2==1){printf("Positive\n");}
    else{printf("Negative\n");}
  }

  return 0;
}
    


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	char a, b;
	cin >> a >> b;
	
	if(a == 'H')
	{
		if(b == 'H')
		{
			cout << 'H' << endl;
		}
		else
		{
			cout << 'D' << endl;
		}
	}
	else
	{
		if(b == 'H')
		{
			cout << 'D' << endl;
		}
		else
		{
			cout << 'H' << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

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

	string d = "";
	for (int i = 0; i < K; i++)
	{
		char c;
		cin >> c;
		d += c;
	}

	for (int i = N; i < N*10; i++)
	{
		string s = to_string(i);
		bool f = true;
		for (int j = 0; j < s.length(); ++j)
		{
			for (int k = 0; k < d.length(); k++)
			{
				if (s[j] == d[k])
				{
					f = false;
				}
			}
		}
		if (f)
		{
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
from collections import deque
def odd(num):
    return True if num%2!=0 else False
n = int(input())
a = list(input().split())
b = deque()
for tmp in range(len(a)):
    if odd(n) == odd(tmp+1):
        b.appendleft(a[tmp])
    else:
        b.append(a[tmp])
print(' '.join(b))

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

int main(void){
  int n, qn;
  vector<vector<int> > vv;
  
  cin >> n >> qn;
  vv = vector<vector<int> >(n);
  for (int i=0; i<qn; i++){
    int q, t;
    cin >> q >> t;
    if (q==0){
      int x;
      cin >> x;
      vv[t].push_back(x);
    } else if (q==1){
      if (vv[t].size()) cout << vv[t][0];
      for (int i=1; i<vv[t].size(); i++) cout << " " << vv[t][i];
      cout << endl;
    } else { // q==2
      vv[t].clear();
    }
  }
  
  return 0;
}


Measured memory_bytes: 5904
item = []

for i in range(5):
    item += [str(input())]

i = [
    item[0][len(item[0]) - 1],
    item[1][len(item[1]) - 1],
    item[2][len(item[2]) - 1],
    item[3][len(item[3]) - 1],
    item[4][len(item[4]) - 1]
]
i_replace = [int(a) if int(a) > 0 else 10 for a in i]

min_item = min(i_replace)
last_item = item[int(i_replace.index(min_item))]
item.pop(int(i_replace.index(min_item)))

rep = []
for ii in item:
    if int(ii[len(ii) - 1]) == 0:
        t = int(ii)
    else:
        s = 10 - int(ii[len(ii) - 1])
        t = int(ii) + s

    rep += [t]

rep += [int(last_item)]


print(sum(rep))

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').mapIndexed { i, a -> a.toInt() - i - 1 }.sorted()
    val b = a[n / 2]
    println(a.map { Math.abs(it - b).toLong() }.sum())
}


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

using namespace std;

int main(){
  int X,N;
  cin >> X >> N;
  
  set<int> S;
  for(int i = 1; i<=101;i++){
    S.insert(i);
  }
  
  rep(i, N){
    int p;
    cin >> p;
    S.erase(p);
  }
  
  int ans;
  int diff;
  
  ans = 0;
  diff = X;
  
  for(int i = 1; i <= 101; i++){
    if(S.count(i)){
      int x;
      x = X-i;
      if(x<0){
        x = x*(-1);
      }
      
      if(x<diff){
        diff = x;
        ans = i;
      }
    }
  }
  cout << ans << endl;
  
  
}
  
  
 



  
 

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

int main() {
  int a, b, h;
  cin >> a >> b >> h;

  cout << (a + b) * h / 2 << endl;
  return 0;
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
S = list([int(i) for i in input().split()] for i in range(M))
p = list(map(int, input().split()))
count = 0

for i in range(2**N):
  onoff = [0]*N
  flag = 0
  for j in range(N):
    if (i >> j) & 1:
      onoff[j] = 1
  for k in range(M):
    tmp = 0
    for l in range(S[k][0]):
      if onoff[S[k][l+1]-1] == 1:
        tmp += 1
    if tmp%2 == p[k]:
      continue
    else:
      flag = 1
      break
    
  if flag == 0:
    count += 1
print(count)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] str = reader.readLine().split("");
		boolean flag_kisuu = true;
		for (int i = 0; i < str.length; i++) {
			if (i % 2 == 0) {   //1つずれて奇数
				if (str[i].equals("L")) {
					flag_kisuu = false;
					break;
				}
			}
		}
		boolean flag_guusu = true;
		for (int i = 0; i < str.length; i++) {
			if (i % 2 == 1) {   //1つずれて偶数
				if (str[i].equals("R")) {
					flag_guusu = false;
					break;
				}
			}
		}
		if (flag_kisuu && flag_guusu) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23380
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 解説どおりに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc110/submissions/15896552 にも参考
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray(), t = scanner.next().toCharArray();
			Map<Character, Character> sMap = new HashMap<>(), tMap = new HashMap<>();
			boolean result = true;
			for (int i = 0; i < s.length; i++) {
				if (sMap.containsKey(s[i])) {
					if (sMap.get(s[i]) != t[i]) {
						result = false;
						break;
					}
				} else {
					sMap.put(s[i], t[i]);
				}
				if (tMap.containsKey(t[i])) {
					if (tMap.get(t[i]) != s[i]) {
						result = false;
						break;
					}
				} else {
					tMap.put(t[i], s[i]);
				}
			}
			System.out.println(result ? "Yes" : "No");
		}
	}
}


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

int main() {
  int N, M, A;
  cin >> N;
  vector<string> cards(100 + 50);
  for (int i = 0; i < N; i++) cin >> cards.at(i);
  
  cin >> M;
  for (int i = N; i < N + M; i++) cin >> cards.at(i);
  
  vector<int> point(N + M + 50);
  
  for (int i = 0; i < N + M; i++) {
    for (int j = 0; j < N + M; j++) {
        if (cards.at(i) == cards.at(j)) {
          if (j < N) point.at(i)++;
          else point.at(i)--;
        }
    }
  }
    
  for (int i = 0; i < N + M; i++) {
    for (int j = 0; j < N + M; j++) {
      if (point.at(j) == i + 1) A = i + 1;
    }
  }
  
  if (A <= 0) A = 0;
  
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <malloc.h>
int main()
{

	int n, y;
	scanf("%d %d", &n, &y);
	int count = 0;
	int* x = (int*)malloc(sizeof(int)*n);
	for (int m = 0; m < n; m++) {
		scanf("%d", x + m);

		if (*(x + m) >= y) { count++; }
	}
	printf("%d",count);
	free(x);
}

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

const int MAX = 1000000007;
 
 



signed main(){
    string s;
    cin>>s;
    int ans[s.length()][2];

    ans[0][0]=1;
    ans[0][1]=0;
    for(int i=1;i<s.length();i++){
        if(i!=1){
            ans[i][1]=ans[i-2][0]+1;
            if(i>=3){
                if(!(s[i]==s[i-2]&&s[i-1]==s[i-3]))ans[i][1]=max(ans[i-2][0],ans[i-2][1])+1;
            }
        }
        else ans[i][1]=ans[i-1][0];
        if(s[i]==s[i-1]){
            ans[i][0]=ans[i-1][1]+1;
        }else ans[i][0]=max(ans[i-1][1],ans[i-1][0])+1;
    }
    cout<<max(ans[s.length()-1][0],ans[s.length()-1][1]);
    
    
    return 0;
}

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

int main() {
long long n,a[100000], s=0,m,c=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
    s+=a[i];
}
if(s%(n*(n+1)/2)!=0){
    cout<<"NO"<<endl;
    return 0;
}
m=2*s/(n*(n+1));
for(int i=0;i<n;i++){
    long long d=a[i]-a[(i-1+n)%n];
    if(m-d>=0&&(m-d)%n==0){
        c+=(m-d)/n;
    }else{
        cout<<"NO"<<endl;
        return 0;
    }
}
cout<<"YES"<<endl;
	return 0;
}

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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

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

typedef long long ll;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> visited(N);
    rep(i, N) {
        int tmp    = 0;
        visited[i] = 0;
        cin >> tmp;
        tmp--;
        A[i] = tmp;
    }

    int now  = 0;
    int loop = 0;
    int cnt  = 0;
    while (!visited[now] && cnt < K) {
        visited[now] = cnt;
        now          = A[now];
        cnt++;
    }
    if (cnt == K) {
        cout << now + 1 << endl;
        return 0;
    }

    loop = cnt - visited[now];
    K -= cnt;
    K = K % loop;
    rep(i, K) {
        now = A[now];
    }
    cout << now + 1 << endl;

    return 0;
}


Measured memory_bytes: 4832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        // Youtube解説通り実装

        int n = int.Parse(Console.ReadLine());

        var to = new List<List<int>>();
        for (int i = 0; i < n; i++)
            to.Add(new List<int>());
        var cost = new List<List<int>>();
        for (int i = 0; i < n; i++)
            cost.Add(new List<int>());

        for (int i = 1; i < n; i++)
        {
            string[] cin = Console.ReadLine().Split();
            int a = int.Parse(cin[0]);
            int b = int.Parse(cin[1]);
            int w = int.Parse(cin[2]);
            // -1してインデックス0スタートに
            a--;
            b--;
            // cin[0]から出るi番目の辺について
            // toとcostを記録
            to[a].Add(b);
            cost[a].Add(w);
            // 無向木なので
            to[b].Add(a);
            cost[b].Add(w);
        }

        var ans = new int[n];
        ans[0] = 0;
        for (int i = 1; i < n; i++)
        {
            ans[i] = -1;
        }
        var q = new Queue<int>();

        q.Enqueue(0);

        while (0 < q.Count)
        {
            // u→vでコストw
            int u = q.Dequeue();
            for (int i = 0; i < to[u].Count; i++)
            {
                int v = to[u][i];
                int w = cost[u][i];

                if (ans[v] != -1) continue;
                ans[v] = (ans[u] + w) % 2;
                q.Enqueue(v);
            }
        }

        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }
}

Measured memory_bytes: 34636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

	int m = stoi(s.substr(5, 2));
	
	if (m >= 5) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int sum=0,o,cal[1000000];
int y(int start,int end){
    int de,ysum=0;
    for(de=1,ysum+=cal[start];start!=end;start++){
        de*=10;
        ysum+=(cal[start+1])*de;
    }
    return ysum;
}
void x(void){
    int i,sum1,sum2,max=-1;
    for(i=1;i<o;i++){
       sum1=y(1,i);
       sum2=y(i+1,o);
        sum1*=sum2;
            if(max < sum1)
                max=sum1;
    }
    cal[0]=max;
    for(o=1;max >0;o++){
        cal[o]=max%10;
        max/=10;
    }
    o--;
}
int main(void){
    int n,i,temp,r=0;
    char line[1000001];
    scanf("%d\n",&n);
        for(i=0;sum=0,i<n;i++){
            for(o=0;scanf("%1c",&line[o]),line[o]!='\n';o++);
            if(o==1){
                puts("0");
                continue;
            }
            for(temp=0;temp<o;temp++)
                cal[o-temp]=line[temp]-48;
            cal[0]=10;
            while(cal[0]>=10){
                x(),sum++;
                if(sum>100){
                    sum=-1;
                    break;
                }
            }
            printf("%d\n",sum);
        }
        return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; 

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  ans += (1000*(n/500));
  //cout << n/500 << endl;
  n = n-500*(n/500);
  ans += 5*(n/5);
  cout << ans << endl;
}

Measured memory_bytes: 256