akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--) //ループ変数は1ずつデクリ
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--) //ループ変数は1ずつデクリ
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) ll(x.size())      // sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007    // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

int main() {
    string s;
    cin >> s;
    ll cnt = 0;
    REP(i, s.length()) {
        if (s[i] == '1') {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3592
S = input().split()
a, b, c, d = int(S[0]), int(S[1]), int(S[2]), int(S[3])
if abs(c - a) <= d:
    print('Yes')
else:
    if abs(b - a) <= d and abs(c - b) <= d:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <atcoder/all>

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using namespace atcoder;

using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint t; cin >> t;
  for (int i = 0; i < t; i++) {
    lint n, m, a, b; cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << endl;
  }
  return 0;
}


Measured memory_bytes: 3208
using System;
using static System.Console;

public class C
{
  static void Main()
  {
    var s = ReadLine();
    var t = '0';
    var ansBW = 0;
    foreach(var c in s)
    {
      if (t != c) ansBW++;
      t = t == '0' ? '1' : '0';
    }
    t = '1';
    var ansWB = 0;
    foreach (var c in s)
    {
      if (t != c) ansWB++;
      t = t == '0' ? '1' : '0';
    }
    WriteLine(Math.Min(ansBW, ansWB));
  }
}

Measured memory_bytes: 13280
def partition(A, p, r):
    x = A[r]
    i = p - 1

    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i + 1], A[r] = A[r], A[i + 1]

    return i + 1


def main():
    n = int(input())
    A = list(map(int, input().split()))

    p = partition(A, 0, n - 1)

    print(*A[0: p], end=" ")
    print(f"[{A[p]}]", end=" ")
    print(*A[p + 1:])


if __name__ == "__main__":
    main()



Measured memory_bytes: 16400
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, t, A;
	scanf("%d %d %d", &n, &t, &A);
	double best = (-1) ^ (1 << 31);
	int ans = -1;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		double tmp = t - a*0.006;
		if (fabs(tmp-A) < fabs(best-A)) {
			best = tmp;
			ans = i + 1;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
a = list("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")

for i in range(len(s)):
  for j in range(26):
    if s[i] == a[j]:
      s[i] = a[j + n]
      break

for i in s:
  print(i, end = "")

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

set<int>s;
bool digit(int n) {
	while (9 < n) {
		if (s.count(n % 10))return false;
		n /= 10;
	}
	if (s.count(n))return false;
	return true;
}

int main() {
	int n, k, d,ans=0;
	cin >> n >> k;
	rep(i, n) {
		cin >> d;
		s.insert(d);
	}
	for (int i = n; i <= i * 10; i++) {
		if (digit(i)) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;

long long int lucas(int n)
{
  long long int l[n+2];
  l[0]=2;
  l[1]=1;
  int i;
  for(i=2;i<=n;++i)
       l[i]=l[i-1]+l[i-2];
  
  return l[n];
}
 
int main()
{
  int n;
  scanf("%d",&n);
  printf("%lld",lucas(n));
}

Measured memory_bytes: 256
// abc174_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;



template <typename T>
struct RangeTree {
    int n;
    vector<vector<T>> dat;
    vector<T> val;

    explicit RangeTree(vector<T>& val_): val(val_) {
        n = 1;
        while (n < val.size()) n <<= 1;
        dat.assign(n << 1, vector<T>());

        build(0, 0, val.size());
    }

    void build(int k, int l, int r) {
        if (r-l == 1) {
            dat[k].emplace_back(val[l]);
        } else {
            int lch = 2*k+1, rch = 2*k+2;
            build(lch, l, (l+r)/2);
            build(rch, (l+r)/2, r);
            dat[k].resize(r-l);
            merge(dat[lch].begin(), dat[lch].end(), dat[rch].begin(), dat[rch].end(), dat[k].begin());
        }
    }

    int query(int i, int j, T x) {
        return query(i, j, x, 0, 0, val.size());
    }

    int query(int i, int j, T x, int k, int l, int r) {
        if (j <= l || r <= i) return 0;
        // x以下の要素の数
//        if (i <= l && r <= j) return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
        // x未満の要素の数
        if (i <= l && r <= j) return lower_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
        int lch = query(i, j, x, 2*k+1, l, (l+r)/2);
        int rch = query(i, j, x, 2*k+2, (l+r)/2, r);
        return lch+rch;
    }
};


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, Q;
//    cin >> N >> Q;
    scanf("%d", &N);
    scanf("%d", &Q);
    vector<int> C(N);
//    REP(i, N) {scanf("%d", cin >> C[i]; C[i]--;}
    REP(i, N) {scanf("%d", &C[i]); C[i]--;}

    vector<int> last(N, N);
    vector<int> nxt(N);
    REP_REV(i, N){
        nxt[i] = last[C[i]];
        last[C[i]] = i;
    }

    // [l,r)で、r未満の要素の数を数える
    RangeTree<int> rt(nxt);

    REP(i, Q){
        int l, r;
//        cin >> l >> r; l--;
        scanf("%d", &l); l--;
        scanf("%d", &r);
        int ans = r - l - rt.query(l, r, r);
//        print(ans);
        printf("%d\n", ans);
    }


    return 0;
}


Measured memory_bytes: 98804
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int> 
#define N (1<<7)

int n,m;
char a[55][55],b[55][55];

bool _check(int x,int y)
{
	if(x+m>n||y+m>n)return false;
	for(int i=x;i<x+m;i++)for(int j=y;j<y+m;j++)
	{
		if(a[i][j]!=b[i-x][j-y])return false;
	}
	return true;
}

int main()
{
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>b[i];
	rep(i,n)rep(j,n)
	if(_check(i,j)==true)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	for(int i=0; i<x; i++){
		cin >> a[i];
	}
	for(int i=0; i<y; i++){
		cin >> b[i];
	}
	for(int i=0; i<z; i++){
		cin >> c[i];
	}
	vector<ll> d;
	for(int i=0; i<x; i++){
		for(int j=0; j<y; j++){
			d.push_back(a[i]+b[j]);
		}
	}
	sort(d.rbegin(), d.rend());
	vector<ll> ans;
	for(int i=0; i<min((int)d.size(), k); i++){
		for(int j=0; j<z; j++){
			ans.push_back(d[i]+c[j]);
		}
	}
	sort(ans.rbegin(), ans.rend());
	for(int i=0; i<k; i++){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 43368
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;



int main() {
    int n, ans=INF;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        int count = 0;
        while (1) {
            if (t % 2 != 0) break;
            else {
                count++;
                t /= 2;
            }
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

char sd[1000];
int main()
{
	scanf("%s",sd);
	if(strlen(sd)<4) puts("No\n");
	else if(sd[0]=='Y'&&sd[1]=='A'&&sd[2]=='K'&&sd[3]=='I')
		puts("Yes\n");
	else puts("No\n");
	return 0 ;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		long st = 1, sa = 1;
		long INF = (long)1e18;
		for(int i=0;i<n;i++) {
			int t = fs.nextInt(), a = fs.nextInt();
			long l = 0, r = INF/Math.max(t, a)+100;
			while(l+1<r) {
				long c = (l+r)/2;
				if(t*c>=st&&a*c>=sa)r=c;
				else l=c;
			}
			st = t*r;
			sa = a*r;
		}
		long ans = st + sa;
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

Measured memory_bytes: 22740
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		long[] a=new long[n];
		long[] b=new long[n];
		long[] c=new long[n];
		long d=0,e=0;
		for(int i=0;i<n;i++){
			a[i]=int.Parse(Console.ReadLine());
		}
		Array.Sort(a);
		if(n%2==0){
			for(int i=0;i<n/2;i++){b[i*2+1]=a[i];}
			for(int i=n/2;i<n;i++){b[(i-n/2)*2]=a[i];}
		}
		else{
			for(int i=0;i<n/2;i++){b[i*2+1]=a[i];}
			b[n-1]=a[n/2];
			for(int i=n/2+1;i<n;i++){b[(i-n/2)*2-2]=a[i];}
			for(int i=n-1;i>n/2;i--){c[i-(n-i)]=a[i];}
			c[n-1]=a[n/2];
			for(int i=0;i<n/2;i++){c[n-((i+1)*2)-1]=a[i];}
		}
		for(int i=1;i<n;i++){
			d+=Math.Abs(b[i-1]-b[i]);
			e+=Math.Abs(c[i-1]-c[i]);
		}
		Console.WriteLine("{0}",Math.Max(d,e));
	}
}

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

#define MAXN 55
#define EPS 1e-6
#define g 9.8
#define PI acos(-1)

struct Obstacle
{
    int l;
    int r;
    int t;
    int b;
} ob[MAXN];

int n,v,tx,ty;
double a,b,c;

void getabc(double angle)
{
    double vx = v * cos(angle); //x?方向速度
    double vy = v * sin(angle); //y?方向速度
    a = -0.5 * g / (vx * vx);
    b = vy / vx;
    c = 0;
}

bool check1(double x, double up, double down)    //是否会撞到障碍物的左（右）?端或者左（右）底端
{
    if(x >= tx)   //如果障碍物的x坐?在猪的x坐?的右?，?就算会撞到也不要?（?炸??死猪不受?障碍物影?）
        return false;
    double y = a * x * x + b * x + c;   //求出相?的y坐?
    if(up <= y && y <= down)    //会撞到
        return true;
    return false;
}

bool check2(double y, double left, double right)
{
    double delta = b * b - 4 * a * y;
    if(delta < 0)   //抛物?与障碍物上（下）的左端和右端形成的?段没有交点，?不会相撞
        return false;
    delta = sqrt(delta);
    double x1 = (-b + delta) / (2 * a);
    double x2 = (-b - delta) / (2 * a);
    if(x1 < tx && left <= x1 && x1 <= right)    //如果抛物?与障碍物上（下）的左端点有交点且交点的x坐?在猪的左?，?无法?死猪
        return true;
    if(x2 < tx && left <= x2 && x2 <= right)    //如果抛物?与障碍物上（下）的右端点有交点且交点的x坐?在猪的左?，?无法?死猪
        return true;
    return false;
}

bool check3(double x, double y, double h, double t, double l, double r)
{
    if(l <= x && x <= r && y <= t && t <= h)    //如果障碍正好?在白??行的抛物??迹和猪的中?，?炸蛋无法?中猪
        return true;
    return false;
}

bool check(double angle)
{
    getabc(angle);
    double h = a * tx * tx + b * tx + c;
    if(h < ty)    //?不到猪的上方，?不可能?死猪
        return false;
    for(int i=0; i<n; i++)
    {
        if(check1(ob[i].l,ob[i].b,ob[i].t))
            return false;
        if(check1(ob[i].r,ob[i].b,ob[i].t))
            return false;
        if(check2(ob[i].b,ob[i].l,ob[i].r))
            return false;
        if(check2(ob[i].t,ob[i].l,ob[i].r))
            return false;
        if(check3(tx,ty,h,ob[i].b,ob[i].l,ob[i].r))
            return false;
        //if(check3(tx,ty,h,ob[i].t,ob[i].l,ob[i].r))
        //    return false;
    }
    return true;
}

bool solve()
{
    for(double i=0; i<0.5*PI; i+=0.000001)
    {
        if(check(i))
            return true;
    }
    return false;
}

int main()
{
    scanf("%d%d%d%d",&n,&v,&tx,&ty);
    for(int i=0; i<n; i++)
        scanf("%d%d%d%d",&ob[i].l,&ob[i].b,&ob[i].r,&ob[i].t);
    if(solve())
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

const ll mod = 1e9 + 7;

long long gcd(ll x, ll y){
	if(x > y) swap(x, y);
	while(x != 0){
		y %= x;
		swap(x, y);
	}
	return y;
}


ll mpow(ll x, ll r){
	if(r == 1) return x;
	if(r % 2 == 1) return x * mpow(x, r-1) % mod;
	else{
		ll aa = mpow(x, r/2);
		return aa*aa%mod;
	}
}

ll N;
ll A[200010];
ll ans[200010];

ll solve(int num){
	
}

int main(){
	cin >> N;
	rep(i, N) cin >> A[i];
	if(N%2 == 0){
		ll cnt = 0, ans;
		rep(i, (N/2)+1){
			if(i==0){
				rep(j, N/2){
					cnt += A[2*j+1];
				}
				ans = cnt;
			}else{
				cnt -= A[2*i-1];
				cnt += A[2*i-2];
				if(cnt > ans) ans = cnt;
			}
		}
		cout << ans << endl;
	}else{
		ll dp[N+1];
		ll sum[N];
		for(int i=N-1; i>=0; i--){
			if(i%2==1) continue;
			if(i==N-1) sum[i] = A[i];
			else{
				sum[i] = A[i] + sum[i+2];
			}
		}
		rep(i, N+1){
			if(i<=1) dp[i] = 0;
			else{
				if(i%2==0){
					dp[i] = max(A[N-i]+dp[i-2], sum[N-i+1]);
				}else{
					dp[i] = max(sum[N-i+2], max(A[N-i]+dp[i-2], A[N-i+1]+dp[i-3]));
				}
			}
		}
		cout << dp[N] << endl;
	}
	return 0;
}

Measured memory_bytes: 8328
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<math.h>

using namespace std;

int main() {
	 long long n, k;
	cin >> n >> k;
	vector<long long>h(n);
	long long cou = 0;

	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end(), std::greater<long long>());
	if (k < n) {
		for (long long i = k; i < n; i++) {
			cou += h[i];
		}
	}
	cout << cou << endl;
}


Measured memory_bytes: 1792
n,h = gets.chomp.split.map(&:to_i)
as = []
bs = []
cnt = 0
n.times do
  a,b = gets.chomp.split.map(&:to_i)
  as << a
  bs << b
end
as.sort!.reverse!
bs.sort!.reverse!
while h > 0
  if !bs.empty? && (as[0] < bs[0])
    cnt += 1
    h -= bs[0]
    bs.shift
  else
    if h % as[0] != 0
      cnt += 1
    end
    cnt += h / as[0]
    break
  end
end
puts cnt

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

typedef long long int int64;
static const int64 mod = 998244353LL;
using bs = std::bitset<101>;
struct bscomp {
	bool operator() (const bs &a,const bs &b) const {
		return memcmp(&a, &b, sizeof(bs)) < 0;
	}
};
std::map<bs,int,bscomp> dp;
bs mask[102];

int work(bs cur)
{
	auto it = dp.find(cur);
	if(it != dp.end()) return it->second;
	int64 val = work(cur>>1);
	if(cur[0] == 1) val *= 2;
	int len = 100;
	while(!cur.test(len)) --len;
	for(int i = 1;i <= len;++i) {
		bs nex = cur;
		bs all = mask[i+1];
		for(int k = 1;i*k <= len;++k) {
			all &= ~(mask[i] & ~nex);
			nex >>= i;
			if(k >= 2) {
				val += (int64)work(all) * work(nex) % mod;
			}
		}
	}
	val %= mod;
	dp[cur] = val;
	return val;
}
int main()
{
	mask[101].set();
	for(int i = 100;i >= 0;--i) mask[i] = mask[i+1] >> 1;
	std::string inp;
	std::cin >> inp;
	bs init(inp);
	// most significant bit indicates length
	init.set(inp.size());
	dp[bs("1")] = 1;
	printf("%d\n", work(init));
}


Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;

    return 0;
}


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

using namespace std;

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

    string res = "";
    for (int i = 0; i < s.size(); i++) {
        if ((i + 1) % 2 != 0) res += s[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>

int n;
using p = std::pair<int, int>;
using Edmonds = std::vector<std::vector<int>>;

// 2部グラフの最大マッチングを利用

bool BipartiteMatching(Edmonds &G, int u, std::vector<bool> &seen, std::vector<int> &match){
    for(int v = 0; v < n; v++){
        if(G[u][v] && !seen[v]){
            seen[v] = true;
            if(match[v] < 0 || BipartiteMatching(G, match[v], seen, match)){
                match[v] = u;
                return true;
            }
        }
    }
    return false;
}

int maxBM(Edmonds &G){
    std::vector<int> match(n, -1);
    
    int result = 0;
    for(int u = 0; u < n; u++){
        std::vector<bool> seen(n, false);

        if(BipartiteMatching(G, u, seen, match)) result++;
    }
    return result;
}

int main(){
    std::cin >> n;
    std::vector<p> red(n), blue(n);
    for(int i = 0; i < n; i++) std::cin >> red[i].first >> red[i].second;
    for(int i = 0; i < n; i++) std::cin >> blue[i].first >> blue[i].second;

    std::sort(red.begin(), red.end());
    std::sort(blue.begin(), blue.end());
    Edmonds bpGraph(n, std::vector<int>(n, 0));
    for(int i = 0; i < n; i++){
        auto iter = std::lower_bound(blue.begin(), blue.end(), red[i]);
        for(;iter != blue.end(); iter++){
            if((*iter).second > red[i].second){
                int j = std::distance(blue.begin(), iter);
                bpGraph[i][j] = 1;
            }

        }
    }

    std::cout << maxBM(bpGraph) << std::endl;
    return 0;
}

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

using namespace std;

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

const int SIZE= 1000000;
bool prime[SIZE];
vector<int> primes;

int main() {
  rep (i, SIZE) prime[i] = true;
  prime[0] = prime[1] = false;
  for (int i = 0; i * i <= SIZE; ++i) {
    if (!prime[i]) continue;
    for (int j = i * i; j <= SIZE; j += i) {
      prime[j] = false;
    }
  }
  rep (i, SIZE) if (prime[i]) primes.push_back(i);
  int n, p;
  while (true) {
    cin >> n >> p;
    if (n == -1 && p == -1) break;
    int pos = upper_bound(primes.begin(), primes.end(), n) - primes.begin();
    vector<int> res;
    rep (i, p) rep (j, p) {
      res.push_back(primes[pos + i] + primes[pos + i + j]);
    }
    sort(res.begin(), res.end());
    cout << res[p - 1] << endl;
  }
  return 0;
}

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

int n,x,a[51],b[51],sum,l;

int dfs(int l,int r,int B){
	if(r<=x)return a[B];
	if(x<l)return 0;
	int m=(l+r)/2;
	return dfs(l+1,m-1,B-1)+dfs(m,m,0)+dfs(m+1,r-1,B-1);
}

signed main(){
	cin>>n>>x;
	x--;
	a[0]=1;
	b[0]=1;
	a[1]=3;
	b[1]=5;
	for(int i=2;i<=50;i++){
		a[i]=a[i-1]*2+1;
		b[i]=b[i-1]*2+3;
	}
	cout<<dfs(0,b[n]-1,n)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
ll gcd(ll x, ll y){
  if(x<y) swap(x,y);
  if(x%y==0)return y;
  return gcd(y,x%y);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin >> a >> b;
  cout << a / gcd(a,b) * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using pint = pair<ll, ll>;

int main(){
    char x;
    cin >> x;
    if(x<='Z' && x>='A')cout <<'A' <<endl;
    else
      cout << 'a' << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
	int n;
  cin >> n;
	int saito = n%10;
  if(saito==3){
   cout<<"bon"<<endl; 
  }
  else if(saito==0||saito==1||saito==6||saito==8){
   cout<<"pon"<<endl; 
  }
  else{
    cout<<"hon"<<endl;
  }
}
    



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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int sum = 0;
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i+1; j < n; j++)
            {
                if (i == j) continue;
                sum += d[i] * d[j];
            }
        }

        Console.WriteLine(sum);
    }

}



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

fflag = False
for i in range(n):
    if a[i] == 0:
        fflag = True
        break

ans = 1
flag = True
for i in range(n):
    if fflag == True:
        ans = 0
        break
    ans = ans * a[i]
    if ans == 0:
        break
    if ans > 1000000000000000000:
        print(-1)
        flag = False
        break

if flag == True:
    print(ans)

Measured memory_bytes: 21608
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(ALL(v));
    int ans = v[n/2] - v[n/2-1];

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
typedef long long ll;


int main()
{
	ll n,sum=0,tmp = -1;
	cin >> n;
	vector<ll>a(n), b(n), c(n-1);
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n-1)cin >> c[i];
	sum += b[a[0]-1];
	tmp = a[0];
	for (ll i = 1; i < n;i++) {
		sum += b[a[i]-1];
		if (tmp + 1 == a[i])sum += c[a[i]-2];
		tmp = a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
int a[101][101];
ll dp[101][101][2];

ll func(int i, int j, int f){
	if(dp[i][j][f]!=-1){
		return dp[i][j][f];
	}
	if((i==0) && (j==0)){
		return dp[i][j][f] = 0;
	}
	else if(i==0){
		if(f==a[i][j-1]){
			return dp[i][j][f] = func(i,j-1,f);
		}
		else{
			if(f==0){
				return dp[i][j][f] = func(i,j-1,1)+1;
			}
			else{
				return dp[i][j][f] = func(i,j-1,0);
			}
		}
	}
	else if(j==0){
		if(f==a[i-1][j]){
			return dp[i][j][f] = func(i-1,j,f);
		}
		else{
			if(f==0){
				return dp[i][j][f] = func(i-1,j,1)+1;
			}
			else{
				return dp[i][j][f] = func(i-1,j,0);
			}
		}
	}
	else{
		ll l,u;
		if(f==a[i][j-1]){
			l = func(i,j-1,f);
		}
		else{
			if(f==0){
				l = func(i,j-1,1)+1;
			}
			else{
				l = func(i,j-1,0);
			}
		}

		if(f==a[i-1][j]){
			u = func(i-1,j,f);
		}
		else{
			if(f==0){
				u = func(i-1,j,1)+1;
			}
			else{
				u = func(i-1,j,0);
			}
		}

		return dp[i][j][f] = min(l,u);
	}
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m,h,w;
	cin>>h>>w;
	string s;
	MSET(dp,-1);
	for(int i=0;i<h;i++){
		cin>>s;
		for(int j=0;j<w;j++){
			a[i][j] = s[j]=='.'?0:1;
		}
	}
	if(!a[h-1][w-1]){
		cout<<func(h-1,w-1,0);
	}
	else{
		cout<<func(h-1,w-1,1)+1;
	}




	return 0;
}







Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string str;
    cin >> str;
    int maxx = 0, minn = 9999999;
    for (register int i = 0; i <= str.length(); i++)
    {
        if (str[i] == 'F')
            maxx = i;
        if (str[i] == 'C')
            minn = i;
    }
    if (minn < maxx)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

int main(){
        int N, M, A;
        cin >> N >> M;
        long long sum = 0;
        for(int i = 0; i < M; ++i){
                cin >> A;
                sum += A;
        }

        if(sum <= N) cout << N - sum << endl;
        else         cout << -1 << endl;

        return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMaximum(Node x){
  while(x->right != NIL)x = x->right;
  return x;

}

Node treeMinimum(Node x){
  while(x->left != NIL)x = x->left;
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; 
  Node x; 

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }
  else{
    if(y == y->parent->left){
      y->parent->left = x;
    }
    else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }

  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;  
    }
  }

  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL) return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL) return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 20492
package main

import (
	"fmt"
)

func min(a, b int) int{
	if a <= b {
		return a
	} else {
		return b
	}
}

func main() {
	var n,a,b int
	fmt.Scan(&n,&a,&b)
	
	fmt.Println(min(n*a,b))
}

Measured memory_bytes: 512
import numpy as np

N = int(input().rstrip())
if N > 3:
  line = input().rstrip().split()
  L = [int(i) for i in line]
  L.sort(reverse = True)

  count = 0

  for i in range(len(L)):
    for j in range(len(L)):
      for k in range(len(L)):
        if i != j and j != k and k != i:
          if i < j and j < k:
            x = L[i]
            y = L[j]
            z = L[k]
            if x < y+z:
              if y-z < x:
                if x != y and y != z and z !=x:
                  count += 1

  print(count)
  
else:
  print(0)

Measured memory_bytes: 27108
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
#define f(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define pii pair< int,int >
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define vii vector<pii>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)
// #define int long long int
using namespace std;


int32_t main()
{
    int t;
    cin>>t;
    if(t%1000==0)cout<<0<<endl;
    else cout<<1000-(t%1000)<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
using namespace std;
const ll N = 2e5+50, inf = 1e3+5, mod = 1e9+7, NN = 1e5+10;
int a[N] ;
int main()
{
    Tsetso
    int n , k;
    cin >> n >> k ;
    for ( int i = 0 ; i < n ; i++)
            cin >> a[i] ;
    int mn = 2e9 , s = 0;
    sort(a,a+n) ;
    for ( int i = k-1 ; i < n ; i++)
                mn = min(mn,a[i]-a[s++]);
    cout << mn ;
}


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

using namespace std;

const int peppa = 2*1e5+10;

int n;
//int jobt[peppa],jobd[peppa];
bool me = true;

struct Job
{
	int time,deadline;
}job[peppa];

bool cmp(Job m,Job n)
{
	return m.deadline < n.deadline;
}

int sum;

int main()
{
	cin >> n;
	for(int i = 1;i <= n;i ++)
		cin >> job[i].time >> job[i].deadline;
		//s[i] += job.t[i];
	sort(job+1,job+n+1,cmp);
	for(int i = 1;i <= n;i ++)
	{
		sum += job[i].time;
		if(sum > job[i].deadline)
			me = false;
	}
	if(me)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int x = scanner.nextInt();
			System.out.println(((x >= a) && (x <= a + b)) ? "YES" : "NO");
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static bool dfs(std::vector<std::vector<int>>& graph, int from, int here, int col, std::vector<int>& color)
{
	bool ans = true;
	if (color[here] == -1) {
		color[here] = col;
	}
	for (auto it = graph[here].begin(); it != graph[here].end(); it++) {
		if (*it == from) continue;
		else if (color[*it] == col) {
			ans = false;
			break;
		}
		else if (color[*it] == -1) {
			ans = dfs(graph, here, *it, col ^ 1, color);
			if (!ans) break;
		}
	}
	return ans;
}

static void exec()
{
	int N;
	get(N);

	std::vector<std::string> table(N);
	for (int i = 0; i < N; i++) {
		get(table[i]);
	}

	std::vector<int> color(N, -1);
	std::vector<std::vector<int>> dist(N, std::vector<int>(N, MOD_NUM));
	std::vector<std::vector<int>> graph(N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (table[i][j] == '1') {
				graph[i].push_back(j);
				dist[i][j] = 1;
			}
		}
	}

	if (!dfs(graph, 0, 0, 0, color)) {
		printf("-1\n");
		return;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if (i == j) {
					dist[i][j] = 0;
				}
				else {
					dist[j][k] = std::min(dist[j][k], dist[j][i] + dist[i][k]);
				}
			}
		}
	}
	int diam = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (dist[i][j] != MOD_NUM && diam < dist[i][j]) {
				diam = dist[i][j];
			}
		}
	}
	printf("%d\n", diam + 1);
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  n--;
  while (n>0 && s!="Y") {
    cin >> s;
    n--;
  }
  if (s == "Y")
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


