akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


int main()
{
  int x, a;
  cin >> x >> a;
  if (x < a)
    cout << "0\n";
  else
    cout << "10\n";
  return 0;
}

Measured memory_bytes: 256
void main(){
	int a, b, c, k;
	readf("%d %d %d\n", &a, &b, &c);
	k = _scan();
	// k回の操作
	foreach(i; 0..k){
		// Cが他のどれよりも大きくない.
		if(c<=a || c<=b){
			c *= 2;
			continue;
		}
		// BがAより大きくない.
		if(b<=a){
			b *= 2;
			continue;
		}
	}
	// 結果
	bool MagicRes = true;
	if(c<=b || c<=b || b<=a)MagicRes=false;
	writeln(MagicRes? "Yes": "No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

using namespace std;

int
main()
{
  int H, W, N;
  cin >> H >> W >> N;
  int cnt = 0;
  int colored = 0;
  int l;
  H > W ? l = H : l = W;
  while (colored < N) {
    colored += l;
    cnt++;
  }
  cout << cnt << endl;
  return 0; 
}

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

using namespace std;

int mat[110][110];

typedef pair<int,int> P;

P edge[10010];

bool cmp(P a,P b)
{
    return mat[a.first][a.second]>mat[b.first][b.second];
}

int p[110];

void init(int n)
{
    for(int i=0;i<n;i++)
    {
        p[i]=i;
    }
}

int fnd(int x)
{
    if(p[x]!=x)
    {
        p[x]=fnd(p[x]);
    }
    return p[x];
}

bool unit(int a,int b)
{
    int fa=fnd(a),fb=fnd(b);

    if(fa!=fb)
    {
        p[fa]=fb;
    }
}

bool same(int a,int b)
{
    return fnd(a)==fnd(b);
}

int main()
{

    int n;
    cin>>n;

    int cnt=0;

    init(n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>mat[i][j];

            if(mat[i][j]!=-1)
            {
                edge[cnt++]=make_pair(i,j);
            }
        }
    }

    sort(edge,edge+cnt,cmp);

    int ans=0;
    while(cnt--)
    {
        P tmp=edge[cnt];

        if(!same(tmp.first,tmp.second))
        {
            ans+=mat[tmp.first][tmp.second];
            unit(tmp.first,tmp.second);
        }
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3188
fn main() {
    let v = read_vec::<u64>();
    let x = v[0];
    let y = v[1];

    let mut n = x;
    let mut ans = 0;
    while n <= y {
        ans += 1;
        n += n;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define maxn 505
using namespace std;
int n,x[maxn],a[maxn*maxn],c[maxn];
bool solve(){
	for(int i=1;i<=n*n;i++){
		for(int j=1;j<=n;j++) if(x[j]==i){
			if(++c[j]<j) return 0;
			a[i]=j; break;
		}
		if(a[i]) continue;
		int k=0;
		for(int j=1;j<=n;j++) if(x[j]>i&&c[j]<j-1&&x[j]<x[k]) k=j;
		if(k) {c[a[i]=k]++;continue;}
		for(int j=1;j<=n;j++) if(x[j]<i&&c[j]<n) {k=j;break;}
		if(k) c[a[i]=k]++;
		else return 0;
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&x[i]); x[0]=n*n+1;
	if(!solve()) return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=n*n;i++) printf("%d%c",a[i],i==n*n?10:32);
}

Measured memory_bytes: 2176
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	chars := strings.Split(s, "")

	var longest = ""
	var substring string
	for _, char := range chars {
		if strings.Contains("ATGC", char) {
			// pile chars up
			substring += char
		} else if len(substring) > len(longest) {
			longest = substring
			substring = ""
		} else {
			substring = ""
		}
	}

	if len(substring) > len(longest) {
		longest = substring
	}

	fmt.Println(len(longest))
}


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

int main(){
    char s[3];
    cin >> s;
    //cout << s<<endl;
    for(int i=0;i<3;i++){
        if(s[i]=='1')s[i]='9';
        else if(s[i]=='9')s[i]='1';
    }
    cout << s<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if ( m >= 2 * n ) {
        ans = n;
        m -= 2 * n;
//        cout << m << endl;
        ans += m / 4;
    }
    else {
        ans = m / 2;
    }
    cout << ans << endl;
    return 0;
}

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

string s;

int main(){

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

    cin>>s;
    if(s=="SUN")cout<<7<<endl;
    if(s=="MON")cout<<6<<endl;
    if(s=="TUE")cout<<5<<endl;
    if(s=="WED")cout<<4<<endl;
    if(s=="THU")cout<<3<<endl;
    if(s=="FRI")cout<<2<<endl;
    if(s=="SAT")cout<<1<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,y;
vector<int>v[100010];
int vi[100010];
long long dp[100010][2];
void dfs(int p){
	vi[p]=-2;
	dp[p][0]=1;
	dp[p][1]=1;
	for(int i=0;i<v[p].size();i++){
		int j=v[p][i];
		if(vi[j]==-2)continue;
		dfs(j);
		dp[p][0]=dp[p][0]%1000000007*(dp[j][0]+dp[j][1]);
		dp[p][1]=dp[p][1]%1000000007*dp[j][0];
	}
	dp[p][0]%=1000000007;
	dp[p][1]%=1000000007;
	vi[p]=-1;
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(n/2+1);
	cout<<(dp[n/2+1][0]+dp[n/2+1][1])%1000000007;
	return 0;
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
#define ll long long
#define Test int t;cin>>t;while(t--)
#define PI acos(-1)
#define endl "\n"
#define fx(x) fixed<<setprecision(x)
#define sz(s) s.size()
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
const double eps=1e-9;
const int mod=1e9+7;
int dx[]={-1,-1,-1,0,0,1,1,1};
int dy[]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll x,ll y) {return(!y)?x:gcd(y,x%y);}
ll lcm(ll x,ll y) {return((x/gcd(x,y))*y);}
using namespace std;
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const int N=(int)1e5+10;
int dp[3][N];
int a[N],n;
int solve(int p,int idx){
    if(idx>=n)return 1000000;
    if(idx==n-1)return 0;
    int &ret=dp[p][idx];
    if(ret!=-1)return ret;
    if(p==1)ret=abs(a[idx+1]-a[idx]),idx++;
    else ret=abs(a[idx+2]-a[idx]),idx+=2;
    ret+=min(solve(1,idx),solve(2,idx));
    return ret;
}
int main()
{
    fast();
    cin>>n;
    for(int i=1;i<3;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<min(solve(1,0),solve(2,0));
    return 0;
}


Measured memory_bytes: 7152
#include <iostream>
#include <string>
#include <queue>
#include <vector>
using namespace std;
int main() {
    int now = 0;
    vector<string> S(3);
    vector<queue<char>> q(3);
    cin >> S[0] >> S[1] >> S[2];
    for (int i = 0; i < 3; i++) for (int j = 0; j < S[i].size(); j++) q[i].push(S[i][j]);
    while (q[now].front()) {
        int next = q[now].front() - 'a';
        q[now].pop();
        now = next;
    }
    cout << (char)(now + 'a' - 0x20) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		final int x=sc.nextInt();
		int xmin=x;
		int xmax=x;
		int n=sc.nextInt();
		int p[]=new int[n];
		for (int i = 0; i <n; i++) {
			p[i]=sc.nextInt();
		}
		boolean flag=true;
		while (flag) {
			flag=false;
			for (int i = 0; i <n; i++) {
				if(xmin==p[i]){flag=true;xmin--;break;}
			}
		}
		flag=true;
		while (flag) {
			flag=false;
			for (int i = 0; i <n; i++) {
				if(xmax==p[i]){flag=true;xmax++;break;}
			}
		}
		if(Math.abs(xmin-x)<=Math.abs(xmax-x)){System.out.println(""+xmin);}
		else if(Math.abs(xmin-x)>=Math.abs(xmax-x)){System.out.println(""+xmax);}
}
}

Measured memory_bytes: 38976
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())
A, B = inpl()
P = inpl()

a, b, c = 0, 0, 0
for p in P:
    if p <= A:
        a += 1
    elif A < p <= B:
        b += 1
    else:
        c += 1
print(min(a, b, c))

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = A + B, R = C + D;
    if (L > R) {
        cout << "Left" << endl;
    } else if (L == R) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define _USE_MATH_DEFINES
# define M_PI 3.14159265358979323846
# define MOD 1000000007
#define ll long long int
#define pii pair<ll, ll>
#define pb push_back
#define MIN -9,223,372,036,854,775
#define N 100005
#define all(v) v.begin(),v.end()

void solve(){
    ll i,j,k,n,ans=0;
    cin>>n;
    ll v[n];
    for(i=0;i<n;i++){
        cin>>v[i];
    }
    for(i=1;i<n;i++){
        if(v[i]<v[i-1]){
            ans += v[i-1]-v[i];
            v[i] = v[i-1];
        }
      //cout<<i<<" "<<ans<<"\n";
    }
    cout<<ans;
}

int main() {
    ll t=1;
	//cin>>t;
	while( t-- ){
	    solve();
	    cout<<"\n";
	}

	return 0;
}
/*

3
33 27
6 10
5 6
100 200
10 10
5 5
1 19
1 3
19 5

*/


Measured memory_bytes: 4756
#include <bits/stdc++.h>
#include <cmath>
#define ll double
#define pi 3.1415926535897932384626433
#define l long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    l a,b,c,k,dif1=0,dif2=0;
    cin>>a>>b>>c>>k;
    if(k<=a)
    cout<<k<<endl;
    else if(k>a)
    {
        dif1=k-a;
        if(dif1<=b)
        cout<<a<<endl;
        else
        {
            dif2=dif1-b;
        cout<<a-dif2<<endl;
        }
    }
}


Measured memory_bytes: 3556
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a%b!=0)<<endl;
}






Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Set;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int K = sc.nextInt();
        Set<String> set = new TreeSet<String>();
        for(int i = 0;i < s.length();i++){
            for(int j = 1;j <= K;j++){
                if(i+j > s.length()){
                    break;
                }
                set.add(s.substring(i,i+j));
            }
        }
        //System.out.println(Arrays.toString(set.toArray()));
        int it = 0;
        for(String str : set){
            if(it == K-1){
                System.out.println(str);
            }
            it++;
        }
    }
}


