akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
using P = complex<double>;
using L = pair<P,P>;
#define X real()
#define Y imag()
const double EPS = (1e-10), INF = (1e15);

double dot(P a, P b){ return a.X * b.X + a.Y * b.Y; }
double cross(P a, P b){ return a.X * b.Y - a.Y * b.X; }

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if( cross(b,c) > EPS ) return +1;
  if( cross(b,c) < -EPS ) return -1;
  if( dot(b,c) < 0 ) return +2;
  if( abs(b) + EPS < abs(c) ) return -2;
  return 0;
}

P intersection(L a, L b){
  //直線aと直線bの交点
  return a.first + cross(b.second-b.first,a.first-b.first)/(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first))*(a.second-a.first);
}

P circumcenter(P a, P b, P c){
  L l1((a+b)/2.0,(a+b)/2.0+(a-b)*P(0,1));
  L l2((a+c)/2.0,(a+c)/2.0+(a-c)*P(0,1));
  return intersection(l1,l2);
}

bool ok(P c, double r, const vector<P> &ps){
  for(auto p : ps)
    if(abs(p-c) > r+EPS)
      return false;
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<P> ps;
  for(int i = 0; i < N; ++i){
    double x, y;
    cin >> x >> y;
    ps.emplace_back(x,y);
  }
  double ans = INF;
  for(int i = 0; i < N; ++i){
    for(int j = i+1; j < N; ++j){
      for(int k = j+1; k < N; ++k){
        if(abs(ccw(ps[i],ps[j],ps[k])) != 1)
          continue;
        P c = circumcenter(ps[i],ps[j],ps[k]);
        double r = abs(ps[i]-c);
        if(ok(c,r,ps))
          ans = min(ans,r);
      }
    }
  }
  for(int i = 0; i < N; ++i){
    for(int j = i+1; j < N; ++j){
      double r = abs(ps[i]-ps[j])/2;
      P c = (ps[i]+ps[j])/2.0;
      if(ok(c,r,ps))
        ans = min(ans,r);
    }
  }
  printf("%.12f\n",ans);
}


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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll L, R, d;
  cin >> L >> R >> d;

  ll ans = 0;
  REP(i, L, R+1){
    if (i%d==0) ans++;
  }

  cout << ans << endl;


}

Measured memory_bytes: 3624
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp

