akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	vl A(9);
	for (i = 0; i < 9; i++) {
		cin >> A[i];
	}
	cin >> N;
	for (i = 0; i < N; i++) {
		ll b;
		cin >> b;
		for (j = 0; j < 9; j++) {
			if (b == A[j]) {
				A[j] = 0;
			}
		}
	}
	if (A[0] == 0 && A[1] == 0 && A[2] == 0) {
		ans = 1;
	}
	if (A[3] == 0 && A[4] == 0 && A[5] == 0) {
		ans = 1;
	}
	if (A[6] == 0 && A[7] == 0 && A[8] == 0) {
		ans = 1;
	}
	if (A[0] == 0 && A[3] == 0 && A[6] == 0) {
		ans = 1;
	}
	if (A[1] == 0 && A[4] == 0 && A[7] == 0) {
		ans = 1;
	}
	if (A[2] == 0 && A[5] == 0 && A[8] == 0) {
		ans = 1;
	}
	if (A[0] == 0 && A[4] == 0 && A[8] == 0) {
		ans = 1;
	}
	if (A[2] == 0 && A[4] == 0 && A[6] == 0) {
		ans = 1;
	}
	if (ans == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


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

int main(){
  char i, j, h;
  cin >> i >> j >> h;
  if(i=='1'){
    cout << '9';
  }
  else{
    cout << '1';
  }
  if(j=='1'){
    cout << '9';
  }
  else{
    cout << '1';
  }
  if(h=='1'){
    cout << '9';
  }
  else{
    cout << '1';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll k;
  cin >> k;
  rep(i,k) cout << "ACL";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define MAXN 100100
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
inline ll mod(ll n, ll m){ll ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int dp[MAXN];
int pai[MAXN];
vector<int> adj[MAXN];
int M ;
int solve(int v,int p=-1){
	if(dp[v]!=-1)return dp[v];
	
	if(adj[v].size()==1 && p!=-1)return dp[v] = 2;
	
	int op1 = 1;
	int op2 = 1;
	for(int i=0;i<adj[v].size();i++){
		int to = adj[v][i];
		if(to==p)continue;
		pai[to] = v; 
		op2 = (op2*solve(to,v))%M;
	}
	return dp[v] = (op1 + op2)%M;
}

int ans[MAXN];
int phi;
int passou[MAXN];
int pre[MAXN],suf[MAXN];

void dfs(int v,int p=-1){
	if(v==1){
		ans[v] = mod(dp[v] - 1,M);
			pre[0] = 1;
		suf[adj[v].size()] = 1;
		for(int i=0;i<adj[v].size();i++){
			int to = adj[v][i];
			if(to==p)continue;
			pre[i+1] = (pre[i]*dp[to])%M;  	
		}
		for(int i=(int)adj[v].size() - 1;i>=0;i--){
			int to = adj[v][i];
			if(to==p)continue;
			suf[i] = (suf[i+1]*dp[to])%M;
		}
		
		for(int i=0;i<adj[v].size();i++){
			int to = adj[v][i];
			if(to==p)continue;
			passou[to] = (pre[i]*suf[i+1])%M;
		}
	}else{
		int r = mod(passou[v]+1,M);
		
		ans[v] = r;
		pre[0] = 1;
		suf[adj[v].size()] = 1;
		for(int i=0;i<adj[v].size();i++){
			int to = adj[v][i];
			pre[i+1] = pre[i]; 
			if(to==p)continue;
			ans[v] = mod(ans[v]*dp[to],M);
			pre[i+1] = (pre[i]*dp[to])%M;  	
		}
		for(int i=(int)adj[v].size() - 1;i>=0;i--){
			int to = adj[v][i];
			suf[i] = suf[i+1];
			if(to==p)continue;
			suf[i] = (suf[i+1]*dp[to])%M;
		}
		
		for(int i=0;i<adj[v].size();i++){
			int to = adj[v][i];
			if(to==p)continue;
			passou[to] = (pre[i]*suf[i+1])%M;
			passou[to] = (passou[to]*r)%M; 	
		}
		
	}
	for(int i=0;i<(int)adj[v].size();i++){
		int to = adj[v][i];
		if(to==p)continue;
		dfs(to,v);
	}
}


int32_t main(){
	fastio;
	int n;
	cin>>n>>M;
	memset(dp,-1,sizeof(dp));
	
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	solve(1);
	
	dfs(1);
	
	for(int i=1;i<=n;i++)cout<<mod(ans[i],M)<<endl;
	
	// Math -> gcd it all
	//did you check N=1? Did you mix up N,M?
}


Measured memory_bytes: 14464
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;

inline LL read()
{
	LL x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

LL gcd(LL x,LL y)
{
	if(y==0) return x; else return gcd(y,x%y);
}

int main()
{
	int n;
	n=read();
	LL ans=1,a=0;
	for(int i=1;i<=n;i++)
	{
		a=read();
		ans=ans/gcd(ans,a)*a;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;

    vector<int> ans(n);
    for (int i=0; i<n; i++) {
        queue<pair<int, int>> q;
        q.push({i, 0});
        vector<bool> vis(n);
        
        while (!q.empty()) {
            auto cur = q.front();
            q.pop();
            if (cur.first > i)
                ans[cur.second]++;
            if (cur.first != n-1 && !vis[cur.first+1]) { q.push({cur.first+1, cur.second+1}); vis[cur.first+1] = true; }
            if (cur.first != 0 && !vis[cur.first-1]) { q.push({cur.first-1, cur.second+1}); vis[cur.first-1] = true; }
            if (cur.first == x && !vis[y]) { q.push({y, cur.second+1}); vis[y] = true; }
        }
    }
    for (int i=1; i<n; i++) cout << ans[i] << "\n";
}


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

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		List<Integer> list = new ArrayList<>();

		for(int i=0;i<3;i++){
			int thi = sc.nextInt();
			list.add(thi);
		}
		Collections.sort(list);

		System.out.println(list.get(0)*list.get(1)/2);




	}

}

Measured memory_bytes: 23892
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a+b>c+d)
        printf("Left\n");
    else if (a+b==c+d)
        printf("Balanced\n");
    else
        printf("Right\n");
    return 0;
}


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

int main(){
	int i,a,b,n,k,tmp;
	scanf("%d",&n);
	scanf("%d",&k);
	for(i = 0;i < k;i++){
		scanf("%d %d",&a,&b);
		if(b > a){
			tmp = b;
			b = a;
			a = tmp;
		}
		if(a < n - b + 2) printf("%d\n",(b - 1) % 3 + 1);
		else printf("%d\n",(n - a) % 3 + 1);
	}
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
#include <set>
  
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

int fld[1010][1010];
P memo[1000100];
bool is_prime[1000100];

bool big(P a,P b){
	if(a.first!=b.first)return a.first<b.first;
	return a.second<b.second;
}

P rec(int x,int y,int m){
	//cout<<fld[x][y]<<endl;
	if(memo[fld[x][y]].first!=-1)return memo[fld[x][y]];

	P res,res1;res.first=0;res.second=0;

	for(int i=-1;i<=1;i++){
		if(fld[x+i][y+1]!=-1&&fld[x+i][y+1]<=m){
			res1=rec(x+i,y+1,m);
			if(big(res,res1))res=res1;
		}
	}
	if(is_prime[fld[x][y]]){
		res.first++;
		if(res.first==1)res.second=fld[x][y];
	}
	//cout<<fld[x][y]<<" "<<res.first<<" "<<res.second<<endl;
	return memo[fld[x][y]]=res;
}

int main(){
	int x1=505,y1=505;
	memset(fld,-1,sizeof(fld));
	fld[x1][y1]=1;
	int p=1;
	while(1){
		fld[x1+p][y1+p]=(2*p+1)*(2*p+1);//右下
		fld[x1-p][y1-p]=(fld[x1+p][y1+p]+fld[x1+p-1][y1+p-1])/2;//左上
		fld[x1+p][y1-p]=(fld[x1-p][y1-p]+fld[x1+p-1][y1+p-1])/2;//右上
		fld[x1-p][y1+p]=(fld[x1+p][y1+p]+fld[x1-p][y1-p])/2;//左下
		for(int i=1;i<fld[x1+p][y1-p]-fld[x1+p-1][y1+p-1];i++){
			fld[x1+p][y1+p-i]=fld[x1+p-1][y1+p-1]+i;
		}
		for(int i=1;i<fld[x1-p][y1-p]-fld[x1+p][y1-p];i++){
			fld[x1+p-i][y1-p]=fld[x1+p][y1-p]+i;
		}
		for(int i=1;i<fld[x1-p][y1+p]-fld[x1-p][y1-p];i++){
			fld[x1-p][y1-p+i]=fld[x1-p][y1-p]+i;
		}
		for(int i=1;i<fld[x1+p][y1+p]-fld[x1-p][y1+p];i++){
			fld[x1-p+i][y1+p]=fld[x1-p][y1+p]+i;
		}
		if((2*p-1)*(2*p-1)>1e6)break;
		p++;
	}
	memset(is_prime,true,sizeof(is_prime));
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=1e6;i++){
		if(is_prime[i]){
			for(int j=2*i;j<=1e6;j+=i){
				is_prime[j]=false;
			}
		}
	}
	int n,m;
	while(1){
		cin>>m>>n;
		if(n==0&&m==0)break;
		REP(i,1e6+1)memo[i].first=-1;
		memset(memo,-1,sizeof(memo));
		int x=-1,y=-1;
		REP(i,1010){
			REP(j,1010){
				if(fld[i][j]==n){
					x=i;y=j;break;
				}
			}
			if(x!=-1)break;
		}
		P ans=rec(x,y,m);
		cout<<ans.first<<" "<<ans.second<<endl;
	}

}



Measured memory_bytes: 15964
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  int n,x,m[200],a,b;
  cin >> n >> x;
  rep(i,n)cin >> m[i];
  rep(i,n)a+=m[i];
  sort(m,m+n);
  b=(x-a)/m[0];
  printf("%d",b+n);
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define re register
#define il inline
#define inf 0x3f3f3f
int n, m;
char r[600][600], b[600][600], a[600][600];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i += 2)
    for (int j = 1; j <= m; j++)
      r[i][j] = '#';
  for (int i = 2; i <= n; i += 2)
    for (int j = 1; j <= m; j++) {
      r[i][j] = '.';
    }
  for (int i = 2; i <= n; i += 2)
    for (int j = 1; j <= m; j++)
      b[i][j] = '#';
  for (int i = 1; i <= n; i += 2)
    for (int j = 1; j <= m; j++) {
      b[i][j] = '.';
    }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char cur;
      cin >> cur;
      if (cur == '#') {
        r[i][j] = '#';
        b[i][j] = '#';
      }
    }
  }
  for (int i = 1; i <= n; i++)
    r[i][1] = '#', b[i][1] = '.';
  for (int i = 1; i <= n; i++)
    r[i][m] = '.', b[i][m] = '#';
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      cout << r[i][j];
    cout << endl;
  }
  cout << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      cout << b[i][j];
    cout << endl;
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y, x%y);
}

