akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &k)

	if n == k {
		fmt.Println(0)
		return
	}

	tmp := n
	for tmp > k {
		tmp = tmp % k
	}
	ans := min(tmp, abs(tmp-k))
	fmt.Println(ans)

}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val x = (0 until n).map { sc.next().toLong() }
    println(problem107c(n, k, x))
}

fun problem107c(n: Int, k: Int, x: List<Long>): Long {
    var min = Long.MAX_VALUE
    for (i in 0 .. n - k) {
        if (i < 0 && x[i + 1] < 0) continue
        if (i > 0 && x[i - 1] > 0) continue
//        debugLog(i, x[i], x[i + k - 1], Math.abs(x[i] - x[i + k - 1]) * 2, Math.abs(x[i] * 2 - x[i + k - 1]))
        if (x[i] > 0) {
            min = Math.min(min, x[i + k - 1])
            continue
        }
        if (x[i + k - 1] < 0) {
            min = Math.min(min, Math.abs(x[i]))
            continue
        }
        min = listOf(min, Math.abs(x[i] - x[i + k - 1] * 2), Math.abs(x[i] * 2 - x[i + k - 1])).min()!!
    }
    return min
}

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

namespace AOJ
{
    public class ITP1_2_C{
        public static void Main(){
            IEnumerable<string> orderedItems = Console.ReadLine().Split(' ')
                                                    .Select(int.Parse)
                                                    .OrderBy(item => item)
                                                    .Select(item => item.ToString());
            Console.WriteLine(string.Join(" ", orderedItems));
        }
    }
}



Measured memory_bytes: 16512
//Why it is WA?It should be AC.
#include<bits/stdc++.h>
long long a[10000],b[10000];
using namespace std;
int main()
{
	long long n,i=0,j=0,k,ba=0;
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>a[t];
		i=i+a[t];
	}
	//cout<<i<<" ";
	for(int t=0;t<n;t++)
	{
		cin>>b[t];
		j=j+b[t];
	}
	//cout<<j<<endl;
	if(i<=j)
	{
		k=j-i;
		//cout<<k<<" ";
		for(int t=0;t<n;t++)
		{
			if(a[t]<b[t])
			{
				ba=ba+(b[t]-a[t]+1)/2;
				//cout<<(b[t]-a[t]+1)/2<<" "; 
			} 
		}
		//cout<<ba<<" ";
		if(ba>k)
		{
			cout<<"No";
		}
		else
		{
			cout<<"Yes";
		}
	}
	else
	{
		cout<<"No";
	}
	return 0;
} 

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    S = ins()
    return "x" * len(S)


print(solve())


Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

typedef long long ll;

ll n, m, ans;
char a[N], b[N];
map < ll , char > h;

