akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
    int a,b,answer2,answer1;
    double answer3,a1,b1;
    scanf("%d %d",&a,&b);
    answer1=a/b;
    answer2=a%b;
    a1=a;
    b1=b;
    answer3=a1/b1;
    printf("%d %d %f\n",answer1,answer2,answer3);
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<ll> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VL a(n), s(n+1, 0);
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n) {
    s[i+1] = s[i] + a[i];
  }
  VL l(n, -1), r(n, -1);
  int left = 0;
  for(int right = 1; right < n - 2; ++right) {
    while(left < right && s[left + 1] < s[right + 1] / 2) {
      left++;
    }
    l[right] = (abs(s[left + 1] - (s[right + 1] - s[left + 1])) < abs(s[left] - (s[right + 1] - s[left]))) ? left : left - 1;
  }
  int right = n - 1;
  for(int left = n - 3; left > 0; --left) {
    while(left < right && (s[n] - s[right + 1]) < (s[n] - s[left + 1]) / 2) {
      right--;
    }
    r[left] = (abs((s[n] - s[right + 1]) - (s[right + 1] - s[left + 1])) < abs((s[n] - s[right + 2]) - (s[right + 2] - s[left + 1]))) ? right : right + 1;
  }

  ll ans = LINF;
  FOR(i, 1, n - 2) {
    ll ma = max(s[l[i] + 1], max((s[i + 1] - s[l[i] + 1]), max((s[r[i] + 1] - s[i + 1]), s[n] - s[r[i] + 1])));
    ll mi = min(s[l[i] + 1], min((s[i + 1] - s[l[i] + 1]), min((s[r[i] + 1] - s[i + 1]), s[n] - s[r[i] + 1])));
    ans = min(ans, ma - mi);
  }
  out(ans);

  return 0;
}


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

int main() {
  int n,f=0,j=1;
  cin >> n;
  
  for(int i=0;i < 9;i++) {
    f += n%(10*j)/j;
    j *= 10;
  } 
  
  if (n%f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n, k;
	cin >> n >> k;
	string s;
	vector<int>length;
	vector<int>check;
	cin >> s;
	int renzoku = 0;
	char buck = ' ';
	for (int i = 0; i < s.size();i++) {
		if (i == 0) {
			renzoku = 1;
			buck = s[i];
			continue;
		}
		if (buck == s[i]) {
			renzoku++;
		}
		else {
			length.push_back(renzoku);
			if (buck == '0') {
				check.push_back(1);
			}
			else {
				check.push_back(0);
			}
			renzoku = 1;
			buck = s[i];
		}
	}
	length.push_back(renzoku);
	if (buck == '0') {
		check.push_back(1);
	}
	else {
		check.push_back(0);
	}
	vector<int>a;
	vector<int>b;
	a.push_back(0);
	b.push_back(0);
	for (int i = 0; i < check.size(); i++) {
		int t = a[i] + check[i];
		a.push_back(t);
	}
	for (int i = 0; i < length.size(); i++) {
		int t = b[i] + length[i];
		b.push_back(t);
	}
	if (k >= a[a.size() - 1]) {
		cout << b[b.size() - 1];
		return 0;
	}
	int ans = 0;
	int z[3];
	z[0] = k;
	z[1] = k + k;
	z[2] = k + k + 1;
	for (int n = 0; n <= 2; n++) {
		int f = z[n];
		for (int i = 0; i < length.size(); i++) {
			if (f + i > a.size() - 1) {
				if (a[a.size() - 1] - a[i] > k) {
					continue;
				}
				ans = max(ans, b[a.size() - 1] - b[i]);
				continue;
			}
			if (a[i + f] - a[i] > k) {
				continue;
			}
			ans = max(ans, b[i + f] - b[i]);
		}
	}
	cout << ans;
}

Measured memory_bytes: 2356
# -*- coding: utf-8 -*-
# D

# BFSで各点から到達可能な最も遠いところを探索する
# 1回探索はO(HW)なのでO(HHWW)
# BFSなのでdeque / queue使う・・・微妙に1つだけTLE残る

# 全ての地点から全ての地点への最短経路を求める

'''
3 5
...#.
.#.#.
.#...
'''

import sys
from collections import deque

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

H, W = na()
# data = [ns() for _ in range(H)]

data = [list("#" * (W + 2))]
# 周りを'#'で埋めておく
for _ in range(H):
    data.append(["#"] + list(input()) + ["#"])
data += [list("#" * (W + 2))]


def bfs(h, w):
    dist = [[-1] * (W+2) for _ in range(H+2)]
    q = deque()

    max_dist = 0
    dist[h][w] = 0
    q.append((h, w, 0))

    # while len(q) > 0:
    while len(q) > 0:
        h, w, val = q.popleft()

        m = [(1, 0), (-1, 0), (0, 1), (0, -1)]
        for dx, dy in m:
            h_new, w_new = h + dx, w + dy
            if data[h_new][w_new] == '.' and dist[h_new][w_new] == -1:
                q.append((h_new, w_new, val+1))
                dist[h_new][w_new] = val + 1
                max_dist = max(max_dist, val + 1)

    return max_dist


ans = 0
for h in range(H+2):
    for w in range(W+2):
        if data[h][w] == '.':
            res = bfs(h, w)
            if ans < res:
                ans = res

print(ans)


Measured memory_bytes: 43372
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int D, L;
	cin >> D >> L;
	cout << D / L + D % L << endl;
	return 0;
}