signed main(){
    int n, x;
    cin >> n >> x;
    int ans; cin >> ans;
    ans = abs(x-ans);
    rep(i,n-1){
        int t; cin >> t;
        ans = gcd(abs(t-x),ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define opt ios_base::sync_with_stdio(false); cin.tie(NULL);

void freak__()
{
    int n,i,j;
    cin >> n;
    int h[n],flag,cnt=0;
    for(i=0;i<n;i++) cin >> h[i];
    for(i=0;i<n;i++)
    {
        flag=1;
        for(j=0;j<i;j++)
        {
            if(h[j]>h[i])
            {
                flag=0;
                break;
            }
        }
        if(flag) cnt++;
    }
    cout << cnt;
    cout << "\n";
}

int main()
{
    opt;
    freak__();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
string A[20];

int n;
bool used[1<<18][10][10],mem[1<<18][10][10];
bool dfs(int bit,int l,int r){
  if(bit == (1<<n)-1) return 1;
  if(used[bit][l][r])return mem[bit][l][r];
  used[bit][l][r] = 1;
  
  bool res = 0;
  for(int i=0;i<n;i++){
    if(bit>>i&1) continue;
    int nbit = bit | (1<<i);
    
    if(l == A[i][0]-'0') res |= dfs(nbit,A[i][1]-'0',r);
    if(l == A[i][1]-'0') res |= dfs(nbit,A[i][0]-'0',r);
    if(r == A[i][0]-'0') res |= dfs(nbit,l,A[i][1]-'0');
    if(r == A[i][1]-'0') res |= dfs(nbit,l,A[i][0]-'0');
    if(res) break;
  }
  return mem[bit][l][r] = res; 
}

signed main(){

  while(cin>>n){
    for(int i=0;i<n;i++) cin>>A[i];
    memset(used,0,sizeof(used));
    memset(mem,0,sizeof(mem));
    bool ans = dfs(1,A[0][0]-'0',A[0][1]-'0');
    cout<<(ans? "Yes":"No") <<endl;
  }
  return 0;
}

Measured memory_bytes: 54336
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {           
    public static void main(String[] args) {		        
      Scanner sc = new Scanner(System.in);                                       
         
      String alphabet[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};         
    
    HashMap<String,Integer> map = new HashMap<>();                            

    int N = sc.nextInt();
    
    String target[] = new String[N];
    
    for(int i = 0;i < N;i++){
        target[i] = sc.next();
    }
    
    
    for(int j = 0; j < 26;j++){          
       int min = Integer.MAX_VALUE;
       for(int i = 0;i < N;i++){                 
          String item   =  alphabet[j];         
          Pattern  p = Pattern.compile(item);
          Matcher m = p.matcher(target[i]);         

          int count = 0;
          int s = 0;                  
          
          while (m.find(s)) {
           count++;
           s = m.end();
          }         
          
          min = Math.min(count,min);
          
          map.put(item,min);                                      
       }            
    }        
    
        
    StringBuilder ans = new StringBuilder();    
    
    for (String key : map.keySet()){        
        for(int i = 0;i < map.get(key);i++){
          ans.append(key);
        }          
    }  

    System.out.println(ans.toString());

    
  }
}
        
        
        
        
        

Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include<vector>


int main() {
    long long n, t; std::cin >> n >> t;

    std::vector<long long> T(n);
    for(int i = 0; i < n;i ++) {
        std::cin >> T[i];
    }

    long long ans = 0;
    for(int i = 0; i < n - 1; i++) {
        if (std::abs(T[i + 1] - T[i]) < t)
        {
            ans += std::abs(T[i + 1] - T[i]);
        }
        else
        {
            ans += t;
        }
    }

    ans += t;

    std::cout << ans << "\n";

}

Measured memory_bytes: 4756
import sys
input = sys.stdin.readline
n = int(input())
A = [int(input()) for _ in range(n)]
dic = {}
for a in A:
    if dic.get(a,0):
        dic[a] = 0
    else:
        dic[a] = 1
print(sum([v for k,v in dic.items()]))

Measured memory_bytes: 16268
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[m],sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    if(sum>n)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<n-sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String c = s.next();
	
		if(c.equals("a") || c.equals("e") || c.equals("i") || c.equals("o") ||c.equals("u") ){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}
	}	
}


Measured memory_bytes: 9556
using System;
using System.Linq;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int count;
            while((count = int.Parse(Console.ReadLine())) != 0) {
                int[] score = new int[2];
                for(int i=0; i < count; ++i) {
                    int[] cards = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
                    if(cards[0] == cards[1]) {
                        score[0] += cards[0];
                        score[1] += cards[1];
                    }
                    else {
                        score[cards[0] > cards[1] ? 0 : 1] += cards[0] + cards[1];
                    }
                }
                Console.WriteLine("{0} {1}", score[0], score[1]);
            }
        }
    }
}

