akhauriyash/Code-Regression huggingface dataset:
'use strict';
(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  const N=input[0],
        K=input[1],
        L=N-K+1,
        M=(1e9+7);
  function sum(a,b){
    return (a+b)%M;
  }
  function mult(a,b){
    let a1=(a>>18),
        a2=(a>>9)-(a1<<9),
        a3=a-(a1<<18)-(a2<<9),
        A=[a3,a2,a1],
        b1=(b>>18),
        b2=(b>>9)-(b1<<9),
        b3=b-(b1<<18)-(b2<<9),
        B=[b3,b2,b1];
    let r=0;
    for(let i=0;i<3;i++){
      for(let j=0;j<3;j++){
        let m=(A[i]*B[j])%M;
        for(let k=0;k<i+j;k++){
          m=(m*(1<<9))%M;
        }
        r=sum(r,m);
      }
    }
    return r;
  }
  const combination=new Array(N+1).fill(0).map((zero,n)=>new Array(n+1).fill(1));
  for(let n=2;n<N+1;n++){
    for(let k=1;k<n;k++){
      combination[n][k]=sum(combination[n-1][k-1],combination[n-1][k]);
    }
  }
  const ans=[];
  for(let I=0;I<K;I++){
    let i=I+1;
    if(L<i){
      ans.push(0);
      continue;
    }
    ans.push(mult(combination[L][i],combination[K-1][i-1]));
  }
  console.log(ans.join('\n'));
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 53220
fn solve(k: i64, hs: Vec<i64>) -> i64 {
    use std::cmp::max;

    let n = hs.len();
    let mut dp = vec![std::i64::MAX; n];
    dp[0] = 0;

    for i in 1..n {
        let m = max(i as i64 - k, 0) as usize;
        for j in m..i {
            if dp[i] > dp[j] + (hs[i] - hs[j]).abs() {
                dp[i] = dp[j] + (hs[i] - hs[j]).abs();
            }
        }
    }

    dp[n - 1]
}

#[test]
fn solve_test() {
    assert_eq!(solve(3, vec![10, 30, 40, 50, 20]), 30);
    assert_eq!(solve(1, vec![10, 20, 10]), 20);
    assert_eq!(solve(100, vec![10, 10]), 0);
    assert_eq!(solve(4, vec![40, 10, 20, 70, 80, 10, 20, 70, 80, 60]), 40);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (_n, k) = parse_line!(usize, i64);
    let hs = parse_vec!(i64);
    println!("{}", solve(k, hs));
}


Measured memory_bytes: 6396
module Main where

  import Data.Functor

  main :: IO ()
  main = do
    { [a, b] <- getInts
    ; if a < b then putStrLn "a < b"
      else if a > b then putStrLn "a > b"
           else putStrLn "a == b"
    }

  getInts :: IO [Int]
  getInts = map read . words <$> getLine

Measured memory_bytes: 3592
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int *read(int &n, int &k) {
    cin >> n >> k;
    int *v = new int[n + 1];
    for (int i = 1; i <= n; ++i)
        cin >> v[i];

    return v;
}

int main() {
    int n, k;
    int *h = read(n, k);
    int *dp = new int[n + 1];
    for (int i = 0; i <= n; ++i) {
        dp[i] = 0;
    }

    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);

    //cout << dp[2] << ' ';

    for (int i = 3; i <= n; ++i) {
        int MIN = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 2; j <= k && i - j >= 1; ++j) {
            MIN = min(dp[i - j] + abs(h[i] - h[i - j]), MIN);
        }
        dp[i] += MIN;
    }

    cout << dp[n] << '\n';
    free(h);
    free(dp);
    return 0;
}

Measured memory_bytes: 1024
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N;
    cin >> N;
    cout << (N + 1) / 2 << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		
		if(n/10==9 || n%10==9) System.out.println("Yes");
		else System.out.println("No");
	}
} 

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> v(n+1),ans(n+1),sum(n+1),ans2;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    for(int i=n;i;i--){
        for(int j=i+i;j<=n;j+=i)
            sum[i]+=ans[j];
        sum[i]%=2;
        if(v[i]!=sum[i])
            ans[i]=1;
    }
    for(int i=1;i<=n;i++)
        if(ans[i])
            ans2.push_back(i);
    cout<<ans2.size()<<"\n";
    prArr(ans2,ans2.size());
    return 0;
}


