akhauriyash/Code-Regression huggingface dataset:
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::{max, min};
use std::collections::HashMap;
fn main() {
    input! {
        n:usize,
        an:[usize;n],
    }
    let ans: usize = an
        .iter()
        .filter(|&x| x % 2 == 0)
        .map(|&x| calc(x))
        .fold(0, |y, x| y + x);
    println!("{:?}", ans);
}
fn calc(x: usize) -> usize {
    let mut s = x.clone();
    let mut cnt = 0;
    while s % 2 == 0 {
        s /= 2;
        cnt += 1;
    }
    cnt
}

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

///0:left man
///1:right man
int dp[1000][1000][2];
int dp2[2000];
int N;
int c[1000],w[1000];
int main(){
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d%d",&c[i],&w[i]);
        dp[i][i][0]=dp[i][i][1]=w[i];
    }

    for(int i=2;i<=N;i++){
        for(int j=0;j+i-1<N;j++){
            if((dp[j+1][j+i-1][0]||dp[j+1][j+i-1][1])&&c[j]>=max(dp[j+1][j+i-1][0],dp[j+1][j+i-1][1])){
                dp[j][j+i-1][0]=max(dp[j+1][j+i-1][0],dp[j+1][j+i-1][1])+w[j];
            }
            if((dp[j][j+i-2][0]||dp[j][j+i-2][1])&&c[j+i-1]>=max(dp[j][j+i-2][0],dp[j][j+i-2][1])){
                dp[j][j+i-1][1]=max(dp[j][j+i-2][0],dp[j][j+i-2][1])+w[j+i-1];

            }
        }
    }

    for(int i=0;i<=N;i++)dp2[i]=i;

    for(int i=0;i<N;i++){
        for(int j=i+1;j<=N;j++){
            if(dp[i][j-1][0]||dp[i][j-1][1]){
                dp2[j]=min(dp2[j],dp2[i]+1);
            }
        }
    }

    /*
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            cout<<i+1<<" "<<j+1<<" "<<max(dp[i][j][0],dp[i][j][1])<<endl;
        }
    }
    */
    //for(int i=0;i<=N;i++)cout<<"dp2 "<<dp2[i]<<endl;

    cout<<dp2[N]<<endl;
    return 0;
}

Measured memory_bytes: 7604
fun main() {
    // 文字列
    val str = readLine()!!
    // 数値
//    val int =readLine()!!.toInt()
    // 行
    val list = readLine()!!.split(" ").map (String::toInt )
//    val (a,b) = readLine()!!.split(" ").map(String::toInt)

    var sum=0
    var ii=1
    for (i in list){
        if (i==0) continue

        if (ii%2==1){
            if (i%2==1){
                sum++
            }
        }
        ii++
    }

    print(sum)
}

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

class Bmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var V = Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray();
        var C = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray(); ;
        var ans = long.MinValue;
        var count = Math.Pow(2, N);
        for (int i=0;i<count;i++)
        {
            var bitArray = new bool[N];
            for (int j=0;j<N;++j) bitArray[j] = (1 & i >> j) == 1;
            var X = 0L;
            var Y = 0L;
            for (int j=0;j<N;++j)
            {
                if (bitArray[j])
                {
                    X += V[j];
                    Y += C[j];
                }
            }
            var sa = X - Y;
            if (ans < sa) ans = sa;
        }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 15388
# DISCO 2020
# 方針：全体の長さn、累積和を取りつつnとの差分も取る
# 正と負の最小の絶対値の小さいほうが答え
n = gets.to_i
a = gets.split.map &:to_i
cs = Array.new(n+1,0)

n.times do |i|
  cs[i+1] = cs[i] + a[i]
end
sum = cs[n]

diff = Array.new(n-1,0)
(n-1).times do |i|
  diff[i] = sum - cs[i+1] * 2
end

b = diff.select{|v|v >= 0}.min
c = diff.select{|v|v < 0}.map{|v|v.abs}.min
ans = [b,c].compact.min

puts ans


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