Measured memory_bytes: 6088
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
import fractions
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def getyaku(n):
    res = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            res.append(i)
            res.append(n // i)

    return(sorted(list(set(res))))

def judge(cand, nums):
    w = 0
    for num in nums:
        if num % cand !=0:
            if w == 1:
                return False
            else:
                w += 1

    return True

def main():
    n = getN()
    nums = getlist()

    ans = 0
    cands = getyaku(nums[0])

    for cand in cands:
        if judge(cand, nums):
            if ans < cand:
                ans = cand
    cands = getyaku(nums[1])

    for cand in cands:
        if judge(cand, nums):
            if ans < cand:
                ans = cand

    print(ans)
    return

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Measured memory_bytes: 89580
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 

using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
int n,x;
std::cin >> n >> x;
std::vector<int> count(1,1);
std::vector<int> pate(1,1);
for(int i = 1; i <= n; i++){
    count.pb(2 * count[i - 1] + 3);
    pate.pb(2 * pate[i - 1] + 1);
}

int it = n;
int sum = 0;
int now = 0;
int b = n;
int flag = 0;
while((count[it] - 1)/2 + 1 != x - now){
    if(it < 0){
        flag = 1;
        break;
    }
    if((count[it] - 1)/2 == x - now){
       sum += (pate[it] - 1)/2;
       flag = 1;
       break;
    }
    if((count[it] - 1) / 2 + now < x){
        sum += (pate[it]) / 2 + 1;
        now += (count[it])/2 + 1;
        it--;
    } else {
        it--;
        now++;
        if(x <= now || it < 0){
            flag = 1;
            break;
        }
    }
}
if(flag || (count[it] - 1)/2 + 1 + now < x){
    std::cout << sum << std::endl;
}else {
sum += (pate[it] - 1)/2 + 1;
std::cout << sum << std::endl;
}



return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_C

#include <iostream>
using namespace std;
int main(){
  int n, b, f, r, v;
  //b?£?f??????r???????????¨?±????v???
  cin >> n;
  int a[4][3][10];
  //?£?,

  for(int h=0; h<4; h++){
    for(int i=0; i<3; i++){
      for(int j=0; j<10; j++){
        a[h][i][j] = 0;
      }
    }
  }//?????????

  for(int i=0; i<n; i++){
    cin >> b >> f >> r >>v;
    b -= 1; f -= 1;r -= 1;
    a[b][f][r] += v;
  }

  for(int h=0; h<3; h++){
    for(int i=0; i<3; i++){
      for(int j=0; j<10; j++){
        cout << " " << a[h][i][j];
      }
      cout << endl;
    }
    cout << "####################" << endl;
  }
  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      cout << " " << a[3][i][j];
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

vll enum_div(ll n) //nの約数を列挙
{
    vll ret;
    for (ll i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
            {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    vll div = enum_div(N);
    repb(i, 1, div.size())
    {
        if (N / div[i] == N / (div[i] - 1))
        {
            ans += div[i] - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
use std::cmp;
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let days: usize = iter.next().unwrap().parse().unwrap();
    let hapinesses: Vec<(u32, u32, u32)> = (0..days)
        .map(|_| {
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
            )
        })
        .collect();
    let mut dp = vec![vec![0; 3]; days];
    dp[0] = vec![hapinesses[0].0, hapinesses[0].1, hapinesses[0].2];

    for i in 1..days {
        dp[i][0] = hapinesses[i].0 + cmp::max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = hapinesses[i].1 + cmp::max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = hapinesses[i].2 + cmp::max(dp[i - 1][0], dp[i - 1][1]);
    }
    match dp[days - 1].iter().max() {
        Some(n) => println!("{}", n),
        None => println!("error"),
    }
}


Measured memory_bytes: 12540
#include <iostream>
#include <map>
using namespace std;
int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    string s;
    while (cin >> s) {
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3636
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n,k ;
	cin >> n >> k ;
	if(k==1) cout << 0 << endl ;
	else cout << n-k << endl ;
}


Measured memory_bytes: 256
import itertools
import math

N=int(input())
X=[]
Y=[]
s=0
l=[int(x) for x in range(N)]
L = list(itertools.permutations(l, N))
for i in range(N):
    x,y=map(int,input().split())
    X.append(x)
    Y.append(y)
for i in range(math.factorial(N)):
    for j in range(N-1):
        s+=((X[L[i][j]]-X[L[i][j+1]])**2+(Y[L[i][j]]-Y[L[i][j+1]])**2)**0.5
print(s/(math.factorial(N)))

Measured memory_bytes: 13820
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;
long long int N, K;


int main(void) {

	cin >> N >> K;

	int ans = 0;
	while (N > 0) { ans++; N /= K; }

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def count(n):
    c=0
    for i in range(1,int(n**(0.5))+1):
        if n%i==0:    
            if (n/i)==i:
                c+=1
            else:
                c+=2
    return c 
n=int(input())
cou=0
for i in range(n+1):
    if i%2!=0 :
        if count(i)==8:
            cou+=1
print(cou)        
        

Measured memory_bytes: 3060
#include<iostream>
#include <vector>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;

int main()
{
    long x,y;
    // string s;
    cin  >> x >> y;

    long tmp=x;
    long ans=1;
    for (int i = 2; i < y/x+1; ++i){
      tmp+=tmp;
      if (tmp >y)break;
      ans=i;
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
s=input()
if len(s)%2!=0:
    print("No")
else:
    ans="Yes"
    for i in range(len(s)):
        if i%2==0 and s[i]!="h":
            ans="No"
            break
        elif i%2==1 and s[i]!="i":
            ans="No"
            break
    print(ans)

Measured memory_bytes: 3060
N = int(input())
B = list(map(int, input().split()))

A = [max(B)] * N

for n in range(N-1):
    if B[n] < A[n]:
        A[n] = B[n]
    if B[n] < A[n+1]:
        A[n+1] = B[n]
print(sum(A))

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int32 add(int32 a, int32 b){
	if(a == 1 && b == 1) return 1;
	return min((int32)2, a+b);
}

int32 mul(int32 a, int32 b){
	if(a*b == 0) return 0;
	if(a == 1 || b == 1) return 1;
	return 2;
}

int32 nnot(int32 a){
	return 2-a;
}

int32 val[3];

int32 eval(string s){
	if(s.size() == 1 && '0' <= s[0] && s[0] <= '3') return s[0]-'0';
	if(s.size() == 1) return val[s[0]-'P'];
	if(s[0] == '-') return nnot(eval(s.substr(1, s.size()-1)));
	int32 now = 0;
	REP(i, s.size()){
		if(s[i] == '(') now++;
		if(s[i] == ')') now--;
		if(now == 1 && s[i] == '+') return add(eval(s.substr(1, i-1)), eval(s.substr(i+1, s.size()-i-2)));
		if(now == 1 && s[i] == '*') return mul(eval(s.substr(1, i-1)), eval(s.substr(i+1, s.size()-i-2)));
	}
}

int main(void){
	string s;
	while(cin >> s && s != "."){
		int32 res = 0;
		REP(i, 3){
			REP(j, 3){
				REP(k, 3){
					val[0] = i; val[1] = j; val[2] = k;
					if(eval(s) == 2) res++;
				}
			}
		}
		cout << res << endl;
	}
}


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

int main() {
    int a, b;
    cin >> a >> b;
    vector<int> vec = {a+b, a-b, a*b};
    //rep(i,3) cout << vec[i] << endl;
    int ans = *max_element(vec.begin(), vec.end());
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    string S;
    cin>>S;

    for(int i=0;i<S.size();i++){
        if(S[i]==','){
            S[i]=' ';
        }
    }
    cout<<S<<endl;
}

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

int main(){
    int N;
    map <long long,long long,greater<long long>> dic;
    cin>>N;
    
    for(int i=0; i<N; i++){
        long long a;
        cin>>a;
        dic[a]++;
    }

    long long ans = 1;
    int cnt = 0;

    for(auto a : dic){
        if(cnt == 2) break;
        if(a.second >= 4 && cnt == 0){
            ans = a.first*a.first;
            cnt = 2;
            break;
        }

        if(a.second >= 2){
            ans *= a.first;
            cnt++;
        }
    }

    if(cnt == 2) cout<<ans<<endl;
    else cout<<"0"<<endl;
}

Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Globalization;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            long mod = 1000000007;
            long ans = 1;
            int N = int.Parse(Console.ReadLine());
            for(int i = 1; i <= N; i++)
            {
                ans *= i;
                ans %= mod;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
using namespace std;
 
int hoge(int hoge)
{
 
    int ans = 0;
 
    while ( hoge > 0 ) {
        ans += hoge % 10;
        hoge /= 10;
    }
 
    return ans;
}
 
int main()
{
 
    long long N, A, B, pans;
    cin >> N;
 
    pans = 1LL<<60;
 
    for ( long long i = 1; i < N; i++ ) {
 
        int j = N - i;
        long long ans = hoge(i) + hoge(j);
 
        pans = min(pans, ans);
    }
 
    cout << pans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <functional>
using namespace std;

typedef long long ll;
const ll InF = 1e15;

int main() {
  int N;
  cin>>N;
  ll firstB,lastA,dual,ABcount;
  firstB = lastA = dual = ABcount = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin>>s;
    int slen = s.size() - 1;
    if (s[0]=='B') firstB++;
    if (s[slen]=='A') lastA++;
    if (s[0]=='B' && s[slen]=='A') dual++;
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i]=='A' && s[i+1]=='B') ABcount++;
    }
  }
  ll ans;
  if (firstB > 0 && firstB == lastA && lastA == dual) {
    ans = ABcount + firstB - 1;
  } else ans = ABcount + min(firstB,lastA);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 200020
using namespace std;
inline int getint(){
    char c=getchar();int x=0;bool p=0;
    while((c>'9'||c<'0')&&c!='-')c=getchar();
    if(c=='-')p=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(p)x=-x;return x;
}
int w[maxn];
ll dp[maxn][5],s[maxn],rs[maxn];
int main(){
	int n=getint();s[0]=0;rs[n+1]=0;
	for(int i=1;i<=n;++i)w[i]=s[i]=rs[i]=getint();
	for(int i=2;i<=n;++i)s[i]+=s[i-1];
	for(int i=n-1;i>=1;--i)rs[i]+=rs[i+1];
	memset(dp,0,sizeof(dp));
	ll ans=rs[1]; 
	for(int i=1;i<=n;++i){
		dp[i][1]=min(dp[i-1][1],s[i-1])+(w[i]&1)+((w[i]==0)*2);
		dp[i][2]=min(s[i-1],min(dp[i-1][1],dp[i-1][2]))+((w[i]&1)^1);
		dp[i][3]=min(dp[i-1][2],dp[i-1][3])+(w[i]&1)+((w[i]==0)*2);
		for(int j=1;j<=3;++j)ans=min(ans,dp[i][j]+rs[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11904
#include<stdio.h>
using namespace std;
int a[100000];int n;int m;
bool s(int k)
{
    a[n]=k;
    int i=0;
    while(a[i]!=k)i++;
    return i!=n;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&m);
    int k,sum=0;
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&k);
        if(s(k)) sum++;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 2752
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
const int MOD = 1e9+7;
//}}}

int main(){
	int N;
	cin >> N;
	if(N%2) N*=2;
	cout<<N<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}


int main(){
  ll ans = 0;
  int n,m;
  cin >> n >> m;
  vector<int> in(n);
  rep(i,n){
    cin >> in[i];
  }
  sort(in.begin(), in.end());

  vector<pair<int,int> > pii(m);
  rep(i,m){
    int num, val;
    cin >> num >> val;
    pii[i].first  = val;
    pii[i].second = num;
  }
  sort(pii.begin(), pii.end(), greater<pair<int,int> >());

  int j = 0;
  rep(i,n){
    if (j < pii.size() && pii[j].first > in[i]){
      ans += pii[j].first;
      pii[j].second--;
      if (pii[j].second == 0)j++;
    } else {
      ans += in[i];
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    set<int> OR;
    set<int> AND;
    set<int> a;
    set<int> b;
    for(int i = 1; i <= n; i++) {
        int in;
        cin >> in;
        a.insert(in);
        OR.insert(in);
    }
    for(int i = 1; i <= m; i++) {
        int in;
        cin >> in;
        OR.insert(in);
        if(a.find(in) != a.end()) AND.insert(in);
    }
    cout << AND.size() << " " << OR.size() << endl;
    for(auto itr = AND.begin(); itr != AND.end(); itr++) {
        cout << *itr << endl;
    }
    for(auto itr = OR.begin(); itr != OR.end(); itr++) {
        cout << *itr << endl;
    }
    return 0;
}


Measured memory_bytes: 20084
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;


int main() {
  int n,k;
  double num,ki,ans;
  cin >> n >> k;
  std::vector<double> v(n+1);
  v[0] = 0;
  for(int i=1; i<=n; i++) {
    cin >> num;
    // ki = (num*(num+1.0)/2.0)/num;
    ki = (num+1)/2.0;
    v[i] = v[i-1] + ki;
  }
  ans = 0;
  for(int i=0; i<n-k+1; i++) {
    ans = max(ans, v[i+k] - v[i]);
  }
  printf("%.7f", ans);
}


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

using namespace std;

#define MAX_SIZE 200005
#define modulo 1000000007L

int nums[MAX_SIZE], right_sums[MAX_SIZE];

int main() {
  int n_nums = 0;
  scanf("%d", &n_nums);
  memset(nums, 0, sizeof(nums));
  memset(right_sums, 0, sizeof(right_sums));

  for (int i = 0; i < n_nums; ++i) {
    scanf("%d", nums+i);
  }

  // reverse sum
  for (int i = n_nums-1; i >= 0; --i) {
    right_sums[i] = (right_sums[i+1] + nums[i]) % modulo;
  }


  long long ans = 0;
  for (int i = 0; i < n_nums-1; ++i) {
    ans = (ans + (long long)(right_sums[i+1]) * (long long)nums[i]) % modulo;
  }
  printf("%d\n", int(ans));
  return 0;
}

Measured memory_bytes: 5392
#include<iostream>
#include<queue>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
std::vector<std::vector<T>> mk2d(size_t s1, size_t s2, T const& val) {
  std::vector<T> tmp(s2, val);
  return std::vector<std::vector<T>>(s1, tmp);
}

template<typename T>
std::vector<T> mk1d(size_t s, T const& val) {
  return std::vector<T>(s, val);
}

int const dx[4] = {1, 0, -1, 0};
int const dy[4] = {0, 1, 0, -1};
int64_t const INF = 1e18;
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int H, W, K; std::cin >> H >> W >> K;
  int xs, ys, xg, yg; std::cin >> xs >> ys >> xg >> yg;
  auto bm = mk2d(H+2, W+2, '@');
  for(int h = 1; h <= H; ++h) for(int w = 1; w <= W; ++w) std::cin >> bm[h][w];
  auto dtmp = mk2d(H+2, W+2, INF);
  auto dist = mk1d(4, dtmp);
  using TP = std::tuple<int64_t,int,int,int>;
  std::priority_queue<TP, std::vector<TP>, std::greater<TP>> q;
  q.emplace(0, 0, xs, ys);
  q.emplace(0, 1, xs, ys);
  q.emplace(0, 2, xs, ys);
  q.emplace(0, 3, xs, ys);
  while(!q.empty()) {
    int d, x, y; int64_t c;
    std::tie(c, d, x, y) = q.top(); q.pop();
    if(c >= dist[d][x][y]) continue;
    dist[d][x][y] = c;
    for(int j = 1; j <= 3; ++j) {
      int64_t nc = ((c+K-1)/K)*K;
      q.emplace(nc, (d+j)%4, x, y);
    }
    int nx = x + dx[d];
    int ny = y + dy[d];
    if(bm[nx][ny] == '.') q.emplace(c+1, d, nx, ny);
  }
  int64_t ans = dist[0][xg][yg];
  if(ans == INF) ans = -1; else ans = (ans+K-1)/K;
  fin(ans);
  return 0;
}


Measured memory_bytes: 123844
#include <stdio.h>

void max(int a, int b, int x, int y);
void sort(int a[]);
void swap(int *x, int *y);

int list[100];
int rank[100];
int n;
int i, j;

int main(void)
{
	int match;
	int a, b;
	int p1, p2;
	
	scanf("%d", &n);
	
	match = n * (n - 1) / 2;
	
	for (i = 0; i < match; i++){
		scanf("%d %d %d %d", &a, &b, &p1, &p2);
		max(a - 1, b - 1, p1, p2);
	}
	
	for (i = 0; i < n; i++){
		rank[i] = list[i];
	}
	
	sort(rank);
	
	for (i = 0; i < n; i++){
		for (j = 0; j < n; j++){
			if (list[i] == rank[j]){
				printf("%d\n", j + 1);
				break;
			}
		}
	}
	
	return (0);
}

void max(int a, int b, int x, int y)
{
	if (x > y){
		list[a] += 3;
	}
	else if (x < y){
		list[b] += 3;
	}
	else {
		list[a] += 1;
		list[b] += 1;
	}
}

void sort(int a[])
{
	int i, j;
	
	for (i = 0; i < n - 1; i++){
		for (j = i + 1; j < n; j++){
			if (a[j] > a[i]){
				swap(&a[j], &a[i]);
			}
		}
	}
}

void swap(int *x, int *y)
{
	*x += *y;
	*y = *x - *y;
	*x -= *y;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file freopen("out.out","w",stdout);
#define RE cout<<233<<endl;
#define Tone(x) cout<<x<<endl;
#define Tall(x,n) for(int i=0;i<n;i++)cout<<x[i]<<(i==n-1?"\n":" ");
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int a,b;
char t[111][111];
vpii v;

int I_Love_Hashimoto_Kanna() {
  fastio;
  cin>>a>>b;
	a--;b--;
  FOR(i,0,50)FOR(j,0,100){
  	t[i][j]='.';
  	if(i!=0&&i!=49&&j!=0&&j!=99){
  		if(i%2==0&&j%2==0)v.push_back({i,j});
		}
	}
	int pos=0;
  while(b){
  	b--;
  	t[v[pos].first][v[pos].second]='#';
		pos++;
	}
	v.clear();
  FOR(i,50,100)FOR(j,0,100){
  	t[i][j]='#';
  	if(i!=50&&i!=99&&j!=0&&j!=99){
  		if(i%2==0&&j%2==0)v.push_back({i,j});
		}
	}
	pos=0;
  while(a){
  	a--;
  	t[v[pos].first][v[pos].second]='.';
		pos++;
	}
	cout<<100<<" "<<100<<endl;
	FOR(i,0,100){
	  FOR(j,0,100)cout<<t[i][j];
	  cout<<endl;
	}
  
  return 0;
}


Measured memory_bytes: 256
n, @a, @b=gets.split.map(&:to_i)
@hp=[]
n.times{@hp << gets.to_i}

def check(t)
  _t=0
  @hp.each do |e|
    res=e-@b*t
    # next if res<=0
    _t+=[0, (res+@a-@b-1)/(@a-@b)].max
  end
  _t<=t
end

l, u=0, (@hp.max+@b-1)/@b
while u-l>1
  m=(u+l)/2
  if check(m)
    u=m
  else
    l=m
  end
end

puts u


Measured memory_bytes: 2996
function Main(input) {
  // 文字列をsplitして配列に格納
  input = input.split("\n");
  tmp1 = input[0].split(" ");
  tmp2 = input[1].split(" ");

  let n = parseInt(tmp1[0], 10);
  let m = parseInt(tmp1[1], 10);
  let kadai = tmp2.map(e => parseInt(e));
  let total = kadai.reduce(function(a, x){ return a + x;});
  let days_left = n - total;

  if (days_left >= 0){
    console.log(days_left);
  } else {
    console.log(-1);
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30800
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        W:i64,
        H:i64,
        x:i64,
        y:i64
    }
    let mut ans = ((W*H) as f64)*0.5f64;
    if (x==W/2 && W%2==0) && (y==H/2 && H%2==0) {
        println!("{:.18} 1", ans);
    }else{
        println!("{:.18} 0", ans);
    }
}

Measured memory_bytes: 4352
#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;
  

  cout << N*N*N << endl;
}

Measured memory_bytes: 256