akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
class P
{
    static void Main()
    {
        int[] ab = Console.ReadLine().Split().Select(x => (int.Parse(x) + 11) % 13).ToArray();
        string res = "";
        if (ab[0] > ab[1]) res = "Alice";
        if (ab[0] < ab[1]) res = "Bob";
        if (ab[0] == ab[1]) res = "Draw";
        Console.WriteLine(res);
    } 
}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main()
{

    int h,w;
    while (true){
        cin >> h>>w;
        if(h==0&&w==0)break;
        for(int j=1;j<=h;j++){
            for (int i=1;i<=w;i++){
                if((i+j)%2==0){
                    cout <<"#";
                }
                else {
                    cout <<".";
                }

            }
            cout << endl;
        }
        cout<<endl;
    }

    return 0;
}




Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>
//#include <math.h>
#include <cmath>
 
using namespace std;

int main(void)
{
    long double a, b, c;
    int aa, bb, cc;
    scanf("%d%d%d", &aa, &bb, &cc);
    a = aa, b = bb, c = cc;
    long double eps = 1.0e-14;
    
    if (sqrt(a) + sqrt(b) + eps < sqrt(c)) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
int F[400010],N[400010],a[400010],num[200010][2];
void add(int x,int y){
	a[++k]=y;
	N[k]=F[x];
	F[x]=k;
}
char c[200010];
int q[200010],h,t;bool vis[200010];
int main(){
	n=r;m=r;scanf("%s",c+1);
	for(rt i=1;i<=m;i++){
		x=r;y=r;
		add(x,y);add(y,x);
		num[y][c[x]=='A']++;
		num[x][c[y]=='A']++;
	}
	
	for(rt i=1;i<=n;i++)if(!num[i][0]||!num[i][1])q[++t]=i,vis[i]=1;
	while(h<t){
		x=q[++h];
		for(rt i=F[x];i;i=N[i])if(!vis[a[i]]){
			if(!--num[a[i]][c[x]=='A'])vis[a[i]]=1,q[++t]=a[i];
		}
	}
	for(rt i=1;i<=n;i++)if(!vis[i])return puts("Yes"),0;
	puts("No");
	return 0;
}


Measured memory_bytes: 6784
#include<iostream>
using namespace std;
int main(){
	int N, X, L[1000];
	int count = 0;
	int D = 0;
	cin >> N >> X;
	for (int i = 0; i < N; i++){
		cin >> L[i];
	}
	for (int i = 0; i <= N; i++){
		D += L[i];
		count++;
		if (D > X)break;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
class Node():
    def __init__(self, node_id, left, right):
        self.node_id    =   node_id
        self.left       =   left
        self.right      =   right

    def pre_order_search(self):
        l = self.left
        r = self.right
        print(" " + str(self.node_id), end="")
        if l != -1:
            tree[l].pre_order_search()
        if r != -1:
            tree[r].pre_order_search()

    def in_order_search(self):
        l = self.left
        r = self.right
        if l != -1:
            tree[l].in_order_search()
        print(" " + str(self.node_id), end="")
        if r != -1:
            tree[r].in_order_search()

    def post_order_search(self):
        l = self.left
        r = self.right
        if l != -1:
            tree[l].post_order_search()
        if r != -1:
            tree[r].post_order_search()
        print(" " + str(self.node_id), end="")

n = int(input())
tree = [None for i in range(n)]
root_set = set(range(n))

for i in range(n):
    node_id, left, right = map(int, input().split())
    tree[node_id] = Node(node_id, left, right)
    root_set -= set([left, right])
root = root_set.pop()

print("Preorder")
tree[root].pre_order_search()
print()

print("Inorder")
tree[root].in_order_search()
print()

print("Postorder")
tree[root].post_order_search()
print()

Measured memory_bytes: 7824
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define MOD 1000000007//998244353

ll arr[105],dp[105][100005];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll i,j,n,k;
	cin>>n>>k;
	for(i=1;i<=n;i++) cin>>arr[i];
	dp[0][0]=1; //BASE CASE
	for(i=1;i<=k;i++) dp[0][i]=0; //BASE CASE
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++)
			dp[i-1][j]=(dp[i-1][j]+dp[i-1][j-1])%MOD;
			
		for(j=0;j<=k;j++){
			ll mn=j-arr[i]-1;
			dp[i][j]=dp[i-1][j];
			if(mn>=0) dp[i][j]=(dp[i][j]-dp[i-1][mn]+MOD)%MOD;
		}
	}
	cout<<dp[n][k]<<endl;
	return 0;
}