int N, K;

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

    long long ans = 0;
    ans = K * pow(K - 1, N - 1);

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

  ll N, Z, W;
  cin >> N >> Z >> W;
  vector<ll> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  if(N == 1){
    cout << abs(a[0] - W) << endl;
  }else{
    cout << max(abs(a[N-1]-W), abs(a[N-1]-a[N-2])) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [[(0, 0)] * (1<<N) for _ in range(N+1)]
A[0] = [(int(a), 0) for a in input().split()]
combine = lambda a, b: a if a[1] >= b[0] else b if b[1] >= a[0] else (a[0], b[0]) if a[0] > b[0] else (b[0], a[0])

for i in range(1, N+1):
    ii = 1 << i - 1
    for j in range(1<<N):
        if j & ii:
            A[i][j] = combine(A[i-1][j], A[i-1][j^ii])
        else:
            A[i][j] = A[i-1][j]

ANS = [0] * (1<<N)
for i in range(1, 1<<N):
    ANS[i] = max(ANS[i-1], sum(A[-1][i]))

print("\n".join(map(str, ANS[1:])))

Measured memory_bytes: 177964
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#ifdef DEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dreplace(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dreplace(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}

typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
template<typename T> using V = vector<T>;
constexpr LL LINF=334ll<<53; constexpr int INF=15<<26; constexpr LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    LL n,a,b;
    cin >> n >> a >>b;
    vector<LL> s(n+2);
    for(int i=1; i<=n; ++i){
        cin >> s[i];
    }
    s[0]=-1e18-10;
    s[n+1]=LINF;
    vector<vector<LL>> dp (n+1,vector<LL>(4));
    dp[1][1]=1;dp[1][2]=1;
    queue<pair<LL,LL>> xx,yy;
    xx.push(make_pair(s[0],1ll)),yy.push(make_pair(s[0],1ll));
    for(int i=2; i<=n; ++i){
        LL dif=s[i]-s[i-1];
        DBG(i,dif)
        while(true){
            if(xx.empty())break;
            if(s[i]-xx.front().first<b)break;
            LL q=xx.front().second;
            DBG(1,xx.front().first,q)
            xx.pop();
            dp[i-1][1]=(dp[i-1][1]-q+MOD)%MOD;
            dp[i-1][0]=(dp[i-1][0]+q)%MOD;
        }
        while(true){
            if(yy.empty())break;
            if(s[i]-yy.front().first<a)break;
            LL q=yy.front().second;
            DBG(2,yy.front().first,q)
            yy.pop();
            dp[i-1][2]=(dp[i-1][2]-q+MOD)%MOD;
            dp[i-1][3]=(dp[i-1][3]+q)%MOD;
        }

        DBG(i,dp[i-1][0],dp[i-1][1],dp[i-1][2],dp[i-1][3])
        if(dif>=a){
            dp[i][0]=dp[i-1][0];
            dp[i][1]=dp[i-1][1];
        }else{
            while(!xx.empty())xx.pop();
        }
        if(dif >= b){
            dp[i][3]=dp[i-1][3];
            dp[i][2]=dp[i-1][2];
        }else{
            while(!yy.empty())yy.pop();
        }
        dp[i][1]=(dp[i][1]+dp[i-1][3])%MOD;
        dp[i][2]=(dp[i][2]+dp[i-1][0])%MOD;
        xx.push({s[i-1],dp[i-1][3]});
        yy.push({s[i-1],dp[i-1][0]});

        DBG(i,dp[i][0],dp[i][1],dp[i][2],dp[i][3])
    }
    cout << (dp[n][0]+dp[n][1]+dp[n][2]+dp[n][3])%MOD <<"\n";


    return 0;
}



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

int main(void){
    int n,m;
    cin >> n >> m;
    int food[m] = {};

    // for(int i=0;i<m;i++){
    //     cout << food[i] << ' ';
    // }
    // cout << endl;

    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int num;
            cin >> num;
            food[num-1]++;
        }
    }
    int cnt = 0;
    for(int i=0;i<m;i++){
        if(food[i]==n){
            cnt++;
        }
    }

    // for(int i=0;i<m;i++){
    //     cout << food[i] << ' ';
    // }
    // cout << endl;

    cout << cnt << endl;
    return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll n;
    cin >> n;
    if (n%2==1) cout << 0 << endl;
    else {
        ll ans = n / 10, r = 50;
        while (r <= n) {
            ans += n / r;
            r *= 5;
        }
       ans += n / r;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,m;
  cin>>n>>m;
  ll i;
  vector<pair<ll,ll>> vp;
  for(i=0;i<n;i++)
  {
    ll a,b;
    cin>>a>>b;
    vp.push_back({a,b});
  }
  ll ans =0;
 sort(vp.begin(), vp.end());
  auto it = vp.begin();
 priority_queue<ll> pq;
 for(i=1;i<=m;i++)
 {
  while( it!=vp.end() and (it->first)<=i)
  {
//  cout<<"PUSHED "<<it->second<<"\n";
    pq.push(it->second);
    it++;
  }
   if(!pq.empty())
   {
     ans+=pq.top();
    //  cout<<"ADDED "<<pq.top()<<"\n";
     pq.pop();
   }
 }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
    cout << "Yes"<< endl;
    }
    else{cout << "No" << endl;}
}


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

int main(){

	int a = 1;
	int b = 1;
	int r = 0;

	for(a=1;a<=9;a++){
		for(b=1;b<=9;b++){
			r = a*b;
			cout << a;
			cout << "x";
			cout << b;
			cout << "=";
			cout << r << endl;
		}
		b = 1;
	}

    return 0;
}