ll gcd(ll x, ll y){
	if(y == 0)
		return x;
	return gcd(y, x%y);
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld %s %s",&n ,&m ,a + 1, b + 1);
	ans = n*m/gcd(n, m);
	for(int i = 1; i <= n; i++)
		h[1ll*(i - 1)*(ans/n) + 1ll] = a[i];
	for(int i = 1; i <= m; i++){
		ll yer = 1ll*(i - 1)*(ans/m) + 1ll;
		if(h.count(yer) == 0)
			continue;
		if(h[yer] != b[i]){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int l[n];
  REP(i,n){
    cin>>l[i];
  }
  sort(l,l+n,greater<int>());
  int sum=0;
  REP(i,k){
    sum+=l[i];
  }
  cout<<sum<<endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 1000001

typedef long long int ll;

using namespace std;

int main()
{
    si(n);
    ll a[n];
    fr(i,0,n)
        cin>>a[i];
    ll sum=0;
    fr(i,0,n)
    {
        fr(j,i+1,n)
        {
            sum+=a[i]*a[j];
        }
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int CASE;
int L, E[210];
int dp[210][2100];

int solve() {
    if (L == 1) return E[0];
    if (L == 2) return E[1];
    
    memset(dp, 0, sizeof(dp));
    dp[0][E[0]] = E[1];
    for (int i = 0; i < L-2; ++i) {
        for (int j = 0; j < 2000; ++j) {
            if (j > 0 && dp[i][j] > 0) { 
                chmax(dp[i+1][dp[i][j]-1], j+E[i+2]); 
                //cout << i << ", " << j << " : " << dp[i][j] << endl;
            }
            chmax(dp[i+1][dp[i][j]], E[i+2]);
        }
    }
    int res = E[L-1];
    for (int j = 0; j < 2100; ++j) chmax(res, dp[L-2][j]);
    
    return res;
}

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    cin >> CASE;
    for (int AAA = 0; AAA < CASE; ++AAA) {
        cin >> L;
        for (int i = 0; i < L; ++i) cin >> E[i];
        cout << solve() << endl;
    }
    return 0;
}


Measured memory_bytes: 2892
#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--)
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a,b;
	cin >> a >> b;
	int x = stoi(a+b);
	bool f = false;
	rep(i,1000){
		if(i*i == x){
			f = true;
		}
	}
	cout << (f?"Yes":"No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        final int N = sc.nextInt();

        long ans = 0;

        for (int i = 0; i < N; i++) {
            final long A = sc.nextLong();
            ans = gcd(ans, A);
        }

        System.out.println(ans);
    }

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


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

bool hangaku(int x, int y){
	int max=19*60+30, min=17*60+30;
	int n=x*60+y;

	if(min<=n && n<=max) return true;
	else return false;
}

int main(){
	//料金
	int p[8][8]={0};
	p[1][2]=300; p[1][3]=500; p[1][4]=600; p[1][5]=700; p[1][6]=1350; p[1][7]=1650;
	p[2][3]=350; p[2][4]=450; p[2][5]=600; p[2][6]=1150; p[2][7]=1500;
	p[3][4]=250; p[3][5]=400; p[3][6]=1000; p[3][7]=1350;
	p[4][5]=250; p[4][6]=850; p[4][7]=1300;
	p[5][6]=600; p[5][7]=1150;
	p[6][7]=500;     
	
	for(int i=1; i<8; ++i){
		for(int j=i+1; j<8; ++j){
			p[j][i]=p[i][j];
		}
	}
	
	//半額になるかどうか
	bool half[8][8];
	for(int i=0; i<8; ++i)
		for(int j=0; j<8; ++j)
			half[i][j]=true;
			
	half[1][6]=false; half[1][7]=false; half[2][7]=false; half[3][7]=false;
	half[6][1]=false; half[7][1]=false; half[7][2]=false; half[7][3]=false;
			
	//処理
	while(1){
		int inic, outic, h1, m1, h2, m2;
		
		scanf(" %d", &inic);
		if(inic==0) break;
		
		scanf(" %d %d", &h1, &m1);
		scanf(" %d", &outic);
		scanf(" %d %d", &h2, &m2);
	
		int price=p[inic][outic];
		if(half[inic][outic]){
			if(hangaku(h1, m1) || hangaku(h2,m2)){
				price/=2;
				if(price%50!=0){
					price+=50-(price%50);	
				}
			}		
		}
		printf("%d\n", price);
	}
	return 0;
}

Measured memory_bytes: 1188
/**
*    created: 15.06.2020 11:16:29
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

const int INF = 1000000000;
vector<int> to[100005];

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n,-1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    

    cout << "Yes" << endl;
    rep(i,n) {
        if (i == 0) continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 13712
abc= gets.split(" ").map { |e| e.to_i }
k = gets.to_i

max = abc.max
n_max = abc.index(max)
count = 0

for i in 0..2 do
  if i == n_max
    count += max * 2**k
  else
    count += abc[i]
  end
end

puts count


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	ll N,A,B;
	cin >> N >> A >> B;
	cout << max(0LL,(B*(N-1)+A) - (A*(N-1)+B) + 1 )<< endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    string S, T; cin >> S >> T;
    deque<char> s, t;

    REP(i, S.size()) {
        s.push_back(S[i]);
    }

    string str = "";
    char res = 'a';
    REP(i, S.size()) {
        res = s[S.size() - 1];
        s.pop_back();
        s.push_front(res);

        string st(s.begin(), s.end());
        if(st == T) {
            str = "Yes";
            break;
        }

        if(i == S.size() - 1) {
            str = "No";
        }
    }

    cout << str << endl;
}

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

typedef struct {
	int x;
	int y;
	int h;
}coordinates;

int dmax(int a, int b) {
	if (a > b) {
		return a;
	}
	else {
		return b;
	}
}

int main() {
	int N, i, ok, CX, CY, H, h0 = -1;
	coordinates info[100];

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d %d %d", &info[i].x, &info[i].y, &info[i].h);
		if (info[i].h != 0 && h0 == -1) h0 = i;
	}

	for (CX = 0; CX < 101; CX++) {
		for (CY = 0; CY < 101; CY++) {
			ok = 1;
			H = info[h0].h + abs(info[h0].x - CX) + abs(info[h0].y - CY);
			for (i = 0; i < N && ok; i++) {
				ok = (info[i].h == dmax(H - abs(info[i].x - CX) - abs(info[i].y - CY), 0));
			}
			if (ok) break;
		}
		if (ok) break;
	}

	printf("%d %d %d", CX, CY, H);

	return 0;
}

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

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

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

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

void solve() {
    ll n;
    cin >> n;
    ll con[4] = {0, 0, 0, 0};
    REP(i, n) {
        string s;
        cin >> s;
        if(s == "AC")
            con[0]++;
        else if(s == "WA")
            con[1]++;
        else if(s == "TLE")
            con[2]++;
        else
            con[3]++;
    }

    cout << "AC x " << con[0] << en;
    cout << "WA x " << con[1] << en;
    cout << "TLE x " << con[2] << en;
    cout << "RE x " << con[3] << en;
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t)
    solve();
    */

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
	string s;
	cin >>s;
	s[3]='8';

	cout <<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<char>s(n);
    ll cnt_r=0,cnt_g=0,cnt_b=0;
    for(ll i=0;i<n;i++){
        cin >> s[i];
        if(s[i]=='R') cnt_r++;
        if(s[i]=='G') cnt_g++;
        if(s[i]=='B') cnt_b++;
    }
    ll ans=cnt_r*cnt_g*cnt_b;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll k=2*j-i;
            if(k>=n) continue;
            if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i]){
                ans--;
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	int sum1=a+b;
	int sum2=a+a-1;
	int sum3=b+b-1;
	int ans=max(sum1,max(sum2,sum3));
	cout<<ans<<endl;
	return 0;
}

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

int main(){
 int n; cin >> n;
 string s; cin >> s;
 int cnt=0;
 for(int i=0;i<n-2;i++)
 if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')cnt++;
 cout << cnt << endl;
}

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

int main(){
    string S,T,W;
    cin >> S >> T;
    for(int i = 0; i< S.size(); i++){
        W = S[S.size()-1]+S.substr(0,S.size()-1);
        S = W;
        if(S == T){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

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

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

using Graph = vector<vector<ll>>;
vector<bool> seen;
vector<ll> dist;
void distance(const vector<vector<pair<ll,ll>>> &G, int v) {
    seen[v] = true; // v を訪問済にする
    for(int i = 0;i < G[v].size();i++){
        if(seen[G[v][i].F]){
            continue;
        }
        dist[G[v][i].F] = dist[v] + G[v][i].S;
        distance(G,G[v][i].F);
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in();
    vector<vector<pair<ll,ll>>> graph(N,vector<pair<ll,ll>>());
    REP(i,N-1){
        ll a = in()-1,b=in()-1,c = in();
        graph[a].pb(mp(b,c));
        graph[b].pb(mp(a,c));
    }
    ll Q = in(),K = in()-1;
    seen.assign(N, false);
    dist.assign(N,INT64_MAX-INT32_MAX);
    dist[K] = 0;
    distance(graph,K);
    REP(i,Q)cout << dist[in()-1] + dist[in()-1] << "\n";
}

Measured memory_bytes: 14336
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	long double a,b,x;
	cin>>a>>b>>x;
	cout<<(long long)(floor(b/x)-floor((a-1)/x))<<endl;
}


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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if( abs(x-a) > abs(x-b) ){
    cout << 'B' << endl;
  }else{
	cout << 'A' << endl;
  }
  return 0;
}


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

A.sort(reverse=True)

T = (sum(A)/(4*M))
n = 0
for i in range(N):
    if A[i] < T:
        continue
    n += 1

if n >= M:
    print('Yes')
else:
    print('No')

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


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> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int n;
int dfs(vvi &dp, vi &p, vi &t, int i, int j) {
	if (j == 3)return INF;
	if (dp[i][j] != -1)return dp[i][j];
	if (i == n - 1)return dp[i][j] = 0;

	int ret = INF;
	if (t[i + 1] - t[i] >= p[i] * (j + 2) + p[i + 1])ret = min(ret, dfs(dp, p, t, i + 1, 0) + p[i + 1] + p[i]);
	if (t[i + 1] - t[i] >= abs(p[i + 1] - p[i])*(j + 2))ret = min(ret, dfs(dp, p, t, i + 1, j + 1) + abs(p[i + 1] - p[i]));

	return dp[i][j] = ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> n, n) {
		vi p(n), t(n);
		REP(i, n)cin >> p[i] >> t[i];
		vvi dp(n, vi(3, -1));
		if (p[0] > t[0]) {
			cout << "NG " << 1 << endl;

		}
		else {
			int a = dfs(dp, p, t, 0, 0);
			if (a == INF) {
				cout << "NG ";
				REP(i, n) {
					int cnt = 0;
					REP(j, 3) {
						if (dp[i][j] == -1)cnt++;
					}
					if (cnt == 3) {
						cout << i + 1 << endl;
						break;
					}
				}
			}
			else cout << "OK " << a + p[0] + p[n - 1] << endl;
		}
	}
}

Measured memory_bytes: 3096
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()
x = list(li())
if n >= m:
    print(0)

else:
    diffs = []
    
    x.sort()
    
    for idx in range(m-1):
        diffs.append(x[idx+1]-x[idx])
        
    diffs.sort()
    
    for _ in range(n-1):
        diffs.pop()
        
    print(sum(diffs))

Measured memory_bytes: 14076
#include<stdio.h>

static const int NMAX = 100;

void bubblesort(int A[], int N)
{
	int times = 0;
	int flag = 1;
	for(int i = 0 ; i < N && flag == 1; i++)
	{
		flag = 0;
		for(int j = 0 ; j < N - (i + 1) ; j++)
		{
			if(A[j] > A[j+1])
			{
				int temp = A[j];
				A[j] = A[j+1];
				A[j+1] = temp;
				flag = 1;
				times++;
			}	
		}
	}
	for(int i = 0 ; i < N ; i++)
	{
		if(i > 0)
		{
			printf(" ");
		}
		printf("%d", A[i]);
		if(i == N - 1)
		{
			printf("\n");
		}
	}
	printf("%d\n", times);
}

int main()
{
	int N = 0;
	int flag = 0;
	int A[NMAX] = {0};
	scanf("%d", &N);
	for(int i = 0 ; i < N ; i++)
	{
		scanf("%d", &A[i]);
	}
	bubblesort(A, N);
	return 0;
}


Measured memory_bytes: 2712
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	l := make([]int, n)
	for i := range l {
		fmt.Scan(&l[i])
	}
	fmt.Println(poly(n, l))
}

func poly(n int, l []int) string {
	sort.Ints(l)
	max := l[len(l)-1]
	var total int
	for i := range l {
		if i == len(l)-1 {
			continue
		}
		total += l[i]
	}
	if total > max {
		return "Yes"
	}
	return "No"
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LL long long
#define MOD (LL)1000000007
#define pi acos(-1.0)
#define ULL unsigned long long
#define mem_1(str) memset(str,-1,sizeof(str))
#define mem0(str) memset(str,0,sizeof(str))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define INF 999999999
using namespace std;
struct ee{            //存放每边的起点终点和权值 
	LL x,y;
	int id;
}num[200000];  
LL p[200000];
struct edge{            //存放每边的起点终点和权值 
	LL u,v;
	LL w;
}myedge[500000];  
bool cmp(const edge& p1,const edge& p2)    
{
	 if(p1.w<p2.w)return true;
     else return false;
}
bool cmpp(const ee& p1,const ee& p2)    
{
	 if(p1.x<p2.x)return true;
     else return false;
}
bool cmppp(const ee& p1,const ee& p2)    
{
	 if(p1.y<p2.y)return true;
     else return false;
}
LL findset(LL x)             //寻找根节点并压缩路径 
{
	if(p[x]==x)return x;
	else p[x]=findset(p[x]);
	return p[x];
}
LL kruskal(int n,int m)      //kruskal算法 
{
	LL x,y;
	LL ans=0;
	for(int i=1;i<=n;i++)
	    p[i]=i;
	sort(myedge+1,myedge+m+1,cmp);
	for(int i=1;i<=m;i++) 
	{	
		x=findset(myedge[i].u);
		y=findset(myedge[i].v);
		if(x!=y)
		{
			ans+=myedge[i].w; 
			p[y]=x;                                  
		}
	}
	return ans;
}
int main()
{
	int n;
	LL ans; 
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&num[i].x ,&num[i].y );
		num[i].id =i;
	}
	sort(num+1,num+n+1,cmpp);
	int s=0;
	for(int i=1;i<n;i++)
	{
		myedge[++s].u =num[i].id ;
		myedge[s].v =num[i+1].id ;
		myedge[s].w =num[i+1].x -num[i].x ;
	}
	sort(num+1,num+n+1,cmppp);
	for(int i=1;i<n;i++)
	{
		myedge[++s].u =num[i].id ;
		myedge[s].v =num[i+1].id ;
		myedge[s].w =num[i+1].y -num[i].y ;
	}
	ans=kruskal(n,s);
	printf("%lld",ans);
}

Measured memory_bytes: 12544
import sys
input = sys.stdin.readline

N, W = map(int, input().split())
dp = [0] * (W + 1)

for _ in range(N):
    w, v = map(int, input().split())
    for i in range(W, w - 1, -1):
        dp[i] = max(dp[i], dp[i - w] + v)

print (dp[W])

Measured memory_bytes: 41708
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
using namespace std;

int main() {
    long long h,m,s;
    long long S;
    cin >> S;
    h = S/3600;
    m = (S%3600)/60;
    s = (S-h*3600-m*60);
    cout << h << ":" << m << ":" << s << endl;
}



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL c_keta(LL a){
    LL keta = 0;

    while(a > 0){
        keta++;
        a/=10;

    }
    return keta;

}

bool check(LL a){
    LL keta = c_keta(a);
    
    int t = a%10;
    a /= 10;
    bool f = true;
    FOR(i,1,keta){
        if(abs(t-a%10) > 1){
            f = false;
        }
		t = a%10;
        a /= 10;
    }
    return f;

}

LL next(LL a){
    if(check(a+1)){
        return a+1;
    }

    LL keta = c_keta(a);
    //dump(keta)

    LL a_back = a;

    do{
        FOR(i,1,keta){
        a = a_back;
            LL kitei = modpow(10,i);
            a += kitei;
            a = (a / kitei) * kitei;

            int now = (a%(kitei*10)) / kitei;
            //dump(now)
            for(int j=i-1;j>=0;j--){
                LL kitei2 = modpow(10,j);
                if(now > 0){
                    a += (now-1) * kitei2;
                    now --;
                }
            }
            if(check(a)){
                break;
            }
        }
        //dump(a)
    }while(!check(a));

    return a;



}

void Main()
{
    LL k; cin>>k;

    LL a = 1;
    LL num = 1;
    //dump(check(k));

    
    while(num != k){

        a = next(a);
        num++;

        //dump(a)
        //dump(num)
    }
    

    cout << a << endl;

    






	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

double calc(int n, double d, double x) {
	return d + (n - 1)*x / 2.0 + (n == 2 ? 0 : calc(n - 2, (d*(n + 2) + 5 * x) / n, (n + 4)*x / n));
}

int main() {
	int n, d, x;
	std::cin >> n >> d >> x;
	std::cout << std::setprecision(16) << calc(2 * n, d, x) << std::endl;
	return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
const int N=100005;
int n,ans,p[1005];
long long x,z,t,k,a[N],b[N];
bool bz[N];
map<long long,int>sum;
map<long long,bool>bo;
int main()
{
	scanf("%d",&n);
	for (int i=2;i<=2155;i++)
	{
		if (!bz[i]) p[++p[0]]=i;
		for (int j=1;j<=p[0] && i*p[j]<=2155;j++)
		{
			bz[i*p[j]]=1;
			if (i%p[j]==0) break;
		}
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&x),a[i]=b[i]=1;
		for (int j=1;j<=p[0];j++)
		if (x%p[j]==0)
		{
			t=0;
			while (x%p[j]==0) t++,x/=p[j];
			t%=3,k=(3-t)%3;
			for (int ii=1;ii<=t;ii++) a[i]*=p[j];
			for (int ii=1;ii<=k;ii++) b[i]*=p[j];
		}
		if (x>1) 
		{
			z=sqrt(x);
			if (z*z==x) t=2; else z=x,t=1;
			t%=3,k=(3-t)%3;
			for (int ii=1;ii<=t;ii++) a[i]*=z;
			for (int ii=1;ii<=k;ii++) b[i]*=z;
		}
	}
	for (int i=1;i<=n;i++) sum[a[i]]++;
	for (int i=1;i<=n;i++)
	if (!bo[a[i]])
	{
		bo[a[i]]=1;
		if (a[i]==b[i]) ans++;
		else
		{
			ans+=max(sum[a[i]],sum[b[i]]);
			bo[b[i]]=1;
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 26752
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int N,M,ans=0,l,r,z=0;
	cin >> N >> M;
	vector<int>L(M),R(M);
	rep(i, M) 
		cin >> L[i] >> R[i];
	l =* max_element(ALL(L));
	r = *min_element(ALL(R));
	cout << max(z,r-l+1) <<endl;
}

Measured memory_bytes: 1792
import math
from functools import reduce
def main():
    K = int(input())
    s = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                s += math.gcd(math.gcd(i, j), k)
    print(s)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9576
@c=($%=<>,2,5,5,4,5,6,3,7,6);@a=sort glob<>;map{//;($p[$_])=sort{$b-$a}map$'<$_?-1:$p[$'-$_]+1,@c[@a]}1..$%;$%-=$c[$~=(grep$p[$#_=$%-$c[$_]]+1==$p[$%],@a)[-1]],print$~while$%

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;


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

    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << el;
    } else{
        cout << "No" << el;
    }

    return 0;
}

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

Measured memory_bytes: 640
/*以下の命令を受けつける双方向連結リストを実装してください。

insert x: 連結リストの先頭にキー x を持つ要素を継ぎ足す。
delete x: キー x を持つ最初の要素を連結リストから削除する。そのような要素が存在しない場合は何もしない。
deleteFirst: リストの先頭の要素を削除する。
deleteLast: リストの末尾の要素を削除する。
*/
#include <stdio.h>
#include <stdlib.h>

typedef struct Node {
  int x;
  struct Node *prev;
  struct Node *next;
} Node;

Node *head, *tail;

void dump() {
  int l = 0;
  Node *p = head;
  while (p != NULL) {
    if (l == 0)  printf("%d",  p->x);
    else printf(" %d", p->x);
    ++l;
    p = p->next;
  }
  printf("\n");
}

void insert(int x) {
  Node *nod = malloc(sizeof(Node));;
  nod->x = x;
  nod->prev = NULL;
  nod->next = NULL;

  if (head == NULL) {
    head = nod;
    tail = nod;
  } else {
    nod->next = head;
    head->prev = nod;
    head = nod;
  }
}

void delete(int x) {
  Node *p = head;
  int flg = 0;

  while (flg == 0 && p != NULL) {
    if (p->x == x) {
      Node *c = p;
      if (c->prev != NULL) {
        p->prev->next = c->next;
      } else {
        head = c->next;
      }

      if (c->next != NULL) {
        p->next->prev = c->prev;
      } else {
        tail = c->prev;
      }
      flg = 1;
    } else {
      p = p->next;
    }
  }
}

void deleteFirst() {
  if (head == tail) {
    head = NULL;
    tail = NULL;
  } else if (head != NULL) {
    if (head->next != NULL) head->next->prev = NULL;
    head = head->next;
  }
}

void deleteLast() {
  if (head == tail) {
    head = NULL;
    tail = NULL;
  } else if (tail != NULL) {
    if (tail->prev != NULL) tail->prev->next = NULL;
    tail = tail->prev;
  }
}

int main(int argc, char **argv) {

  int n;
  scanf("%d\n", &n);

  int i;
  int x;
  char buf[256];
  char tmp[256];
  for (i = 0; i < n; ++i) {
    fgets(buf, 256, stdin);

    if (buf[0] == 'i' || buf[6] == ' ') {
      sscanf(buf, "%s %d", tmp, &x);

      if (buf[0] == 'i') insert(x);
      else               delete(x);
    } else if (buf[6] == 'F') {
      deleteFirst();
    } else if (buf[6] == 'L') {
      deleteLast();
    }
  }

  dump();

  return 0;
}



Measured memory_bytes: 36100
N, M = [int(x) for x in input().split()]

A = []
B = []
C = []

for i in range(N):
    A += [list(input())]

for i in range(M):
    B += [list(input())]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        ans = 'Yes'

#----------- 一致確認 
        for bi in range(M):
            for bj in range(M):
                if A[i+bi][j+bj] != B[bi][bj]:
                    ans = 'No'
                    break
            if ans == 'No':
                break
#----------- 一致確認

        if ans == 'Yes':
            break
    if ans == 'Yes':
        break

print (ans)

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

int main() {
    std::string s;
    std::cin >> s;
    const auto size = s.size();
    
    std::string ret;
    ret += s[0];
    ret += std::to_string(size - 2);
    ret += s[size - 1];

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

char s;

int main() {
	scanf("%c", &s);
	
	if(s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u') {
		printf("vowel");
		return 0;
	}
	else{
		printf("consonant");
	}
	
	return 0;
} 

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int X = s.nextInt();
	if(400 <= X && X < 600){
		System.out.println(8);
	}else if(600 <= X && X < 800){
		System.out.println(7);
	}else if(800 <= X && X < 1000){
		System.out.println(6);
	}else if(1000 <= X && X < 1200){
		System.out.println(5);
	}else if(1200 <= X && X < 1400){
		System.out.println(4);
	}else if(1400 <= X && X < 1600){
		System.out.println(3);
	}else if(1600 <= X && X < 1800){
		System.out.println(2);
	}else{
		System.out.println(1);
	}
    
  }
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

vector<bool> dig(int p) {
  vector<bool> ret(10);
  while(p) {
    ret[p%10] = 1;
    p /= 10;
  }
  return ret;
}

void Main() {
  int N, K;
  cin >> N >> K;

  vector<bool> D(10);
  rep(i, K) {
    int d;
    cin >> d;
    D[d] = 1;
  }

  rep(p, N, 100000) {
    vector<bool> digits = dig(p);
    bool ok = true;
    rep(i, 10) {
      if (digits[i] && D[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      _p("%d\n", p);
      return;
    }
  }
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 384
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



def warshall_floyd(G):
    dist = deepcopy(G)
    n = len(G)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    return dist


def bipartite_or_not(G, s=0):
    n = len(G)
    global color
    color = [0] * n
    color[s] = 1
    dq = deque([s])
    while dq:
        u = dq.popleft()
        for v, bit in enumerate(G[u]):
            if u == v or bit == '0':
                continue
            elif color[v] == 0:
                color[v] = -color[u]
                dq += [v]
            else:
                if color[u] == color[v]:
                    return False
    return True



n = I()
G = SRL(n)
if not bipartite_or_not(G):
    print(-1)
    exit()


for u in range(n):
    for v in range(n):
        if u == v:
            G[u][v] = 0
        elif G[u][v] == '1':
            G[u][v] = 1
        else:
            G[u][v] = INF


dist = warshall_floyd(G)
print(max([dist[u][v] for u in range(n) for v in range(u + 1, n)]) + 1)

Measured memory_bytes: 58844
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
	ll n,m,ans1=0,ans2=0;
	cin>>n>>m;
	ll ac[n]={0},wa[n]={0};
	for(ll i=0;i<m;i++)
	{
		ll in;
		cin>>in;
		string s;
		cin>>s;
		if(s=="AC")
		{
			ac[in-1]=1;
		}
		else
		{
			if(ac[in-1]==0)
			++wa[in-1];
		}
	}
	for(ll i=0;i<n;i++)
	{
		ans1=ans1+ac[i];
		if(ac[i]==1)
		ans2=ans2+wa[i];
	}
	cout<<ans1<<" "<<ans2<<endl;
 	return 0;
}


Measured memory_bytes: 1792
/*input
3
8 12 40
*/
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	int mx = 50000;
	for(int i=0;i<n;++i){
		int x;
		cin >> x;
		int ct = 0;
		while(x % 2 == 0)x/=2, ct++;
		mx = min(mx, ct);
	}
	cout << mx << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vll arr(n);
    for (auto &it : arr)
        cin >> it;
    int threshold = accumulate(all(arr), 0) / (4 * m) + (accumulate(all(arr), 0) % (4 * m) != 0);
    sort(all(arr));
    if (arr[n - m] < threshold)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
    }

    return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<sstream>
#include<iostream>

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;

int main(){
	int n, y;
	cin>>n>>y;
	y /= 1000;
	int m10 = y / 10 + 1;
	REP(i,m10){
		int r10 = y - i * 10;
		if(r10 < 0)continue;
		int m5 = r10 / 5 + 1;
		REP(j,m5){
			int r5 = r10 - j * 5;
			if(r5 < 0)continue;
			if(i + j + r5 == n){
				cout<<i<<" "<<j<<" "<<r5<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
posX, posY, h = [], [], []

for i in range(N):
    tmp = list(map(int, input().split()))
    posX.append(tmp[0])
    posY.append(tmp[1])
    h.append(tmp[2])

h_start = max(h)

for x in range(101):
    for y in range(101):
        for k in range(h_start, h_start + 201):
            flag = True
            for i in range(N):
                tmp_h = max(k - abs(posX[i] - x) - abs(posY[i] - y), 0)
                #print(x, y, k, tmp_h, h[i])
                if tmp_h != h[i]:
                    flag = False
                    break
            if flag == True:
                print(x, y, k)
                exit
        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main(){
  int n,k,cnt=0,h=-1;
  string s;
  cin>>n>>k>>s;
  char c=s[0];
  rep(i,n){
     if(c==s[i]){
        h++; 
     } else{
        c=s[i];
        cnt++; 
     }
  }
  if(k>=cnt/2+cnt%2){
     cout<<n-1; 
  }else{
     cout<<h+k*2; 
  }
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m,j,k,x,y,a,b,t;
	string s;
	
	cin >> s;
	if(s=="SSS")
		cout << 0;
	if(s=="RSR")
		cout << 1;
	if(s=="RSS")
		cout << 1;
	if(s=="SRS")
		cout << 1;
	if(s=="SSR")
		cout << 1;
	if(s=="RRS")
		cout << 2;
	if(s=="SRR")
		cout << 2;
	if(s=="RRR")
		cout << 3;

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,K;
  cin >> N >> K;
  int n=0;
  for(int i=0;i<N;i++){
    cin >> n;
  }

  cout << (N-2)/(K-1)+1 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        boolean isFirst = false;
        for (int i = 0; i < n; i++) {
            boolean isOdd = as[i] % 2 == 1;
            if (isOdd) {
                isFirst = true;
            }
        }

        if (isFirst) {
            System.out.println("first");
        } else {
            System.out.println("second");
        }
    }
}


Measured memory_bytes: 50548
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N, A, B;
	cin >> N >> A >> B;
	int res = min(N*A, B);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256