akhauriyash/Code-Regression huggingface dataset:
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    lint n, k;
    cin >> n >> k;
    cin >> s;
    k--;
    if(s[k] == 'A'){
        s[k] = 'a';
    }
    if(s[k] == 'B'){
        s[k] = 'b';
    }
    if(s[k] == 'C'){
        s[k] = 'c';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(){
    int q,dice[7],x,y,ans[25];
    for(int i=1;i<=6;i++){
        cin>>dice[i];
    }
    cin>>q;
    for(int i=1;i<=q;i++){
        int ans=0;
        cin>>x>>y;
        for(int j=1;j<=6;j++){
            if(x==dice[j])ans=j;
        }
        switch(ans){
            case 1:
                if(y==dice[2]){
                    cout<<dice[3]<<endl;
                }else if(y==dice[3]){
                    cout<<dice[5]<<endl;
                }else if(y==dice[5]){
                    cout<<dice[4]<<endl;
                }else{
                    cout<<dice[2]<<endl;
                }
                break;
            case 2:
                if(y==dice[1]){
                    cout<<dice[4]<<endl;
                }else if(y==dice[4]){
                    cout<<dice[6]<<endl;
                }else if(y==dice[6]){
                    cout<<dice[3]<<endl;
                }else{
                    cout<<dice[1]<<endl;
                }
                break;
            case 3:
                if(y==dice[1]){
                    cout<<dice[2]<<endl;
                }else if(y==dice[2]){
                    cout<<dice[6]<<endl;
                }else if(y==dice[6]){
                    cout<<dice[5]<<endl;
                }else{
                    cout<<dice[1]<<endl;
                }
                break;
            case 4:
                if(y==dice[1]){
                    cout<<dice[5]<<endl;
                }else if(y==dice[5]){
                    cout<<dice[6]<<endl;
                }else if(y==dice[6]){
                    cout<<dice[2]<<endl;
                }else{
                    cout<<dice[1]<<endl;
                }
                break;
            case 5:
                if(y==dice[1]){
                    cout<<dice[3]<<endl;
                }else if(y==dice[3]){
                    cout<<dice[6]<<endl;
                }else if(y==dice[6]){
                    cout<<dice[4]<<endl;
                }else{
                    cout<<dice[1]<<endl;
                }
                break;
            case 6:
                if(y==dice[2]){
                    cout<<dice[4]<<endl;
                }else if(y==dice[4]){
                    cout<<dice[5]<<endl;
                }else if(y==dice[5]){
                    cout<<dice[3]<<endl;
                }else{
                    cout<<dice[2]<<endl;
                }
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const ll INF = ll(1e18)+1;
 
int main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while (l+1 < r) {
    ll x = (l+r)/2;
    bool ok = [&]{
      ll tot = 0;
      rep(i,n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) r = c; else l = c;
          }
          tot += n-r;
        } else {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) l = c; else r = c;
          }
          tot += r;
        }
        if (a[i]*a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok) l = x; else r = x;
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;	cin >> n;
  if(n%10==3){
    cout << "bon";
    return 0;
  }else if(n%10==0||n%10==1||n%10==6||n%10==8){
    cout << "pon";
    return 0;
  }else{
    cout << "hon";
    return 0;
  }
}

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

int main(){
  int r,d,x[11];
  cin >> r >> d >> x[0];
  for(int i=0;i<10;i++){
    x[i+1] =  r*x[i]-d;
    cout << x[i+1] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(raw_input())

times = n
for i in range(n+1):
    c = 0
    six = i
    nine = n-i
    while six>0:
        c += six%6
        six /= 6
    while nine>0:
        c += nine%9
        nine /= 9
    if c<times:
        times = c

print times





Measured memory_bytes: 5764
//Created by Young Charlie
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int(a.size())

int main(){
	int t = 0;
	vector<int> a(3);
	for(int i = 0; i < 3; i++){
		cin>>a[i];
		t += a[i];
	}
	int k; cin>>k;
	sort(a.begin(), a.end());
	
	cout<<t - a[2] + a[2] * pow(2, k)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T> bool chmix(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;

	Vec a(n);
	vector<VecP> t(n);
	rep(i, n){
		cin >> a[i];
		t[i].resize(a[i]);
		rep(j, a[i]){
			cin >> t[i][j].fs >> t[i][j].sc;
			t[i][j].fs--;
		}
	}

	ll ans = 0;
	rep(bit, (1 << n)){
		bitset<30> bits(bit);

		bool flg = true;
		rep(i, n){
			if(bits[i]){
				for(P j : t[i]){
					if(j.sc != bits[j.fs]){
							flg = false;
							break;
					}
				}
			}
			if(!flg) break;
		}
		if(flg) chmax(ans, (ll)bits.count());
	}
	co(ans);

	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++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,l;
    cin >> n >> l;
    vector<int> taste(n);
    rep(i,n){
        taste[i] = l + i;
    }
    int total = 0;
    rep(i,n) total += taste[i];
    if(l >= 0) total -= taste[0];
    else if(n+l <= 0) total -= taste[n-1];
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<unordered_set>
#define rep(a,b,c,g) for(int a=b,back=(g>=0?1:-1);back*a<=back*c;a+=g)
using namespace std;
int n,m;
unordered_set<int> red;
int box[100009];
int isred[100009];
int main(){
	cin>>n>>m;
	red.insert(1);
	fill(box,box+n+1,1);
	isred[1]=1;
	int p,q;
	while(m--){
		cin>>p>>q;
		if(box[p]){
			box[p]--;
			box[q]++;
			if(isred[p]){
				isred[q]=1;
				red.insert(q);
				if(box[p]==0){
					isred[p]=0;
					red.erase(p);
				}
			}
		}	
	}
	cout<<red.size();
	return 0;
}

Measured memory_bytes: 5024
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

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

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

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

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	A := make([]int, n)
	B := make([]int, n-1)

	for i := 0; i < n-1; i++ {
		B[i] = readInt()
	}

	A[0] = B[0]
	for i := 0; i < n-2; i++ {
		if B[i] <= B[i+1] {
			A[i+1] = B[i]
		} else {
			A[i+1] = B[i+1]
		}
	}
	A[n-1] = B[n-2]

	ans := 0
	for _, v := range A {
		ans += v
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include <bitset>

using namespace std;
int main() {
    int N;
    double ans = 0.0,A;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        ans += 1.0 / A;
    }

    ans = 1.0 / ans;
    cout << setprecision(16) << ans << endl;
    //cout << ans << endl;
    
}

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

void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
	vis[node] = true; 

	for (int i = 0; i < adj[node].size(); i++) { 

		if (!vis[adj[node][i]]) 
			dfs(adj[node][i], adj, dp, vis); 

		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
        //cout<<node<<" "<<adj[node][i]<<" "<<dp[node]<<" "<<dp[adj[node][i]]<<endl;
	} 
} 

void addEdge(vector<int> adj[], int u, int v) 
{ 
	adj[u].push_back(v); 
} 

int findLongestPath(vector<int> adj[], int n) 
{ 
	int dp[n + 1]; 
	memset(dp, 0, sizeof dp); 


	bool vis[n + 1]; 
	memset(vis, false, sizeof vis); 

	for (int i = 1; i <= n; i++) { 
		if (!vis[i]) 
			dfs(i, adj, dp, vis); 
	} 

	int ans = 0; 

	for (int i = 1; i <= n; i++) { 
		ans = max(ans, dp[i]); 
	} 
	return ans; 
} 
//pehleke submission dekhna ....isme usme ek chees ka difference hai..bas dfs fun mai...isme mai path length backward mai store kr rhii..pehle wale maii forward mai kr rhi thi..but forward krne mai kai bar visited note dobara visit nhi ho rhee..which gives wrong answer
int main() 
{ 
	int n,m; 
	cin>>n>>m;
	vector<int> adj[n + 1]; 

	
	while(m--)
	{
		int u,v;
		cin>>u>>v;
	addEdge(adj, u, v); 
	}

	cout << findLongestPath(adj, n); 
	return 0; 
} 


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

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll x;
cin>>x;
if(x==3||x==5||x==7){
    cout<<"YES"<<endl;
}else{
    cout<<"NO"<<endl;
}
}









Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <complex>
#include <vector>
#include <cfloat>
#include <algorithm>
using namespace std;

#define EPS 1e-8 //許容される誤差の程度
#define PI acos(-1.0)

typedef complex<double> point;
typedef vector<point> polygon;

int n;
double r[101];
point c[101];

double dot(point va, point vb){
	return real(va) * real(vb) + imag(va) * imag(vb);
}

double cross(point va, point vb){
	return real(va) * imag(vb) - imag(va) * real(vb);
}

//円同士の交点
//AOJ 1292で使用。
vector<point> intersectcircle(point p1, double r1, point p2, double r2){
	double d = abs(p2 - p1);
	double phi = arg(p2 - p1);
	
	vector<point> ret;
	
	double costheta = (d * d + r1 * r1 - r2 * r2) / (2.0 * d * r1);
	if( abs(costheta) > 1.0 ){	return ret;	}	//交点なし
	
	double theta = acos(costheta);

	ret.resize(2);
	ret[0] = p1 + polar(r1, phi + theta);
	ret[1] = p1 + polar(r1, phi - theta);
	if( ret[0] == ret[1] ) ret.resize(1);
	return ret;
}

//点が円に含まれているかどうか
bool contains_cp(point pc, double r, point pt){
	return norm(pc - pt) < r*r;
}

double solve()
{
	double res = 0;
	
	for(int k = 0; k < n; k++){
		
		//cout << res << endl;
		vector<point> intrsct;
		
		//円kとそれ以外の円の交点をすべて求め、intrsctに格納
		for(int i = 0; i < n; i++){
			if(k==i)
				continue;
			
			vector<point> intrsct_sub = intersectcircle(c[k], r[k], c[i], r[i]);
			
			if( intrsct_sub.size() == 2 )
				for(int j = 0; j < 2; j++)
					intrsct.push_back(intrsct_sub[j]);
		}
		
		//円kの中心から交点へのベクトルの偏角を求める
		vector<double> intrarg;
		
		intrarg.push_back(-PI);
		intrarg.push_back(PI);
		
		for(int i = 0; i < intrsct.size(); i++){
		
			intrarg.push_back(arg(intrsct[i]-c[k]));
		}
		
		sort(intrarg.begin(), intrarg.end());
		
		for(int i = 0; i < intrarg.size()-1; i++){
			//交点と次の交点の弧がほかの円に含まれているかどうか判定
			point pcir = c[k] + polar(r[k], (intrarg[i]+intrarg[i+1])/2);
			bool f = true;
			
			for(int j = 0; (j < n)&&f; j++){
				if( k!=j && contains_cp(c[j], r[j], pcir))
					f = false;
			}
			
			if(f==true){
				//含まれていなければ、弧の長さを加算
				res += r[k]*(intrarg[i+1]-intrarg[i]);
			}
		}
	}
		
	return res;
}
		
int main(){
	
	while(cin >> n, n){
		for(int i = 0; i < n; i++){
			double x, y;	
			cin >> x >> y >> r[i];
			c[i] = point(x, y);
		}
		
		printf("%.12f\n", solve());
	}
	
	return 0;
}

Measured memory_bytes: 1364
import java.io.*;
 
class Main
{
    public static void main (String args[]) throws IOException
{
    BufferedReader br =
    new BufferedReader(new InputStreamReader(System.in));
 
    String str = br.readLine();
    int x = Integer.parseInt(str);
 
  
        System.out.println((int)Math.pow(x,3));
     }
     
}

Measured memory_bytes: 24232
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 2019;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	string s;
	cin >> s;
	ll n = s.size();
	Vec t(n);
	rep(i, n) t[i] = s[i] - '0';
	Vec pos(n);
	repr(i, n){
		if(i == n - 1) pos[i] = 1;
		else pos[i] = (pos[i + 1] * 10) % MOD;
	}

	Vec cnt(MOD);
	cnt[0]++;

	ll ans = 0;
	ll r = 0;
	repr(i, n){
		r += pos[i] * t[i];
		r %= MOD;
		ans += cnt[r];
		cnt[r]++;
	}

	co(ans);

	return 0;
}


Measured memory_bytes: 6732
from operator import itemgetter
from math import ceil
N, C, K = map(int, input().split())
T = []
for i in range(N):
  T.append(int(input()))
  
T.sort()
i=0
ans=0
while i < N:
  buscnt = 0
  tlimit = T[i] + K
  while i < N and T[i] <= tlimit and buscnt < C:
    buscnt += 1
    i += 1
  if i==N:
    break
  
  #print(i,T[i],tlimit)
  ans += 1

if buscnt > 0:
  ans += 1

print(ans)


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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	ll a,b;
	cin>>a>>b;
	ll c = a + b;
	if(c%2==0)
	{
		cout<<c/2;
	}
	else
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;

    int x;
    cin >> x;
    long min, max, sum;
    min = max = sum = x;
    for (int i = 1; i < n; ++i)
    {
        cin >> x;
        if (x < min) min = x;
        if (max < x) max = x;
        sum += x;
    }
    cout << min << ' ' << max << ' ' << sum << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int func (vector<int> A) {
    int mn = 100;
    for (int i = 0; i < (int)A.size(); i++) {
        for (int j = i+1; j < (int)A.size(); j++) {
            int dis = abs(A[i]-A[j]);
            chmin(mn, dis);
        }
    }
    return mn;
}

int main() {
    int N;
    cin >> N;
    vector<int> D(N+1, 0);
    for (int i = 0; i < N; i++) cin >> D[i];
    // 25人以上 (N >= 24) の場合、鳩ノ巣原理より答えは 0
    // ここまでは合ってるっぽい
    if (N >= 24) { cout << 0 << endl; return 0; }
    
    /*
        2^23 = 8388608 = 8.3 * 1e6
        2^23 * 23 = 1.9 * 1e8
    */
    sort(D.begin(), D.end());
    vector<int> t1, t2;
    for (int i = 0; i <= N; i++) {
        if (i&1) t1.emplace_back(D[i]);
        else t1.emplace_back((24-D[i])%24);
    }
    for (int i = 0; i <= N; i++) {
        if (i&1) t2.emplace_back((24-D[i])%24);
        t2.emplace_back(D[i]);
    }
    
    int ans = max(func(t1), func(t2));
    cout << ans << endl;
    return 0;
}
    

Measured memory_bytes: 256
#include <cstdio>

const int MaxN = 100 + 5, MaxK = 100000 + 5;
const int Mod = 1000000007;

int N, K;
int A[MaxN];
int F[MaxK], G[MaxK];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }
inline int max(int x, int y) { return x > y ? x : y; }

void init() {
  scanf("%d %d", &N, &K);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
}

inline void makePre() {
  G[0] = F[0];
  for (int i = 1; i <= K; ++i)
    G[i] = add(G[i - 1], F[i]);
}

inline int qrange(int l, int r) {
  if (l == 0) return G[r];
  else return sub(G[r], G[l - 1]);
}

void solve() {
  F[0] = 1;
  makePre();
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= K; ++j) {
      int l = max(0, j - A[i]);
      F[j] = qrange(l, j);
    }
    makePre();
  }
  printf("%d\n", F[K]);
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 896
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