Measured memory_bytes: 82508
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
  cin >> n;
  vector<int> b(n-1);
  for(int i=0 ; i<n-1 ; i++){
    cin >> b[i];
  }
  vector<int> a(n);
  long long sum = 0;
  a[0] = b[0];  a[n-1] = b[n-2];
  for(int i=1 ; i<n-1 ; i++){
    a[i] = min(b[i-1], b[i]);
    sum += a[i];
  }
  sum += a[0] + a[n-1];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "bufio"
  "strings"
  "os"
  "strconv"
)

func main() {
  var N int
  fmt.Scanf("%d", &N)
  activities := make([][]int, 0)
  var scanner = bufio.NewScanner(os.Stdin)
  for scanner.Scan() {
    temp := scanner.Text()
    temps := strings.Split(temp, " ")
    day := make([]int, 4)
    m := 1
    for i, str := range temps {
      num, _ := strconv.Atoi(str)
      day[i] = num
      m = max(m, num)
    }
    day[3] = m
    activities = append(activities, day)
  }
  fmt.Println(solve(N, &activities))
}

// dp[i][j] 表示第i天选择活动j得到的 the maximum possible total points of happiness
// dp[i][j] = max_{{j=0}^2, {k=0}^2}(dp[i][j], dp[i-1][k!=j])
// dp[i][j] = max_{j=0}^2(dp[i][j], max_{{k=0}^2}(dp[i-2][k]))

func solve(n int, arr *[][]int) int {
  dp := make([][]int, n)
  for i:=range dp {
    dp[i] = make([]int, 4)
  }
  for k:=0;k<4;k++ {
    dp[0][k]=(*arr)[0][k]
  }
  if n==1 {
    return dp[0][3]
  }
  //
  m := 1
  for j:=0;j<3;j++ {
    for k:=0;k<3;k++ {
      if j==k {
        continue
      }
      dp[1][j] = max(dp[1][j], dp[0][k]+(*arr)[1][j])
    }
    m = max(m, (*arr)[1][j])
  }
  dp[1][3] = m
  //
  for i:=2;i<n;i++ {
    m = 1
    for j:=0;j<3;j++ {
      m = max(m, (*arr)[i][j])
      dp[i][j] = (*arr)[i][j] + dp[i-2][3] // dp[i] = arr[i] + max(arr[i-2])
      for k:=0;k<3;k++ {
        if j==k {
          continue
        }
        // dp[i] = arr[i] + max_{k!=j}(dp[i-1][k])
        dp[i][j] = max(dp[i][j], dp[i-1][k]+(*arr)[i][j])
      }
    }
    dp[i][3] = m
  }
  // 返回结果
  m = 1
  for _, cnt := range dp[n-1] {
    m = max(m, cnt)
  }
  return m
}

func max(a, b int) int {
  if a > b {
    return a
  }
  return b
}

Measured memory_bytes: 17792
#include<stdio.h>
#include<stdlib.h>

int get_gcd(int a, int b){
  int m,n,tmp;
  if(a<b){
    m = a;
    n = b;
  }else{
    m = b;
    n = a;
  }

  do{
    tmp = n;
    n = m % n;
    m = tmp;
  }while(n!=0);


  return m;
}

int main(){
  int n,x_start;
  int xs[100000];
  int tmp;
  int gcd;

  scanf("%d %d", &n, &x_start);

  for(int i=0;i<n;i++){
    scanf("%d", &tmp);
    tmp -= x_start;
    xs[i] = tmp;
  }

  gcd = abs(xs[0]);

  for(int i=0;i<n;i++){
    gcd = get_gcd(gcd, abs(xs[i]));

  }

  printf("%d\n", gcd);

  return 0;
}

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

typedef long long ll;

ll dp[51][51][2501];
ll N, A, x[51];


void solve() {
    dp[0][0][0] = 1;
    
    for (ll i = 1; i <= N; i++) {
        for (ll j = 0; j <= N; j++) {
            for (ll k = 0; k <= 2500; k++) {
                //not select
                dp[i][j][k] = dp[i-1][j][k];
                if (j > 0 && k >= x[i])
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - x[i]];
            }
        }
    }
    
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
            ans += dp[N][i][i*A];
    }
    
    cout << ans << endl;
}

int main() {
    
    cin >> N >> A;
    for (ll i = 1; i <= N; i++)
        cin >> x[i];
    
    
    solve();
    
    
    
    return 0;
}



Measured memory_bytes: 50048
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }

}

use std::cmp::{max, min};

