akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  ll a[N];
  rep(i,N) cin>>a[i];
  ll ans=a[0];
  rep(i,N){
    ans=lcm(ans,a[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
N, X, M = map(int, input().split())

A_change_list = [0] * (M + 1)
check_list = [0] * (M + 1)

for i in range(1, M + 1):
    A_change_list[i] = i**2 % M

A = X
count = 0
sum_value = 0
ans = 0
for i in range(1, N + 1):
    if check_list[A] != 2:
        if check_list[A] == 1:
            count += 1
            sum_value += A
        ans += A
        check_list[A] += 1
        A = A_change_list[A]
    else:
        if A == 0:
            break
        elif A == 1:
            ans += N - i + 1
            break
        else:
            div, mod = divmod((N - i), count)
            ans += sum_value * div
            for _ in range(mod + 1):
                ans += A
                A = A_change_list[A]
            break

print(ans)


Measured memory_bytes: 13644
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n=0,i=0,j=0,k=0,sum=0,ii=0;

        int aa[128][128];
    for(ii=0;;ii++){
            //int bb[]={};
        cin >> n;
        if(n==0)break;
        //if(n==0 && x==0)break;
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                cin >> k;
                aa[i][j]=k;
                sum+=k;
            }
            aa[i][j]=sum;
            sum=0;
        }


        for(j=0;j<n+1;j++){
            for(i=0;i<n;i++){
                sum+=aa[i][j];
            }
        aa[i][j]=sum;
        sum=0;
        }
        for(i=0;i<n+1;i++){
            for(j=0;j<n+1;j++){
                if(aa[i][j]<10000)cout << ' ';
                if(aa[i][j]<1000)cout << ' ';
                if(aa[i][j]<100)cout << ' ';
                if(aa[i][j]<10)cout << ' ';
                cout << aa[i][j];
            }
            cout << endl;
        }
    }
    //cout << endl;


}

Measured memory_bytes: 1172
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(1){
		c = c - b;
		if(c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a = a - d;
		if(a <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
}



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

using namespace std;

#define LL long long
#define reg register
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a )
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a )
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a )
#define debug(x) cerr<<#x<<" = "<<x<<endl;

template<class T>inline bool Max(T &a,T b) {
	return a<b?a=b,1:0;
}
template<class T>inline bool Min(T &a,T b) {
	return a>b?a=b,1:0;
}

inline int Read(void) {
	int res=0,flag=1;
	char c;
	while(c=getchar(),c<48||c>57)if(c=='-')flag=0;
	do res=(res<<1)+(res<<3)+(c^48);
	while(c=getchar(),c>=48&&c<=57);
	return flag?res:-res;
}

const int N=2e3+5,M=1e6+5,mod=1e9+7;
const int dx[4]= {1,-1,0,0},dy[4]= {0,0,1,-1};

int f=0,t=1e9,Ans,A[N];