Measured memory_bytes: 1116
import math
n=input()
N=n
a=[]

x=2
while x*x<=N:
	while n%x==0:
		a.append(str(x))
		n=n/x
	if n==1: break
	x+=1
else:
	a.append(str(n))


print str(N)+": "+" ".join(a)



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

using namespace std;


int main(){
    int N;
    int ans = 0;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j < i; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

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

int main()
{
    double x1, y1, x2, y2,distance;
    cin >> x1 >> y1 >> x2 >>y2;
    distance = pow(pow((x1 - x2), 2) + pow((y1 - y2), 2), 1. / 2);
    cout << fixed << setprecision(5) << distance << endl;
    return 0;
}



Measured memory_bytes: 3424
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long LL;

constexpr long long INFLL = 1e18;

using namespace std;

int main()
{
    int n;
    int k;
    cin >> n >> k;
    vector<int> a(n + 2);
    for (int i = 1; i <= n; i++)
    {
        cin >> a.at(i);
    }

    for (int l = 0; l < k; l++)
    {
        vector<int> temp(n + 2, 0);
        for (int i = 1; i <= n; i++)
        {
            temp.at(max(0, i - a.at(i)))++;
            temp.at(min(n, i + a.at(i)) + 1)--;
        }
        for (int i = 1; i <= n; i++)
        {
            temp.at(i) += temp.at(i - 1);
        }
        if (a == temp)
        {

            break;
        }

        a = temp;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << a.at(i) << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4400
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#define gc getchar()
#define lint long long
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
#define N 200010
#define Max(a,b,c,d) max(max(a,b),max(c,d))
#define Min(a,b,c,d) min(min(a,b),min(c,d))
#define update(ans,a,b,c,d) ans=min(ans,Max(a,b,c,d)-Min(a,b,c,d))
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int a[N];lint s[N];
int main()
{
	int n=inn();lint ans=LLONG_MAX;
	for(int i=1;i<=n;i++) a[i]=inn();
	for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
	for(int i=2,j=1,k=3;i<n-1;i++)
	{
		while(j<i-1&&s[j+1]<=s[i]-s[j+1]) j++;
		while(k<n-1&&s[k+1]-s[i]<=s[n]-s[k+1]) k++;
		lint s1=s[j],s2=s[i]-s[j],s3=s[k]-s[i],s4=s[n]-s[k];
		update(ans,s1,s2,s3,s4);int L=(j<i-1),R=(k<n-1);
		if(L) update(ans,s1+a[j+1],s2-a[j+1],s3,s4);
		if(R) update(ans,s1,s2,s3+a[k+1],s4-a[k+1]);
		if(L&&R) update(ans,s1+a[j+1],s2-a[j+1],s3+a[k+1],s4-a[k+1]);
	}
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 2560
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    x = int(input().rstrip('\n'))
    for i in range(x, 10 ** 10):
        b = True
        for j in range(2, int(i ** 0.5) + 1):
            if i % j == 0:
                b = False
                break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    solve()


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

int main() {
int64_t N, M;
cin >> N >> M;
vector<int> A(M);
for (int i = 0; i < M; i++) {
  cin >> A.at(i);
}

int64_t sum=0;
for(int i=0; i<M; i++){
    sum += A.at(i);
}

if(N-sum>=0){
cout << N - sum << endl;
}else{
    cout << -1 << endl;
}

return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>
#define N 1000000

int binarySearch(int S[], int key, int n){
  int left, right, mid;
  left = 0;
  right = n;
  while(left < right){
    mid = (left + right)/2;
    if(S[mid] == key) return 1;
    if(key > S[mid]) left = mid + 1;
    else if(key < S[mid]) right = mid;
  }
  return 0;
}

int main(){
  int i, n, S[N], q, key, cont = 0;

  scanf("%d", &n);
  for( i = 0 ; i < n ; i++ ){
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for( i = 0 ; i < q ; i++ ){
    scanf("%d", &key);
    if( binarySearch(S, key, n) ) cont++;
  }
  printf("%d\n", cont);
  return 0;
}



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

using namespace std;

void solve(){

	string strs[] = { "SAFE", "SUSPICIOUS" };

	int h, w;
	cin >> h >> w;

	vector< string > screen( h );
	vector< bool > flg( 26, false );

	for( int i = 0; i < h; i++ )
		cin >> screen[ i ];
	
	bool fig = true;

	while( fig ) {

		fig = false;

		for( int x = 0; x < w; x++ ) {
			for( int y = 0; y < h; y++ ) {
				char ch = screen[ y ][ x ];

				if( ch == '.' || ch == '*' ) continue;
				if( flg[ ch - 'A' ] ) continue;

				int stx = w, sty = h, edx = -1, edy = -1;
				for( int tx = 0; tx < w; tx ++ ) {
					for( int ty = 0; ty < h; ty ++ ) {
						if( screen[ty][tx] != ch ) continue;
						stx = min( stx, tx );
						sty = min( sty, ty );
						edx = max( edx, tx );
						edy = max( edy, ty );
					}
				}

				bool fillflg = true;
				for( int tx = stx; tx <= edx && fillflg; tx ++ ) {
					for( int ty = sty; ty <= edy && fillflg; ty ++ ) {
						fillflg &= ( screen[ ty ][ tx ] == ch || screen[ ty ][ tx ] == '*' );
					}
				}
				fig |= fillflg;
				if( fillflg ) {
					flg[ ch - 'A' ] = true;
					for( int tx = stx; tx <= edx; tx ++ ) {
						for( int ty = sty; ty <= edy; ty ++ ) {
							screen[ ty ][ tx ] = '*';
						}
					}
				}
			}
		}
	}

	bool b = false;
	for( int x = 0; x < w; x++ ) {
		for( int y = 0; y < h; y++ ) {
			b |= ( screen[ y ][ x ] != '.' && screen[ y ][ x ] != '*' );
		}
	}
	cout << strs[ b ] << endl;
}

int main( void ) {

	int n;
	cin >> n;

	for( int i = 0; i < n; i++ )
		solve();

	return 0;
}

Measured memory_bytes: 3040
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

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

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

	sort(all(a));

	int mi = INF;
	for (int i = 0; i < n - k + 1; i++) {
		chmin(mi, a[i + k - 1] - a[i]);
	}

	out(mi);

	return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;

    string S;
    cin >> S;

    i64 cnt0=0,cnt1=0;
    rep(i,0,S.size()){
        if(S[i]=='0') ++cnt0;
        else ++cnt1;
    }

    cout << S.size()-(max(cnt0,cnt1)-min(cnt0,cnt1)) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <cstdio>
//#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include <string>//"reverse(s's it,s's it)"
//#include <functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include <cmath>//"abs" "sqrt"
//#include <numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include <algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

#define MAX_N 100000

int main(){
	int n;
	ll k;
	cin>>n>>k;
	vector<ll> v;
	for(ll l=1;l<=k;l*=2) if((l&k)==l){
		v.pb((k-l)|(l-1));
	}
	v.pb(k);
	vector<ll> ans(v.size());
	fill(ans.begin(),ans.end(),0);
	for(int i=0;i<n;++i){
		ll a,b;
		cin>>a>>b;
		for(int j=0;j<v.size();++j) if((a&v[j])==a) ans[j]+=b;
	}
	k=0;
	for(int j=0;j<ans.size();++j) k=max(k,ans[j]);
	cout<<k<<endl;
}

Measured memory_bytes: 384
n = int(input())
w = [int(input()) for i in range(n)]

l = [0 for i in range(n)]
r = [0 for i in range(n)]
for i in range(1,n):
  l[i] = max(w[i-1], l[i-1])
  r[-(i+1)] = max(w[-(i)], r[-i])

for i in range(n):
  print(max(l[i], r[i]))
            

Measured memory_bytes: 15636
import java.util.*;
class Main {
public static void main(String []args) {
	Scanner sc = new Scanner (System.in);
	int n=sc.nextInt();
	int m=sc.nextInt();
	int arr[]=new int [m];
	for(int i=0;i<m;i++) {
		arr[i]=sc.nextInt();
	}
	for(int i=0;i<m;i++) {
		n=n-arr[i];
	}
	if(n>=0) {
		System.out.println(n);
	}
	else {
		System.out.println("-1");
	}
}
}


Measured memory_bytes: 39420
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


# いっこ入力
n =int(input())

k=0
for i in range(2,1000):
    a = i *(i-1) // 2
    if n == a:
        k = i
        break

if k >= 2:
    print("Yes")
else:
    print("No")
#    sys.exit()
if k >= 1:
    print(k)
    m = [[0]*(k-1) for ii in range(k)]

# print(m)
    t = 1
    for i in range(0,k):
        print(k-1, end=" ")
        for j in range(0,i):
            m[i][j]=m[j][i-1]
            print(m[i][j], end=" ")
        for j in range(i,k-1):
            m[i][j]=t
            t = t + 1
            print(m[i][j], end=" ")
        print("")

#print(m)



Measured memory_bytes: 18232
import sys
sys.setrecursionlimit(100010)
class UnionFind:
    """
    Disjoint sets
    """

    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.size = size
        self.parent = [-1] * size

    def find(self, x):
        """
        xを含む集合の代表を求める
        """
        if self.parent[x] < 0:
            return x
        root = self.find(self.parent[x])
        self.parent[x] = root
        return root

    def union(self, x, y):
        """
        xを含む集合とyを含む集合を併合する
        """
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x != root_y:
            if self.parent[root_x] >= self.parent[root_y]:
                self.parent[root_x] += self.parent[root_y]
                self.parent[root_y] = root_x
            else:
                self.parent[root_y] += self.parent[root_x]
                self.parent[root_x] = root_y

    def get_size(self, x):
        return -self.parent[self.find(x)]



n,m = map(int, input().split())
bs = []
for i in range(m):
    a,b = map(int, input().split())
    bs.append((a-1,b-1))

uf = UnionFind(n)

res  = []
fuben = n*(n-1)//2
for a,b in bs[::-1]:
    res.append(fuben)
    if uf.find(a) != uf.find(b):
        fuben -= uf.get_size(a) * uf.get_size(b)
    uf.union(a,b)

for v in res[::-1]:
    print(v)

Measured memory_bytes: 54596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m; cin >> n >> m;
  vector<int>a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  
  bool ans = false;
  int x=0, y=0;
  for(int i=0; i<n; i++) x += a[i];
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for(int i=0; i<m; i++){
    if(a[i]*4*m >= x) y++;
  }
  
  if(y >= m) ans = true;
    
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
def dfs():
    n = int(input())
    weight = list(map(int, input().split()))
    value = list(map(int, input().split()))
    
    
    def knapsack(n, weight, value):
        dp = [i for i in range(n+1)]
        for i in range(3):
            for j in range(weight[i], n+1):
                dp[j] = max(dp[j], dp[j-weight[i]] + value[i])
        return(dp[-1])
    
    
    new_n=knapsack(n=n, weight=weight, value=value)
    print(knapsack(n=new_n, weight=value, value=weight))
 
    
dfs()

Measured memory_bytes: 422960
c=[]
flag=true
3.times{|i|
  c[i]=gets.split(' ').map(&:to_i)
}
2.times{|j|
  bef=c[0][j+1]-c[0][j]
  2.times{|i|
    flag=false if c[i+1][j+1]-c[i+1][j] != bef
  }
}
2.times{|i|
  bef=c[i+1][0]-c[i][0]
  2.times{|j|
    flag=false if c[i+1][j+1]-c[i][j+1] != bef
  }
}
puts flag ? 'Yes' : 'No'

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

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

    int n, m;
    cin >> n >> m;

    int time = m * 1900 + (n - m) * 100;
    cout << 1LL * time * (1 << m) << endl;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		int B = sc.nextInt();

		int yen = 0 ;
		if(13 <= A) {
			yen = B ;
		}else if(6 <= A && A <= 12) {
			yen = B/2 ;
		}

		// 出力
		System.out.println(yen);

	}

}


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

typedef long long int ll;

// ====================================================================

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  ll ans = 0;
  for (int i = 0; i <= k; i++) {  // i…取る回数
    if (i > v.size()) continue;
    for (int l = 0; l <= i; l++) {
      priority_queue<ll, vector<ll>, greater<ll>> s;         // lは左から取る回数
      for (int x = 0; x < l; x++) s.push(v[x]);              // 左から取る
      for (int x = 0; x < i - l; x++) s.push(v[n - 1 - x]);  // 右から取る
      for (int p = 0; (p < k - i) && !s.empty() && s.top() < 0; p++) s.pop();
      ll res = 0;
      while (!s.empty()) {
        res += s.top();
        s.pop();
      }
      ans = max(ans, res);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from collections import Counter
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ct = Counter(a_ls)
ans = 0
for k, v in ct.items():
    ans += k * v
q = int(input())
for i in range(q):
    b, c = [int(i) for i in sys.stdin.readline().split()]
    ans += (c - b) * ct[b]
    print(ans)
    ct[c] += ct[b]
    ct[b] = 0

Measured memory_bytes: 88352
#!/usr/bin/env python3
import sys


def solve(K: int, S: str):
    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(K, S)

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  int a, b, c, d, sum = 0;

  cin >> a >> b >> c >> d;

  if (a > b){
    sum += b;
  } else {
    sum += a;
  }

  if (c > d){
    sum += d;
  } else {
    sum += c;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import math
X=int(input())

def sosu(a):
    if a==1:
        return False
    for i in range(2,int(math.sqrt(a))+1):
        if a%i==0:
            return False
    return True

while True:
    if sosu(X):#関数内がFalseのとき実行されない
        print(X)
        break
    X+=1

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

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

//INSERT ABOVE HERE
const Int MAX = 32;
vector<vector<Int> > X;
vector<Int> Y;
Int dpa[MAX][MAX];
Int dpb[MAX][MAX];
Int dfs(Int l,Int r,Int (*dp)[MAX],vector<Int> &s,Int n){
  //if(l>=r) cout<<l<<" "<<r<<endl;
  Int &res=dp[l%n][r%n];
  if(~res) return res;
  if(l+1==r) return res=1LL<<s[l];
  res=0;
  for(Int i=0;i<(Int)X.size();i++){
    Int k=X[i].size();
    vector<vector<Int> > dp2(MAX*2,vector<Int>(MAX*2,0));
    dp2[l][0]=1;
    for(Int p=l;p<r;p++){
      for(Int j=0;j<k;j++){
	if(!dp2[p][j]||r-p<k-j) continue;
	dp2[p+1][j+1]|=s[p]==X[i][j];	
	for(Int q=p+2;q<=r;q++)
	  dp2[q][j+1]|=(dfs(p,q,dp,s,n)>>X[i][j])&1;
      }
    }
    res|=dp2[r][k]<<Y[i];
  }
  return res;
}

Int n,m;
inline Int ag(Int l,Int r){return dpa[l%n][r%n];};
inline Int bg(Int l,Int r){return dpb[l%m][r%m];};

Int dp[MAX*2][MAX*2];

signed main(){
  Int r;
  while(cin>>n>>m>>r,n){
    vector<Int> A(n),B(m);
    for(Int i=0;i<n;i++) cin>>A[i];
    for(Int i=0;i<m;i++) cin>>B[i];
    vector<vector<Int> > x(r);
    vector<Int> y(r);
    for(Int i=0;i<r;i++){
      Int k;
      cin>>k;
      x[i].resize(k);
      for(Int j=0;j<k;j++) cin>>x[i][j];
      cin>>y[i];
    }
    for(Int i=0;i<n;i++) A.emplace_back(Int(A[i]));
    for(Int i=0;i<m;i++) B.emplace_back(Int(B[i]));
    X=x;Y=y;
    memset(dpa,-1,sizeof(dpa));
    memset(dpb,-1,sizeof(dpb));
    for(Int i=0;i<n;i++)
      for(Int l=1;l<=n;l++)
	dfs(i,i+l,dpa,A,n);
    for(Int i=0;i<m;i++)
      for(Int l=1;l<=m;l++)
	dfs(i,i+l,dpb,B,m);

    memset(dp,-1,sizeof(dp));
    Int ans=-1;
    for(Int i=0;i<n;i++){
      for(Int j=0;j<m;j++){
	dp[i][j]=0;
	for(Int a=0;a<n;a++){
	  for(Int b=0;b<m;b++){
	    if(dp[i+a][j+b]<0) continue;
	    int res=dp[i+a][j+b];
	    dp[i+a][j+b]=-1;
	    if(res+min(n-a,m-b)<=ans) continue;
	    for(Int na=a+1;na<=n;na++)
	      for(Int nb=b+1;nb<=m;nb++)
		if(ag(i+a,i+na)&bg(j+b,j+nb))
		  chmax(dp[i+na][j+nb],res+1); 
	  }
	}
	
	chmax(ans,dp[i+n][j+m]);
	for(Int a=0;a<n;a++) dp[i+a][j+m]=-1;
	for(Int b=0;b<m;b++) dp[i+n][j+b]=-1;
	//cout<<dp[i+n][j+m]<<endl;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



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

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

int needed_kaisu(long long a, long long N, long long *A) {
	int count = 0;
	for (long long i = 0; i < N; i++) {
		count += (A[i]+a-1) / a -1;
	}
	return count;
}


int main() {


	long long keta,sum;
	string N;
	cin >> N;
	keta = N.length();
	sum = 0;

	for (int i = 0; i < keta; i++) {
		sum = sum + stoi(N.substr(i,1));
	}

	string ans = "Yes";

	if (sum % 9 != 0) {
		ans = "No";
	}

	cout << ans <<endl;

	cin >> N;

	return 0;


}



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

using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

#define INF 1000000000

struct edge{int to;};
using graph = vector<vector<edge>>;

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

    ll n, k;
    cin >> n >> k;

    vi A(n), seen(n, -1);
    trav(Ai, A) {cin >> Ai, Ai--;}

    ll town = 0, t = 0, offset, len;
    while (true) {
        if (t == k) {
            cout << town+1 << endl;
            return 0;
        }
        if (seen[town] >= 0) {
            offset = seen[town];
            len = t - offset;
            break;
        } else {
            seen[town] = t++;
            town = A[town];
        }
    }
    ll pos = (k - offset) % len;
    rep (i, 0, pos) town = A[town];
    cout << town+1 << endl;
    
}


Measured memory_bytes: 4784
n = int(input())

def f(x):
    res = 0
    while x%2==0:
        x //= 2
        res += 1
    return res

cnt = 0
res = 1
for i in range(1,n+1):
    c = f(i)
    if c>cnt:
        cnt = c
        res = i

print(res)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int n,m,l;
    int i,j,k;
    int a[101][101],b[101][101];
    long c[101][101]={0};
    /*入力部*/
    scanf("%d %d %d",&n,&m,&l);
    for(i = 0;i < n;i++){
        for(j = 0;j < m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i = 0;i < m;i++){
        for(j = 0;j < l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for (i = 0; i < n; i++){
        for(j = 0;j < l;j++){
            for(k = 0;k < m;k++)c[i][j] += a[i][k] * b[k][j];
            printf("%ld",c[i][j]);
            printf((j + 1 < l)? " ": "");
        }
        printf("\n");
	}
    return 0;
}



Measured memory_bytes: 2092
# -*- coding: utf-8 -*-
def solve():
    N = int(input())
    S = input()
    L1 = [0 for _ in range(10)]
    L2 = [0 for _ in range(100)]
    L3 = [0 for _ in range(1000)]
    for s in S:
        s = int(s)
        L3[s::10] = L2[:]
        L2[s::10] = L1[:]
        L1[s] = 1
    return str(sum(L3))

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3064
from itertools import*
n,a,b,c,*l=map(int,open(0).read().split())
a=a,b,c
m=10**18
for s in product(*[range(4)]*n):
  if all(i in s for i in(0,1,2)):
    t,c=[0]*4,[0]*4
    for i,v in zip(s,l):
      t[i]+=v
      c[i]+=1
    m=min(m,sum(abs(x-y)+~-z*10for x,y,z in zip(a,t,c)))
print(m)

Measured memory_bytes: 50908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll n;
  cin >> n;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  cout << 180*(n-2) << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;

public class MainApp
{
    static public void Main(string[] args)
    {
        var read = Console.ReadLine();
        int[] x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int[] color = new int[9];

        int min = 0;
        int max = 0;

        for (int c = 0; c < x.Length; c++)
        {
            int ratecheck = x[c] / 400;
            if (ratecheck > 8) ratecheck = 8;
            color[ratecheck]++;
        }
        int havecolor = 0;
        for (int c = 0; c < 8; c++)
        {
            havecolor += color[c];

        }
        if (havecolor == 0)//つまり、全員好きな色
        {
            min = 1;
            max = color[8];
        }
        else
        {

            for (int c = 0; c < 8; c++)
            {
                if (color[c] != 0)
                    min += 1;

            }
            max = min+ color[8];

        }
        Console.WriteLine("{0} {1}", min, max);
    }
    

}

Measured memory_bytes: 13268
<?php
    list($a, $b) = explode(" ", trim(fgets(STDIN)));
    $str1 = "";
    $str2 = "";
    for($i = 0;$i < $b; $i++){
        $str1 = $str1.$a;
    }
    for($i = 0;$i < $a; $i++){
        $str2 = $str2.$b;
    }
    $ans = array($str1, $str2);
    sort($ans, SORT_STRING);
    echo $ans[0];
    
?>

Measured memory_bytes: 4604
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define maxm 100005
#define maxn 100005
using namespace std;
typedef long long ll;

template <typename T>void read(T &t)
{
	t=0;ll f=0;char c=getchar();
	while(!isdigit(c)){f|=c=='-';c=getchar();}
	while(isdigit(c)){t=t*10+c-'0';c=getchar();}
	if(f)t=-t;
}

ll n,m;
ll a[maxm],b[maxm];
ll prt[maxn],siz[maxn],ans[maxm];
ll cnt;

ll getroot(ll u)
{
	return prt[u]==u?u:prt[u]=getroot(prt[u]);
}

int main()
{
	read(n),read(m);
	for(register ll i=1;i<=m;++i)
		read(a[i]),read(b[i]);
	for(register ll i=1;i<=n;++i)
		prt[i]=i,siz[i]=1;
	cnt=n*(n-1)/2;
	for(register ll i=m;i;--i)
	{
		ans[i]=cnt;
		ll r1=getroot(a[i]),r2=getroot(b[i]);
		if(r1!=r2)
		{
			cnt-=siz[r1]*siz[r2];
			siz[r2]+=siz[r1];
			prt[r1]=r2;
		}
	}
	for(register ll i=1;i<=m;++i)
		printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 5248
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
    //fios;
    
    int x;
    cin >> x;
    if(x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    double N=gd();

	  //  System.out.print(c);

        if (N%2==0) {
        	System.out.print((double)1/2);
        } else {
        	System.out.print(((N+1)/2) /N);
        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35904
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll k;
    cin >> k;
    ll ans = 0;
    REP1(i, k) REP1(j, k) REP1(l, k) {
        ans += gcd((ll)i, gcd((ll)j, (ll)l));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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


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


Measured memory_bytes: 2048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  string s;
  cin >> s;
  int n=s.size();
 
  int a,z;
  
  rep(i,n){
    if(s[i]=='A') {
    a=i;
    break;
    }
  }
  
  for(int i=n-1;i>=0;i--) {
    if(s[i]=='Z') {
    z=i;  
    break;
    }
  }
  
    cout << z-a+1 << endl;
  
}


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

using namespace std;
typedef long long ll;




int main()
{
    
    int N;cin>>N;
    vector<int> L(N);
    rep(i,N) cin >> L[i];
    sort(all(L));
    int a=0;
    rep(i,N-1) a+=L[i];
    if(a>L[N-1]) cout<<"Yes"<<endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
while True:
  a, op, b = input().split()

  if op == "?":
    break
  elif op == "+":
    print(int(a) + int(b))
  elif op == "-":
    print(int(a) - int(b))
  elif op == "*":
    print(int(a) * int(b))
  elif op == "/":
    print(int(a) // int(b))



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

int gcd2(int,int);
int gcd3(int,int,int);

int main(){

    int ans=0;
    int k;
    cin>>k;

    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans+=gcd3(a,b,c);
            }
        }
    }
    cout<<ans<<endl;



    return 0;
}

int gcd2(int a,int b){

    if(a<b) swap(a,b);
    if(a%b==0) return b;
    
    return gcd2(b,a%b);

}


int gcd3(int a,int b,int c){

    return gcd2(gcd2(a,b),c);

}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

vector<vll> cmb(vector<vll> &v) {
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

void solve() {
  int N, P;
  cin >> N >> P;
  vi A(N, 0);
  int odd = 0, even = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] % 2 == 0)
      even++;
    else
      odd++;
  }
  ll ans = 0;
  vector<vll> v(N + 1, vll(N + 1, 0));
  cmb(v);
  for (int i = 0; i <= even; i++) {
    for (int j = P; j <= odd; j += 2) {
      ans += v[odd][j] * v[even][i];
    }
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


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

int main()
{
   int d,i;
   while(cin>>d){
       int ans=0;
       for(i=1;i*d<600;i++){
           ans+=i*d*i*d*d;
       }
       cout<<ans<<endl;
   }
}


Measured memory_bytes: 2988
import math
N = int(input())
A = list(map(int, input().split()))
count = []
for i in A:
    if i%4 == 0:
        count.append("4")
    elif i%2 == 0:
        count.append("2")
    else:
        count.append("1")
B1 = count.count("4")
B2 = count.count("1")
if count.count("2") == 0:
    print("Yes" if B1+1 >= B2 else "No")
else:
    print("Yes" if B1 >= B2 else "No")

Measured memory_bytes: 20440
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define Int const int &

int main(void) {
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int u=a+b, v=c+d;
	if (u==v) puts("Balanced");
	else puts(u>v ? "Left" : "Right");
	return 0;
}

Measured memory_bytes: 256
N, K=map(int,input().split())
scores=input().split()
for i in range(N):
  scores[i]=int(scores[i])
new=K
old=0
while new<N:
  if scores[new]>scores[old]:
    print("Yes")
  else:
    print("No")
  new+=1
  old+=1

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

typedef long long ll;

int N,N_,A,B,Q;
int X[200010];
ll INF = 1001001001001001001;
ll seg[2][800010];

void init()
{
    N_ = 1;
    while(N_ <= N)N_ *= 2;
    for(int i = 0; i < N_ * 2 - 1; i++)seg[0][i] = seg[1][i] = INF;
    return;
}

void update(int t,int p,ll x)
{
    p += N_ - 1;
  seg[t][p] = x;
    //seg[t][p] = min(seg[t][p],x);
    while(p)
    {
        p = (p - 1) / 2;
        seg[t][p] = min(seg[t][p * 2 + 1],seg[t][p * 2 + 2]);
    }
    return;
}

ll get_min(int t,int a,int b,int k = 0,int l = 0,int r = N_)
{
    if(b <= l || r <= a)return INF;
    if(a <= l && r <= b)return seg[t][k];
    ll L = get_min(t,a,b,k * 2 + 1,l,(l + r) / 2);
    ll R = get_min(t,a,b,k * 2 + 2,(l + r) / 2,r);
    return min(L,R);
}

ll unit()
{
    ll ans = INF,mem = 0;
    for(int i = 1; i <= Q; i++)
    {
        ll L = get_min(0,0,X[i]) + X[i],R = get_min(1,X[i],N) - X[i];
        ll res = min(L,R) - abs(X[i] - X[i - 1]);
        update(0,X[i - 1],res - X[i - 1]);
        update(1,X[i - 1],res + X[i - 1]);
        mem += abs(X[i] - X[i - 1]);
    }
    for(int i = 0; i < N; i++)ans = min(ans,get_min(0,i,i + 1) + i);
    return ans + mem;
}

int main()
{
    scanf("%d%d%d%d",&N,&Q,&A,&B);
    A--;B--;
    for(int i = 1; i <= Q; i++)scanf("%d",X + i),X[i]--;
    ll ans = INF;

    init();
    X[0] = B;
    update(0,A,-A);
    update(1,A,A);
    ans = unit();

    init();
    X[0] = A;
    update(0,B,-B);
    update(1,B,B);
    ans = min(ans,unit());

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 13440