Measured memory_bytes: 6052
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0,max=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i>0){
      if(a[i]<=a[i-1]){
        ans++;
        if(ans>=max)
        max=ans;
      }else{
        ans=0;
      }
    }
  }
  cout<<max<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
     if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005;
int a[N],f[N],A[N],B[N];
vector<int> v;
int main(){
	int n=read();
	ll k=read();
	For(i,1,n)a[i]=read();
	Rep(i,n,1)A[a[i]]=i;
	f[n+1]=1;
	Rep(i,n,1){
		if(B[a[i]])f[i]=f[B[a[i]]+1];
		else f[i]=A[a[i]]+1;
		B[a[i]]=i;
	}
	int cnt=1;
	for(int i=f[1];i!=1;i=f[i])cnt++;
	k%=cnt;
	int jb=n+1;
	For(i,1,k)jb=f[jb]; //cout<<jb<<endl;
	memset(B,0,sizeof(B));
	For(i,jb,n){
		if(B[a[i]]){
			while(B[a[i]]){
				B[v.back()]=0;
				v.pop_back();
			}
		}else {
			B[a[i]]=1;
			v.pb(a[i]);
		}
	}
	for(auto i:v)wri(i);
}
/*
1212
*/

Measured memory_bytes: 5492
n, m, q = map(int, input().split())
image = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    image[l - 1][r - 1] += 1
sumimage = [[0] * (n + 1) for _ in range(n + 1)]
for l in range(1, n + 1):
    s = 0
    for r in range(1, n + 1):
        s += image[l - 1][r - 1]
        sumimage[l][r] = sumimage[l - 1][r] + s
for _ in range(q):
    a, b = map(int, input().split())
    c = sumimage[b][b] - sumimage[a - 1][b]
    print(c)


Measured memory_bytes: 58840
from collections import defaultdict


def dfs(v, t):
    if start[v] == 0:
        start[v] = t
        t += 1
    else:
        return t

    for nv in graph[v]:
        t = dfs(nv, t)

    end[v] = t
    t += 1

    return t


n = int(input())

graph = defaultdict(list)

for _ in range(n):
    u, k, *v = map(int, input().split())
    for v in v:
        graph[u].append(v)

start = [0] * (n + 1)
end = [0] * (n + 1)


t = 1

for i in range(1, n + 1):
    t = dfs(i, t)

for i in range(1, n + 1):
    print(i, start[i], end[i])


Measured memory_bytes: 6112
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int x,y,z;cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
	int n;
	ll k;
	cin>>n>>k;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	vector<int> next(n+1,-1);
	vector<int> fst(200001,-1);
	vector<int> cnt(200001,0);
	vector<int> mp(200001,-1);
	{
		for(int i = 0; i < n; i++) {
			if(fst[arr[i]]==-1) {
				fst[arr[i]] = i;
			}
			if(mp[arr[i]]==-1) {
				mp[arr[i]]=i;
			}else {
				next[mp[arr[i]]]=i;
				mp[arr[i]]=i;
			}
			cnt[arr[i]]++;
		}
	}
	/*
	for(int i = 0; i < n; i++) {
		cout << next[i] << " ";
	}
	cout << endl;
	*/
	vector<int> loop;
	loop.push_back(n);
	while(true) {
		int p = loop[loop.size()-1];
		//cout << "start " << p << endl;
		if(p==n) p=0;
		else {
			//if(next[p]==-1&&cnt[arr[p]]>=2&&(cnt[arr[p]]%2)==1) {
			if(next[p]==-1&&cnt[arr[p]]>=2) {
				p = fst[arr[p]]+1;
				//cout << "fst" << endl;
				//cout << p << endl;
			}else {
				p++;
				if(p==n) break;
			}
		}
		while(p<n&&next[p]>=0) {
			p = next[p]+1;
			//cout << "jmp" << endl;
			//cout << p << endl;
		}
		//cout << "end " << p << endl;
		if(p==n) break;
		loop.push_back(p);
	}
	/*
	for(int i = 0; i < loop.size(); i++) {
		cout << loop[i] << " ";
	}
	cout << endl;
	*/

	k %= (ll)loop.size();
	int start_index = loop[k];

	vector<int> ans;
	for(int i = start_index; i < n; i++) {
		//cout << i << endl;
		while(next[i]>=0) {
			//cout << "next " << next[i] << endl;
			/*
			cout << "i" << i << endl;
			cout << "arr" << arr[i] << endl;
			cout << "next" << next[i] << endl;
			*/
			i = next[i]+1;
		}
		//cout << i << endl;
		if(i<n) {
			ans.push_back(arr[i]);
		}
	}
	if(ans.size()>0) {
		cout << ans[0];
		for(int i = 1; i < ans.size(); i++) {
			cout << " " << ans[i];
		}
		cout << endl;
	}
}