puts 'x' * S.length


Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
bool check(int n){
int cnt=0;
while(n!=0){
    n/=10;
    cnt++;
}
if(cnt%2!=0)return true;
return false;
}
int main(){
int N,cnt=0;
cin>>N;
for(int i=1;i<=N;i++){
    if(check(i))cnt++;
}
cout<<cnt;
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int A, B; cin >> A >> B;
    bool match = false;
    int ans = -1;
    for(int i=0;i<=1000;i++){
        if((int)(i*0.08) == A && (int)(i*0.1) == B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++){
		 int grid[4][4];
		 bool yes[4][4];
		 for(int i = 1; i <= 3; i++){
			 for(int j = 1; j <= 3; j++){
				 yes[i][j] = false;
				 cin >> grid[i][j];
			 }
		 }
		 int n;
		 cin >> n;
		 map<int,bool> present;
		 for(int i = 1; i <= n; i++){
			 int in;
			 cin >> in;
			 present[in] = true;
		 }
		 for(int i = 1; i <= 3; i++){
			 for(int j = 1; j <= 3; j++){
				 if(present[grid[i][j]]){
					 yes[i][j] = true;
				 }
			 }
		 }
		 for(int i = 1; i <= 3; i++){
			 if((yes[i][1] and yes[i][2] and yes[i][3]) or (yes[1][i] and yes[2][i] and yes[3][i])){
				 cout << "Yes\n";
				 return 0;
			 }
		 }
		 if((yes[1][1] and yes[2][2] and yes[3][3]) or (yes[1][3] and yes[2][2] and yes[3][1])){
			 cout << "Yes\n";
			 return 0;
		 }
		 cout << "No\n";
	 }
}



Measured memory_bytes: 3636
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{try{BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str[] = br.readLine().split(" ");
	long k=Long.parseLong(str[0]);
	int n= Integer.parseInt(str[1]);
	String str1[]= br.readLine().split(" ");
	long max =-1;
	int i;
	for(i=0;i<n-1;i++){
		if((Long.parseLong(str1[i+1])-Long.parseLong(str1[i]))>max) max = Long.parseLong(str1[i+1])-Long.parseLong(str1[i]);
	}
	long t = k+Long.parseLong(str1[0])-Long.parseLong(str1[n-1]);
	if(t>max)max =t;
	System.out.print(k-max);
		
	}catch(Exception e){}
		
	}
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int deg[4] = {};
  for (int i = 0; i < 3; ++i) {
    int a = in() - 1, b = in() - 1;
    deg[a]++;
    deg[b]++;
  }

  bool f = true;
  for (int i = 0; i < 4; ++i) {
    if (deg[i] == 3) f = false;
  }

  cout << (f ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[1111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector<ll> vec;
	int n; cin>>n;
	ll k; cin>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		ll sum=0;
		for(int j=i;j<n;j++)
		{
			sum+=a[j];
			vec.pb(sum);
		}
	}
	ll ans = 0;
	for(int i=60;i>=0;i--)
	{
		vector<ll> newv;
		for(ll s:vec)
		{
			if(s&(1LL<<i))
			{
				newv.pb(s);
			}
		}
		if(newv.size()>=k)
		{
			vec=newv; ans^=(1LL<<i);
		}
	}
	cout<<ans<<'\n';
}


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

int main(){
	int n, k, a[100000] = {};
	long long int sum = -10000000, tmp;
	while(cin >> n >> k){
		if(n == 0 && k == 0) break;
		tmp = 0;
		for(int i = 0;i<n;i++){
			cin >> a[i];
			if(i < k) tmp += a[i];
		}
		for(int i = 0;i + k<n;i++){
			if(sum < tmp) sum = tmp;
			tmp = tmp - a[i] + a[i+k];
		}
		cout << sum << endl;
	}
	return 0;
}

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

#pragma warning(disable:4996)
using namespace std;

struct aa {
	pair<int,int> prev_place;
	int prev_char;
	pair<int,int>now_place;
};
int memo[5001][5001];
int main() {
	int N;cin>>N;
	vector<int>v(N);
	for(int i=0;i<N;++i)cin>>v[i];
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	N=v.size();
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			memo[i][j]=2;
		}
	}
	int ans=0;
	for (int i = 0; i < N; ++i) {
		for (int j = 1; j < N; ++j) {
			ans=max(ans,memo[i][j]);
			int sa=v[j]-v[i];
			long long int x=v[j]*2-v[i];
			if(x>(1e9)+5)continue;
			else {
				int nx=x;
				auto it=lower_bound(v.begin()+j,v.end(),nx);
				if (it != v.end() && *it == nx) {
					memo[j][it-v.begin()]=max(memo[j][it-v.begin()],memo[i][j]+1);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(void) {
    int n, a, b;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << "\n";
    } else {
        cin >> a >> b;
        cout << a + b << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long n = (long)Math.sqrt(N);

			while(n > 0) {
				if(N % n == 0) {
					System.out.println(n + N/n - 2);
					break;
				}
				n--;
			}


		sc.close();
	}
}


Measured memory_bytes: 22100
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import Data.Char (isNumber)

solve :: Int -> Int -> Double
solve n k = (/nf) . foldr (+) 0.0 $ map inner  [1..n] where
    nf = fromIntegral n
    kf = fromIntegral k
    inner :: Int -> Double
    inner diceNum = if diceNum >= k then 1.0 else 
                        (0.5**) . fromIntegral . ceiling $ 
                            logBase 2.0 (kf / (fromIntegral diceNum :: Double))

main = do
    s <- getLine
    let [n, k] = read <$> words s :: [Int]
    print $ solve n k


Measured memory_bytes: 1276
n = int(input())
t = []
a = []
for i in range(n):
    c = list(map(int,input().split()))
    t.append(c[0])
    a.append(c[1])
for i in range(n-1):
    d = max(1,-(-t[i]//t[i+1]),-(-a[i]//a[i+1]))
    t[i+1] =t[i+1]*d
    a[i+1] =a[i+1]*d
print(t[-1]+a[-1])

Measured memory_bytes: 3316
A,B,K=map(int,input().split())
ans=[]

for i in range(K):
    if A+i<=B:
        ans.append(A+i)
    if B-i>=A:
        ans.append(B-i)
    
l=set(ans)
ans2=list(l)
ans2.sort()

for i in range(len(ans2)):
    print(ans2[i])



Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  vector<int> v(3,0);
  ll ans=1;
  for(int i=0;i<N;i++){
    ll num=0;
    for(int k=0;k<3;k++){
      if(A[i]==v[k]) num++;
    }
    ans=ans*num%MOD;

    for(int k=0;k<3;k++){
      if(A[i]==v[k]){
        v[k]++;
        break;
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
N, X = list(map(int, input().split()))

m = []

count = 0

for i in range(N):
    m.append(int(input()))
    X -= m[i]
    count += 1
    
while True:
    if X < min(m):
        break
    else:
        X -= min(m)
        count += 1

print(count)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,A[110];
	float s;
	cin >> a;
	for (int i = 0; i < a; ++i)
	{
		int b;
		cin >> b;
		s += (1.0/b);
	}
	cout << 1/s;
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') a++;
  }
  int ans = max(a, b);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R')
      a--;
    else
      b++;
    int now = max(a, b);
    ans = min(ans, now);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3668
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string str =Console.ReadLine();
      if(str.Substring(2,1)==str.Substring(3,1)&&str.Substring(4,1)==str.Substring(5,1))
      {Console.WriteLine("Yes");
      }else{
        Console.WriteLine("No");
      }
    }
    
  }

}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<long long> ai(n+1);
  vector<long long> bi(n);
  for(int i=0; i<n+1; i++){
    cin >> ai[i];
  }
  for(int i=0; i<n; i++){
    cin >> bi[i];
  }

  long long ans = 0;
  for(int i=0; i<n; i++){
    int left = min(ai[i], bi[i]);
    ans += left;
    bi[i] -= left;
    int right = min(ai[i+1], bi[i]);
    ans += right;
    bi[i] -= right;
    ai[i+1] -= right;
  }
  cout << ans << endl;

  return 0;
}


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

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "next", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    long ok = 10001, ng = -1;
    while (abs(ok - ng) > 1)
    {
        auto mid = (ok + ng) / 2;
        if (mid * 1000 >= n)
            ok = mid;
        else
            ng = mid;
    }
    writeln(1000 * ok - n);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2684
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	t := stdin.Text()
	time, _ := strconv.Atoi(t)


	hour := time / 3600;
	time = time % 3600;

	minute := time / 60
	time = time % 60

	second := time

	fmt.Printf("%v:%v:%v\n", hour, minute, second)
}



Measured memory_bytes: 1084
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	static final long INF = 0;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		sc.close();
		System.exit(0);
	}

	void solve() {
		int N = nextInt(); // N個の町
		int M = nextInt(); // M本の道
		long L = nextLong(); // 燃料タンクの容量

		long INF = (long) 1e+17;
		long[][] fuel = new long[305][305];
		long[][] dist = new long[305][305];
		int[] A = new int [100000];
		int[] B = new int [100000];
		int[] C = new int [100000];
		int[] s = new int[105000];
		int[] t = new int[105000];
		for(int i=1;i<=M;i++) {
			A[i]=nextInt();
			B[i]=nextInt();
			C[i]=nextInt();
		}
		int Q = nextInt();

		for(int i=1;i<=Q;i++) {
			s[i] = nextInt();
			t[i] = nextInt();
		}

	    for(int i = 1; i <= N; i++) {
	        for(int j = 1; j <= N; j++) {
	            fuel[i][j] = INF;
	            dist[i][j] = INF;
	        }
	        fuel[i][i] = 0;
	        dist[i][i] = 0;
	    }

	    for(int i = 1; i <= M; i++) {
	    	fuel[A[i]][B[i]] = Math.min(fuel[A[i]][B[i]], C[i]);
	    	fuel[B[i]][A[i]] = Math.min(fuel[B[i]][A[i]], C[i]);
	    }
	    for(int i = 1; i <= N; i++) {
	        for(int j = 1; j <= N; j++) {
	            for(int k = 1; k <= N; k++) {
	            	fuel[j][k] = Math.min(fuel[j][k], fuel[j][i] + fuel[i][k]);
	            }
	        }
	    }
	    for(int i = 1; i <= N; i++) {
	        for(int j = 1; j <= N; j++) {
	            if(i == j) continue;
	            if(fuel[i][j] <= L) dist[i][j] = Math.min(dist[i][j], 1L);
	        }
	    }
	    for(int i = 1; i <= N; i++) {
	        for(int j = 1; j <= N; j++) {
	            for(int k = 1; k <= N; k++) {
	            	dist[j][k] = Math.min(dist[j][k], dist[j][i] + dist[i][k]);
	            }
	        }
	    }
	    for(int i = 1; i <= Q; i++) {
	        if(dist[t[i]][s[i]] < INF) out.println(dist[t[i]][s[i]] - 1);
	        else out.println(-1);
	    }
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

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

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
	int h ,w , n;
	cin >> h >> w >> n;
	int a = (n / h) , b = (n / w);
	if(n % h != 0) a++;
	if(n % w != 0) b++;
	cout << min(a,b) << "\n";
		
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, M = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
B_C = [list(map(int, input().split(' '))) for _ in range(M)]


A.sort() # 昇順
B_C.sort(key=lambda x: -x[1]) # 降順
# print(A)
# print(B_C)
i, j = 0, 0
while i != N and j != M:
    b, c = B_C[j]
    if A[i] >= c:
        break
    else:
        while i != N and b != 0:
            if A[i] >= c:
                break
            else:
                A[i] = c
                b -= 1
                i += 1
        j += 1

print(sum(A))


Measured memory_bytes: 81448
var cc : array [1..4] of int64 ;
    so : array [1..4] of real ;
    a,b,c,d,e,f,g : longint ;
    sum,count,h,i,o,j,k,l : int64 ;

procedure swap(var x,y : int64) ;
var z : int64;
begin
 z:=x;
 x:=y;
 y:=z;
end;
procedure swap2(var x,y : real) ;
var z : real;
begin
 z:=x;
 x:=y;
 y:=z;
end;

begin
 for a:=1 to 4 do
  begin
   read(cc[a]);
  end;
 so[1]:=1;
 so[2]:=1;
 so[3]:=1;
 so[4]:=2;
 cc[1]:=cc[1]*4;
 cc[2]:=cc[2]*2;
 for a:=1 to 3 do
  for b:=1 to 3 do
   if cc[b]*(1/so[b])>cc[b+1]*(1/so[b+1]) then
    begin
     swap(cc[b],cc[b+1]);
     swap2(so[b],so[b+1]);
    end;
//    for a:=1 to 4 do  write(cc[a]:5);
    readln(sum);
  while sum>0 do
   begin
    for a:=1 to 4 do
     begin
      if sum=0 then
       break
      else if so[a]<=sum then
       begin
//        writeln(cc[a]);
        if so[a]<>2 then
         begin
          count:=count+cc[a]*sum;
          sum:=0;
          break;
         end
        else
         begin
          count:=count+cc[a]*(sum div 2);
          sum:=sum-(sum div 2)*2;
         end;
       end;
     end;
   end;
  writeln(count);
end.


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

string s,t,ans="~";
bool good(string a,string b)
{
	for(int i=0;i<a.size();i++)
		if(a[i]!='?'&&a[i]!=b[i])
			return false;
	return true;
}
int main()
{
	cin>>s>>t;
	for(int i=0;i<=(int)s.size()-(int)t.size();i++)
	{
		string u=s.substr(i,t.size());
		if(good(u,t))
		{
			string v=s;
			for(int j=i;j<i+t.size();j++)
				v[j]=t[j-i];
			for(int j=0;j<v.size();j++)
				if(v[j]=='?')
					v[j]='a';
			ans=min(ans,v);
		}
	}
	if(ans=="~")
		cout<<"UNRESTORABLE";
	else
		cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[1001],c=0,f=0,i;
	gets(a);
	for(i=0;i<strlen(a);i++){
		if(a[i]=='C')
			c=1;
		if(c==1 and a[i]=='F')
			f=1;
	}
	if(f==1)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


ll dp[205][100005];

int main(int argc, char* argv[])
{
    long n, x;
    scanf("%ld%ld", &n, &x);

    vector<long> s(n);
    long i,j;
    for(i=0; i<n; i++) {
        scanf("%ld", &s[i]);
    }
    sort(s.rbegin(), s.rend());

    dp[0][x]=1;
    for(i=0; i<n; i++) {
        for(j=0; j<=x; j++) {
            if(dp[i][j]) {
                if(i<n-1) {
                    dp[i+1][j] = (dp[i+1][j] + (dp[i][j]* (n-i-1)))%MOD;
                    dp[i+1][j%s[i]] = (dp[i+1][j%s[i]] + dp[i][j])%MOD;
                }
                else {
                    dp[i+1][j%s[i]] = (dp[i+1][j%s[i]] + dp[i][j])%MOD;
                }
            }
        }
    }

    ll ans=0;
    for(i=0; i<s[n-1]; i++) {
        ans = (ans + i*dp[n][i])%MOD;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 155904
#include<iostream>
using namespace std;
int main(void) {
	int t;
	   cin >> t;
	     int h, m, s;
	         h = t / 3600;
	         m = (t- h * 3600) / 60;
	         s = t - h * 3600 - m * 60;
	   cout << h << ":" << m << ":" << s << "\n";
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	set<int> values;
	for (int i = 0; i < 3; i++) {
		values.insert(A[i]);
	}

	cout << values.size() << endl;
	
}

Measured memory_bytes: 256
def inpl():
    return list(map(int, input().split()))


N, K = inpl()
V = inpl()
left_sum = [sum(V[:i]) for i in range(N + 1)]
right_sum = [sum(V[::-1][:i]) for i in range(N + 1)]

ans = 0
for left_k in range(K + 1):
    for right_k in range(K + 1 - left_k):
        if left_k + right_k > N:
            break

        # print(left_sum, left_k)
        # print(right_sum, right_k)
        tmp_ans = left_sum[left_k] + right_sum[right_k]
        if left_k == 0 and right_k == 0:
            A = []
        elif left_k == 0:
            A = V[-1 * right_k:]
        elif right_k == 0:
            A = V[:left_k]
        else:
            A = V[:left_k] + V[-1 * right_k:]

        A.sort()
        rest = K - left_k - right_k
        i = 0
        while i < len(A) and A[i] < 0 and i < rest:
            tmp_ans -= A[i]
            i += 1
        # print(left_k, right_k, tmp_ans)
        ans = max(ans, tmp_ans)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s; cin >> s;
    sort(s.begin(), s.end());
    rep(i,s.length()-1) {
        if (s[i] == s[i+1]) {
            cout << "no\n";
            return 0;
        } 
    }
    cout << "yes\n";
    return 0;
}

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


int main(){
	int n,l;
	char d[100];
	int x[100];
	while(cin>>n>>l,n|l){
		int count=0;
		int leave,t=0;
		for(int i=0;i<n;i++)cin>>d[i]>>x[i];
		while(count<n){
			for(int i=0;i<n;i++){
				if(x[i]==-1)continue;
				if(d[i]=='L')x[i]--;
				else x[i]++;
			}
			for(int i=0;i<n;i++){
				if(x[i]==-1)continue;
				for(int j=i+1;j<n;j++){
					if(x[j]==-1)continue;
					if(x[i]==x[j])swap(d[i],d[j]);
				}
			}
			leave=-1;
			for(int i=0;i<n;i++){
				if(x[i]==0||x[i]==l){
					count++;
					x[i]=-1;
					if(leave==-1 || d[leave]=='R')leave=i;
				}
			}
			t++;
		}
		cout<<t<<' '<<leave+1<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll Wi;
    vector<ll> W;
    for(int i=0;i<N;i++){
        cin >> Wi;
        if(i>0) W.push_back(Wi + W.back());
        else    W.push_back(Wi);
    }
    ll vmin = LLONG_MAX;
    for(int i=0;i<N;i++){
        auto v = abs(W.back()-2*W[i]);
        if(v<vmin) vmin = v;
    }
    cout<<vmin<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace V0002{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            int[] input;
            while((input = sr.Next<int>(2))[0] != int.MinValue) Console.WriteLine(input.Sum().ToString().Length);
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T) typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T) Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var result = new T[x];
            for(var i = 0; i < x; ++i){
                result[i] = Next<T>();
            }
            return result;
        }
    }
}

Measured memory_bytes: 10056
/* ****VIKRAM ADITYA**** */
#include<bits/stdc++.h>

#define ll          int
#define F           first
#define S           second
#define pb          push_back
#define mp          make_pair
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define ld             long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;


// vector<vector<ll>> dp(n,vector<ll>(n00000,-1));
// ll dfs(ll wom ,ll mask, ll &n )
// {
//     if(wom>=n)
//         return 0;

    
//     // if(mask==(1<<n)-1)
//     //     return 1;
//     if(dp[wom][mask]!=-1)
//         return dp[wom][mask];
    
//     ll ans=0;
//         for (int i = 0; i <n; ++i)
//         {
//             if(((mask & (1<<i))==1) && (v[wom][i]==1))
//                 ans=(ans+dfs(wom+1,(mask &(0<<i)), n))%hell;
//         }
//         return dp[wom][mask]=ans;
        
    

// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);
    #endif
    ll t = 1;
    // cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        
        ll v[n][n];
        for (int i = 0; i < n; ++i)
        {
            /* code */
            for (int j = 0; j < n; ++j)
            {
                cin>>v[i][j];
                // v[i].pb(r);
            }

        }



        // ll mask;
       
            ll mask=(1<<n)-1;
        
        
         ll dp[1<<n];
         memset(dp,0,sizeof(dp));
         dp[0]=1;
        // memset()
        for (int i = 0; i <=(1<<n)-2 ; ++i)
        {
        	
        	ll x=__builtin_popcount(i);
        	for (int j = 0; j < n; ++j)
        	{
        		if(v[x][j] && ((i&(1<<j))==0)) dp[i|((1<<j))]=(dp[i|((1<<j))]+dp[i])%hell;
        	}
        }

        cout<<dp[(1<<n) -1];
    }

    
    time
    return 0;
} 