Measured memory_bytes: 256
def card_shift(p_c)
  card = p_c.values.first.shift
  case card
  when 'a'
    card_shift(@a)
  when 'b'
    card_shift(@b)
  when 'c'
    card_shift(@c)
  when nil
    puts p_c.keys.first
  end
end

@a = {'A' => gets.chomp.split('')}
@b = {'B' => gets.chomp.split('')}
@c = {'C' => gets.chomp.split('')}

card_shift(@a)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int h, w, k;
  cin >> h >> w >> k;
  vstr s(h);
  cin >> s;
  vector<vi32> sums(h + 1, vi32(w + 1));
  rep(i, h) rep(j, w) {
    if (s[i][j] == '1') {
      sums[i + 1][j + 1] += 1;
    }
    sums[i + 1][j + 1] += sums[i + 1][j] + sums[i][j + 1] - sums[i][j];
  }
  int ans = 1e9;
  rep(i, bit32(h - 1)) {
    int cnt = 0;
    vi32 v = {0};
    rep(j, h - 1) if (i & bit32(j)) {
      v.push_back(j + 1);
      cnt += 1;
    }
    v.push_back(h);
    int l = 0, r = 0;
    bool end = true;
    while (r < w) {
      bool ok = true;
      rep(j, v.size() - 1) {
        int u = v[j];
        int d = v[j + 1];
        int sum = sums[d][r + 1] - sums[d][l] - sums[u][r + 1] + sums[u][l];
        if (sum > k) {
          ok = false;
          break;
        }
      }
      if (ok) {
        r += 1;
      } else {
        if (l == r) {
          end = false;
          break;
        } else {
          l = r;
          cnt++;
        }
      }
    }
    if (end) {
      amin(ans, cnt);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#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 prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
const int INF=1e+9;
const ll INFLL=1e+17;
int N;
ll A[100010];
void solve(){
  int cnt=0;
  ll sum=0;
  rep(i,N){
    sum+=std::abs(A[i]);
    if(A[i]<=0){
      cnt++;
    }
  }
  if(cnt%2==1){
    ll min=INFLL;
    rep(i,N){
      min=std::min(min,std::abs(A[i]));
    }
    sum-=min*2;
  }
  prin(sum);
}  
int main(){
  cin>>N;
  rep(i,N) cin>>A[i];
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8
int an[100007];

int main(){
    char S[100007];
    int crk,crg,rlp;
    crk=crg=rlp=0;
    cin >> S;
    for(int i=0;i<strlen(S);){
        if(S[i]=='R' && S[i+1]=='L'){
            if(i%2==0){
                an[i]+=crg;
                an[i+1]+=crk;
            }
            else{
                an[i]+=crk;
                an[i+1]+=crg;
            }
            rlp=i;
            an[i]++;
            an[i+1]++;
            i+=2;
            crg=crk=0;
        }
        else if(S[i]=='R'){
            if(i%2==1){
                crk++;
            }
            else{
                crg++;
            }
            i++;
        }
        else if(S[i]=='L'){
            if((rlp-i)%2==0){
                an[rlp]++;
            }
            else{
                an[rlp+1]++;
            }
            i++;
        }

    }
    rep(i,strlen(S)){
        cout << an[i] << " ";
    }
    cout << endl;


}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
using namespace std;
struct a{
long long money;
long long have;	
long long act;
};
int cmp(a b,a c){
	return b.money<c.money;
}
int main(){
//int n,a[100001]={0};
//cin>>n;
//cout<< <<endl;
a a[5];
long long n;
for(int i=1;i<=4;i++){
	cin>>a[i].money;
	a[i].act=a[i].money;
	if(i==1){
	   a[i].have=1;a[i].money*=8;
	}
	if(i==2){
	a[i].money*=4;
	a[i].have=2;
    }
	if(i==3){
	a[i].money*=2;
	a[i].have=4;
    }
    if(i==4)a[i].have=8;
}
sort(a+1,a+5,cmp);
cin>>n;
n*=4;
long long sum=0;
for(int i=1;i<=4;i++){
	if(n%a[i].have==0){
		cout<<n/a[i].have*a[i].act+sum;//<<" "<<a[i].have;
		return 0;
	}
	else {
		sum+=(n/a[i].have)*a[i].act;
		n%=a[i].have;
	}
	//cout<<sum<<" "<<n<<endl;
}
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[] x = new int[5];
        x[0] = sc.nextInt();
        x[1] = sc.nextInt();
        x[2] = sc.nextInt();
        x[3] = sc.nextInt();
        x[4] = sc.nextInt();
        int result = 0;

        int min = 9;
        int index = 0;
        for (int i = 0; i < 5; i++) {
            int temp = x[i] % 10;
            if (temp != 0 && temp < min) {
                min = temp;
                index = i;
            }
        }

        for (int i = 0; i < 5; i++) {
            if (i == index) continue;
            if (x[i] % 10 == 0) result += x[i];
            else result += (x[i]/10+1)*10;
        }
        result += x[index];
        System.out.println(result);
    }
}

Measured memory_bytes: 23124
class UF():
  def __init__(self, N):
    self.parents = [-1] * (N+1)

  def union(self, f, t):
    p1 = self.find(f)
    p2 = self.find(t)
    if p1 == p2:
      return

    if self.parents[p1] > self.parents[p2]:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def find(self, node):
    if self.parents[node] < 0:
      return node
    else:
      self.parents[node] = self.find(self.parents[node])
      return self.parents[node]

  def same(self, n1, n2):
    return self.find(n1) == self.find(n2)

N,M = map(int, input().split())
p = list(map(int, input().split()))
uf = UF(N)
xy = [ list(map(int, input().split())) for _ in range(M) ]

# for _ in range(M):
#   x,y = map(int, input().split())
#   uf.union(x,y)
for x,y in xy:
  uf.union(x,y)

res = 0
for i in range(N):
  if i+1 == p[i] or uf.same(i+1, p[i]):
    res += 1

print(res)

Measured memory_bytes: 100844
#include <stdio.h>
int main(void){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)break;
    
    if(x<y)
    printf("%d %d\n",x,y);
    else 
    printf("%d %d\n",y,x);
    }
    return 0;
}


Measured memory_bytes: 1980
#include <iostream>
using namespace std;
int main() {
    int N, lim;

    cin >> N >> lim;
    int a[1000];
    int b[1000];

    int min;
    int cost = 10000;

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

    
    for(int i = 0; i < N; i++){
        if(b[i] <= lim){ 

            if(a[i] < cost){
                cost = a[i];
            }

        }

    }
    if(cost == 10000){
        cout << "TLE" << endl;
    } else {
        cout << cost << endl;
    }

}

Measured memory_bytes: 256