int main(void) {
	int n=Read(),L=Read();
	rep(i,1,n)A[i]=i+L-1;
	sort(A+1,A+n+1);
	rep(i,1,n) {
		Ans+=A[i];
		if(Min(t,abs(A[i]))){
			if(A[i]<0)f=-1;
			else f=1;
		}
	}
	Ans-=f*t;
	printf("%d",Ans);
	return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;
const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
//	a=((ll)a+b)%mod;
	a+=b;
	if(a>=mod)a-=mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

int dp[2][2][5010];

signed main(){
	int n=read(),m=read(),cur=0;
	assert(1<=n&&n<=3000);
	assert(1<=m&&m<=3000);
	FOR(i,1,n+1)dp[cur][0][i]=1;
	dp[cur][1][0]=1;
	REP(_,m){
		int nx=cur^1;
		memset(dp[nx],0,sizeof(dp[nx]));
		REP(k,2)REP(i,n+1)REP(j,2)
			if(0<=i-j&&i-j<=n-1){
				int d=k|(i-j==0);
				add(dp[nx][d][i-j+1],dp[cur][k][i]);
			}
		swap(nx,cur);
		memset(dp[nx],0,sizeof(dp[nx]));
		REP(k,2)REP(i,n+1)REP(j,2)
			if(0<=i-j&&i-j<=n){
				int d=k|(i-j==0);
				add(dp[nx][d][i-j],dp[cur][k][i]);
			}
		swap(nx,cur);
	}
	int ans=0;
	REP(i,n+1)add(ans,dp[cur][1][i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 384
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let s: String = scan(tokens);
    let t: String = scan(tokens);
    println!("{}{}", t, s);
}


Measured memory_bytes: 4352
dic = {}
N = int(input())
for _ in range(N):
  s = input()
  if s not in dic:
    dic[s] = 0
  else:
    dic[s] += 1
max_val = max(dic.values())
keys_of_max_val = [key for key in dic if dic[key] == max_val]
keys_of_max_val.sort()
for item in keys_of_max_val:
  print(item)

Measured memory_bytes: 32732
N, S = gets.split.map(&:to_i).tap{|it| it[1] /= 1000}
ans = (0 .. N).inject([-1,-1,-1]) do |notfound, y|
  f = S - 5 * y
  break notfound if f < 0
  
  r,m = (S - 5 * y).divmod(10)
  x = (0 .. r).find{|x| x + y + (r - x) * 10 + m == N }
  
  break [x, y, N - x - y] if x
    
  notfound
end
puts ans.join(' ')

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

int main()
{
	long long N;
	scanf("%lld", &N);
	long long velo{1LL << 60};
	for (int i{}; i < 5; i++)
	{
		long long a;
		scanf("%lld", &a);
		velo = std::min(velo, a);
	}
	printf("%lld\n", (N + velo - 1) / velo + 4);

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;


int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
    int N,A;
    cin>>N>>A;
    vector<int> x(N);
    rep(i,N){ 
    	cin>>x[i];
    	x[i]-=A;
    }
    int dp[51][501];
    rep(i,N+1) rep(k,501) dp[i][k]=0;
    dp[0][250]=1;
    rep(i,N) rep(k,501){
    	dp[i+1][k]=dp[i][k];
    	int tmp=k-x[i];
    	if(0<=tmp&&tmp<=500)dp[i+1][k]+=dp[i][k-x[i]];
    }
    cout<<dp[N][250]-1<<endl;;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 384
N = int(input())
V = sorted([float(v) for v in input().split()])

while len(V) > 1:
    if len(V) > 2:
        pick = V[0:2]
        V = [sum(pick)/2] + V[2:]
    else:
        V = [sum(V)/2]

print(V[0])

Measured memory_bytes: 3060
import java.util.Map.Entry;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		int ans = 0;
		while(true){
			if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1)
				break;
			
			if(A == B && B == C && C == A){
				System.out.println(-1);
				return;
			}
			
			int a = A / 2; int b = B / 2; int c = C / 2;
			A = b + c;
			B = c + a;
			C = a + b;
			ans++;
		}
		
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <deque>
#define MAX 200010
#define lli long long int
#define endl "\n"
#define whats(x) cout<<#x<<" is: "<<x<<endl;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; char c; int cmd;
    cin>>s;
    int f;
    int q;
    int cnt=0;
    deque<char> d;
    for(char x: s){
        d.push_back(x);
    }
    cin>>q;
    while(q--){
        cin>>cmd;
        if(cmd==2){
            cin>>f>>c;
            if(f==1){
                if(cnt%2==0)
                    d.push_front(c);
                else
                    d.push_back(c);
            }
            else{
                if(cnt%2==0)
                    d.push_back(c);
                else
                    d.push_front(c);
            }
        }
        else
            cnt++;
    }
    if(cnt%2){
        for(auto it=d.rbegin(); it!=d.rend(); ++it){
            cout<<*it;
        }
    }
    else{
        for(auto it: d){
            cout<<it;
        }
    }
    cout<<endl;
    return 0;
}


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


char s[15];
int ans,last;
int main(){
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++){
		if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')
			last++;
		else ans=max(last,ans),last=0;
	}
	ans=max(ans,last);
	printf("%d\n",ans);
}

Measured memory_bytes: 256
/*input
10 7
14 15 92 65 35 89 79 32 38 46
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k; cin >> n >> k;
    ll ans = 0;
    vector<int> a(n);
    vector<int> pre(n + 1);
    map<int, ll> mapp;
    for(int i = 0; i < n; i++)
    {
    	cin >> a[i];
    	a[i]--;
    	if(!i) pre[i + 1] = (a[i] % k);
    	else pre[i + 1] = (pre[i] + (a[i] % k)) % k;
    }
    for(int i = 0; i < min(n + 1, k); i++)
    {
    	ans += mapp[pre[i]];
    	mapp[pre[i]]++;
    }
    for(int i = k; i < n + 1; i++)
    {
    	mapp[pre[i - k]]--;
    	ans += mapp[pre[i]];
    	mapp[pre[i]]++;
    }
    cout << ans;

    return 0;
}

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

bool compare_by_b(pair<pair<string, int>,int > a, pair<pair<string, int>,int > b) {
    if(a.first.first != b.first.first){
      return a.first.first < b.first.first;
    }
    else
    {
      return a.first.second > b.first.second;
    }
}

int main(){
  int n;
  vector<pair<pair<string,int>,int> > shop;
  cin>>n;
  shop.resize(n);
  for (int i = 0; i < n; i++){
    cin >> shop[i].first.first >> shop[i].first.second;
    shop[i].second = i+1;
  }

  sort(shop.begin(), shop.end(),compare_by_b);

  // cout << "sorted" << endl;

  for (int i = 0; i < n; i++){
    cout << shop[i].second << endl;
  }
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (a, b): (Vec<usize>, Vec<usize>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };

    let G = {
        let mut G = vec![std::collections::HashSet::new(); N + 1];
        for i in 0..M {
            G[a[i]].insert(b[i]);
            G[b[i]].insert(a[i]);
        }
        G
    };

    let mut dp = vec![100000000; N + 1];
    let mut q = std::collections::BinaryHeap::new();
    q.push((0i64, 1));
    dp[1] = 0;
    while !q.is_empty() {
      let (c, i) = q.pop().unwrap();
      let c = -c;
      for &j in &G[i] {
        if c + 1 < dp[j] {
          q.push((-(c + 1), j));
          dp[j] = c + 1;
        }
      }
    }
    let ans = if dp[N] <= 2 { "POSSIBLE" } else { "IMPOSSIBLE" };

    println!("{}", ans);
}


Measured memory_bytes: 127168
# -*- coding: utf-8 -*-
X, Y = map(str, input().split())
dic = {"A":10,"B":11,"C":12,"D":13,"E":14,"F":15,}
if dic[X]>dic[Y]:
    print(">")
elif dic[X]<dic[Y]:
    print("<")
elif dic[X]==dic[Y]:
    print("=")


Measured memory_bytes: 3060
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int K = sc.nextInt();
   int[] hi = new int[N];
   for(int i = 0;i<N;i++)
   {
    hi[i] = sc.nextInt();
   }
   Arrays.sort(hi);
   int count =0;
   int ans = hi[N-1];
   int ex=0;
   while(N-K-count>=0)
   {
    ex = hi[N-1-count] - hi[N-K-count];
    if(ans >ex) ans =ex;
     count++;
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 50572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef struct n
{
    ll x,y;
}m;
m q[1000005];
char p[1000005];
int main()
{
    ll a,b,c,d,e;
    cin>>a>>b;
    cin>>p;
    char u =p[0];
    ll ans=0,n=1;
    if(p[a-1]=='1')
        p[a]='0';
    else
        p[a]='1';
    for(ll i=0;i<=a;i++)
    {
        if(u==p[i])
        {
            ans++;
        }
        else
        {
            q[n].x=ans;
            q[n].y=u-'0';
            n++;
            ans=1;
            u=p[i];
        }
    }
    ll k=0;
    ans=0;
    ll flag=0;


    for(ll i=1;i<n;i++)
    {
        if(q[i].y==0)
        {

            if(k>=b)
            {
               ans =ans+q[i].x-q[i-2*k].x -q[i-2*k-1].x;
               flag=max(flag,ans);
            }
            else
            {
                k++;
            ans+=q[i].x;
            flag=max(flag,ans);
            }


        }
        else

        {
            ans+=q[i].x;
            flag=max(flag,ans);
        }
    }
    cout<<flag;

}


Measured memory_bytes: 5228
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int k = saori.saori_hayami();
		for(int i = 0;i < k;i++){
			if(i % 2 == 0){
				b += a/2;
				a /= 2;
			} else {
				a += b/2;
				b /= 2;
			}
		}
		System.out.println(a + " " + b);

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main() {
    string S;
    cin>>S;
    string tmp[16];
    tmp[0] = "AKIHABARA";
    tmp[1] = "AKIHBR";
    tmp[2] = "AKIHBRA";
    tmp[3] = "AKIHABR";
    tmp[4] = "AKIHBAR";
    tmp[5] = "AKIHBARA";
    tmp[6] = "AKIHABAR";
    tmp[7] = "AKIHABRA";
    tmp[8] = "KIHBR";
    tmp[9] = "KIHABR";
    tmp[10] = "KIHBAR";
    tmp[11] = "KIHBRA";
    tmp[12] = "KIHBARA";
    tmp[13] = "KIHABRA";
    tmp[14] = "KIHABAR";
    tmp[15] = "KIHABARA";
    bool ans = false;
    for(int i=0;i<16;++i){
        if(S==tmp[i])ans = true;
    }
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

int main(void) {
    int64_t N,M;
    cin >> N >> M;

    // どちらも1の場合 1
    if(N == 1) {
        if(M == 1) {
            cout << "1\n";
        } else {
            cout << M-2 << endl;
        }
    } else {
        if(M == 1) {
            cout << N-2 << endl;
        } else {
            cout << (N-2)*(M-2) << endl;
        }
    }
    //どちらかが1の場合、
    // 隅は2回、辺は3回=> 辺の数-2
    
    // どちらも2以上の場合
    // 隅は4回 辺は6回 中は9回

    return 0;
}


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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
C = Counter()
for i in range(M):
    a, b = MAP()
    C[a] += 1
    C[b] += 1

for k, v in C.items():
    if v%2 == 1:
        NO()
        exit()
YES()


Measured memory_bytes: 9428
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

bool canmake(int m,vector<int> a){
    if(m<0) return false;
    else if(m==0) return true;
    else if(a.size()==1){
        if(m==a.at(0)) return true;
        else return false;
    }
    else{
        vector<int> b = a;
        b.pop_back();
        if(canmake(m-a.back(),b)) return true;
        else if(canmake(m,b)) return true;
        else return false;
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int m;
        cin >> m;
        if(canmake(m,a)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3180
#include <stdio.h>
int main(void)
{
  int a,sam,i,x,y,z;
  scanf("%d%d%d",&x,&y,&z);
  if (x<y)
    {  sam = x;
  x = y;
  y = sam;}
  if (y<z)
    {  sam = y;
  y = z;
  z = sam;}
   if (x<y)
    {  sam = x;
  x = y;
  y = sam;}
  for (i=0;i<7;i++)
    {
      scanf("%d" ,&a);
      if (a>=x)
	{z = y;
      y = x;
      x = a;}
      else 
      {if(a>=y)
	  {z = y;
	    y = a;}
	else {if(a>=z)
	    z = a;}
      }
    }
  printf("%d\n%d\n%d\n" ,x,y,z);
  return(0);
}

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

#include <algorithm>
#include <vector>

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  rep(i, n) cin >> vec[i];
  sort(vec.begin(), vec.end());
  int result = 0;
  rep(i, k) result += vec[i];
  cout << result << endl;
}

Measured memory_bytes: 3608
#include <utility>
#include <vector>
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, M, X;
    cin >> N >> M >> X;
    int A[M] = {};
    for(int i = 0; i < M; i++){
        cin >> A[i];
    }
    int costR = 0;
    int costL = 0;
    for(int i = 0; i < M; i++){
        if(A[i] < X){
            costL++;
        }else if (A[i] > X){
            costR++;
        }
    }
    int ans = min(costL, costR);
    
    cout << ans <<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String tmpStr = br.readLine();

			if(tmpStr == null){
				break;
			}
			
			double inputV = Double.parseDouble(tmpStr);
			for(int i = 1;  ; i++){
				int height = i * 5 - 5;
				double v = Math.sqrt(2*9.8*height);
				//System.out.println(v);
				if(v >= inputV){
					System.out.println(i);
					break;
				}
				if(v > 200){
					break;
				}
			}
		}
	}

}

Measured memory_bytes: 24392
#include <cstdio>

using namespace std;

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if((a + b) % 2 == 0) {
        printf("%d", (a + b) / 2); return 0;
    }
    printf("%d",  (a + b) / 2 + 1);
}

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

#define s second
#define f first

const int maxn = 301 * 10;

int n;
int sang[maxn];
pair<int, int> a[maxn];
bool state[maxn];
vector<int> adj[maxn];
set<int> ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i].f;
        sang[i] = a[i].f;
        a[i].s = i;
    }
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
}

void solve(){
    sort(a, a + n);
    for(int i = 0; i < n; i++)
        for(auto j: adj[a[i].s])
            if(sang[j] < sang[a[i].s])
                if(state[j] == 0)
                    state[a[i].s] = 1;
}

void out(){
    for(int i = 0; i < n; i++)
        if(state[i] == 1)
            cout << i + 1 << ' ';
    cout << '\n';
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
	int q;
	while (true) {
		cin >> q;
		if (q==-1) break;
		
		double q_ = static_cast<double>(q);
		double x = 0.5 * q_;
		while ( abs(x*x*x - q_) >= 0.00001 * q_ ) {
			x -= (x*x*x - q_) / (3.0*x*x);
		}
		cout << fixed << setprecision(6) << x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3148
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = [0] * (N + 1)
    for a in A:
        B[a] += 1

    total = 0
    for b in B:
        total += b * (b - 1) // 2

    ans = [0] * N
    for i, a in enumerate(A):
        ans[i] = total - (B[a] - 1)

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 42928
# include <stdio.h>
int main ()
{ 
 int r,g,b,n;
 int ans=0;
 int i,j,k;
 scanf ("%d%d%d%d",&r,&g,&b,&n);
 //printf ("%d %d %d %d\n",r,g,b,n);
 for (i=0;i<=(n/r)+10;++i)
    {
    	for (j=0;j<=(n/g)+10;++j)
    	    {
              int p=n-i*r-g*j;
              if (p%b==0&&p/b>=0)
                  ans++;
    	    }
    }
 printf ("%d\n",ans);
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, m, l, p = 1000000007, o = 1, z;
int f[1000020];
int v[1000020];
int t[1000020];
int C(int n, int m) {
	return (long long)f[n] * v[m] % p * v[n - m] % p;
}
int main() {
	scanf("%d%d%d", &n, &m, &l);
	t[0] = f[0] = v[0] = v[1] = 1;
	for (int i = 2; i <= 1000000; i++) {
		v[i] = (long long)v[p % i] * (p - p / i) % p;
	}
	for (int i = 1; i <= 1000000; i++) {
		f[i] = (long long)f[i - 1] * i % p;
		v[i] = (long long)v[i - 1] * v[i] % p;
		t[i] = (long long)t[i - 1] * 3 % p;
	}
	for (int i = 0; i <= m + l; i++) {
		z = (z + (long long)o * C(n + i - 1, n - 1) % p * t[m + l - i]) % p;
		o = o * 2 % p;
		if (i >= m) {
			o = (o + p - C(i, m)) % p;
		}
		if (i >= l) {
			o = (o + p - C(i, l)) % p;
		}
	}
	printf("%d\n", z);
	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  int a,b,i;
  for(;;){
    cin >> s;
    if(s == "0")break;
    a = b = 0;
    for(i=1;i<s.length();i++){
      if(s[i] == 'A') a++;
      else if(s[i] == 'B') b++;
    }
    if(a>b) a++;
    else b++;
    cout << a << " " << b << endl;
  }
  return 0;
}

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

int search(int a[], int n, int key)
{
	int i = 0;
	a[n] = key;
	while (a[i] != key)++i;
	return i != n;
}

int main()
{
	int i, n, a[10000 + 1], q, key, sum = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> a[i];
	cin >> q;
	for (int i = 0; i < q; ++i){
		cin >> key;
		if (search(a, n, key))++sum;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  string s,t;
  int a,b;
  string u;

  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  if(u == s){
    a -= 1;
  }
  if(u == t){
    b -= 1;
  }

  cout << a << " " << b << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,m,k,i,j,a,cards[200],cards1[200],cards2[200];
  scanf("%d %d",&n,&m);
  for(i=0;i<2*n;i++)cards[i]=i+1;
  for(i=0;i<m;i++){
    scanf("%d",&k);
    if(k==0){ /*リシャッフル*/
      for(j=0;j<n;j++) cards1[j]=cards[j];
      for(j=n,a=0;j<2*n-k;j++,a++) cards2[a]=cards[j];
      for(j=0,a=0;j<2*n;j+=2,a++){
	cards[j]=cards1[a];
	cards[j+1]=cards2[a];
      }
	
    }else{ /*カット*/
      for(j=0;j<k;j++) cards1[j]=cards[j];
      for(j=k,a=0;a<2*n-k;j++,a++) cards2[a]=cards[j];

      for(a=0;a<=2*n-k;a++){
	cards[a]=cards2[a];
      }

      for(j=2*n-k,a=0;a<k;j++,a++){
	cards[j]=cards1[a];
      }
    }
  }
  for(i=0;i<(2*n);i++){
    printf("%d\n",cards[i]);
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;

int main(){
    int k,a,b;
    scanf("%d%d%d",&k,&a,&b);
    if(a%k==0)  {printf("OK");return 0;}
    int m=a/k;
    k*=m+1;
    if(a<=k&&k<=b)
        printf("OK");
    else printf("NG");
    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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 ll mod = pow(10,9)+7;

int main() {
  ll N,M;
  scanf("%lld%lld", &N,&M);
  ll ans = 1;
  
  if(N==M){
    FOR(i,1,N){
      ans = ans*i%mod;
      ans = ans*i%mod;
    }
    ans = ans*2%mod;
  }
  else if(abs(N-M)==1){
    FOR(i,1,N){
      ans = ans*i%mod;
    }
    FOR(i,1,M){
      ans = ans*i%mod;
    }
  }
  else ans = 0;

  cout << ans << endl;
}



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

def computeGCD(x, y):
    while (y):
        x, y = y, x % y

    return x

result = list()
sum = 0
for a in range(1, K+1):
    intermediate_result = list()
    for b in range(1, K+1):
        intermediate_result.append(computeGCD(a, b))
    result.append(intermediate_result)

for a in range(1, K+1):
    for b in range(1, K+1):
        intermediate = result[a-1][b-1]
        for c in range(1, K+1):
            sum += result[intermediate-1][c-1]

print(sum)

Measured memory_bytes: 9416
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,ans=0,mn=0,rem;
    cin>>n;
    char ch;
    int a[n+1]={0};
    for(i=1;i<=n;i++){
    cin>>ch;
        if(ch=='R'){a[i]=1;mn++;}
    }
    rem=n-mn;
    for(i=1;i<=mn;i++){if(rem<=0)break;
        if(!a[i]){ans++;rem--;}
        }//ans+=rem;
        cout<<ans;
    return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int cc=0;

    for(int M = A; M <= B; ++M) {
        int m[5];
        int a = 100000;
        int M_d = M;
        for(int i = 0; i < 5; ++i) {
            a /= 10;
            m[i] = M_d/a;
            M_d -= m[i]*a;
        }
        for(int i = 0; i < 5; ++i) {
            M_d += m[i]*a;
            a *= 10;
        }
        if(M == M_d) {
            ++cc;
        }
        //cout << m[0] << m[1] << m[2] << m[3] << m[4] << endl;
    }
    cout << cc << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const int MOD = 1e9 + 7;
int N;
vector<int> adj[110000];
ll dp[110000][2];

void dfs(int nd, int prv = -1) {
	dp[nd][0] = dp[nd][1] = 1;
	for (int nxt : adj[nd]) {
		if (nxt == prv) continue;
		dfs(nxt, nd);
		dp[nd][1] *= dp[nxt][0];
		dp[nd][0] *= dp[nxt][0] + dp[nxt][1];
		dp[nd][1] %= MOD;
		dp[nd][0] %= MOD;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b; cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(0);
	cout << (dp[0][0] + dp[0][1]) % MOD << '\n';
	return 0;
}

Measured memory_bytes: 14464
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}



int main(){
    ll x,y;
    while(1){
        cin>>x>>y;
        if(x == 0 && y == 0)break;
        if(x<y){
            cout<<x<<" "<<y<<endl;
        }else{
            cout<<y<<" "<<x<<endl;
        }
    }
    
    return 0;
}
 



Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()


int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for(auto &e : a) cin >> e;
	cout << *max_element(all(a)) - *min_element(all(a)) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int a;
int main() {
	scanf("%d", &a);
	if (a != 1)
		printf("%d\n", (a * a * a * a - 1) / (a - 1) - 1);
	else
		printf("3\n");
}

Measured memory_bytes: 1732
/**
 * @author torith
 * @date 2018-10-01
 */

#include <bits/stdc++.h>

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        ans += tmp-1;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

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

int main()
{
	ll a, b, c, d, ans=0,buf1,buf2,buf3;

	cin >> a >> b >> c >> d;
	
	buf1 = b - b / c - b / d + b /(c*d/gcd(max(c, d), min(c, d)));
	buf2 = (a-1) - (a-1) / c - (a-1) / d + (a-1) / (c*d / gcd(max(c, d), min(c, d)));

	ans = buf1-buf2;

	cout << ans;

}


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

int main(void){
  int n,m,t,p;
  int a[2000];
  
  cin >> n >> m;
  t=0;
  for (int i=0; i<n; i++){
    cin >> a[i];
    t += a[i];
  }
  p=0;
  for (int i=0; i<n; i++){
    if (a[i]*4*m>=t) p++;
  }
  //cout << p << endl;
  cout << (p>=m?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

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

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

    // 素数である
    return true;
}

// a と b の最大公約数を返す関数
ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
  ll A,B,C,D;
  cin >> A>>B>>C>>D;
  ll tmp = A*C;
  tmp = max(tmp, A*D);
  tmp = max(tmp, B*C);
  tmp = max(tmp, B*D);
  
  cout << tmp << endl;

}

Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            if (n == k) {
                out.println(1);
                return;
            }

            out.println((n - 1 + (k - 1) - 1) / (k - 1));
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
using namespace std;
int main() {
    string w;
    cin >> w;
    array<int, 26> cnt {};
    for (char c : w) cnt[c - 'a']++;
    cout << (all_of(cnt.cbegin(), cnt.cend(), [](int i) { return i % 2 == 0; }) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

int main() {
  int m,k;
  cin >> m >> k;
  if(m==0){
    if (k==0){
      cout<<"0 0";
    }
    else cout<<"-1";
  }
  else if (m==1){
    if (k==0){
      cout<<"0 1 1 0";
    }
    else cout<<"-1";
  }
  else{
    ll temp=RepeatSquaring(2,m,INF);
    if (k>=temp)cout<<-1;
    else{
      cout<<k<<" ";
      rep(i,temp){
        if (i==k)continue;
        cout<<i<<" ";
      }
      cout<<k<<" ";
      rep(i,temp){
        if (temp-i-1==k)continue;
        cout<<temp-i-1<<" ";
      }


    }


  }
}


Measured memory_bytes: 3576
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine(800 * N - (N / 15) * 200);
        }
    }
}


Measured memory_bytes: 27308
a = list(input())
b = list(input())
c = list(input())

turn = "a"
while 1:
    if turn == "a":
        if len(a) > 0:
            turn = a.pop(0)
        else:
            print(turn.upper())
            break
    if turn == "b":
        if len(b) > 0:
            turn = b.pop(0)
        else:
            print(turn.upper())
            break
    if turn == "c":
        if len(c) > 0:
            turn = c.pop(0)
        else:
            print(turn.upper())
            break


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

const int MC=100010;
int N,M;
vector<pair<int,int>> V[MC];
bool b[MC];
int x[MC];

bool dfs(int q){
    b[q]=1;
    for(auto u : V[q]){
        if(b[u.first]){
            if(x[u.first]!=x[q]+u.second) return 0;
            continue;
        }
        else{
            x[u.first]=x[q]+u.second;
            if(!dfs(u.first)) return 0;
        }
    }
    return 1;
}

int main(){
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int l,r,d;
        cin>>l>>r>>d;
        V[l].push_back(make_pair(r,d));
        V[r].push_back(make_pair(l,-d));
    }
    for(int i=1;i<N+1;i++){
        if(b[i]) continue;
        if(!dfs(i)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
#include <bitset>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const int infty = 1000000007;

int N, M;
int edge[15][15];
int setcost[1 << 15];
int dp[1 << 15][15];

auto two(int x) {
  return static_cast<std::bitset<4> >(x);
}

int main() {
  cin >> N >> M;
  fill(&edge[0][0], &edge[0][0]+15*15, infty);
  for (auto i = 0; i < M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a][b] = c;
    edge[b][a] = c;
  }
  fill(setcost, setcost+(1 << 15), 0);
  for (auto i = 0; i < (1 << N); ++i) {
    for (auto j = 0; j < N; ++j) {
      if (((i >> j) & 1) == 0) continue;
      for (auto k = j+1; k < N; ++k) {
        if (((i >> k) & 1) == 0) continue;
        if (edge[j][k] == infty) continue;
        setcost[i] += edge[j][k];
      }
    }
  }
  fill(&dp[0][0], &dp[0][0]+(1 << 15)*15, infty);
  dp[1][0] = 0;
  for (auto x = 1; x < (1 << N); ++x) {
    for (auto i = 0; i < N; ++i) {
      if (((x >> i) & 1) == 0) continue;
      if (dp[x][i] >= infty) continue;
      // cerr << "x = " << two(x) << ", i = " << i << endl;
      // cerr << "nobashi" << endl;
      for (auto j = 0; j < N; ++j) {
        if (((x >> j) & 1) == 1 ||
            edge[i][j] == infty) {
          continue;
        }
        int z = x | (1 << j);
        dp[z][j] = min(dp[z][j],
                       dp[x][i] + setcost[z] - setcost[x] - edge[i][j]);
        // cerr << "setcost[" << two(z) << "] = " << setcost[z] << endl;
        // cerr << "setcost[" << two(x) << "] = " << setcost[x] << endl;
        // cerr << "edge[" << i << "][" << j << "] = " << edge[i][j] << endl;
        // cerr << "dp[" << two(z) << "][" << j << "] = " << dp[z][j] << endl;
      }
      // cerr << "tsuke" << endl;
      int z = (((1 << N)-1)^x) & ((1 << N)-1); // all \setminus x
      int w = x - (1 << i); // x \setminus \{ i \}
      int y = z;
      do {
        dp[x | y][i] = min(dp[x | y][i],
                           dp[x][i] + setcost[w | y] - setcost[w] - setcost[y]);
        // cerr << "dp[" << two(x | y) << "][" << i << "] = " << dp[x | y][i] << endl;
        y = (y - 1) & z;
      } while (y != z);
    }
  }
  cout << dp[(1 << N)-1][N-1] << endl;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  int X; cin>>X;
  if(X<600) cout<<"8";
  else if(X<800) cout<<"7";
  else if(X<1000) cout<<"6";
  else if(X<1200) cout<<"5";
  else if(X<1400) cout<<"4";
  else if(X<1600) cout<<"3";
  else if(X<1800) cout<<"2";
  else cout<<"1";
  cout<<endl;
  return 0;
}

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

int main() {
    int n, x;

    while (std::cin >> n >> x, n) {
        int ans = 0;
        for (int a = 1; a <= n; ++a) {
            for (int b = a + 1; b <= n; ++b) {
                for (int c = b + 1; c <= n; ++c) {
                    if (a + b + c == x) ans++;
                }
            }
        }

        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 3088
n = int(input())
a = list(map(int,input().split()))

a.sort()
ans=a[-1]
cnt=1
for i in range(n-2,0,-1):
    if cnt+2>=n-1:
        if cnt+2-n+1==0:
            ans+=2*a[i]
        else:
            ans+=a[i]
        break
    ans+=a[i]*2
    cnt+=2
print(ans)


Measured memory_bytes: 31432