Measured memory_bytes: 11824
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct BIT {
    int n;
    vi dat;

    BIT(int n) : n(n) { dat.resize(n + 1); }

    void add(int i, int x)
    {
        while (i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }

    int sum(int i)
    {
        int res = 0;

        while (i > 0) {
            res += dat[i];
            i -= i & -i;
        }

        return res;
    }
};

signed main()
{
    int N, Q; cin >> N >> Q;    

    BIT bit(N);

    rep(i, Q) {
        int c, x, y; cin >> c >> x >> y;

        if (c == 0) {
            bit.add(x, y);
        } else {
            cout << bit.sum(y) - bit.sum(x - 1) << endl;
        }
    }
}

Measured memory_bytes: 1536
/***
 
            Bismillahir Rahmanir Rahim
            Rabbi Zidni Ilma
            Author : Saidur Rahman
            Department of CSE, City University, Bangladesh.
 
***/

#include<iostream>
#include<string>
using namespace std;

#define         sf                  scanf
#define         sff(a)              scanf("%d",&a)
#define         sfl(a)              scanf("%lld",&a)
#define         sfff(a,b)           scanf("%d%d",&a,&b)
#define         sfll(a,b)           scanf("%lld%lld",&a,&b)
#define         sffff(a,b,c)        scanf("%d%d%d",&a,&b,&c)
#define         sflll(a,b,c)        scanf("%lld%lld%lld",&a,&b,&c)
#define         pff(a)              printf("%d\n",a)
#define         pfl(a)              printf("%lld\n",a)
#define         pf                  printf
#define         pb                  push_back
#define         vi                  vector<int>
#define         newline             printf("\n")
#define         NO                  printf("NO\n")
#define         no                  printf("no\n")
#define         YES                 printf("YES\n")
#define         yes                 printf("yes\n")
#define         endl                "\n"
#define         kaj_shuru           int main()
#define         kaj_shesh           return 0

#define         PI                  acos(-1.0)
#define         f0(i,b)             for(int i=0;i<(b);i++)
#define         f1(i,b)             for(int i=1;i<=(b);i++)
#define         f2(i,a,b)           for(int i=(a);i<=(b);i++)
#define         TEST_CASE(t)        for(int Case=1 ; Case<=t ; Case++)
#define         input               freopen("input.txt", "r", stdin);
#define         output              freopen("output.txt", "w", stdout);

int         SetBit (int n, int X)       { return n | (1 << X); }
int         ClearBit (int n, int X)     { return n & ~(1 << X); }
int         ToggleBit (int n, int X)    { return n ^ (1 << X); }
bool        CheckBit (int n, int X)     { return (bool)(n & (1 << X)); }


/******************************** Code Started From Here **********************************/

const int MAX=1e8;
typedef long long ll;


kaj_shuru
{
   // std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
 #ifndef ONLINE_JUDGE 
    input;
    output;
#endif
    string s;
    cin >> s;
    int l = s.size();
    if(s[l-1]=='s')
        s += "es";
    else
        s += 's';
    cout << s << endl;
    kaj_shesh;
}


Measured memory_bytes: 3040
#include<stdio.h>
    int min2(int x, int y, int z)
    {
    int min = x+y;
      if (y+z < min) min = y+z;
      if (z+x < min) min = z+x;
      return min;
    }
   
    int main()
    {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        printf("%d \n",min2(a,b,c));
        return 0;
    }

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

int main() {
	ll x,y,ans=0;
	cin >> x >> y;
	if(x==1) ans+=300000;
	if(x==2) ans+=200000;
	if(x==3) ans+=100000;
	if(y==1) ans+=300000;
	if(y==2) ans+=200000;
	if(y==3) ans+=100000;
	if(x==1 && y==1) ans+=400000;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>

#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

// <<fixed<<setprecision(6)<<

int gcd(lint x, lint y){
	return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
    int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main(){
  int a,b,x,y;
  cin>>a>>b;
  x=Combination(a,2);
  y=Combination(b,2);
  cout<<x+y;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

inline int gcd(int a, int b) {
	while (a != 0) {
		int t = b % a;
		b = a;
		a = t;
	}
	return b;
}

inline int abs(int x) {
	return x < 0 ? -x : x;
}

struct Frac {
	int a, b;
	Frac() : a(1), b(1) {}
	Frac(int a, int b) : a(a), b(b) {
		reduce();
	}
	void reduce() {
		int g = gcd(a, b);
		a /= g;
		b /= g;
	}
	bool operator < (const Frac& f) const {
		return (long long)a * f.b < (long long)b * f.a;
	}
};

inline void checkMin(Frac& ret, const Frac& val) {
	if (val < ret) {
		ret = val;
	}
}

inline void checkMax(Frac& ret, const Frac& val) {
	if (ret < val) {
		ret = val;
	}
}

int n;
int a[100000];
Frac dp[2][200001];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= a[0] * 2; ++i) {
		dp[0][i] = Frac(0, 1);
	}
	for (int i = 0; i < n; ++i) {
		int lim = i + 1 == n ? 0 : a[i + 1] * 2;
		for (int j = 1; j <= a[i] * 2; ++j) {
			checkMax(dp[i % 2][j], Frac(abs(j - a[i]), a[i]));
			for (int k = j; k <= lim; k += j) {
				checkMin(dp[1 - i % 2][k], dp[i % 2][j]);
			}
		}
	}
	Frac res;
	for (int i = 1; i <= a[n - 1] * 2; ++i) {
		checkMin(res, dp[(n - 1) % 2][i]);
	}
	printf("%.13lf\n", (double)res.a / res.b);
	return 0;
}

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

using namespace std;

int main()
{
    int n,max;
    long sum = 0;

    cin >> n;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                max = 1;
                for (int l = 1; l <= i && l <= j && l <= k; l++) {
                    if (i%l == 0 && j % l == 0 && k % l == 0)max = l;
                }
                sum += max;
            }
        }
    }

    cout << sum << endl;

    return 0;
}

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