int main(){
  ll a,b;
  cin >> a >> b;
  if(a*b%2==0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,l,r,a[100000];
	while(cin>>n>>l>>r,n){
		int ans=0;
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=l;i<=r;i++){
			int flag=0;
			for(int j=0;j<n;j++){
				if(i%a[j]==0){
					if(j%2==0)ans++;
					flag++;
					goto L;
				}
			}
			L:;
			if(!flag){
				if(n%2==0)ans++;
			}
		}
		cout<<ans<<endl;
	}
}


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

int main() {
    int N;
    cin>>N;
    vector<int> h(N);
    map<int,int> m;
    for (int i = 0; i < N; i++){
        cin>>h[i];
        m[i-h[i]]++;
    }
    long long count=0;
    for (int i = 0; i < N; i++){
        count+=m[i+h[i]];
    }
    cout<<count<<endl;
}

Measured memory_bytes: 21040
/*
Jugemu Jugemu
Goko-no surikire
Kaijarisuigyo-no
Suigyomatsu Unraimatsu Furaimatsu
Kuunerutokoro-ni Sumutokoro
Yaburakoji-no burakoji
Paipopaipo Paipo-no-shuringan
Shuringan-no Gurindai
Gurindai-no Ponpokopi-no Ponpokona-no
Chokyumei-no Chosuke
*/

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;