Measured memory_bytes: 3208
def main():
    from collections import deque
    from itertools import chain
    import sys
    input = sys.stdin.readline

    N = int(input())

    graph = tuple(set() for _ in range(N))
    for _ in range(N - 1):
        a, b = (int(x) - 1 for x in input().split())
        graph[a].add(b)
        graph[b].add(a)

    bipartite = [-1] * N
    bipartite[0] = 0

    dq = deque([0])
    while dq:
        v = dq.popleft()
        nb = bipartite[v] ^ 1
        for u in graph[v]:
            if ~bipartite[u]: continue
            bipartite[u] = nb
            dq.append(u)

    s0 = bipartite.count(0)
    s1 = N - s0

    it1 = iter(range(1, N + 1, 3))
    it2 = iter(range(2, N + 1, 3))
    it3 = iter(range(3, N + 1, 3))
    it123 = chain(it1, it2, it3)
    it13 = chain(it1, it3)
    it23 = chain(it2, it3)

    ans = [-1] * N
    K = N // 3
    if s0 <= K:
        for v in range(N):
            if bipartite[v] == 0:
                ans[v] = next(it3)
            else:
                ans[v] = next(it123)  # 余った3をこちらで消費するので12ではなく123
    elif s1 <= K:
        for v in range(N):
            if bipartite[v] == 1:
                ans[v] = next(it3)
            else:
                ans[v] = next(it123)
    else:
        for v in range(N):
            if bipartite[v] == 0:
                ans[v] = next(it13)
            else:
                ans[v] = next(it23)

    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82664
from math import ceil

n, k = map(int, input().split())
A = list(map(int, input().split()))

index_min = A.index(1)
if not index_min % (k - 1) == 0:
    index_min = (index_min // (k - 1) + 1) * (k - 1)
index_min = min(index_min, n-1)

ans = ceil(index_min / (k - 1))
ans += ceil((n - index_min - 1) / (k - 1))

print(ans)


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

int main() {
	double min_h = 100000000, max_h = 0;

	double h;
	while (cin >> h) {
		min_h = min(min_h, h);
		max_h = max(max_h, h);
	}

	cout << max_h - min_h << endl;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main(void){

  int a,b,c,out;
  int n;
  cin >> n;
  while(n--){

    a = b = c = out = 0;

    for( int l = 10 ; l > 0 ; l-- ){
      cin >> a;
      if( b < a ){
	b = a;
      }
      else if( c < a ){
	c = a;
      }
      else out = a;
    }
    if( out == 0 )cout << "YES" << endl;
    else cout << "NO" << endl;
  }
 return 0;
}

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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    ll n, k;
    cin >> n >> k;
    ll ans = n;
    if(k >= n) {
        ans = min(ans, k-n);
    }
    else {
        ll x1 = n%k;
        ll x2 = k - x1;
        ans = min(ans, min(x1, x2));
    }
    cout << ans;
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin >> a >> b;
	int k=(a+b)/2;
	if (abs(a-k)==abs(b-k)) cout << k << endl;
	else cout << "IMPOSSIBLE\n"; 
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void change(int *,int *);

int main(){
  int x,y;

  scanf("%d%d",&x,&y);
 
    
  while(1){
    change(&x,&y);
    if(x%y==0)break;
    x=x%y;
  }

  printf("%d\n",y);
  return 0;
}

    void change(int *x,int *y){
      int i;
      i=*x;
       *x=*y;
       *y=i;
    }



Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {

        try (final Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] V = new int[N];
            int max = 0;
            for (int i = 0; i < N; i++) {
                V[i] = sc.nextInt();
            }
            for (int i = 0; i < N; i++) {
                int profit = V[i] - sc.nextInt();
                if (profit > 0) {
                    max += profit;
                }
            }
            System.out.println(max);
        }
    }
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d){
    cout << "Left" << endl;
  }else if (a + b < c + d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
  
  return 0;
}
      

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<algorithm>
typedef signed long long int int64;
inline unsigned getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register unsigned x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
inline int64 min(const int64 &a,const int64 &b) {
	return a<b?a:b;
}
const int64 inf=0x7ffffffffffffff;
const int N=200001;
int n;
class FenwickTree {
	private:
		int64 val[N];
		int lowbit(const int &x) const {
			return x&-x;
		}
	public:
		FenwickTree() {
			std::fill(&val[0],&val[N],inf);
		}
		void modify(int p,const int64 &x) {
			while(p<=n) {
				val[p]=min(val[p],x);
				p+=lowbit(p);
			}
		}
		int64 query(int p) const {
			int64 ret=inf;
			while(p) {
				ret=min(ret,val[p]);
				p-=lowbit(p);
			}
			return ret;
		}
};
FenwickTree ta;
class RevFenwickTree {
	private:
		int64 val[N];
		int lowbit(const int &x) const {
			return x&-x;
		}
	public:
		RevFenwickTree() {
			std::fill(&val[0],&val[N],inf);
		}
		void modify(int p,const int64 &x) {
			while(p) {
				val[p]=min(val[p],x);
				p-=lowbit(p);
			}
		}
		int64 query(int p) const {
			int64 ret=inf;
			while(p<=n) {
				ret=min(ret,val[p]);
				p+=lowbit(p);
			}
			return ret;
		}
};
RevFenwickTree tb;
int64 f[N];
inline void modify(const int &p,const int64 x) {
	if(x<f[p]) {
		f[p]=x;
		ta.modify(p,x-p);
		tb.modify(p,x+p);
	}
}
int main() {
	n=getint();
	int q=getint(),a=getint(),b=getint();
	std::fill(&f[0],&f[N],inf);
	modify(a,0);
	int64 sum=0;
	while(q--) {
		a=b;
		b=getint();
		sum+=abs(a-b);
		int64 t1=ta.query(b)+b,t2=tb.query(b)-b;
		modify(a,min(t1,t2)-abs(a-b));
	}
	int64 tmp=inf;
	for(register int i=1;i<=n;i++) {
		tmp=min(tmp,f[i]);
	}
	printf("%lld\n",tmp+sum);
	return 0;
}