int main(){
  int x,y;
  cin >> x >> y;
  
  bool ans = true;
  for(int i=0; i<=x; i++){
    if(2*i+4*(x-i)==y){
      cout << "Yes" << endl;
      ans = false;
      break;
    }
  }
  if(ans) cout << "No" << endl;
}

Measured memory_bytes: 3632
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    ans = [0 for _ in range(N)]
    for s in range(N):
        dist = [-1 for _ in range(N)]
        dist[s] = 0

        d = deque([s])
        while(len(d) > 0):
            v = d.popleft()
            if v == X:
                if dist[Y] == -1:
                    d.append(Y)
                    dist[Y] = dist[v] + 1
            elif v == Y:
                if dist[X] == -1:
                    d.append(X)
                    dist[X] = dist[v] + 1
            if v + 1 < N:
                if dist[v+1] == -1:
                    d.append(v+1)
                    dist[v+1] = dist[v] + 1
            if v - 1 >= 0:
                if dist[v-1] == -1:
                    d.append(v-1)
                    dist[v-1] = dist[v] + 1

        for i in range(N):
            ans[dist[i]] += 1
 
    for k in range(1, N):
        print(ans[k] // 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 49500
require 'prime'

is_prime = Array.new( 10 ** 5 + 1, false )

primes = Prime.each(10**5).to_a

primes.each do |p|
  is_prime[p] = true
end

nums_like_2017 = []
primes.each do |p|
  nums_like_2017 << p if is_prime[(p+1)/2]
end

Q = gets.to_i

Q.times do |i|
  
  l, r = gets.split.map(&:to_i)
  
  rn = nums_like_2017.bsearch_index{ |x| x > r }
  rn = 672 if rn.nil?
  ln = nums_like_2017.bsearch_index{ |x| x >= l }
  ln = 672 if ln.nil?
  
  puts rn - ln
end

Measured memory_bytes: 3892
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 200000
 
void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[MAX]; 
  if (left >= right) return;
  else{
    mid = (left + right)/2; 
    merge_sort(array, left, mid);  
    merge_sort(array, mid+1, right);  
    for (i = mid; i >= left; i--) { work[i] = array[i]; } 
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; 
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}
 
int main(void){
  int A[MAX];
  int i;
  int N,flag=0;
  
  scanf("%d",&N);
  for(i=0;i<N-1;i++){
    scanf("%d ",&A[i]);
  }
  scanf("%d",&A[N-1]);
 
  merge_sort(A,0,N-1);
 
  for(i=0;i<N-1;i++){
    if(A[i] == A[i+1]){
      flag++;
      break;
    }
  }
  if(flag) printf("NO");
  else printf("YES");
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    x--;
    p[i]=x;
  }
  int cnt=0;
  for(int i=0;i<n-1;i++){
 	 if(p[i]==i) {swap(p[i],p[i+1]); cnt++; }
  }
  for(int i=n-1;i>0;i--){
    if(p[i]==i) {swap(p[i],p[i-1]); cnt++;}
  }
  cout<<cnt<<endl;
}
  