Measured memory_bytes: 25380
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
  int N;
  cin >> N;
  ll sum=0;
  int ans;
  for(int i=1; i<=N; i++){
    sum += i;
    if(sum>=N){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    if((n + 1) / 2 >= k) printf("YES\n");
    else printf("NO\n");
}

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

int main() {
  int n;
  while(1) {
    cin>>n;
    if(!n) break;
    int c = 5,sum = 0;;
    while(c<=n) {
      sum += n/c;
      c *= 5;
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
 
int main() {
	int M[28],A[31],o=0;
	for(int i=0;i<28;i++){
		cin >> M[i];
	}
	for(int i=0;i<28;i++){
		A[M[i]]=M[i];
	}
	for(int i=1;i<31;i++){
		if(A[i]==i){
 
		}
		else{
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A1 = RD;
	auto A2 = RD;
	auto A3 = RD;

	writeln(A1+A2+A3 >= 22 ? "bust" : "win");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_min = min(a)
b_min = min(b)
ans = a_min + b_min

for i in range(M):
    x,y,c = list(map(int, input().split()))
    w = a[x-1] + b[y-1] - c
    if w < ans:
        ans = w

print(ans)

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


int main(){
ll n; cin>>n;
ll iron[200000];
ll rui1[200000];
ll rui2[200000];
ll zen = 0;
for(int i = 0;i<n;i++)cin>>iron[i], zen+=iron[i];
rui1[0]=0;
rui2[0]=zen;
for(int i=0;i<n;i++){
rui1[i+1]=rui1[i]+iron[i];
rui2[i+1]=rui2[i]-iron[i];
}
ll ans = 202020202020;
for(int i=0;i<n;i++){
ll kari=abs(rui1[i]-rui2[i]);
ans=min(kari,ans);
}
cout<<ans<<endl;
}


Measured memory_bytes: 4992
//  Super Star Aizu - 1231 
//  status:
//  time:
//  main.cpp
//  Created by livin2 on 18/04/20.
//  Copyright © 2017年 livin2. All rights reserved.
//  Note:#
//#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
//#include <map>
//#include <fstream>
using namespace std;
const int precision = 100000;
const double DZERO = 1e-9;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
struct pos
{
	double x, y,z;
	pos() {}
	pos(double x,double y,double z):x(x),y(y),z(z){}
	void moveRand(double step);
};
double len(const pos &a,const pos &b)
{
	return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y) + (a.z - b.z)*(a.z - b.z));
}
double Rand()
{
	return (double)(rand() % precision) / precision;
}

struct SuperStar
{
	int n;
	//double X, Y;
	double maxX = 100.0;
	double Dstep, ans;
	pos ansp;
	static const int pRandNum = 40;
	static const int stepRandNum = 20;
	const double minDstep = 1e-6;
	const double ratio = 0.98;
	vector<pos> P;
	vector<double> Rs;
	vector<pos> ansPs;
	SuperStar(int n);
	pos posRand();
	double getRadius(const pos &p);
	bool isInRange(const pos &p);
	void solve();
};
int main()
{
	double x, y;int n;
	while (cin>>n&&n)
	{
		SuperStar exp(n);
		exp.solve();
		cout <<fixed<<setprecision(5)
			<<exp. ans << endl;
	}
	return 0;
}

SuperStar::SuperStar(int n):n(n),Rs(pRandNum), ansPs(pRandNum)
{
	double xx, yy,zz;
	for (int i = 0; i < n; i++)
	{
		cin >> xx >> yy>>zz;
		P.push_back(pos(xx,yy,zz));
	}
	Dstep = sqrt(2) * maxX / sqrt(n);//sqrt (2) *...
}
void pos::moveRand(double step)
{
	double ang = Rand() * 2 * PI;
	z += step * sin(ang);
	double xy = step * cos(ang);
	ang = Rand() * 2 * PI;
	x += xy * cos(ang);
	y += xy * sin(ang);
	
}
pos SuperStar::posRand()
{
	double x = maxX * Rand();
	double y = maxX * Rand();
	double z = maxX * Rand();
	return pos(x,y,z);
}

double SuperStar::getRadius(const pos &p)
{
	double res = 0;
	for (int i = 0; i < P.size(); i++)
		res = max(res,len(P[i],p));
	return res;
}

bool SuperStar::isInRange(const pos & p)
{
	if (p.x > DZERO&&p.x - maxX <= DZERO && p.y > DZERO&&p.y - maxX <= DZERO && p.z > DZERO&&p.z - maxX <= DZERO)
		return true;
	return false;
}



void SuperStar::solve()
{
	//init
	for (int i = 0; i < pRandNum; i++)
	{
		ansPs[i] = posRand();
		Rs[i] = getRadius(ansPs[i]);
	}
	//SA
	while (Dstep>minDstep)
	{
		for (int i = 0; i < pRandNum; i++)
		{
			pos cur = ansPs[i];
			for (int j = 0; j < stepRandNum; j++)
			{
				cur.moveRand(Dstep);
				if (isInRange(cur))
				{
					double rad = getRadius(cur);
					if (rad < Rs[i])
					{
						Rs[i] = rad;
						ansPs[i].x = cur.x;
						ansPs[i].y = cur.y;
						ansPs[i].z = cur.z;
					}
				}
			}
		}
		Dstep *= ratio;
	}
	//
	ans = INF;
	ansp = ansPs[0];
	for (int i = 0; i < pRandNum; i++)
	{
		if (Rs[i] < ans)
		{
			ans = Rs[i];
			ansp = ansPs[i];
		}
	}
}





Measured memory_bytes: 3544
while True:
    m, f, r = map(int, (input().split()))
    score = m + f
    if m == f == r == -1:
        break
    else:
        if m == -1 or f == -1:
            print("F")
        elif score >= 80:
            print("A")
        elif 80 > score >= 65:
            print("B")
        elif 65 > score >= 50:
            print("C")
        elif 50 > score >= 30 and r >= 50:
            print("C")
        elif 50 > score >= 30 and r < 50:
            print("D")
        else:
            print("F")

Measured memory_bytes: 6724
k=gets.to_i
s=gets.chomp
 s.length
if k>=s.length
  puts s
else
line=[]
line.push(s.chars)
ary=[]
k.times do |i|
ary[i]=line[0][i]
  

end
if k<s.length
  ary.push('...')
end
   puts str = ary.join
end

Measured memory_bytes: 14352
import java.util.Scanner;

public class Main {

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

	    long N=gl();
	    long M=gl();

	    long a=(M*1900) + (N-M)*100;
	    a=(long)(a*Math.pow(2, M));



	    System.out.print(a);
	}

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

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

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

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

Measured memory_bytes: 35588
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int main(void){
  int i,N;
  map<string,int> memo;
  cin >> N;
  string str,pre;
  bool flg = true;
  REP(i,N){
    cin >> str;
    if(i==0){
      memo[str] = 1;
      pre = str;
      continue;
    }
    if(memo.count(str) == 1 || pre[pre.length()-1] != str[0]){
      flg = false;
    }
    memo[str]=1;
    pre=str;
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>

using namespace std;

int main(){
    int k,a,b;

    cin >> k >> a >> b;

    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl; return 0;
        }
    }
    cout << "NG" << endl;



    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int A;
  int B;
  int C;
  cin >> A >> B >> C;
 
  if(A + B + C >= 22){
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
arr = [input() for _ in range(n)]
dic = {}
for i in range(n):  # 各単語の出現回数を数える
    if arr[i] not in dic:
        dic[arr[i]] = 1
    else:
        dic[arr[i]] += 1
largest = max(dic.values())  # 最大の出現回数を求める
ans = []
for keys in dic.keys():
    if dic[keys] == largest:  # 出現回数が最も多い単語を集計する
        ans.append(keys)
ans = sorted(ans)  # 単語を辞書順に並べ替えて出力する
for words in ans:
    print(words)


Measured memory_bytes: 35216
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static boolean KYS(String S) {
        ArrayList<String> A = new ArrayList();
        for (int I = 0; I < S.length(); I++) {
            if (!A.contains(S.charAt(I) + "")) {
                A.add(S.charAt(I) + "");
            } else {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        boolean B = KYS(S);
        if (B) {
            System.out.println("yes");
        } else {
            System.out.println("no");
        }

    }
}

//Learn Before You Earn


Measured memory_bytes: 21844
S=input()
mae=int(S[0]+S[1])
usiro=int(S[2]+S[3])

maeMM = True if 0< mae and mae<13 else False
usiroMM =True if 0< usiro and usiro<13 else False

if maeMM and usiroMM:
    print('AMBIGUOUS')
elif maeMM:
    print('MMYY')
elif usiroMM:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
    int x1,x2,x3,x4,y1,y2,y3,y4;
    while(cin>>x1>>y1>>x2>>y2){
        x4=x1-(y2-y1);
        y4=y1+x2-x1;
        x3=x2-(y2-y1);
        y3=y2+x2-x1;
        cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> a >> b;
  if(a%b==0) std::cout << -1 << '\n';
  else{
    std::cout << a << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fastio1 ios_base::sync_with_stdio(false)
#define fastio2 cin.tie(NULL)
#define ll long long
#define MOD 1000000007
using namespace std;
 
int main(){
    fastio1; fastio2;
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	int maxBits = 45;
	ll tracker[maxBits];
	for (int i = 0; i < maxBits; i++){
		tracker[i] = 0;
	}
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
		ll temp = a[i];
		int b = 0;
		while(temp > 0){
			tracker[b] += (temp % 2);
			temp /= 2;
			b++;
		}
	}
	
	
	ll x = 0;
	for (int i = maxBits-1; i >= 0; i--){
		if (tracker[i] < n-tracker[i]){
			if (x + (1LL<<i) <= k){
				x += (1LL<<i);
			}
		}
	} 
	
	ll total = 0;
	for (int i = 0; i < n; i++){
		total += x^a[i];
	}
	cout << total << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
typedef map<int,ll> mi;
int n,m;
ll a[100010];
mi mp;
int main(){
  scan(n);scan(m);
  rep(i,n)scan(a[i]);
  ll s[100010];//累積和
  ll sum=0;
  s[0]=0;
  rep(i,n){
    sum+=a[i];
    s[i+1]=sum;
  }
  rep(i,n+1){
    mp[s[i]%m]++;
  }
  ll res=0;
  for(auto ite=mp.begin();ite!=mp.end();ite++){
    ll a=ite->second;
    res+=a*(a-1)/2;
  }
  prin(res);
  
  return 0;
}


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

int main() {
    int N, W;
    cin >> N >> W;

    vector<int> weight(N + 1);
    vector<int> val(N + 1);

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

    vector<vector<long long>> dp(N + 1, vector<long long>(W + 1));


    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= W; j++) {
            dp[i][j] = dp[i - 1][j];

            if (j >= weight[i]) {
                dp[i][j] = max(dp[i][j], val[i] + dp[i - 1][j - weight[i]]);
            }
        }
    }

    cout << dp[N][W] << endl;
}

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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n+1000);
    for(int i = 0;i < n;i ++){
        cin >> h.at(i);
    }
    vector<int> dp(n+1000,1000000000);

    dp.at(0) = 0;

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

        for(int j = 1;j < k+1;j ++){
            dp.at(i+j) = min(dp.at(i+j), dp.at(i) + abs(h.at(i+j) - h.at(i)));
        }
    }

    cout << dp.at(n-1) << endl;

}


Measured memory_bytes: 1024
n, a, b = map(int, raw_input().split())
s = raw_input()

bs = 0
passed = 0
for i in range(len(s)):
	if s[i] == 'a':
		if passed < a+b:
			print 'Yes'
			passed += 1
		else:
			print 'No'
	elif s[i] == 'b':
		if passed < a+b and bs < b:
			print 'Yes' 
			bs += 1
			passed += 1
		else:
			print 'No'
	if s[i] == 'c':
		print 'No'

Measured memory_bytes: 6276
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val n = sc.nextInt()
        val s = Array(n) { sc.nextInt() }

        val f = Array(10001) { false }
        f[0] = true
        s.forEach {
            for (i in 10000 downTo 0) {
                if (f[i]) f[i + it] = true
            }
        }

        for (i in 10000 downTo 0) {
            if (f[i] && i % 10 != 0) {
                println(i)
                return
            }
        }
        println("0")
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 38256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<climits>

#define FASTREAD      ios_base::sync_with_stdio(0);cin.tie(nullptr);
#define ll long long
#define dd double
#define scl(n)        scanf("%lld",&n)
#define scd(n)        scanf("%lf",&n)
#define scc(n)        scanf("%c",&n)
#define scs(n)        scanf("%s",&n)
#define ptl(n)        printf("%lld",n)
#define ptd(n)        printf("%f",n)
#define ptc(n)        printf("%c",n)
#define pts(n)        printf("%s",n)
#define nline         printf("\n")
#define pb            push_back
#define FOR(i,a,b)    for(ll i=a;i<=b;i++)
#define FORr(i,a,b)   for(ll i=a;i>=b;i--)
#define pi            2*acos(0.0)
#define pii           pair<ll,ll>
#define uu            first
#define vv            second

using namespace std;
ll dp[105][100005];
int main()
{
    ll n,W,w[105],v[105],op1,op2;
    scl(n);
    scl(W);
    FOR(i,1,n)
    {
        scl(w[i]);
        scl(v[i]);
    }
    dp[n+1][0]=0;
    FORr(i,n,1)
    {
        FOR(j,0,W)
        {
            if(j-w[i]>=0)
                op1=dp[i+1][j-w[i]]+v[i];
            else
                op1=LONG_MIN;
            op2=dp[i+1][j];
            dp[i][j]=max(op1,op2);
        }
    }
    ptl(dp[1][W]);
    nline;
    return 0;
}


Measured memory_bytes: 81832
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[200001];

bool check(int x) {
	map<int, int> str;	//(桁の位置(0-indexed), 桁の値(0～x-1)). (pos, 0)以外を記録.
	int i;
	
	for (i = 1; i < n; i++) {
		if (a[i] > a[i - 1]) continue;
		while (!str.empty() && str.rbegin()->first >= a[i]) str.erase(str.rbegin()->first);
		str[a[i] - 1]++;
		
		int cur = a[i] - 1;
		while (str[cur] >= x) {
			str.erase(cur);
			cur--;
			str[cur]++;
			if (cur < 0) { return false; }
		}
	}
	return true;
}

int main() {
	int i;
	
	cin >> n;
	a[0] = 0;
	rep(i, n) cin >> a[i + 1];
	n++;
	
	//check(1)を呼び出すと,桁上がりの処理がO(A_i)回行われる可能性があるので、答え=1かの判定は先にやる
	bool ok1 = true;
	for (i = 1; i < n; i++) if (a[i] <= a[i - 1]) ok1 = false;
	if (ok1) { cout << 1 << endl; return 0; }
	
	//2分探索
	int st = 1, ed = n, mid;	//xxxooo, (st, ed]
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (check(mid)) ed = mid;
		else st = mid;
	}
	cout << ed << endl;
	return 0;
}

Measured memory_bytes: 1024
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)
'''
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt=  0
i = 1
cycle = ['1']

for c in range(n):
    i = a[i-1]
    if(i in cycle):
        break
    else:
        cycle.append(i)

ind = cycle.index(i)
k-= ind
rcycle = cycle[ind:]
if(k <= 0):
    print(cycle[k+ind])
else:
    now = (k+1)%len(rcycle)
    print(rcycle[now-1])
'''
n,k = map(int,input().split())
a = list(map(int,input().split()))
already = ["1"]
set = {"1"}
now = 1
 
for i in range(n):
    now = str(a[int(now)-1])
    if now in set:
        break
    else:
        already.append(now)
        set.add(now)
 
 
ind = already.index(now)
k -= ind
cycle = already[ind:]
 
if k <= 0:
    print(already[k+ind])
else:
    now = (k+1) % len(cycle)
    print(cycle[now-1])

Measured memory_bytes: 102980
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n;
  cin>>k;
  vector<int> vec;
  for(int i=0;i<n;i++){
      int c;
      cin>>c;
      vec.push_back(c);
      
  }
  sort(vec.begin(),vec.end());
  int ans=0;
  for(int i=0;i<k;i++){
      ans+=vec[i];
  }
  cout<<ans;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long r = count(begin(s), end(s), 'R');
  long long g = count(begin(s), end(s), 'G');
  long long b = count(begin(s), end(s), 'B');
  auto res = r * g * b;
  for (int j = 1; j < n; ++j) {
    for (int i = 0; i < j; ++i) {
      int k = 2 * j - i;
      if (k < n) {
        res -= s[i] != s[j] and s[j] != s[k] and s[k] != s[i];
      }
    }
  }
  cout << res << '\n';
}


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

int main() {
  int N;
  cin>>N;
  vector<int> l(N);

  for(int i=0;i<N;i++) cin>>l[i];
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=N-1;i>=2;i--){
    int a=l[i];
    for(int j=i-1;j>=1;j--){
      int b=l[j];
      auto it = lower_bound(l.begin(),l.end()-(N-j),a-b+1);
      int idx = it-l.begin();
      if(j-idx>0) ans +=j- idx;

    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

long long gcd(long long a, long long b){
    while(b!=0){
        long long r = a%b;
        a=b;
        b=r;
    }
    return a;
}
 
using namespace std;
int main() {
    double n;
    cin >> n;
    
    cout << 2*n*3.14159265358979 << endl;
    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    ll ans=0;
    FOR(i,1,n+1){
        int t=n-i;
        for(int i=1;i*i<=t;i++){
            if(t%i==0){
                ans++;
                if(i*i!=t){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
// comment
// easy
#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

int N;
char S[MAX_N];
int main() {
	scanf("%s", S+1);
	N = strlen(S+1);
	bool isCan = true;
	isCan &= (S[1] == '1');
	isCan &= (S[N] == '0');
	for(int i=1; i<N; i++) isCan &= (S[i] == S[N-i]);
	if(not isCan) {
		puts("-1");
		return 0;
	}
	int head = 1, ix = 1, now = 1;
	vector<pi> Ans;
	for(int i=2; i<N; i++) {
		if(S[i] == '1') {
			Ans.emplace_back(head, ++ix);
			head = ix;
			for(int k=now+2; k<=i; k++) {
				Ans.emplace_back(head, ++ix);
			}
			now = i;
		}
	}
	Ans.emplace_back(head, ++ix);
	for(auto v: Ans) {
		int x, y; tie(x, y) = v;
		printf("%d %d\n", x, y);
	}
	return 0;
}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, c ;
  cin >> a >> b >> c ;
  int d = max({a,b,c}) ;
  int e = min({a,b,c}) ;
  int f = (a+b+c)-(e+d) ;
  
  cout << 10*d+e+f <<endl ;
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,j,k;
	int h,w;

	for (i = 0; 1; i++)
	{
		scanf("%d %d",&h,&w);

		if (h == 0 && w == 0)break;

		for(j = 0; j < h ; j++)
		{
			for (k = 0; k < w; k++)
			{				
				printf("#");
			}
			
			printf("\n");
		}

		printf("\n");
		
	}

	return 0;
}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct LazySegmentTree {
private:
    int n;
    vector<ll> node,lazy;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = node[i*2+1]+node[i*2+2];
    }

    void eval(int k,int l,int r) {
        if (lazy[k] != 0) {
            node[k] += lazy[k];
            if (r-l > 1) {
                lazy[2*k+1] += lazy[k]/2;
                lazy[2*k+2] += lazy[k]/2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a,int b,ll x,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        eval(k,l,r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] += (r-l)*x;
            eval(k,l,r);
        } else {
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = node[2*k+1]+node[2*k+2];
        }
    }

    ll getsum(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        eval(k,l,r);
        if (a <= l && r <= b) return node[k];
        ll vl = getsum(a,b,k*2+1,l,(l+r)/2);
        ll vr = getsum(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    LazySegmentTree seg(vector<ll>(n,0));
    for (int i = 0;i < q;++i) {
        int c,s,t;
        cin >> c >> s >> t;
        if (c) cout << seg.getsum(s-1,t) << endl;
        else {
            int x;
            cin >> x;
            seg.add(s-1,t,x);
        }
    }
    return 0;
}


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

using namespace std;

int main() {
    string s = "";
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import math


def solve():
    n, k = map(int, input().split())
    exp = 0
    for i in range(1,  n + 1):
        if i >= k:
            exp += 1
        else:
            dice_num = math.ceil(math.log2(k / i))
            exp += 0.5 ** dice_num
    return exp / n


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


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    ll n,d,a; cin >> n >> d >> a;
    vector<P> mon(n);
    rep(i,n) cin >> mon[i].first >> mon[i].second;
    sort(all(mon));

    ll sbt=0;
    ll ans=0;
    queue<P> rv;
    rep(i,n){
        for(;;){
            if(rv.empty()) break;
            else{
                if(rv.front().first<mon[i].first){
                    sbt-=rv.front().second;
                    rv.pop();
                }
                else break;
            }
        }
        ll times=((mon[i].second-sbt-1)/a)+1;
        if(mon[i].second-sbt>0){
            ans+=times;
            rv.push(P(mon[i].first+2*d,times*a));
            sbt+=times*a;
        }
    }
    
    cout << ans << endl;
return 0;
}




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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back

int main() {
	int n; scanf("%d", &n);
	
	switch (n % 10) {
		case 3:
			puts("bon");
			return 0;
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			puts("hon");
			return 0;	
	}
	puts("pon");
}

Measured memory_bytes: 3764
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

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

using namespace std;
using lint=long long;

struct interval{
	int a,b;
	interval():a(0),b(0){}
	interval(const int &a,const int &b):a(a<b?a:b),b(a<b?b:a){}
};

bool cmp_l(const interval &I,const interval &J){ return tie(I.a,I.b)<tie(J.a,J.b); }
bool cmp_r(const interval &I,const interval &J){ return tie(I.b,I.a)<tie(J.b,J.a); }

int main(){
	int n; scanf("%d",&n);
	vector<interval> I(n);
	rep(i,n) scanf("%d%d",&I[i].a,&I[i].b);

	lint ans=0;
	rep(_,2){
		multiset<interval,decltype(&cmp_l)> L(&cmp_l);
		multiset<interval,decltype(&cmp_r)> R(&cmp_r);
		for(auto J:I){
			L.emplace(J);
			R.emplace(J);
		}

		lint res=0;
		int x=0;
		while(1){
			bool ok=false;
			if(!L.empty()){
				auto J=*L.rbegin();
				if(x<J.a){
					res+=J.a-x;
					x=J.a;
					L.erase(L.find(J));
					R.erase(R.find(J));
					ok=true;
				}
			}
			if(!R.empty()){
				auto J=*R.begin();
				if(J.b<x){
					res+=x-J.b;
					x=J.b;
					L.erase(L.find(J));
					R.erase(R.find(J));
					ok=true;
				}
			}
			if(!ok) break;
		}
		res+=abs(x);

		ans=max(ans,res);
		rep(i,n){
			I[i].a*=-1;
			I[i].b*=-1;
			swap(I[i].a,I[i].b);
		}
	}
	printf("%lld\n",ans);

	return 0;
}


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

long long solve(long long N){
    if(N%2!=0)return 0;
    long long ans = 0;
    N /= 2;
    while(N){
        ans += N/5;
        N /= 5;
    }
    return ans;
}





int main(){
    long long N;
    cin>> N;
    cout << solve(N) << endl;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;


int main() {
	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3084
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};

use itertools::Itertools;

use maplit::*;

use proconio::{input, fastout};
use proconio::marker::*;

const INF: usize = 1_000_000_007;

#[fastout]
fn solve() {
  input! {
    n: usize, m: usize, q: usize,
    ps: [(usize, usize, usize, i64); q],
  };

  let mut seq = (1..=m).combinations_with_replacement(n);
  let mut res = 0i64;
  while let Some(s) = seq.next() {
    let mut score = 0;
    for p in &ps {
      let (a, b, c, d) = p;
      if s[a - 1] + *c == s[b - 1] {
        score += d;
      }
    }
    res = max(res, score);
  }

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

fn main() {
  std::thread::Builder::new()
    .name("big stack size".into())
    .stack_size(32 * 1024 * 1024)
    .spawn(|| {
      solve();
    })
    .unwrap()
    .join()
    .unwrap();
}

Measured memory_bytes: 2244
import java.util.Scanner;

class MODnCk {
    private static final int mod = 1000000007;

    private static int[] factorialCache = new int[8000];
    private static int factorialCacheIdx = 0;

    static{
        factorialCache[0] = 1;
    }
    
    static int nCk(int n, int k){
        return div((div(factorial(n), factorial(k))), factorial(n-k));
    }

    private static int factorial(int n){
        if(factorialCacheIdx < n){
            setFactorialCache(factorialCacheIdx+1, n);
        }

        return factorialCache[n];
    }

    private static void setFactorialCache(int s, int e){
        for(int i=s; i<=e; i++){
            factorialCache[i] = mul(factorialCache[i-1], i);
        }
        factorialCacheIdx = e;
    }

    private static int div(int a, int b){
        return mul(a, modinv(b));
    }

    static int mul(int a, int b){
        long x = (long)a * (long)b;
        return (int)(x % mod);
    }

    private static int modinv(int a) {
        int b = mod;
        int u = 1;
        int v = 0;
        while (b != 0) {
            int t = a / b;
            a -= t * b;
            int temp = a; a = b; b = temp; // swap(a, b)
            u -= t * v;
            temp = u; u = v; v = temp; // swap(u, v)
        }
        u %= mod;
        if (u < 0) u += mod;
        return u;
    }
}

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
		int n = stdIn.nextInt();
		int k = stdIn.nextInt();

		for(int i=1; i<=k; i++){
			if(n-k+1 < i){
				System.out.println(0);
			}else{
				System.out.println(MODnCk.mul(MODnCk.nCk(k-1, i-1), MODnCk.nCk(n-k+1, i)));
			}
		}
	}
}


Measured memory_bytes: 36472
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
# define maxi 100000
# define maxw 100000
# define maxn 100

int main() {
  int n,a[maxn],color[9]={0},cnt(0);
  cin>>n;
  for(int i(0);i<n;i++){
    cin>>a[i];
    int rank=a[i]/400;
    if (rank<=7){
      if (color[rank]==0) cnt+=1;
      color[rank]+=1;
    }else{
      color[8]+=1;
    }
  }
  if (cnt==0){
    cout << 1 <<" "<< cnt+color[8]<<endl;
  }else{
    cout << cnt <<" "<< cnt+color[8]<<endl;
  }
  return 0;
}


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

bool vis[101];

int main()
{
	int x, n;
	cin >> x >> n;
	
	if(n == 0) {
		printf("%d", x);
		return 0;
	}
	
	int arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		vis[arr[i]] = true;
	}
	
	for(int i = 0; i <= x; i++) {
		for(int j = -1; j <= 1; j++) {
			int ab = x + j*i;
			if(!vis[ab]) {
				printf("%d", ab);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3744