Measured memory_bytes: 7156
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;


int main(){
	int n,m;
	cin >> n;
	string s[n];
	rep(i,n) cin >> s[i];

	cin >> m;
	string t[m];
	rep(i,m) cin >> t[i];

	int ans = 0;
	rep(i,n){
		int tmp = 0;
		rep(j,n){
			if(s[i] == s[j])tmp++;
		}
		rep(j,m){
			if(s[i] == t[j])tmp--;
		}
		if(ans < tmp) ans = tmp;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
A=(int)(input())
B=(int)(input())
C=(int)(input())
X=(int)(input())

count = 0
a_ = X//500
if a_>A:
    a_ = A
for a in range(a_+1):
    x_ = X-a*500
    b_ = x_//100
    if b_>B:
        b_ = B
    for b in range(b_+1):
        x = x_-b*100
        c_ = x//50
        if c_<=C and c_>=0:
            count = count + 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int c,a,b,al=1,bf;
int main()
{
    cin>>a>>b;
    bf=b;
    while(bf){
        al*=10;
        bf/=10;
    }
    c=a*al+b;
    int k=sqrt(c);
    if(k*k!=c) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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


void solve(long long a, std::string s){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;cin >> A;
    string s;cin >> s;

    if(A >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char a,b;
    cin >> a >> b;
    if (a=='H')
    {
      cout << b << endl;
    }
    else if (b=='H')
    {
      cout << 'D' << endl;
    }
    else
    {
      cout << 'H' << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int n;
    cin >> n;

    int *a = new int[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int *b = new int[n];
    for (int i = 0; i < n; i++){
        cin >> b[i];
    }
    int *c = new int[n-1];
    for (int i = 0; i < n-1; i++){
        cin >> c[i];
    }

    int sum = 0;

    for (int i = 0; i < n; i++){
        sum += b[a[i] - 1];
        if (i != 0 && (a[i] - a[i-1] == 1)){
            sum += c[a[i-1] - 1];
        }
    }

    cout << sum << endl;

}

Measured memory_bytes: 888
#include<iostream>

using namespace std;
typedef long long ll;
const int N =1e5+5;
ll a[N];

int main(){
	int n;
	cin>>n;
	a[0]=-1;
	ll ans=0,temp=0;	
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<=a[i-1]) temp++;
		else temp=0;
		ans=max(ans,temp);
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    ll n,q;
    while(true){
        cin>>n>>q;
        if(n==0&&q==0)break;
        map<int,int>ma;
        for(int i=0;i<n;i++){
            int m;
            cin>>m;
            for(int j=0;j<m;j++){
                int d;
                cin>>d;
                ma[d]++;
            }
        }
        int ans1=0,ans2=0;
        for(auto itr=ma.begin();itr!=ma.end();++itr){
            int x=itr->second;
            if(x>=q){
                if(x>ans2){
                    ans1=itr->first;
                    ans2=x;
                }
            }
        }
        cout<<ans1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3012
package main

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

func fill(s []int, x int) {
	for i := 0; i < len(s); i++ {
		s[i] = x
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func readKey() [2]int {
	a := readInt()
	b := readInt()
	m := 0
	for i := 0; i < b; i++ {
		c := readInt()
		m |= 1 << uint(c-1)
	}
	return [2]int{a, m}
}

func main() {
	N := readInt()
	M := readInt()
	keys := make([][2]int, M)
	for i := 0; i < M; i++ {
		keys[i] = readKey()
	}

	dp := make([][]int, M+1)
	for i := 0; i < M+1; i++ {
		dp[i] = make([]int, 1<<uint(N))
		fill(dp[i], math.MaxInt64)
	}

	dp[0][0] = 0
	for i := 0; i < M; i++ {
		a, m := keys[i][0], keys[i][1]
		for j := 0; j < 1<<uint(N); j++ {
			if dp[i][j] == math.MaxInt64 {
				continue
			}
			dp[i+1][j|m] = min(dp[i+1][j|m], dp[i][j]+a)
			dp[i+1][j] = min(dp[i+1][j], dp[i][j])
		}
	}
	if dp[M][(1<<uint(N))-1] == math.MaxInt64 {
		fmt.Println(-1)
	} else {
		fmt.Println(dp[M][(1<<uint(N))-1])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 33920
a,b,c,x,y = map(int,input().split())
z = 0
s=0
if a+b < c*2:
    z = a*x + b*y
else:
    mi = min(x,y)
    z = mi*2*c
    if x > y:
        s = (x-mi)*a
        if s > c * 2 * (x-mi):
            s = (x-mi)*c * 2
    else:
        s = (y-mi)*b
        if s > c * 2 * (y-mi):
            s = (y-mi)*c * 2
z += s
            
print(z)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    map<int, vector<int>> mp;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        mp[a].push_back(b);
        mp[b].push_back(a);
    }
    vector<int> leaf;
    map<int, int> dist;
    map<int, bool> visited;
    queue<int> que;
    rep(i, 1, n + 1)
    {
        if (mp[i].size() == 1)
        {
            que.push(i);
            visited[i] = true;
            dist[i] = 0;
            break;
        }
    }
    while (!que.empty())
    {
        int node = que.front();
        visited[node] = true;
        que.pop();
        if (mp[node].size() == 1)
            leaf.push_back(node);
        rep(i, mp[node].size())
        {
            int next = mp[node][i];
            if (visited[next] == false)
            {
                dist[next] = dist[node] + 1;
                que.push(next);
            }
        }
    }

    int diam = 0;
    int snode = -1;
    rep(i, leaf.size())
    {
        if (diam < dist[leaf[i]])
        {
            diam = dist[leaf[i]];
            snode = leaf[i];
        }
    }

    vector<int> leaf2;
    map<int, int> dist2;
    map<int, bool> visited2;
    queue<int> que2;
    que2.push(snode);
    visited2[snode] = true;
    dist2[snode] = 0;
    while (!que2.empty())
    {
        int node = que2.front();
        visited2[node] = true;
        que2.pop();
        if (mp[node].size() == 1)
            leaf2.push_back(node);
        rep(i, mp[node].size())
        {
            int next = mp[node][i];
            if (visited2[next] == false)
            {
                dist2[next] = dist2[node] + 1;
                que2.push(next);
            }
        }
    }

    diam = 0;
    rep(i, leaf2.size())
    {
        diam = max(diam, dist2[leaf2[i]]);
    }
    cerr << diam << endl;
    diam++;
    if (diam == 2)
    {
        cout << "Second" << endl;
    }
    else if (diam == 3)
    {
        cout << "First" << endl;
    }
    else if (diam % 3 != 2)
    {
        cout << "First" << endl;
    }
    else
    {
        cout << "Second" << endl;
    }
    return 0;
}


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

void fnInput(vector<int> &rvnSort)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvnSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnMerge(vector<int> &rvnSort, int &rnSortCnt, int nLeft, int nMid, int nRight)
{
  vector<int> vnLeft, vnRight;
  int nLeftSiz = nMid - nLeft;
  int nRightSiz = nRight - nMid;

  vnLeft.resize(nLeftSiz + 1);
  vnRight.resize(nRightSiz + 1);

  for (int i = 0; i < nLeftSiz; i++)
    vnLeft[i] = rvnSort[nLeft + i];
  for (int i = 0; i < nRightSiz; i++)
    vnRight[i] = rvnSort[nMid + i];

  vnLeft[nLeftSiz] = INT_MAX;
  vnRight[nRightSiz] = INT_MAX;
  int i = 0, j = 0;

  for (int n = nLeft; n < nRight; n++)
  {
    if (vnLeft[i] <= vnRight[j])
      rvnSort[n] = vnLeft[i++];
    else
      rvnSort[n] = vnRight[j++];
    rnSortCnt++;
  }
}

void fnMergeSort(vector<int> &rvnSort, int &rnSortCnt, int nLeft, int nRight)
{
  if (nLeft + 1 < nRight)
  {
    int nMid = (nLeft + nRight) / 2;
    fnMergeSort(rvnSort, rnSortCnt, nLeft, nMid);
    fnMergeSort(rvnSort, rnSortCnt, nMid, nRight);
    fnMerge(rvnSort, rnSortCnt, nLeft, nMid, nRight);
  }
}

void fnResult(const vector<int> &cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i != 0)  cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnSort;

  fnInput(vnSort);

  int nLeft = 0;
  int nRight = vnSort.size();
  int nSortCnt = 0;
  fnMergeSort(vnSort, nSortCnt, nLeft, nRight);

  fnResult(vnSort, nSortCnt);

  return 0;
}

Measured memory_bytes: 5068
from fractions import gcd
n,x = map(int,input().split())
a = list(map(int, input().split()))
a.append(x)
a = sorted(a)
b = [0]*n
for i in range(n):
    b[i]= a[i+1]-a[i]
c = 0
for j in b:
    c = gcd(c, j)
print(c)

Measured memory_bytes: 16240
from bisect import bisect_left
N=int(input())
inp=[int(i)for i in input().split()]
inp.sort()
ma=inp[-1]
idx = bisect_left(inp[0:-1], ma//2)
if idx >= len(inp)-1:
    if idx >= len(inp)-1:
        print(ma, inp[idx-1])
    else:
        print(ma, inp[idx])
elif abs(inp[idx] - ma//2) < abs(ma//2 - inp[idx - 1]) or abs(ma - inp[idx] - ma//2) < abs(ma//2 - inp[idx - 1]):
    print(ma, inp[idx])
else:
    print(ma, inp[idx-1])


Measured memory_bytes: 14056
#coding: utf-8
S = list(input())
zero, one = ["0"] * len(S), ["0"] * len(S)
for i in range(1, len(S)+1):
    if i % 2 == 0:
        zero[i-1] = "1"
    else:
        one[i-1] = "1"
c1, c2 = 0, 0
for i in range(len(S)):
    if S[i] != zero[i]:
        c1 += 1
    elif S[i] != one[i]:
        c2 += 1
print(min(c1, c2))

Measured memory_bytes: 5544
from collections import Counter
N, M = list(map(int, input().split()))
results = []
for _ in range(M):
    p, s = input().split()
    results.append((int(p), s))

wa_counter = Counter() # ACされていない問題についてのWAのカウンタ
is_active = [True for _ in range(N)] # ACしたかどうか。Trueのとき、まだACされてない。
for p, s in results:
    p -= 1
    if s == 'WA':
        if is_active[p]:
            wa_counter[p] += 1
        else:
            pass
    elif s == 'AC':
        if is_active[p]:
            is_active[p] = False
        else:
            pass

correct = 0 # ACした問題の数
incorrect = 0 # ACした問題のACするまでのWAの数
for i in range(N):
    if is_active[i] is False: # ACされている
        correct += 1
        incorrect += wa_counter[i]
print(correct, incorrect)

Measured memory_bytes: 67032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, x, m;
    cin >> n >> x >> m;
    VL dp(min(n, m) + 10, 0LL);
    set<ll> st;
    map<ll,ll> mp;
    ll next = x;
    ll unit = -1, srt, end;
    dp[1] = x;
    st.insert(x);
    mp[x] = 1;
    rep(i, 2, n+1) {
        ll cur = next;
        next = (cur * cur) % m;
        dp[i] = (dp[i-1] + next);
        if(st.count(next)) {
            srt = mp[next];
            end = i;
            unit = end - srt;
            break;
        } 
        st.insert(next);
        mp[next] = i;
    }
    if(unit == -1) {
        cout << dp[n] << endl;
        return 0;
    }
    ll ans = 0;
    ans += dp[srt-1];
    ll rem = n - srt + 1;
    ll mat = rem / unit;
    ans += (dp[end-1] - dp[srt-1]) * mat;
    ll nokori = rem - mat * unit;
    ans += dp[srt + nokori - 1] - dp[srt - 1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9500
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9+7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void solve() {
	string s;
	cin >> s;
	ll n = s.size();
	string t = s;
	reverse(all(t));
	bool flag = true;
	if (s != t) flag = false;
	string s1 = s.substr(0, (n - 1) / 2);
	string s2 = s.substr((n + 1) / 2, (n - 1) / 2);

	t = s1;
	reverse(all(t));
	if (s1 != t) flag = false;

	t = s2;
	reverse(all(t));
	if (s2 != t) flag = false;

	cout << (flag ? "Yes" : "No") << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;


int main(void) {

    int n;
    string s;
    cin>>n>>s;
    rep(i,s.size()){
        s[i]=(s[i]-'A'+n+26)%26+'A';
    }
    fin(s);
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, p; //p:num of people
  cin >> N;
  for( int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    p += r - l + 1;
  }
  cout << p << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }
    let mut counter = HashMap::new();
    for x in a {
        let count = counter.entry(x).or_insert(0);
        *count = 1 - *count;
    }
    println!("{}", counter.values().sum::<i32>())
}


Measured memory_bytes: 10492
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    s = input()
    ans = 0
    for i in range(len(s)//2):
        if s[i] != s[len(s)-1-i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#define ullint unsigned long long int

// ?????°???(a^b %d ????¨????)
int modpow(ullint a, ullint b, long int d) {
  if (b == 0)     return 1;
  if (b % 2 == 0) return modpow(a*a % d, b/2, d);
  else            return a*modpow(a, b-1, d) % d;
}

// Miller???Rabin?´???°?????????
bool Miller_Rabin_Test(int n){
    int prime_list[4] = {2, 7, 61};

    if(n == 2 || n == 7 || n == 61){  // 2,7,61????´???°
        return true;
    }
    if(n == 1 || n%2 == 0){  // 2??\????????¶??°??¨1????´???°??§??????
        return false;
    }
    // n = 2^s*d + 1 (d????\???°)?????¢????????¢
    int d = n-1;
    int s = 0;
    while(d%2 == 0){  // d????\???°??????????????§?????¢
        d = d/2;
        s++;
    }
    for(int i=0; i<3; i++){  // ??????????????????3???
        bool isProbPrime = false;
        int a = prime_list[i];
        int r = modpow(a, d, n);
        if(r == 1 || r == n-1){
            isProbPrime = true;
            continue;
        }
        for(int j=0; j<s; j++){
            r = modpow(a, pow(2,j)*d, n);
            if(r == n-1){
                isProbPrime = true;
                break;
            }
        }
        if(!isProbPrime){
            return false;
        }
    }
    return true;
}

int Primenum[1000000];

int main(){
    Primenum[1] = 0;
    for(int i=1; i<=1000000; i++){
        if(Miller_Rabin_Test(i)){
            Primenum[i] = Primenum[i-1] + 1;
        }else{
            Primenum[i] = Primenum[i-1];
        }
    }
    for(int n; scanf("%d\n",&n) != EOF;){
        printf("%d\n",Primenum[n]);
    }
    return 0;
}

Measured memory_bytes: 6720
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int cnt =0;

        for(int i = 0; i < 3; i++) {
        	if(String.valueOf(s.charAt(i)).equals(String.valueOf(t.charAt(i)))){
        		cnt++;
        	}
        }
        System.out.println(cnt);
        
        sc.close();
    }
}


Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<ll>a,b;
    ll sm=0;
    for(int i=0;i<=n;i++){
        ll val;
        cin>>val;
        a.push_back(val);
        sm+=val;
    }
    for(int i=0;i<n;i++){
        ll val;
        cin>>val;
        b.push_back(val);
    }
    for(int i=0;i<n;i++){
        ll qw=a[i];
        a[i]=max((ll)0,a[i]-b[i]);
        b[i] = max((ll)0,b[i]-qw);
        if(b[i]>0){
        a[i+1]=max((ll)0,a[i+1]-b[i]);
        }
    }
    ll sum=0;
    for(auto q:a){
        sum+=q;
    }
    cout<<sm-sum<<'\n';
    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//????????¨???????????????????????°??????????????\?????????????????????

#define MAX 100

using Weight = int;
struct Edge {
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s = 0, int d = 0, int w = INF) : s(s), d(d), w(w) {};
};
using Edges = vector<Edge>;
//???????????\???
//g[u].push_back(Edge(u, v, c));
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

//?????¢?´¢, ??¢?´¢???, ??¢?´¢???
enum { WHITE, GRAY, BLACK };

//???????§????????????? (Dijkstra)
//dist: ?§????????????????????????§??????????????¢
//prev: ???????????¨????????????
void dijkstra(Graph g, int s, vector<Weight> &dist, vector<int> &prev) {
	typedef tuple<Weight, int, int> State; //?§?????????????????°?????????? ??? ???
	priority_queue<State, vector<State>, greater<State> >PQ;
	vector<int> color(g.size(), WHITE);
	dist.assign(g.size(), INF); //distance
	prev.assign(g.size(), -1);
	dist[s] = 0; PQ.push(State(0, s, -1)); color[s] = GRAY; //?§????
	while (!PQ.empty()) {
		Weight d; int v; int u;
		tie(d, v, u) = PQ.top(); PQ.pop(); //dist???????°??????¨??????????´????????????????
		if (dist[v] < d) continue; //?????§???????????§???????????°??????
		color[v] = BLACK;
		prev[v] = u;
		for (auto e : g[v]) { //??£??\????????????????????¨????????????		
			if (color[e.d] == BLACK)continue; //??¢?´¢????????????
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				PQ.push(State(dist[e.d], e.d, v));
				color[e.d] = GRAY;
			}
		}
	}
}

//?§?????????????????????§??????????????????
//???????????????????????°?????????????§??????????????????§?????????????????¢????????????
vector<int> getPath(int s, int g, vector<int> prev) {
	vector<int> path;
	for (int i = g; i != s; ) path.push_back(i = prev[i]);
	reverse(path.begin(), path.end());
	return path;
}

//???????????????
void printPath(vector<int> path) {
	cout << "Path: ";
	for (auto p : path) cout << p << " ";
	cout << endl;
}

int main() {
	int n; cin >> n;
	Graph g(n);
	for (int i = 0; i < n; i++) {
		int u, k; scanf("%d%d", &u, &k);
		for (int j = 0; j < k; j++) {
			int v, c; scanf("%d%d", &v, &c);
			g[u].push_back(Edge(u, v, c));
		}
	}
	vector<Weight> dist;
	vector<int> prev;
	dijkstra(g, 0, dist, prev);
	for (int i = 0; i < n; i++) {
		printf("%d %d\n", i, dist[i]);
		//printPath(getPath(0, i, prev));
	}
	return 0;
}

Measured memory_bytes: 3332
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;

  int count=0;
  for(int i=0;i<s.size()/2;i++) {
    if(s[i]!=s[s.size()-i-1])
      count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;



public class Main{
	public static void main(String[] a)  throws IOException
	{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		int[] num = new int[10];
		for(int i=0; i<10; i++){
			num[i] = Integer.parseInt(br.readLine());
		}
		Arrays.sort(num);
		for(int i=num.length-1; i>num.length-4; i--){
			System.out.println(num[i]);
		}
		}
}

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

int main(){
  int k,x;
  cin >> k >> x;
  vector<int> a(k*2-1);
  int cnt=0;
  for(int i=x-(k-1);i<=x+(k-1);i++){
    a[cnt]=i;
    cnt++;
  }
  for(int i=0;i<k*2-1;i++){
    cout << a[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long[] an = new long[5];
        an[0] = sc.nextLong();
        an[1] = sc.nextLong();
        an[2] = sc.nextLong();
        an[3] = sc.nextLong();
        an[4] = sc.nextLong();

        long min = Long.MAX_VALUE;
        for(int i =0;i < 5;i++){
            min = an[i] < min ? an[i] : min;
        }
        long ans = (long)Math.ceil((double)(n-min)/min);
        System.out.println(ans+5);
    }
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i <= 9; ++i)
    for(int j = 0; j <= 9; ++j)
    for(int k = 0; k <= 9; ++k) {
        bool flag1 = false, flag2 = false, flag3 = false;
        for(int z = 0; z < n; ++z) {
            int tmp = s[z] - '0';
            if(!flag1) {
                if(tmp == i) flag1 = true;
            }
            else if(flag1 && !flag2) {
                if(tmp == j) flag2 = true;
            }
            else if(flag1 && flag2) {
                if(tmp == k) {
                    flag3 = true;
                    break;
                }
            }
        }
        if(flag3) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3672
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int i = 0,j;
    int num[] = new int[100000];
    while(true){
      num[i] = stdIn.nextInt();
      if(num[i] == 0){
        break;
      }
      i++;
    }


    for(j = 0;j < i;j++){
      System.out.println("Case " + (j + 1) + ": " + num[j]);
    }
  }
}

Measured memory_bytes: 43392
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(a+b>c+d)cout<<"Left"<<"\n";
    else if(a+b==c+d)cout<<"Balanced"<<"\n";
    else cout<<"Right"<<"\n";

    return 0;
}


Measured memory_bytes: 256
import numpy as np

n = input()
a = list(map(int, input().split()))

x = np.array(a)
cnt = 0
for i in range(1,100):
    if (x % 2 == 0).sum() == int(n):
        x = x/2
        cnt += 1
    else:
        break
print(cnt)

Measured memory_bytes: 12500
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;

char s[N],t[N];
int S[N],T[N];
int n,m,a,b,c,d;

int main(){
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	For(i,1,n+1) S[i]=S[i-1]+(s[i]=='A'?1:2);
	For(i,1,m+1) T[i]=T[i-1]+(t[i]=='A'?1:2);
	for (int q=IN();q--;){
		a=IN(),b=IN(),c=IN(),d=IN();
		puts((S[b]-S[a-1])%3==(T[d]-T[c-1])%3?"YES":"NO");
	}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int a , b,  c , d;
    cin >> a >> b >> c >> d;

    int num1 = (a / d) + (a%d != 0);
    int num2 = (c / b) + (c%b != 0);

    if(num1 >= num2){
        cout << "Yes\n";
    }
    else cout << "No\n";
    return 0;
}

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

// 総数を1000000007で割った余り
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 func(long long n, std::vector<long long> a) {
    vll left(n + 1), right(n + 1);
    left[1]  = a[0];
    right[1] = a[n - 1];
    rep(i, n) {
        left[i + 1]  = gcd(left[i], a[i]);
        right[i + 1] = gcd(right[i], a[n - 1 - i]);
    }

    ll ans = left[n];
    rep(i, n) {
        ll res;
        if (i == 0) {
            res = right[n - 1];
        } else if (i == n - 1) {
            res = left[n - 1];
        } else {
            res = gcd(left[i], right[n - 1 - i]);
        }
        ans = max(ans, res);
    }
    cout << ans << endl;

    return 0;
}

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

    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    func(N, std::move(A));
    return 0;
}


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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (ll i = j; i <= n; i++)
#define down(i,j,n)	for (ll i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

int main(){
	ll n, k, ans = 0; scanf("%lld%lld", &n, &k);
	up (b, k + 1, n) {
		ll cl = k, cr = b - 1;
		ans += (cr - cl + 1) * ((n + 1) / b);
		if (cl == 0) ans--;
		if ((n + 1) % b == 0) continue;
		cmin(cr, n % b);
		if (cl <= cr) ans += cr - cl + 1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = map(int, input().split())

c = Counter(a)

ans = 0
items = sorted([item for item in c.most_common() if item[1] >= 2], key=lambda x: x[0], reverse=True)
if len(items):
    x, count = items[0]
    y = 0
    if count >= 4:
        y = x
    else:
        if len(items) > 1:
            y, _ = items[1]
    ans = x * y

print(ans)




Measured memory_bytes: 24104
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
int main(){
  int N; int T; cin>>N>>T;
  vector<vector<int>> S(N,vector<int>(2));
  int A=0; //TLEしないルート数
  int B=1001; //コスト
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin>>S.at(i).at(j);
     
    }
    if(S.at(i).at(1)<=T){
      A++;
     B=min(B,S.at(i).at(0));
    }
  }
  if(A!=0)
    cout<<B<<endl;
  else cout<<"TLE"<<endl;
}
  


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
  int x;cin>>x;
  for(int i=x;i<=2*x;i++){
    bool flag=true;
    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){
        flag=false;
        break;
      }
    }
    if(flag){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256