Measured memory_bytes: 4864
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


#define NUM 1120

int main(){
	int table[NUM],limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int prime_table[NUM],index = 0;

	for(int i = 2; i < NUM; i++){
		if(table[i] == 1){
			prime_table[index++] = i;
		}
	}

	int*** dp = new int**[15];
	for(int i = 0; i < 15; i++){
		dp[i] = new int*[index];
		for(int k = 0; k < index; k++){
			dp[i][k] = new int[1121];
		}
	}

	for(int i = 0; i < 15; i++){
		for(int k = 0; k < index; k++){
			for(int p = 0; p < 1121; p++)dp[i][k][p] = 0;
		}
	}

	for(int i = 0; i < index; i++){
		dp[1][i][prime_table[i]] = 1;
	}

	for(int k = 2; k <= 14; k++){
		for(int i = 1; i < index; i++){
			for(int p = 0; p <= i-1; p++){
				for(int a = prime_table[i]+1; a <= 1120; a++){
					dp[k][i][a] += dp[k-1][p][a-prime_table[i]];
				}
			}
		}
	}

	int A,B,sum;

	while(true){
		scanf("%d %d",&A,&B);
		if(A == 0 && B == 0)break;

		sum = 0;

		for(int i = 0; i < index; i++)sum += dp[B][i][A];

		printf("%d\n",sum);

	}

	return 0;
}

Measured memory_bytes: 15036
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;