string s;
bool cek[26];

int main(){
    cin >> s;
    for (auto &c : s){
        cek[c - 'a'] = 1;
    }
    if (s.length() < 26) {
        char g = 'a';
        while (cek[g - 'a']) {
            ++g;
        }
        s.pb(g);
        cout << s << endl;
        return 0;
    }
    for (int i = 25; i >= 0; --i){
        for (int j = s[i] - 'a' + 1; j < 26; ++j){
            if (!cek[j]){
                s[i] = 'a' + j;
                cout << s << endl;
                return 0;
            }
        }
        cek[s[i] - 'a'] = false;
        s.pop_back();
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i++)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm


signed main(){
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(10));
  vector<vector<int>> b(n,vector<int>(11));
  
  rep(i,0,n){
    rep(j,0,10){
      cin >> a[i][j];
    }
  }
  
  rep(i,0,n){
    rep(j,0,11){
      cin >> b[i][j];
    }
  }
  
  vector<int> now(10);
  
  int nowi;
  int ans = -INF;
  
  rep(i,1,1024){
    now = {0,0,0,0,0,0,0,0,0,0};
    vector<int> ct(n,0);
    int memo = 0;
    nowi = i;
    
    rep(j,0,10){
      now[j] = nowi%2;
      nowi /= 2;
    }
    
    rep(j,0,n){
      rep(k,0,10){
        if(a[j][k]==1 && now[k]==1) {
          ct[j]++;
        }
      }
    }
    
    rep(j,0,n){
      memo += b[j][ct[j]];
      //cout << memo << ' ';
    }
    
    ans = max(ans,memo);
    //cout << endl;
  }
  
  cout << ans << endl;
}


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