fn main() {
    let s: String = read();
    let s_char: Vec<char> = s.chars().collect();

    let mut ans = true;
    for (i, v) in s_char.iter().enumerate() {
        let oddOrEven = i + 1;
        let v = *v;
        if oddOrEven % 2 == 0 {
            if v == 'R' {
                ans = false
            }
        }

        if oddOrEven % 2 == 1 {
            if v == 'L' {
                ans = false
            }
        }
    }

    if ans {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =1e6+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int n,a[MAXN];
//unordered_map<int,int>mp;
//int need[MAXN];
//map<int,int>mp;
//TLE了 可能思路：每个数*一个数的形式 判断所得的num 然后与n比较 
//这道题注意点：O() 在数据范围小的情况下 尽量开普通数组 然后 是unordered_map（查找快，无序） 最后是map
//自己老是习惯开map 然后tle 不知所措 
int main()
{
	int ans=0;
	for(int i=1;i<=5;i++) 
	{
	    scanf("%d",&a[i]);
	    if(!a[i]) ans=i;
	} 
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 3724
#include <stdio.h>

int main(void)
{
	char moji;
	
	while(1)
	{
		scanf("%c", &moji);
		
		if(moji >= 65 && moji <= 90)
		{
			printf("%c", moji+32);
		}
		else if(moji >= 97 && moji <= 122)
		{
			printf("%c", moji-32);
		}
		else printf("%c", moji);
		
		if(moji == '\n') break;
	}
	
	return 0;
}

Measured memory_bytes: 524
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;




int main()
{
  int a,b,c,s; //かっている数//最大100
  vector<int> num(3);
  cin >> num[0] >> num[1] >> num[2] ;


  sort(num.begin(),num.end(),[](const int a,const int b){
    return a>b;
  });

  cout << num[0]*10+num[1] + num[2];
  return 0;
}



























Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define lli long long int
#include<vector>
#include<algorithm>
#define maxi 1000000007
#include<bits/stdc++.h>
int main(){
  int i,n,sum,tot=0;
  cin>>n;
  int a[n];
  for(i=1;i<=n;i++){
    cin>>a[i-1];
    tot=tot+a[i-1];
  }
  i=1;
  sum=0;
  int mini=maxi;
  while(i<n){
    sum=sum+a[i-1];
    //cout<<sum<<" ";
    int k=tot-sum;
    //cout<<k<<" "<<"\n";
    mini=min(mini,abs(k-sum));
    i++;
  }
  cout<<mini;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N=0;
    string S;
    cin>>S;
    ll L=S.size();
    rep(i,L){
        ll K=S.at(i)-'0';
        N+=K;
    }
    if(N%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3752
import math
a,b=map(int,input().split())
ans=[1]
c=math.gcd(a,b)
for i in range(2,int(c**(1/2))+1):
  if c%i==0:
    while c%i==0:
      c//=i
    ans.append(i)
if c!=1:
  ans.append(c)
print(len(ans))

Measured memory_bytes: 9444
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){

  int n,cnt,in,out,mx;

  cin >> n >> cnt;
  mx=cnt;
  while(n--){
    cin >> in >> out;
    cnt+=in-out;
    mx=max(mx,cnt);

    if(cnt<0){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << mx << endl;

  return 0;
}

Measured memory_bytes: 1160
N, M = map(int, input().split())
S = [input().split() for i in range(N)]
T = [input().split() for j in range(M)]

L = 0
t = 0

for k in range(N):
    L = 1000000000000
    for l in range(M):
        if L > abs(int(S[k][0]) - int(T[l][0])) + abs(int(S[k][1]) - int(T[l][1])):
            L = abs(int(S[k][0]) - int(T[l][0])) + abs(int(S[k][1]) - int(T[l][1]))
            t = l+1
    print(t)



Measured memory_bytes: 3064
let N = Int(readLine()!)!

var edges = Array(repeating: [Int](), count: N)
for _ in stride(from: 0, to: N - 1, by: 1) {
    let input = readLine()!.split(separator: " ").map{ Int($0)! }
    edges[input[0] - 1].append(input[1] - 1)
    edges[input[1] - 1].append(input[0] - 1)
}

var dp = Array(repeating: [true: Optional<Int>.none, false: Optional<Int>.none], count: N)

let divider = 1_000_000_007

func getNumberOfCombinations(_ rootNode: Int, _ previousNode: Int?,  _ canBeColoredBlack: Bool) -> Int {
    guard dp[rootNode][canBeColoredBlack]! == nil else {
        return dp[rootNode][canBeColoredBlack]!!
    }

    var numberOfCombinationsWhenBlack = canBeColoredBlack ? 1 : 0
    var numberOfCombinationsWhenWhite = 1

    for i in stride(from: 0, to: edges[rootNode].count, by: 1) {
        let nextNode = edges[rootNode][i]
        guard nextNode != previousNode else { continue }

        numberOfCombinationsWhenBlack = numberOfCombinationsWhenBlack * getNumberOfCombinations(nextNode, rootNode, false) % divider
        numberOfCombinationsWhenWhite = numberOfCombinationsWhenWhite * getNumberOfCombinations(nextNode, rootNode, true) % divider
    }

    dp[rootNode][canBeColoredBlack] = (numberOfCombinationsWhenBlack + numberOfCombinationsWhenWhite) % divider
    return dp[rootNode][canBeColoredBlack]!!
}

print(getNumberOfCombinations(0, nil, true))


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string s;
    cin >> s;
    ll N = s.size();
    /*
    vector<ll> lan;
    REP(i, s.size()){
    	int j = i;
    	while(j<s.size() && s[j] == s[i])j++;
    	lan.push_back(j-i);
    	i = j-1;
    }
    cout << lan << endl;
    */

    int i = 0;
    int res = 0;
    int prev;
    while(i<N){
    	if(i==0){
    		prev = 1;
    		i++;
    		res++;
    	}else if(prev == 2){
    		prev = 1;
    		i++;
    		res++;
    	}else{
    		if(s[i] == s[i-1]){
    			prev = 2;
    			if(i==N-1){
    				i += 1;
    			} 
    			else{
    				i += 2;
    				res++;
    			}
    		}else{
    			prev = 1;
    			i++;
    			res++;
    		}
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> p(N);
  REP(i, N)
  cin >> p[i];
  int sum = 0;
  int mx = 0;
  REP(i, N)
  {
    sum += p[i];
    mx = max(mx, p[i]);
  }
  cout << sum - mx / 2 << endl;
  return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

ll EvaluateFunction(vll& C,vvll& S,vll &H,ll K,ll maxD){
	vll L(26,0);
	ll D=H.size();
	ll B=0;
	REP(i,D){
		ll d=i+1;
		L[H[i]] = d;
		ll maxB=-(1ll<<60),index=-1;

		B += S[i][H[i]];
		REP(j,26){
			B -= C[j]*(d-L[j]);
		}
	}
	FOR(i,D,min(D+K,maxD)){
		ll d=i+1;
		REP(j,26){
			B -= C[j]*(d-L[j]);
		}
	}
	return B;
}

ll ScoreFunction(vll& C,vvll& S,vll &H){
	vll L(26,0);
	ll D=H.size();
	ll B=0;
	REP(i,D){
		ll d=i+1;
		L[H[i]] = d;
		ll maxB=-(1ll<<60),index=-1;

		B += S[i][H[i]];
		REP(j,26){
			B -= C[j]*(d-L[j]);
		}
	}
	return B;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto D=in();
	auto C=vecin(26);
	vvll S(D,vll(26));
	REP(i,D){
		REP(j,26) S[i][j]=in();
	}

	vll AH;
	ll maxA=-(1ll<<60),indexA=-1;
	REP(k,30){
		vll H;
		REP(i,D){
			ll d=i+1;
			ll maxB=-(1ll<<60),index=-1;
			REP(t,26){
				H.push_back(t);
				auto B = EvaluateFunction(C,S,H,k,D);
				if(B>maxB){
					maxB = B;
					index=t;
				}
				H.pop_back();
			}
			H.push_back(index);
		}
		auto A=ScoreFunction(C,S,H);
		if(maxA<A){
			AH = H;
			maxA = A;
		}
	}

	for(auto& x:AH) out(x+1);
	return 0;
}


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////


string s;
ll n;

bool che(ll m,ll l,ll r){
    rep(i,0,n-1){
        if(s[i]=='0'){
            l--;r--;
            if(l<0)l+=2;
        }else if(s[i]=='1'){
            l++;r++;
            if(r>m)r-=2;
        }else{
            if(l>0)l--;
            else l++;
            if(r<m)r++;
            else r--;
        }
        if(l>r)return false;
    }
    return true;
}
bool check(ll m){
    if(che(m,0,m/2*2))return true;
    if(che(m,1,(m-1)/2*2+1))return true;
    return false;
}


int main(){fastio
    cin>>s;
    n=s.size();
    ll ok=n,ng=0;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(check(mid))ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    
    return 0;
}


Measured memory_bytes: 4184
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(N);
    out(800 * N - 200 * (N / 15));
}


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

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

    int N = S.length();

    vector<int> dream(N, 0);
    for (int i = 0; i < N - 5; i++) {
        string tmp = S.substr(i, 6);
        if (tmp == "eraser") {
            for (int j = 0; j < 6; j++) {
                dream[i + j] = 1;
            }
        }
    }

    for (int i = 0; i < N - 4; i++) {
        string tmp = S.substr(i, 5);
        if (tmp == "erase") {
            bool match = false;
            for (int j = 0; j < 5; j++) {
                if (dream[i + j] == 1) {
                    match = true;
                }
            }
            if (!match) {
                for (int j = 0; j < 5; j++) {
                    dream[i + j] = 1;
                }
            }
        }
    }

    for (int i = 0; i < N - 6; i++) {
        string tmp = S.substr(i, 7);
        if (tmp == "dreamer") {
            bool match = false;
            for (int j = 0; j < 7; j++) {
                if (dream[i + j] == 1) {
                    match = true;
                }
            }
            if (!match) {
                for (int j = 0; j < 7; j++) {
                    dream[i + j] = 1;
                }
            }
        }
    }

    for (int i = 0; i < N - 4; i++) {
        string tmp = S.substr(i, 5);
        if (tmp == "dream") {
            bool match = false;
            for (int j = 0; j < 5; j++) {
                if (dream[i + j] == 1) {
                    match = true;
                }
            }
            if (!match) {
                for (int j = 0; j < 5; j++) {
                    dream[i + j] = 1;
                }
            }
        }
    }

    bool yes = true;
    for (int i = 0; i < N; i++) {
        if (dream[i] == 0) {
            yes = false;
        }
    }
    if (yes) {
        cout << "YES" << endl;

    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3824
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextIntArray(N);

        System.out.println( solve() );
    }

    static int solve() {
        Arrays.sort(A);

        int dame = 0;
        long sum = 0;
        for (int i = 0; i < N-1; i++) {
            if( (sum + A[i]) * 2 < A[i+1] ) {
                // index以下がダメ
                dame = i+1;
            }

            sum += A[i];
        }

        return N - dame;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  vector<int> a;
  vector<int> b;
  vector<int> c;
  for (int i=0; i<n; i++) {
    int tmp;
    cin>>tmp;
    if (tmp % 4 == 0) {
      a.push_back(tmp);
    } else if (tmp % 2 == 1) {
      b.push_back(tmp);
    } else {
      c.push_back(tmp);
    }
  }
  if (b.size() <= a.size()) {
    cout<<"Yes"<<endl;
  } else if (c.size() == 0 && b.size() - 1 == a.size()) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 0;

ll n, m, k;
string s[10], temp[10];

void red(ll x, ll bl){
	if(bl == 0){
		for(ll i = 0; i < m; i++){
			s[x][i] = 'R';
		}
	}
	else{
		for(ll i = 0; i < n; i++){
			s[i][x] = 'R';
		}
	}
}

ll hitung(){
	ll cnt = 0;
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < m; j++){
			if(s[i][j] == '#'){
				cnt++;
			}
		}
	}
	return cnt;	
}

void sama(){
	for(ll i = 0; i < n; i++){
		s[i] = temp[i];
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> m >> k;
	for(ll i = 0; i < n; i++){
		cin >> s[i];
		temp[i] = s[i];
	}
	ll ans = 0;
	ll sum = n + m;
	for(ll i = 0; i < (1 << sum); i++){
		for(ll j = 0; j < n; j++){
			if((1 << j) & i){
				red(j, 0);
			}
		}
		for(ll j = n; j < n + m; j++){
			if((1 << j) & i){
				red(j - n, 1);
			}
		}
		if(hitung() == k){
			ans++;
		}
		sama();
	}
	cout << ans << '\n';
}



Measured memory_bytes: 3656
# -*- coding:utf-8 -*-
K,N = map(int,input().split())
A = list(map(int,input().split()))

li = []
for i in range(N-1):
    li.append(A[i+1]-A[i])

li.append(abs(A[0] + (K - A[-1])))

print(sum(li) - max(li))

Measured memory_bytes: 32172
#include <iostream>

int C[3][3];
int main() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> C[i][j];
        }
    }
    int col_sum[3] = {};
    int row_sum[3] = {};
    for (int j = 0; j < 3; j++) {
        for (int i = 0; i < 3; i++) {
            col_sum[j] += C[i][j];
        }
    }
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            row_sum[i] += C[i][j];
        }
    }
    int a[3];
    int b[3];
    int adiff[2];
    int bdiff[2];
    for (int i = 1; i < 3; i++) {
        adiff[i - 1] = row_sum[i] - row_sum[0];
        bdiff[i - 1] = col_sum[i] - col_sum[0];
    }

    for (int i = 0; i < 2; i++) {
        if (adiff[i] % 3 || bdiff[i] % 3) {
            std::cout << "No" << std::endl;
            return 0;
        }else{
            adiff[i] /= 3;
            bdiff[i] /= 3;
        }
    }

    for(int i = 0; i < 3; i++) {
        if ((row_sum[i] - bdiff[0] - bdiff[1]) % 3) {
            std::cout << "No" << std::endl;
            return 0;
        };
        a[i] = (row_sum[i] - bdiff[0] - bdiff[1]) / 3;
    }
    for(int i = 0; i < 3; i++) {
        if ((col_sum[i] - adiff[0] - adiff[1]) % 3) {
            std::cout << "No" << std::endl;
            return 0;
        };
        b[i] = (col_sum[i] - adiff[0] - adiff[1]) / 3;
    }
    std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <iomanip>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int a;
	cin >> a;
	if (a == 25) { cout << "Christmas" << endl; }
	else if (a == 24) { cout << "Christmas Eve" << endl; }
	else if (a == 23) { cout << "Christmas Eve Eve" << endl; }
	else { cout << "Christmas Eve Eve Eve" << endl; }
}


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

using namespace std;

int main() {
	string str;
	cin >> str;
	int len = str.length();
	char* s = new char[len + 1];
	memcpy(s, str.c_str(), len + 1);
	
	for (int i = 0; i < len; i++) {
		if (s[i] == 'B') {
			if (i >= 1) {
				for (int j = i - 1; j < len - -2; j++) {
					s[j] = s[j + 2];
				}
				len -= 2;
				i = -1;
			}
			if (i == 0) {
				for (int j = i; j < len - 1; j++) {
					s[j] = s[j + 1];
				}
				len -= 1;
				i = -1;
			}
		}
	}
	for (int i = 0; i < len; i++) {
		cout << *(s + i);
	}
	cout << endl;
	return 0;
}

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

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 200000
int N,A[MAXN+5],B[MAXN+5];

int main(){
    //freopen("hopeless.in" ,"r", stdin);
    //freopen("hopeless.out","w",stdout);
    priority_queue<pair<int,int>,vector<pair<int,int> >,less<pair<int,int> > > Q;
    N=read();
    for(int i=1;i<=N;i++)
        A[i]=read();
    for(int i=1;i<=N;i++)
        Q.push(make_pair(B[i]=read(),i));
    long long Ans=0;
    while(!Q.empty()){
        int i=Q.top().second;Q.pop();
        int j=(i-2+N)%N+1,k=i%N+1;
        int Sum=B[j]+B[k],Min=max(max(B[j],B[k]),A[i]);
        int x=(B[i]-Min+Sum-1)/Sum;
        Ans+=x;
        B[i]-=Sum*x;
        if(B[i]<A[i])
            return puts("-1"),0;
        if(B[i]>A[i])
            Q.push(make_pair(B[i],i));
    }
    for(int i=1;i<=N;i++)
        if(A[i]!=B[i])
            return puts("-1"),0;
    printf("%lld",Ans);
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n, tmp;
  cin >> n;
  vector<pair<int,int>> v(n);
  for(int i= 0; i < n; i++){
    cin >> v[i].first;
    v[i].second = i +1;
  }
  sort(v.begin(), v.end());
  for(auto &p: v){
    cout << p.second << endl;
  }
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int n,m;
	int k,t;
	int cnt[30],ans = 0;
	for (int i = 0; i < 30; ++i)
	{
		cnt[i] = 0;
	}


	scanf("%d %d",&n,&m);
	for (int i = 1; i <= n; ++i){
		scanf(" %d",&k);
		for (int j = 1; j <= k; ++j){
			scanf(" %d",&t);
			++cnt[t - 1];
		}
	}
	for (int i = 0; i < m; ++i)
	{
		if(cnt[i] == n)	++ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    bool f = true;
    if (w >= v) {
        f = false;
    } else {
        if (abs(b - a) > t * (v - w)) {
            f = false;
        }
    }
    cout << (f ? "YES" : "NO") << newl;
}

Measured memory_bytes: 3692
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var n, m int
var sc = bufio.NewScanner(os.Stdin)

func read() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Heap []int

func (h Heap) Len() int           { return len(h) }
func (h Heap) Less(i, j int) bool { return h[i] > h[j] }
func (h Heap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *Heap) Push(x interface{}) {
	*h = append(*h, x.(int))
}
func (h *Heap) Pop() interface{}{
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0:n-1]
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	fmt.Scan(&n, &m)
	as := make(Heap, n)
	heap.Init(&as)

	for i := 0; i < n; i++ {
		heap.Push(&as, read())
	}
	
	for j:=0; j<m; j++ {
		m := heap.Pop(&as)
		heap.Push(&as, m.(int)/2)
	}
	ans := 0
	for _, a := range as {
		ans +=a
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8320
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
typedef long long int lli;
int main() {
  int n,d;
  scanf("%d %d", &n, &d);
  int count=0;
  while(n--){
      lli a,b;
      double dis;
      scanf("%lld %lld", &a, &b);
      dis = (sqrt((a*a) + (b*b)));
      if(dis<=d){
          count++;
      }
  }

  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2152
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define int long long
#define pii pair<int,int>
#define pqi priority_queue<int>
#define pb push_back()
#define INF 1000000000000000000
#define pi acos(-1)
#define deb(x) cout<<#x" = "<<x<<" "
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
const int modu=1e9+7;
 
int bigmod(int n,int p){
    if(p==0) return 1;
    int x=bigmod(n,p/2)%modu;
    x=(x*x)%modu;
    if(p%2) return (x*n)%modu;
    return x;
}
 
int modInverse(int a){
    return bigmod(a,modu-2)%modu;
}
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
}
 
void defInit(){
    faster();
    #ifdef OFFLINE
      auto dummy_in=freopen("in.txt", "r", stdin);
      auto dummy_out=freopen("out.txt", "w", stdout);
      if(0) dummy_in=dummy_out;
      else dummy_out=dummy_in;
    #endif
}

int add(int x,int y){
    int z =(x%modu + y%modu)%modu;
    while(z<0) z=(z+modu)%modu;
    return z;
}
 
int mul(int x,int y){
    int z = (x%modu * y%modu)%modu;
    while(z<0) z=(z+modu)%modu;
    return z;
}
// starts here

int32_t main(){
    faster();
    //Now I will start writing codes and start preparation to get errors
 	int n;
    cin>>n;
    int sum=0;
    int ara[n];
    for(int i=0;i<n;i++){
        cin>>ara[i];
        sum+=ara[i];
    }
    int avg=sum/n;
    int avg2=(sum+n-1)/n;
    int ans1=0,ans2=0;
    for(int i=0;i<n;i++){
        ans1+=(ara[i]-avg)*(ara[i]-avg);
        ans2+=(ara[i]-avg2)*(ara[i]-avg2);
    }
    cout<<min(ans1,ans2);
    return 0;

}

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

import math

li = []
for i in range(5):
    li.append(int(input()))

s = 0
for f in li:
    s += (f//10)*10 + 10*(int(bool(f%10)))

li2 = []
for f in li:
    if f%10 != 0:
        li2.append(f%10)
if len(li2) == 0:
    li2.append(10)
print(s + min(li2) - 10)

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a,b,c,k;
    cin >> a>>b>>c;
    cin >>k;
    std::cout << pow(2,k)*max({a,b,c})+a+b+c-max({a,b,c}) << std::endl;
}


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

main(){
  int i,j,n;
  double X=1,Y=0,ans;
  cin >> n;
  double a[n];
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<n;i++) X *= a[i];
  for(i=0;i<n;i++) Y += X/a[i];
  
  ans=X/Y;
  printf("%.10lf",ans);
  
}
      
        
    
  
  

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

int main()
{
	int N;
	cin >> N;
	
	int a[N+1];
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	int i = 1;
	int count = 0;
	bool stop = false;

	while (true) {
	
		if (i == 2) {
			stop = true;
			break;
		}

		if (count == N -1 ) {
			break;
		}

		i = a[i];
		count++;			
		
	}
	
	if (!stop) { count = -1; }

	cout << count << endl;
		
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

vector<LL> a, f;
int n; LL k;

bool F(LL x){
    if(x < 0) return false;
    if(x == 0){
        return accumulate(all(a), 0LL)<=k;
    }
    LL c = 0;
    rep(i, n){
        c += max(a[i] - x/f[i], 0LL);
    }
    // cout << x << " " << c << endl;
    return c<=k;
}

LL binary_search(LL ok, LL ng){
    while (abs(ok - ng) > 1) {
        LL mid = (ok + ng) / 2;
        if(F(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    fastcin();

    cin >> n >> k;
    a.assign(n, 0);
    f.assign(n, 0);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(all(f));
    sort(all(a));
    // reverse(all(f));
    reverse(all(a));
    // repe(i, f) cout << i << " "; cout << endl;
    // repe(i, a) cout << i << " "; cout << endl;

    cout << binary_search(1e18, -1) << endl;

}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, x;
	vector<llong> a;

	cin >> N >> x;
	a.resize(N);
	for(int i = 0; i < N; i++)
		cin >> a[i];

	vector<llong> mini(N,inf);
	llong ans = inf;
	for(int i = 0; i <= N; i++){
		llong res = 0;
		for(int j = 0; j < N; j++){
			mini[j] = min(mini[j], a[(j-i+N)%N]);
			res += mini[j];
		}
		ans = min(ans, res + x*i);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
def main():
    import sys
    input=sys.stdin.readline
    import numpy as np

    n,k=map(int,input().split())
    A=np.array(input().split(),dtype=np.int64)
    F=np.array(input().split(),dtype=np.int64)
    A.sort()
    F.sort()
    F=F[::-1]

    def ok(x): #チームの成績をxとするような修行の仕方が存在するか
        cnt=np.maximum(0,A-x//F).sum()
        return cnt<=k
    
    l=-1
    r=10**12+1
    while r-l>1:
        mid=(r+l)//2
        if ok(mid):
            r=mid
        else:
            l=mid
    print(r)   

if __name__=='__main__':
    main()



Measured memory_bytes: 37144
a, b, c, d = [0] * 4

def format_input(filename = None):
	global a, b, c, d
	if filename == None:
		a, b, c, d = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		a = rng(1, 10**1)
		b = rng(1, 10**1)
		c = rng(1, 10**1)
		d = rng(1, 10**1)
		print(a, b, c, d)

def get_answer():
	t_attack = (c - 1) // b
	a_attack = (a - 1) // d

	if t_attack <= a_attack:
		answer = 'Yes'
	else:
		answer = 'No'
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 9212
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
static const ll max_n = 200010;
static const ll mod = 2019;
// static const ll max_dist = 10000000;
// vector<vector<ll>> distance_table(max_n, vector<ll>(max_n, max_dist));
// vector<ll> distance_list(max_n);
// vector<ll> combination_table(max_n, 0);
// vector<ll> value_num(max_n, 0);
// vector<ll> combination_minus1_table(max_n, 0);
// vector<ll> balls(max_n);
vector<ll> res(max_n);
vector<ll> residual_10(224, 1);
// vector<vector<ll>> res_reverse(mod);
vector<ll> res_backet(mod, 0);
// vector<ll> res_reverse(max_n);

ll N, K;


int main(){
    // int u, v;
    // bool updated = alse;
    string S;
    cin >> S;
    ll N = (ll)S.size();
    for(ll i=1;i<residual_10.size();i++){
        residual_10[i] = (residual_10[i-1] * 10)% mod;
    }
    
    res[N-1] = (ll)(S[N-1] - '0');
    res_backet[res[N-1]] ++;
    for(ll i=N-2;i>=0;i--){
        ll v = (ll)(S[i] - '0');
        v = (res[i+1] + v*residual_10[(N-i-1) % (ll)residual_10.size()]) % mod;
        res[i] = v;
        // printf("res [%lld] = %lld\n", i, res[i]);
        res_backet[v]++;
    }

    ll ans = res_backet[0];
    for(ll i=0;i<mod;i++){
        ans += res_backet[i] * (res_backet[i] - 1) / 2;
    }

    printf("%lld\n", ans);

    return 0;

}

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

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    vector<long> ans;
    vector<long> h(N);
    for(int i=0;i<N;i++){
        cin >> h.at(i);
    }
    sort(h.begin(),h.end());

    vector<long> L;
    for(int i=0;i<N-K+1;i++){
        L.push_back(h.at(i+K-1)-h.at(i));
    }
    
     cout << *min_element(L.begin(),L.end()) << endl;

}


Measured memory_bytes: 2168
// inputに入力データ全体が入る
function Main(input) {

  var inp = input.split('\n');
  var A = parseInt(inp[0]);
  var B = parseInt(inp[1]);
  var C = parseInt(inp[2]);
  var X = parseInt(inp[3]);

  var maxCnt = parseInt(X / (500 * A));
  var cnt = 0;

  for (var i = 0; i <= A; i++) {
    for (var j = 0; j <= B; j++) {
      for (var k = 0; k <= C; k++) {
        var tmp = X - 500 * i - 100 * j - 50 * k;
        if (tmp === 0) {
          cnt++;
        }
      }
    }

  }

  console.log('%d', cnt);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

    int a, b;
    cin >> a >> b;

    int fail = -1;
    if(a < 10 && b < 10)
        cout << (a*b);
    else
        cout << fail;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

double diff(double a, double b)
{
  return (a > b) ? a - b : b - a;
}

int main(void)
{
  int n;
  int t, a;
  int h[1000];

  scanf("%d", &n);
  scanf("%d %d", &t, &a);
  for (int i = 0; i < n; i++)
    scanf("%d", &h[i]);

  double min = diff((double)a, t - h[0] * 0.006);
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (diff((double)a, t - h[i] * 0.006) < min) {
      min = diff((double)a, t - h[i] * 0.006);
      ans = i + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
  
}


Measured memory_bytes: 128