int main(void){
    int s;
    cin >> s;
    vector<int> a(1000001);
    int i=1;
    for(;i<=1000000;i++) {
        if(distance(a.begin(), find(a.begin(), a.end(), s)) != a.size()) break;
        a[i] = s;
        if(s%2==0) {
            s = s / 2;
        }else {
            s = 3*s+1;
        }
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 4224
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    ans = n - sum(a)
    if ans >= 0:
        print(ans)
    else:
        print(-1)


main()


Measured memory_bytes: 68044
#include <iostream>

using namespace std;

int main(void)
{
	int n;
	while (cin >> n, n){
		int ret = 0;

		for (int i = 1; i < n; i++){
			int sum = 0;
			for (int j = i; j < n; j++){
				sum += j;
				if (sum == n) ret++;
				if (sum > n) break;
			}
		}

		cout << ret << endl;
	}
}

Measured memory_bytes: 1160
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let mut f = Vec::new();
    for _ in 0..n {
        f.push(i::uv(10));
    }
    let mut p = Vec::new();
    for _ in 0..n {
        p.push(i::iv(11));
    }

    let mut ans = std::i32::MIN as i64;

    let case = (0..10).fold(1usize, |x, _| x * 2);
    //0は店を営業していないので除外
    for i in 1..case {
        let mut l = i;
        // joisinoの店が営業している時間帯
        let open: Vec<bool> = (0..10)
            .map(|_| {
                let r = l % 2 == 1;
                l >>= 1;
                r
            })
            .collect();
        // 各ショップと営業時間帯が一致する数
        let match_open: Vec<usize> = f
            .iter()
            .map(|v| {
                v.iter()
                    .zip(open.clone())
                    .filter(|fo| *fo.0 == 1 && fo.1)
                    .count()
            })
            .collect();
        let mut a = 0;
        for j in 0..n {
            a += p[j][match_open[j]];
        }
        ans = max(ans, a);
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
import scala.annotation.tailrec
object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val x = readLine.trim
  val d = readInt
  println(calMaxHamming(x, d))
  def calMaxHamming(x: String, d: Int): String = {
    @tailrec
    def sub(distance: Int, digits: List[Int], result: List[Char]): List[Char]= {
      digits match {
        case 1::xs if distance <= xs.length ⇒ sub(distance, xs, '1'::result)
        case 0::xs if distance > 0 ⇒ sub(distance - 1, xs, '1'::result)
        case 0::xs ⇒ sub(distance, xs, '0'::result)
        case 1::xs ⇒ sub(distance - 1, xs, '0'::result)
        case Nil ⇒ result
        case _ ⇒ ???
      }
    }
    sub(d, x.map(_.asDigit).toList, Nil).reverse.mkString
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44288
const LENGTH: usize = 2000;
const S: usize = 500;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let h: usize = sc.read();
    let w: usize = sc.read();
    let d: usize = sc.read();

    let mut big_table = vec![vec!['?'; LENGTH]; LENGTH];
    let colors = vec![vec!['R', 'G'], vec!['B', 'Y']];
    for i in 0..LENGTH {
        for j in 0..LENGTH {
            let ii = (i / d) % 2;
            let jj = (j / d) % 2;
            big_table[i][j] = colors[ii][jj];
        }
    }

    for i in 0..h {
        for j in 0..w {
            let p = S + i + j;
            let q = S + i - j;
            print!("{}", big_table[p][q]);
        }
        println!();
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 20988
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad         (join)
import           Data.Bifunctor        (bimap)
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap.Strict    as M
import           Data.List             (maximumBy, partition)
import           Data.Maybe            (fromJust)
import           Data.Ord              (comparing)

main :: IO ()
main = do
  n <- readLn
  vs <- getInts
  print $ solve n vs

solve :: Int -> [Int] -> Int
solve n vs
  | o1 /= e1 = n - v1 - w1
  | otherwise = min (n - v1 - w2) (n - v2 - w1)
    where
      ((o1, v1, v2), (e1, w1, w2)) = join bimap (findMaxAndSnd . count . fst . unzip) . partition (odd . snd) $ zip vs [1 .. n]

count :: [Int] -> M.IntMap Int
count xs = M.fromListWith (+) [(x, 1) | x <- xs]

findMaxAndSnd :: M.IntMap Int -> (Int, Int, Int)
findMaxAndSnd xs = (x1, v1, v2)
  where
    (x1, v1) = findMax xs
    v2 = findSnd xs x1

findMax :: M.IntMap Int -> (Int, Int)
findMax = maximumBy (comparing snd) . M.toAscList

findSnd :: M.IntMap Int -> Int -> Int
findSnd xs x
  | M.null ys = 0
  | otherwise = snd $ findMax ys
    where
      ys = M.delete x xs

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 34684
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

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

int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;


//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);
        readstring(s);
        map<char,vector<int>> part_sum;

        for (char c1 : vector<char>{'R', 'G', 'B'}) {
          part_sum[c1].push_back(0);
          for(char c : s) {
              part_sum[c1].push_back(part_sum[c1].back() + (c==c1));
          }
        }

        ll ret = 0;
        forr(i,0,s.size()) {
            for(int j = i+1; j < s.size(); j++) {
                if (s[i]!=s[j]) {
                    set<char> pp{'R', 'G', 'B'};
                    pp.erase(s[i]); pp.erase(s[j]);
                    char c_third = *pp.begin();

                    int count_third = part_sum[c_third].back() - part_sum[c_third][j+1];
                    if (j+(j-i) < s.size()) {
                      count_third -= (s[j + (j-i)] == c_third);
                    }
                    ret += count_third;
                }
            }
        }

        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 100000
using namespace std;
ll v[LIM];
int main() {
  ll a, b;
  cin >> a >> b;
  if (a * b > 0) {
    if (a < 0) {
      cout << (((a - b) % 2 == 0) ? "Negative" : "Positive") << endl;
    } else {
      cout << "Positive" << endl;
    }
  } else {
    cout << "Zero" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

int main(){
	lli n, m, ans;
	cin >> n >> m;
	if(n == 1 || m == 1){
		if(n == m) ans = 1;
		else if(n == 2 || m == 2) ans = 0;
		else ans = max(n, m) -2;
	}else ans = (n-2)*(m-2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int a=0, b=0, c=0;
    std::string output = "No";
    
    // 読込む
    std::cin >> a >> b >> c;

    if((0 <= a) && (a < b) && (b < c) && (c <= 100)){
        
        output = "Yes";
        
    }
    
    // 出力
    std::cout << output << std::endl;
}

/*

 テストケース
 a,b,cが0より小さいケース
 a,b,cが100より大きいケース
 a<b<c
 a<c<b
 b<a<c
 b<c<a
 c<a<b
 c<b<a
 
 0<b<c
 0<a<b<100


 
*/


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

int main() {
int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i = 0; i<N;++i){
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans = 0;
  for(int i = 0; i < K;++i){
    ans += l[i];
  }
  cout << ans << endl;
  }
  


Measured memory_bytes: 256
from collections import deque

n, q = map(int, input().split())
cnt = [0] * (n + 1)
g = [[] for _ in range(n + 1)]

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

for _ in range(q):
    u, v = map(int, input().split())
    cnt[u] += v

q = deque()
q.append(1)
checked = [0] * (n + 1)

while q:
    v = q.pop()
    checked[v] = 1
    for u in g[v]:
        if checked[u] == 1:
            continue
        cnt[u] += cnt[v]
        q.append(u)
print(*cnt[1:])


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int c = b - a;
  int h = 0;
  for (int i = 1; i <= c; i++) {
    h += i;
  }
  cout << h - b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h, w, ans;
int c[50][50];
int main(){
  cin>>h>>w;
  string s[h];
  int small[50][50]={10000000};
  // int test=0;
  for(int i=0;i<h;++i)
    cin>>s[i];
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
      c[i][j] = s[i][j] - '0';

  /*
  for(int i=0;i<h;++i)
    ans+=c[i][0];
  for(int i=1;i<w;++i)
    ans+=c[h-1][i];
  */
  /*
  for(int i=0;i<w;++i)
    test+=c[0][i];
  for(int i=1;i<h;++i)
    test+=c[i][w-1];
  
  ans=min(test,ans);
  */
  small[0][0]=0;
  int blank=0;
  for(int i=1;i<w;i++){
    blank += c[0][i];
    small[0][i]+=blank;
  }

  blank=0;
  for(int i=1;i<h;i++){
    blank += c[i][0];
    small[i][0]+=blank;
  }
  
  for(int i=1;i<h;i++){

    for(int j=1;j<w;j++){

      if(small[i-1][j] > small[i][j-1]) small[i][j]=small[i][j-1]+c[i][j];
      else small[i][j]=small[i-1][j]+c[i][j];
  
    }

  }
  /*
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cout<<small[i][j]<<" ";
    cout<<endl;
  }
  */
  
  cout<<small[h-1][w-1]<<endl;
  return 0;
}

Measured memory_bytes: 3208
a,b,h,m = map(int,input().split())
import numpy as np
hkakudo = 0.5 * (60*h + m)
mkakudo = 6 * m
if abs(hkakudo-mkakudo)== 180:
    print(a+b)
elif abs(hkakudo-mkakudo)<180:
    kakudo = abs(hkakudo-mkakudo)
    ans = np.sqrt(a**2 +b**2 - 2*a*b*np.cos(np.pi*kakudo/180))
    print(ans)
else:
    kakudo = 360 - abs(hkakudo - mkakudo)
    ans = np.sqrt(a**2 +b**2 - 2*a*b*np.cos(np.pi*kakudo/180))
    print(ans)

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

double calc_rad( double a, double b, double c )
{
    double cos = ( b * b - a * a - c * c ) / ( -2 * a * c );        //余弦でcosを算出
    return acos(cos);                                               //ラジアンを算出
}

int main()
{
    int n;
    double pi = acos(-1);

    while( cin >> n )
    {
        if( n == -1 )
            break;

        double x = 1, y = 1, rad = pi / 4;
        double a = 1, b = 1, c = sqrt(2);

        n -= 2;

        while( n-- )
        {
            a = c;
            c = sqrt( a * a + b * b );

            rad = rad + calc_rad( a, b, c );
            x = c * cos(rad);
            y = c * sin(rad);
        }
        cout << fixed << setprecision(5) << x << endl << y << endl;
    }
    return 0;
}



Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int t[1001][1001]={0};
int main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			char c;	cin>>c;
			if(c=='.')	t[i][j]=0;
			if(c=='#')	t[i][j]=1;
		}
	}
	for(int i=0;i<m;i++)//blue
	{
		for(int j=0;j<n;j++)
		{
			if(j==0||t[i][j]==1||(i%2==0&&j!=n-1))	cout<<"#";
			else	cout<<".";
		}
		cout<<endl;
	}
	cout<<endl;
	for(int i=0;i<m;i++)//yellow
	{
		for(int j=0;j<n;j++)
		{
			if(j==n-1||t[i][j]==1||(i%2==1&&j!=0))	cout<<"#";
			else	cout<<".";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2688
N, M = map(int, input().split())
A = list(map(int, input().split()))
X = sum(A)
cnt = 0
for i in range(N):
    if A[i] >= (X + 4 * M - 1) // (4 * M):
        cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N),flag(N);
  REP(i,N) cin >> a[i];
  int button=1,ans=0;
  while(1){
    button = a[button-1];
    ans++;
    flag[button-1]++;
    if(button==2) break;
    if(flag[button-1]>1){
      ans=-1;
      break;
    }
  }
  cout << ans << endl;    
}


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

#define loop(i,n) for(int i=0;i<n;i++)
int a[202];
int b[202];
int c[202];
int n;

int zero(int* a){
  for(int i=0;i<n;i++){
    int s=a[i];
    if(a[i]==0)continue;
    for(int j=i+1;j<n;j++){
      if(a[j]==s)a[i]=a[j]=0;
    }
  }
  return 0;
}

int main(){
  cin>>n;
  loop(i,n)cin>>a[i]>>b[i]>>c[i];
  zero(a);
  zero(b);
  zero(c);
  loop(i,n){
    cout<<(a[i]+b[i]+c[i])<<endl;
  }
  return 0;
}

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

int main() {
 ll n;
 cin>>n;
 ll a[n];
 ll ans=0;
 rep(i,n){
   cin>>a[i];
}
 ll sum[n+1];
 sum[0]=0;
 map<ll,ll> b;
 b[0]=1;
 rep(i,n){
  sum[i+1]=sum[i]+a[i];
}
 rep(i,n){
    if(b.find(sum[i+1])==b.end()){
      b[sum[i+1]]=1;
    }
    else {
      b[sum[i+1]]++;
    }
}
for(auto i:b){
    if(i.second>=2){
    ans+=(i.second*(i.second-1))/2;
    }
}
cout<<ans<<endl;
}


Measured memory_bytes: 15872
from math import *
from collections import *
from random import *
from bisect import *
import sys
input=sys.stdin.readline
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
def inp():
    return int(input())
x=inp()
s='No'
if(x>=30):
    s='Yes'
print(s)
            

        
            
        
    
        
    


Measured memory_bytes: 76568
//Try until you reach your goal
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x;
    cin>>x;
    ll y=1000000007;
    ll a[x];
    f(i,x){
        cin>>a[i];
    }
    vll v;
    ll s=0;
    f(i,x){
        s+=a[i];
        v.pb(s);
    }
    ll ans=0;
    for(ll i=0;i<x;i++){
        ll k=(v[x-1]-v[i]+y)%y;
        ll k1=a[i]*k;
        k1%=y;
        ans+=k1;
        ans%=y;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6868
a = list(map(int, input().split()))
cnt_5 = 0
cnt_7 = 0

for i in a:
  if i == 5:
    cnt_5 += 1
  if i == 7:
    cnt_7 += 1
      
if cnt_5 == 2 and cnt_7 == 1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9060
import sys
import math
n = int(input())
f = 1

for i in range(int(n/1.08)-10,int(n//1.08)+12):
    if math.floor(i * 1.08) == n:
        print(i)
        f = 0
        sys.exit()
        
if f == 1:
    print(':(')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        //aとbの値を代入する
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        //面積と周の値を求める
        int area = a * b;
        int periphery = (a + b) * 2;
        
        //面積と周の値を表示する
        System.out.println(area + " " + periphery);
    }
}



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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> vs(h);
  REP(i, h) {
    cin >> vs[i];
  }
  string up(w+2, '#');

  cout << up << endl;
  REP(i, vs.size()) {
    cout << '#';
    cout << vs[i];
    cout << '#' << endl;;
  }
  cout << up << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int ans = 0;
    int N,M;cin >> N;
    string S[N],T[M];
    vector<pair<string,int>> V;
    REP(i,N){
        cin >> S[i];
        V.pb({S[i],1});
    }cin >> M;
    REP(i,M){
        cin >> T[i];
        V.pb({T[i],-1});
    }
    sort ALL(V);
    int cnt = V[0].second;V.pb({"@@@",-1});
    REP(i,N+M){
      //cout << V[i].first << ' ' << V[i+1].first << endl;
        if(V[i].first != V[i+1].first){
            ans = max(ans,cnt);
            cnt = V[i+1].second;
        }
        else{
            cnt += V[i+1].second;
        }
    }
    cout << ans << endl;
}

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

int main() {
	int N;
	std::cin >> N;

	std::vector<int> b(N);
	for(int &bi : b) {
		std::cin >> bi;
	}

	std::vector<int> result;
	while(!b.empty()) {
		int index = -1;
		for(int i = b.size() - 1; i >= 0; i--) {
			if(i + 1 == b.at(i)) {
				index = i;
				break;
			}
		}

		if(index == -1) {
			std::cout << "-1" << std::endl;
			return 0;
		}

		result.emplace_back(index + 1);
		b.erase(b.begin() + index);
	}

	for(auto itr = result.rbegin(); itr != result.rend(); ++itr) {
		std::cout << *itr << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int x;
	cin>>x;
	for(int i=x; ; i++){
		bool dame=0;
		for(int j=2; j*j<=i; j++){
			if(i%j==0){
				dame=1;
				break;
			}
		}
		if(!dame){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int V[50];
long long int dp[51][51][100];

long long int MAX(long long int a, long long int b, long long int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

long long int suteru(long long int sum, int k, int fu[50], int cnt) {
	int i;
	for (i = cnt - 1; i >= 0 && k != 0; i--) {
		sum = sum - fu[i];
		k--;
	}
	return sum;
}

long long int rec(long long int sum, int left, int right, int value, int k, int* fu, int cnt) {
	
	int i;
	int temp[50];

	for (i = cnt - 1; i >= 0; i--) {
		temp[i] = fu[i];
	}

	if (value < 0) {
		for (i = cnt; i > 0 && temp[i - 1] < value; i--) {
			temp[i] = temp[i - 1];
		}		
		temp[i] = value;
		cnt++;
	}

	sum = sum + value;

	if (k == 0 || left > right) {
		return suteru(sum, k, temp, cnt);
	}

	if (dp[left][right][k] != -1) {
		return dp[left][right][k];
	}

	return dp[left][right][k] = MAX(suteru(sum, k, temp, cnt), rec(sum, left + 1, right, V[left], k - 1, temp, cnt), rec(sum, left, right - 1, V[right], k - 1, temp, cnt));
}

int main() {
	int N, K, i, fu[50], cnt = 0;
	long long int vmax = 0;

	memset(fu, 0, sizeof(fu));
	memset(dp, -1, sizeof(dp));

	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) {
		scanf("%d", &V[i]);
	}

	vmax = MAX(0, rec(0, 1, N - 1, V[0], K - 1, fu, cnt), rec(0, 0, N - 2, V[N - 1], K - 1, fu, cnt));

	printf("%lld\n", vmax);

	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0; i < N; i++){
        int val;
        cin >> val;
        v[i] = val - 1;
    }

    vector<int> cont;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(v[i] == i){
            cnt ++;
        }
        else{
            cont.push_back(cnt);
            cnt = 0;
        }
    }
    cont.push_back(cnt);

    ll ans = 0;
    for(int i = 0; i < cont.size(); i++){
        ans += (cont[i] + 1) / 2;
    } 
    cout << ans << endl;

}


Measured memory_bytes: 1276
Y_MASK = 10**10

N, M = STDIN.gets.chomp.split(" ").map(&:to_i)

PYs = (1..M).map{|i| STDIN.gets.chomp.split(" ").map(&:to_i)}

table = PYs.each_with_index.map{|py, i| [i, py]}.group_by{|e| e[1][0]}.each_value{|v| v.sort!{|a, b| a[1][1] <=> b[1][1]}}.each_value{|v| v.each_with_index{|e, i| e.push(sprintf("%06d%06d", e[1][0], i + 1))}}

puts table.values.flatten(1).sort{|a, b| a[0] <=> b[0]}.map{|e| e[2]}.join("\n")


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


def solve(N: int, K: int, h: "List[int]"):
    cnt=0
    for i in h:
        if i >= K:
            cnt += 1
    
    print(cnt)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


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

int main() {
	int a, b;
	cin >> a >> b;

	int sub = b - a;
	int low = 0;
	for (int i = 0; i < sub; i++) {
		low += i;
	}
	int ans = low - a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;



void main() {
    string input;
    const string[] classBoxing = ["light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"];

    while ((input = readln.chomp).length != 0) {
        double weight = input.to!double;
        uint index;

        if (weight <= 48.00) {
            index = 0;
        } else if (weight <= 51.00) {
            index = 1;
        } else if (weight <= 54.00) {
            index = 2;
        } else if (weight <= 57.00) {
            index = 3;
        } else if (weight <= 60.00) {
            index = 4;
        } else if (weight <= 64.00) {
            index = 5;
        } else if (weight <= 69.00) {
            index = 6;
        } else if (weight <= 75.00) {
            index = 7;
        } else if (weight <= 81.00) {
            index = 8;
        } else if (weight <= 91.00) {
            index = 9;
        } else {
            index = 10;
        }

        writeln(classBoxing[index]);
    }
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF (1e9)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define print(s) cout<<(s)<<endl
#define all(x) (x).begin(),(x).end()

int main() {
    int A, B;
    cin >> A >> B;
    if (A <= 9 && B <= 9){
        cout << A * B << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

using namespace std;

const int MAX_N = 2020, mod = 1e9 + 7;

int n, k, dp[MAX_N][MAX_N], fac[MAX_N * MAX_N], fac_inv[MAX_N * MAX_N], fac_tot;

int quick_pow(int bas, int tim)
{
    int ret = 1;
    while (tim)
    {
        if (tim & 1)
            ret = 1LL * ret * bas % mod;
        bas = 1LL * bas * bas % mod;
        tim >>= 1;
    }
    return ret;
}

int comb(int upper, int lower) { return 1LL * fac[upper] * fac_inv[lower] % mod * fac_inv[upper - lower] % mod; }

int main()
{
    scanf("%d%d", &n, &k), fac_tot = n * k;
    if (k == 1)
        puts("1"), exit(0);
    for (int i = fac[0] = 1; i <= fac_tot; i++)
        fac[i] = 1LL * fac[i - 1] * i % mod;
    fac_inv[fac_tot] = quick_pow(fac[fac_tot], mod - 2);
    for (int i = fac_tot - 1; i >= 0; i--)
        fac_inv[i] = 1LL * fac_inv[i + 1] * (i + 1) % mod;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= i; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j > 0)
                dp[i][j] = (1LL * dp[i][j] + 1LL * comb(n - i + (n - j + 1) * (k - 1) - 1, k - 2) * dp[i][j - 1] % mod * (n - j + 1) % mod) % mod;
        }
    printf("%d\n", dp[n][n]);
    return 0;
}

Measured memory_bytes: 47872
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a[12] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    cout << (a[x - 1] == a[y - 1] ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;


// ４つの整数b, f, r, vが与えられます。
// これは、b棟f階のr番目の部屋にv人が追加で入居したことを示します。
int main()
{
	int house[4][3][10];
	int n;
	int b, f, r, v;

	// 初期化
	for(int i = 0; i < 4; i++)
		for(int j = 0; j < 3; j++)
			for(int k = 0; k < 10; k++)
				house[i][j][k] = 0;

	// 入力
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		house[b - 1][f - 1][r - 1] += v;
	}

	// 表示
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++)
				cout << " " << house[i][j][k];
			cout << endl;
		}

		if(i != 3)
			cout << "####################" << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
n=int(input())
l=[9,8,7,6,5,4,3,2]
count=0

if 1*2*3*4*25*6*49*8*9%n==0 and n//9<10:
    for i in l:
        if n%i==0 and n/i<10:
            count+=1
            break
print('Yes' if count==1 or n==1 else 'No')


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


int main(){
    int x,n;
    cin>>x>>n;
    vector<bool> num(200);
    rep(i,110){
        num[i]=false;
    }
    int tmp;
    rep(i,n){
        cin>>tmp;
        num[tmp] = true;
    }

/*
    cout<<"hoGE"<<endl;
        rep(i,110){
            if(num[i]==true)cout<<i<<endl;
        }
    cout<<"hoGE"<<endl;
*/

    int diff=200;
    int ans = 0;
    rep(i,110){
        if(num[i]==false){
            // cout<<"HOGE"<<endl;
            if(abs(i-x) < diff){
                diff = abs(i-x);
                ans = i;
                // cout<<"@:"<<diff<<","<<ans<<endl;
            }
        }
    }

    cout<<ans<<endl;

}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define ps(s)    printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>    pii;
typedef pair<ll, ll>      pl;
typedef vector<int>       vi;
typedef vector<ll>        vl;
typedef vector<pii>       vpii;
typedef vector<pl>        vpl;
typedef vector<vi>        vvi;
typedef vector<vl>        vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
#define MAXN   20000001 
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================


void solve(){
    ll x;
    cin>>x;
    int k=1;
    while((360*k)%x!=0)
    {
        ++k;
    }
    cout<<(360*k)/x<<endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}
vl g[N];


int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


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

int main() {
  int N;
  cin >> N;
  int answer = 0;
  for (int i=1; i<N+1; i+=2) {
    int counter = 0;
    for (int j=1; j<i+1; j++) {
      if (i%j == 0) {
        counter++;
      }
    }
    if (counter == 8) {
      answer++;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 384