int main(){
  int a, b, c, sum=0;
  cin >> a >> b >> c;
  for(int i=a;i<=b;i++){
    if(c % i == 0){
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1164
from collections import deque
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

colors = deque()
for i in range(N):
    index = bisect.bisect_left(colors, A[i])
    if index == 0:
        colors.appendleft(A[i])
    else:
        colors[index - 1] = A[i]
print(len(colors))


Measured memory_bytes: 8060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int bit_count(int num)
{
	int count = 0;

	for (; num != 0; num &= num - 1)
	{
		count++;
	}

	return count;
}

int main()
{
	long long ans = 0;
	int N;
	cin >> N;

	vector<int> table(5, 0);

	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;

		switch (s[0])
		{
		case 'M':
			table[0]++;
			break;
		case 'A':
			table[1]++;
			break;
		case 'R':
			table[2]++;
			break;
		case 'C':
			table[3]++;
			break;
		case 'H':
			table[4]++;
			break;
		default:
			break;
		}
	}

	for (int bin = 1; bin <= 0b11111; bin++)
	{
		if (bit_count(bin) == 3)
		{
			long long multi = 1;
			for (int i = 0; i < 5; i++)
			{
				if (bin & (1 << i))
				{
					multi *= table[i];
				}
			}

			ans += multi;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }
  int bit[1000]={};
  rep(i,n){
    int x=a[i];
    int j=1,c=0;
    while(j<=x){
      bit[c]+=!!(x&j);
      j<<=1;
      c++;
    }
    //cout<<x<<endl;
  }

  int x=1,c=0;
  while(x<=k){
    x<<=1;
    c++;
  }
  x>>=1;
  c--;
  int res=0;
  rrep(i,c){
    if(n-bit[i]>bit[i]&&res+x<=k){
      res+=x;
    }
    x>>=1;
  }

  int ans=0;
  rep(i,n){
    ans+=res^a[i];
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 1024
<?php
$count_list = array();
while (($input = trim(fgets(STDIN))) !== '') {
	$input = intval($input);
	$count = 0;
	for ($i=0; $i < 10; $i++) { 
		for ($j=0; $j < 10; $j++) { 
			for ($k=0; $k < 10; $k++) { 
				for ($l=0; $l < 10; $l++) { 
					if ($i + $j + $k +$l === $input) {
						$count++;
					}
				}
			}
		}
	}
	$count_list[] = $count;
}

foreach ($count_list as $value) {
	echo $value."\n";
}

Measured memory_bytes: 15200
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	int n;
	string a;
	cin >> n>> a;
	int f = 0,t = 0;
	for(int e=0;e<sz(a);e++) if(a[e]=='W') f++;
	t = n - f;
	int ff = f,tt =t;
	for(int e=0;e<t;e++){
		if(a[e]=='R') tt--;
	}
	for(int e=sz(a)-1;e>sz(a)-1-f;e--){
		if(a[e]=='W') ff--;
	}
	printf("%d\n",min(ff,tt));
	return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    int changeCnt = 0;
    cin >> s;
    cin >> t;
    for (int i = 0; i < s.size(); i++)
        if (s[i] != t[i])
            changeCnt++;
    cout << changeCnt << "\n";
    return 0;
}


Measured memory_bytes: 3780
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string s;
  cin>>s;
  int n=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='+'){
      n++;
    }
    else n--;
  }
  cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h, w;
int a[10][10][11];
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> h >> w;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            cin >> a[i][j][0];
        }
    }
    for (int k = 1; k <= 10; k++) {
        for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                a[i][j][k] = (int)1e6;
            }
        }
    }
    for (int k = 1; k <= 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                a[i][j][k] = min(a[i][j][k - 1], a[i][k - 1][k - 1] + a[k - 1][j][k - 1]);
            }
        }
    }
    int t;
    int ans = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> t;
            if (t == -1) continue;
            ans += a[t][1][10];
        }
    }
    cout << ans;
    return 0;
}


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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  
  int temp = X + 1;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    temp = max(temp, x);
  }
  string ans = "No War";
  for (int i = 0; i < M; i++) {
    int y;
    cin >> y;
    if (temp >= y) {
      ans = "War";
      break;
    }
  }
  if (temp >= Y) {
    ans = "War";
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
// abc134c: Exception Handling
#include <stdio.h>

#define rep(i,s,e) for(int i=s;i<e;i++)
#define in(n) scanf("%d",n)
#define outi(d) printf("%d\n",d)

int main(){
  int n;in(&n);
  int ix=-1,f=0,s=0;
  rep(i,0,n){
    int a;in(&a);
    if(a>f){ s=f; f=a; ix=i; }
    else if(a>s) s=a;
  }
  rep(i,0,n) outi(i==ix? s: f);
  return 0;
}

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

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

  int ab = a*b;

  string ODD = "Odd";
  string EVEN = "Even";

  int abyo = ab%2;

  if (abyo == 0) {
    cout << EVEN << endl;
  }else{
    cout << ODD << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 2005
#define ll long long
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<endl;
#define trace(a) cout<<#a<<": "<<a<< endl;

int b[N];
pair<int,int> a[N];
bool hasToVisit[N],cannotVisit[N];
int n,k,q;
bool check(int st,int en) {
	int i,j;
	memset(cannotVisit,false,sizeof(cannotVisit));
	memset(hasToVisit,false,sizeof(hasToVisit));
	for(i = 1;i < st;i++) {
		cannotVisit[a[i].second] = true;
	}
	for(i = st;i <= en;i++) {
		hasToVisit[a[i].second] = true;
	}
	int cnt = 0;
	set<int> indices;
	set<pair<pair<int,int>, int> > se;
	for(i = 1;i <= n;i++) {
		if(cnt >= q) return true;
		if(cannotVisit[i]) {
			se.clear();
			indices.clear();
			continue;
		}
		if(se.size() < k) {
			se.insert({{b[i],(hasToVisit[i] ? -1 : 0)},i});
			indices.insert(i);
		}
		if(se.size() == k) {
			if(se.begin()->first.second == -1) {
				int id = se.begin()->second;
				indices.erase(id);
				se.erase(se.begin());
				cnt++;
			}
			else {
				int smallestIndex = *indices.begin();
				indices.erase(indices.begin());
				se.erase({{b[smallestIndex],(hasToVisit[smallestIndex] ? -1 : 0)},smallestIndex});
			}
		}
		if(cnt >= q) return true;
	}
	if(cnt >= q) return true;
	return false;
}
int main() {
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	int i,j,l,m,t;
	cin >> n >> k >> q;
	for(int i = 1;i <= n;i++) {
		cin >> a[i].first;
		b[i] = a[i].first;
		a[i].second = i;
	}
	int an = 2e9;
	sort(a+1,a+1+n);
	for(i = 1;i <= n;i++) {
		l = i+q-1;
		int r = n;
		int ans = -1;
		if(l > r) continue;
		if(a[l].first - a[i].first >= an) continue;
		while(l <= r) {
			int mid = (l+r)/2;
			// trace(mid);
			if(check(i,mid)) {
				ans = mid;
				r = mid-1;
			}
			else {
				l = mid+1;
			}
		}
		if(ans == -1) break;
		// trace(ans);
		an = min(a[ans].first - a[i].first,an);
	}
	cout << an << endl;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]
use proconio::marker::*;
use proconio::*;
use rand::prelude::*;
use std::i64;
use std::thread::sleep;
use std::time::*;

#[derive(Debug)]
struct State {
    D: usize,
    c: Vec<i64>,
    s: Vec<Vec<i64>>,
    t: Vec<usize>,
    lasts: Vec<usize>,
    d: usize,
    score: i64,
}

impl State {
    fn new(D: usize, c: Vec<i64>, s: Vec<Vec<i64>>) -> State {
        State {
            D,
            c,
            s,
            t: vec![0; D],
            lasts: vec![0; 26],
            d: 0,
            score: 0,
        }
    }

    fn set_rand(&mut self) {
        let mut rng = thread_rng();
        for i in 0..self.D {
            self.t[i] = rng.gen_range(0, 26);
        }
    }

    fn set_greed(&mut self) {
        for i in 0..self.D {
            let mut max_score = i64::min_value();
            let mut q = 0;
            let last = self.lasts[self.t[i]];
            for j in 0..26 {
                self.t[i] = j;
                let score = self.calc(i, j);
                self.lasts[j] = last;
                if score > max_score {
                    max_score = score;
                    q = j;
                }
            }

            self.lasts[q] = i + 1;
            self.t[i] = q;
        }
    }

    fn calc(&mut self, d: usize, q: usize) -> i64 {
        let mut score = self.s[d][q];

        self.lasts[q] = d + 1;
        for i in 0..26 {
            score -= (d + 1 - self.lasts[i]) as i64 * self.c[i];
        }

        score
    }

    fn result(&self) -> i64 {
        let mut score = 0;
        let mut lasts = vec![0; 26];
        for d in 0..self.D {
            score += self.s[d][self.t[d]];
            let l = lasts[self.t[d]];
            lasts[self.t[d]] = d + 1;
            score -= self.c[self.t[d]] * ((d - l) * (d - l + 1) / 2) as i64;
        }

        for i in 0..26 {
            let l = lasts[i];
            score -= self.c[i] * ((self.D - l) * (self.D - l + 1) / 2) as i64;
        }

        score
    }
}

fn main() {
    input! {
        D: usize,
        c: [i64; 26],
        s: [[i64; 26]; D],
    };
    let mut obj = State::new(D, c, s);
    let mut rng = thread_rng();
    let time = SystemTime::now();
    obj.set_greed();
    let mut pre_score = obj.result();

    loop {
        let d = rng.gen_range(0, D);
        let q = rng.gen_range(0, 26);
        let tq = obj.t[d];
        obj.t[d] = q;
        let score = obj.result();
        if score > pre_score {
            pre_score = score;
        } else {
            obj.t[d] = tq;
        }

        if time.elapsed().unwrap().as_millis() > 1900 {
            break;
        }
    }

    for &t in &obj.t {
        println!("{}", t + 1);
    }
}


Measured memory_bytes: 2748
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def gcd(a, b):
  if a > b:
    a, b = b, a
  while b % a:
    a, b = b % a, a
  return a

def main():
  n = int(input())
  As = list(map(int, input().split()))
  rgcds, lgcds = [0] * n, [0] * n
  lgcds[0], rgcds[-1] = As[0], As[-1]
  
  for i in range(1, n):
    lgcds[i] = gcd(lgcds[i-1], As[i])
    rgcds[n-(i+1)] = gcd(rgcds[n-(i)], As[n-(i+1)])
  
  max = -1
  for i in range(n):
    if i==0:
      tmp = rgcds[i+1]
    if i==n-1:
      tmp = lgcds[i-1]
    if 0 < i < n-1:
      tmp = gcd(lgcds[i-1], rgcds[i+1])
    if max < tmp:
      max = tmp
  print(max)
  
if __name__=='__main__':
  main()



Measured memory_bytes: 14428
R, G, B, N = map(int, input().split())  # R個の箱, G個の箱, B個の箱
ans = 0
for r in range(N+1):  # 1
    for g in range(N+1):  # 0
        b = N - (r*R + g*G)  # b = 4 - (1*1 + 0*2) = 3
        if b % B == 0 and b >= 0:
            # print(r, g, b)  # 1, 0, 1のパターンが抜けている
            ans += 1

print(ans)


Measured memory_bytes: 40940
#include <iostream>
#include <cstring>
#include <string>

using namespace std;


using ll = long long;


ll c[1001][1001];
void solve()
{
    string X, Y;
    cin >> X >> Y;

    memset(c, 0, sizeof(c));
    for (ll i = 0; i <= X.length(); i++)
        c[i][0] = 0;
    for (ll i = 0; i <= Y.length(); i++)
        c[0][i] = 0;

    for (ll i = 1; i <= X.length(); i++) {
        for (ll j = 1; j <= Y.length(); j++) {
            if (X[i - 1] == Y[j - 1]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
        }
    }

    cout << c[X.length()][Y.length()] << endl;
}


int main()
{
    ll q;
    ll c[151][151];

    cin >> q;
    for (ll i = 0; i < q; i++) {
        solve();
    }
}



Measured memory_bytes: 10984
import fractions

A,B,C,D = map(int,input().split())

# 全体の数 - (Cで割れる数 + Dで割れる数 - CとDで割れる数)
all_count = B-A+1

# 区間内でAで割れる数 -> 1からDまで割れる数 - 1からCまで割れる数？？？？
# 2で考えると       1 to 13 は 2,4,6,8,10,12の6つ 13//2
#                  1 to 5  は 2,4 の2つ 5//2 
#                  5 to 13 は 6,8,10,12 の4つ
#                  1 to 6  は 2,4,6
#                  6 to 13 は 6,8,10,12 の4つ 6は重複カウントなので、、、

G = C * D // fractions.gcd(C,D)

# 1からA'まで'で割れる数
C_A_count = (A-1) // C
D_A_count = (A-1) // D
G_A_count = (A-1) // G

# 1からBで割れる数
C_B_count = B // C
D_B_count = B // D
G_B_count = B // G

C_count = C_B_count - C_A_count
D_count = D_B_count - D_A_count
G_count = G_B_count - G_A_count

print(all_count - (C_count + D_count - G_count))

Measured memory_bytes: 5048
#include <cstdio>
#include <map>
#include <string>

using namespace std;

int main()
{
	map <string, int> list;
	
	list["I"] = 1;
	list["V"] = 5;
	list["X"] = 10;
	list["L"] = 50;
	list["C"] = 100;
	list["D"] = 500;
	list["M"] = 1000;
	list["N"] = 0;
		
	char s[10001];
	while(scanf("%s", s) != EOF){
		string str = s;
		string str_next = s;
		
		int len = str.size();
		int sum = 0;
		
		
		for(int i = 0; i < len; i++){
			str = s[i];
			str_next = s[i+1];
			
			if(list[str] < list[str_next]){
				sum += list[str_next] - list[str];
				i++;
			}
			
			else sum += list[str];
		}
		
		printf("%d\n", sum);
	}
}

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

int bad[11];

int isok(int n)
{
    while (n != 0) {
        int d = n % 10; n /= 10;
        if (bad[d] == 1) return 0;
    }
    return 1;
}

int main( )
{
    int n, k;
    int i, j, l;
    cin >> n >> k;
    for (i = 0; i < k; i++) {
        cin >> j;
        bad[j] = 1;
    }
    for ( ; ; n++) {
        if (isok(n) == 1) {
            cout << n << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 1001
static const int S=1000;

int longest(char *A,char *B);

int main()
{
  int n,i;
  char A[N],B[N];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s%s",A,B);
    printf("%d\n",longest(A,B));
  }

  return 0;
}

int longest(char *A,char *B)
{
  int i,j,C[S+1][S+1],p,q;

  p=strlen(A);
  q=strlen(B);

  for(i=0; i<=p; i++)C[i][0]=0;
  for(j=1; j<=q; j++)C[0][j]=0;

  for(i=0; i<=p; i++){
    for(j=1; j<=q; j++){
      
      if(A[i-1]==B[j-1])C[i][j]=C[i-1][j-1]+1;
      
      else if(C[i-1][j-1]>=C[i][j-1])C[i][j]=C[i-1][j];
      
      else C[i][j]=C[i][j-1];
    }
  }
  if(i==0 || j==0)return 0;
  else if(p==q)return C[i-1][j-1];
  else if(p!=q)return C[p][q];
  return 0;
}



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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n;
    cin>>n;
    int bw[n];
    rep(i,n) bw[i]=-1;
    stack<int> st;
    vector<pair<int,int>> edge[n];
    rep(i,n-1){
        int u,v,w;
        cin>>u>>v>>w;
        --u;--v;
        edge[u].push_back(make_pair(v,w));
        edge[v].push_back(make_pair(u,w));
    }
    bw[0]=0;
    st.push(0);
    while(!st.empty()){
        int stop=st.top();
        st.pop();
        for(auto it=edge[stop].begin();it!=edge[stop].end();++it){
            int to=it->first;
            int weight=it->second;
            if(bw[to]==-1){
                if(weight%2==0){
                    bw[to]=bw[stop];
                }
                else{
                    bw[to]=1-bw[stop];
                }
                st.push(to);
            }
        }
    }
    rep(i,n){
        cout<<bw[i]<<endl;
    }
}





Measured memory_bytes: 6784
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, max = 0, a, b, c, d, ans = 0;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    if(max <= a) max = a, ans++;
  }
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

int main()
{
	int k;
	cin >> k;

	queue<long long> ans;
	for (int i = 1; i < 10; i++) {
		ans.push(i);
	}

	long long t;
	for (int i = 0; i < k; i++) {
		t = ans.front();
		ans.pop();
		if (t % 10 > 0) {
			ans.push(t * 10 + t % 10 - 1);
		}
		ans.push(t * 10 + t % 10);
		if (t % 10 < 9) {
			ans.push(t * 10 + t % 10 + 1);
		}
	}
	cout << t << endl;

	return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
N=int(input())

dp=[[[[0]*5 for i in range(5)] for j in range(5)] for k in range(N+1)]
dp[0][0][0][0]=1
#A:1 G:2 C:3 T:4
#AGC GAC ACG
#A?GC AG?C
for n in range(N):
    for i in range(5):
        for j in range(5):
            for k in range(5):
                dp[n+1][j][k][1]+=dp[n][i][j][k]
                dp[n+1][j][k][2]+=0 if (j==1 and k==3) else dp[n][i][j][k]
                dp[n+1][j][k][3]+=0 if (i==1 and k==2) or (i==1 and j==2) or (j==1 and k==2) or (j==2 and k==1) else dp[n][i][j][k]
                dp[n+1][j][k][4]+=dp[n][i][j][k]
ans=0
for item in dp[N]:
    for jtem in item:
        ans+=sum(jtem)
print(ans%(10**9+7))


Measured memory_bytes: 3572