Measured memory_bytes: 640
#include<stdio.h>

int main() {

   int S[10000], T[500];
   int i, j, n, q;
   int c = 0;

   scanf("%d", &n);
 
   for (i = 0; i < n; i++) {
      scanf("%d", &S[i]);
   }

   scanf("%d", &q);
 
   for (i = 0; i < q; i++) {
      scanf("%d", &T[i]);
   }

   for (i = 0; i < q; i++) {
      for(j = 0; j < n; j++) {
         if (T[i] == S[j]) {
            c++;
            break;
         }
      }
   }
   printf("%d\n", c);

   return 0;
}



Measured memory_bytes: 1964
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main()
{
    int n;
    cin >> n;
    int ct = 0;
    for (int i = 1; i < n + 1; ++i)
    {
        int x;
        cin >> x;
        if (x % 2 != 0 && i % 2 != 0)
        {
            ++ct;
        }
    }
    cout << ct << endl;
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int n, ans = 0;

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int a;
        cin >> a;
        if (i&a&1) ++ans;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3608
n, k = map(int, input().split())
lst = list(map(int, input().split()))

res = float('inf')
for i in range(n-k+1):
    l = lst[i]
    r = lst[i+k-1]
    distlr = abs(l) + abs(l-r)
    distrl = abs(r) + abs(r-l)
    min_ = min(distlr, distrl)
    if min_ < res:
        res = min_
print(res)

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

int main() {
    int k;
    cin >> k;
    int num[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << num[k - 1] << endl;
    return 0;
}

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

using namespace std;

int main(void) {
    int a, b;
    cin >> a >> b;
    int p = stoi(to_string(a) + to_string(b));
    if((int)sqrt((double)p) * (int)sqrt((double)p) == p) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math

class Point():
	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __repr__(self):
		return "%.8f %.8f"%(self.x, self.y)


def koch(d, a, b):
	th = math.pi * 60.0 / 180.0
	if d == 0:
		return 0
	else:
		s = Point((2 * a.x + b.x) / 3.0, (2 * a.y + b.y) / 3.0)
		t = Point((a.x + 2 * b.x) / 3.0, (a.y + 2 * b.y) / 3.0)
		u = Point((t.x - s.x) * math.cos(th) - (t.y - s.y) * math.sin(th) + s.x,
							(t.x - s.x) * math.sin(th) + (t.y - s.y) * math.cos(th) + s.y)
		koch(d-1, a, s)
		print(s)
		koch(d-1, s, u)
		print(u)
		koch(d-1, u, t)
		print(t)
		koch(d-1, t, b)


if __name__ == "__main__":
	n = int(input())
	p1 = Point(0.0, 0.0)
	p2 = Point(100.0, 0.0)
	print(p1)
	koch(n, p1, p2)
	print(p2)


Measured memory_bytes: 5764