akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    string s;cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

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

int main(){
  int s[5];
  for(int i=0;i<5;i++){
    cin >> s[i];
  }
  int k;
  cin >> k;
  int maxi=0;
  int mini=123;
  for(int i=0;i<5;i++){
    maxi = max(maxi,s[i]);
    mini = min(mini,s[i]);
  }
  int max_len = maxi-mini;
  if(max_len > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ans := calc(n)
	fmt.Println(int(ans))	// intにしないと指数つき表現になってしまう
}

func calc(n int) float64{
	tmp := 100000.0
	for i:=0; i<n; i++{
		tmp*=1.05
		tmp = Ceil(tmp, -3)
	}
	return tmp
}

func Ceil(f float64, places int) float64{
	shift := math.Pow(10, float64(places))
	return math.Ceil(f * shift)/shift
}

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

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 1100
// review
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MAXN = 100010;

ll n, c;
ll x[MAXN], v[MAXN];
ll sumV[MAXN];
ll dp[MAXN], revDp[MAXN];

void solve() {
  for (int i=1;i<=n;i++) {
    sumV[i] = sumV[i - 1] + v[i - 1];
  }

  for (int i=0;i<n;i++) {
    dp[i + 1] = max(dp[i], sumV[i+1] - x[i]);
  }

  for (int i=n-1;i>=0;i--) {
    revDp[i] = max(revDp[i + 1], sumV[n] - sumV[i] - (c - x[i]));
  }

  ll ans = max(dp[n], revDp[0]);
  for (int i=0;i<n-1;i++) {
    ans = max(ans, sumV[i + 1] - 2 * x[i] + revDp[i+1]);
  }
  for (int i=n-1;i>0;i--) {
    ans = max(ans, sumV[n] - sumV[i] - 2 * (c - x[i]) + dp[i]);
  }
  cout << ans << endl;
}

int main() {
  cin >> n >> c;
  for (int i=0;i<n;i++) {
    cin >> x[i] >> v[i];
  }
  solve();
}


Measured memory_bytes: 4096
n,k = map(int, input().split())
h = [[] for i in range(n)]
for i in range(n):
    h[i] = int(input())
h.sort()

diff = [[] for i in range(n-1)]
for i in range(n-1):
    diff[i] = h[i+1]-h[i]

t = [[] for i in range(n-1)]
t[0] = diff[0]
for i in range(1,n-1):
    t[i] = t[i-1]+diff[i]
t = [0] + t

# print(h)
# print(diff)
# print(t)

ans = float("inf")
for i in range(n-k+1):
    a = t[i+k-1]-t[i]
    ans = min(ans, a)

print(ans)


Measured memory_bytes: 19172
#include <stdio.h>
#define TRUE 1
#define FALSE 0


int binarySearch(int A[],int key,int n){
  int right = n;
  int left =0;
  int mid;

  while(left < right){
    mid = (left + right)/2;
    
    if(key == A[mid]) return TRUE;

    if(key > A[mid])
      left = mid+1;  
    

    if(key < A[mid])
      right = mid;
  }

  return FALSE;
  
}

int main(){
  int n,q,i,t;
  int s[100001];
  int cnt=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);
    if(binarySearch(s,t,n) == TRUE) cnt++;
  }

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

  return 0;
  
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#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 = (a); i >= (b); i--)
#define LLFOR(i, a, b) for(long long i = (a); i < (b); ++i)
#define LLRFOR(i, a, b) for(long long i = (a); i >= (b); i--)
#define SORT(v, n) sort(v, v+n)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define LLREP(i, n) for(long long i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)
#define LLRREP(i, n) for(long long i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define ret return

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

#define USFOR(i, a, b) for(unsigned i = (a); i < (b); ++i)
#define USREP(i, n) for(unsigned i = 0; i < (n); ++i)

typedef long long ll;
typedef unsigned long long ull;

int MAX(int a,int b){if(a>b){return a;}return b;}
int MIN(int a,int b){if(a<b){return a;}return b;}
int GCD(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){int c=GCD(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int POW(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
ll LLMAX(ll a,ll b){if(a>b){return a;}return b;}
ll LLMIN(ll a,ll b){if(a<b){return a;}return b;}
ll llGCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
ll llLCM(ll a,ll b){ll c=llGCD(a,b);a/=c;return a*b;}
ll llnCr(ll a,ll b){ll i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
ll llnHr(ll a,ll b){return llnCr(a+b-1,b);}
ll llpow(ll a,ll b){ll i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(){
	//solve AXCxxx-X
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	int w;
	cin >> s;
	cin >> w;
	signed siz = s.size();
	REP(i, siz){
		if(i % w == 0) cout << s[i];
	}
	cout << endl;

	ret 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;
 

signed main(){
    int n;
    cin >> n;
    int now = 0;
    rep(i, 0, n){
        string s;
        cin >> s;
        if(s == "A"){
            now++;
        }else{
            now--;
            if(now < 0){
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    if(now == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  a *= 100;
  b *= 10;
  int t = a+b+c;
  if (t%4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

P = "possible"

Nsum = N *(N+1)//2
if sum(A) % Nsum == 0:
  K = sum(A) // Nsum
  for i in range(N):
    A[i] -= K * (i + 1)
  A0 = A[0]
  for i in range(N):
    A[i] -= A0
  B = [0] * N
  for i in range(1, N):
    if (A[i] - A[i-1])%N != 0:
      P = "impossible"
    else:
      B[i] = (A[i-1] - A[i]) // N
  B[0] = K - sum(B)
  for i in range(N):
    if B[i] < 0:
      P = "impossible"
  for i in range(1, N):
    A0 -= B[i] * (N-i)
  if A0 != 0:
    P = "impossible"
else:
  P = "impossible"
  
if P == "impossible":
  print("NO")
else:
  print("YES")

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

int main() {
    int n, x, t;
    int z;
    cin >> n >> x >> t;

    z = n/x;
    if (n%x != 0) z++;

	cout << z * t << endl;
	return 0;
}


Measured memory_bytes: 3640
while True:
    x = int(input())
    if x == 0:
        break
    s=1000-x
    a=s//500
    b=(s%500)//100
    c=((s%500)%100)//50
    d=(((s%500)%100)%50)//10
    e=((((s%500)%100)%50)%10)//5
    f=((((s%500)%100)%50)%10)%5
    print(a+b+c+d+e+f)


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    int N,M,C; cin >> N >> M >> C;
    VI B(M); REP(i,M) cin >> B[i];
    int A[N][M]; REP(i,N)REP(j,M) cin >> A[i][j];

    int ans = 0;
    REP(i,N){
        int tmp = C;
        REP(j,M) tmp += A[i][j]*B[j];
        if(tmp > 0) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
[ height , width ] = list(map(int,input().split()))

input_map = []
output_map = [[0 for j in range(width)] for i in range(height)]

def is_sharp( input_map , x, y , width , height):
	if( x==-1 or y == -1 or x+1 > width or y+1 > height  ) :return 0
	
	if( input_map[y][x] == '#'):
		return 1
	else:
		 return 0

def count_sharp_num( input_map , x , y):
	count = 0
	count += is_sharp(input_map , x-1 , y-1 , width , height)
	count += is_sharp(input_map , x-1 , y , width , height)
	count += is_sharp(input_map , x-1 , y+1 , width , height)
	count += is_sharp(input_map , x , y-1 , width , height)
	count += is_sharp(input_map , x , y+1 , width , height)
	count += is_sharp(input_map , x+1 , y-1 , width , height)
	count += is_sharp(input_map , x+1 , y , width , height)
	count += is_sharp(input_map , x+1 , y+1 , width , height)
	return count

for i in range( height ):
	input_map.append( input() )


for x in range( width ):
	for y in range( height ):
		output_map[y][x] = count_sharp_num(input_map,x,y)
		if input_map[y][x] == '#':
			output_map[y][x] = '#'


for y in range(height):
	print( ''.join(map(str,output_map[y])))


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
char id[300][20];
int main(void)
{
    int n, m, i, opened;
    scanf("%d", &n);
    for(i=0;i<n;++i) scanf("%s", id[i]);
    scanf("%d", &m);
    opened=0;
    while (m--) {
        char t[20];
        int unknown=1;
        scanf("%s", t);
        for(i=0;i<n;++i) if (!strcmp(id[i], t)) {
            printf("%s by %s\n", opened ? "Closed" : "Opened", t);
            unknown=0;
            opened=1-opened;
            break;
        }
        if (unknown) {
            printf("Unknown %s\n", t);
        }
    }
    return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, M;
  cin>>N>>M;
  ll ans = 1;
  for(int i=0;i<M;++i) ans *= 2;
  cout<<ans*(1900*M+100*(N-M))<<endl;
}



Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		
		if(op == '?'){
			break;
		}
		else if(op == '+'){
			printf("%d\n",a+b);
		} 
		
		else if(op == '-'){
			printf("%d\n",a-b);
		} 
		else if(op == '*'){
			printf("%d\n",a*b);
		} 
		else if(op == '/'){
			printf("%d\n",a/b);
		} 
	}
	 return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
int ans=1;
int n;
string s;
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>s;
char c;
c=s[0];
rep(i,1,s.size())
{
	if(c!=s[i])
	{
		ans++;
		c=s[i];
	}
}
cout<<ans;




}

Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	double n,kari;
	int a,b,c,i, ans = 0,j, x,max;
	
	
	cin >> a >> b;
	
	if (a > 0) {
		cout << "Positive" << "\n";
	}
	else if (a <= 0 and b >= 0) {
		cout << "Zero" << "\n";
	}
	else {
		x = a - b + 1;
		if (x % 2 == 0) {
			cout << "Positive" << "\n";
		}
		else {
			cout << "Negative" << "\n";
		}
	}
}


Measured memory_bytes: 256
using System;

class Q1{
    
    static void Main(string[] args){
        int a,b,c;
        String[] str= Console.ReadLine().Split(' ');
        
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);
        if(a == b)  Console.Write(c);
        else if(a == c)Console.Write(b);
        else if(b == c)Console.Write(a);

    }
}

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

int n;
int a[100010];
vector<int> Z;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i], Z.push_back(a[i]);
	sort(Z.begin(), Z.end());
	for (int i = 1; i <= n; ++i) {
		a[i] = lower_bound(Z.begin(), Z.end(), a[i]) - Z.begin() + 1;
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) if (a[i] % 2 != i % 2) ++ans; 
	cout << ans / 2 << endl;
}

Measured memory_bytes: 1148
#include <iostream>

using namespace std;

bool solve(int X, int Y)
{
	int a = 4 * X - Y;
	if (a < 0 || a % 2 != 0) {
		return false;
	}
	int t = a / 2;
	int k = X - t;
	if (k < 0) {
		return false;
	}
	return true;
}

int main()
{
	int X, Y;
	cin >> X >> Y;

	if (solve(X, Y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int main() {
  int N, K;
  string xd = "";
  cin >> N >> K;

  while(N != 0) {
    int mod = N % K;
    xd += to_string(mod);
    N = N / K;
  }

  cout << xd.length() << endl;
}


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

int N,A,B,i,j,k;
string S;
int l[N_MAX];
int r[N_MAX];
int num[N_MAX] = {0};
int ans=0;

int main(){
  cin >> N;
  for (i=0;i<N;i++) cin >> l[i] >> r[i];
  for (i=0;i<N;i++){
    A=(r[i] - l[i] + 1);
    ans+=A;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A[3][3];
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i){
        int b;
        cin >> b;
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 3; ++j){
                if(b == A[i][j]) A[i][j] = -1;
            }
        }
    }
    int b = false;
    for(int k = 0; k < 3; ++k){
        if(A[k][k] != -1) continue;
        int b1 = true;
        int b2 = true;
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 3; ++j) {
                if(A[i][k] != -1) b1 = false;
                if(A[k][i] != -1) b2 = false;
            }
        }
        b = b || b1 || b2;
    }
    if(A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) b = true;
    if(A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1) b = true;

    if(b) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
import os
import sys

import numpy as np


def solve(inp):
    def bit_add(arr, n, i, x):
        while i <= n:
            arr[i] += x
            i += i & -i

    def bit_sum(arr, i):
        result = 0
        while i > 0:
            result += arr[i]
            i ^= i & -i
        return result

    n = int(inp[0])
    lim = (n * (n - 1) // 2 + 1) // 2
    aaa = inp[1::3]
    bbb = inp[2::3]
    ccc = inp[3::3]

    inclines_x = []
    inclines_y = []
    for i in range(n):
        inclines_x.append((aaa[i] / bbb[i], i))
        inclines_y.append((bbb[i] / aaa[i], i))
    inclines_x.sort()
    inclines_y.sort()
    incline_rank_x = np.zeros(n, dtype=np.int64)
    incline_rank_y = np.zeros(n, dtype=np.int64)
    for k in range(n):
        incline_rank_x[inclines_x[k][1]] = n - k
        incline_rank_y[inclines_y[k][1]] = n - k

    def check_x(m):
        yyy = []
        for i in range(n):
            yyy.append(((ccc[i] - aaa[i] * m) / bbb[i], i))
        yyy.sort()

        bit = np.zeros(n + 1, dtype=np.int64)
        intersection_left = 0
        for j in range(n):
            i = yyy[j][1]
            k = incline_rank_x[i]
            intersection_left += bit_sum(bit, k)
            bit_add(bit, n + 1, k, 1)

        return intersection_left >= lim

    def check_y(m):
        xxx = []
        for i in range(n):
            xxx.append(((ccc[i] - bbb[i] * m) / aaa[i], i))
        xxx.sort()

        bit = np.zeros(n + 1, dtype=np.int64)
        intersection_left = 0
        for j in range(n):
            i = xxx[j][1]
            k = incline_rank_y[i]
            intersection_left += bit_sum(bit, k)
            bit_add(bit, n + 1, k, 1)

        return intersection_left >= lim

    l = -2.0 * 10 ** 8
    r = 2.0 * 10 ** 8
    while r - l > 1e-9 and abs((r - l) / l if l != 0 else r) > 1e-9:
        m = (l + r) / 2
        if check_x(m):
            r = m
        else:
            l = m
    x = l

    l = -2.0 * 10 ** 8
    r = 2.0 * 10 ** 8
    while r - l > 1e-9 and abs((r - l) / l if l != 0 else r) > 1e-9:
        m = (l + r) / 2
        if check_y(m):
            r = m
        else:
            l = m
    y = l

    return x, y


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(f8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(f8[:],)', cache=True)(solve)

inp = np.fromstring(sys.stdin.buffer.read(), dtype=np.float64, sep=' ')
try:
    x, y = solve(inp)
    print(x, y)
except ZeroDivisionError:
    print('WA')
    exit()


Measured memory_bytes: 30184
import java.util.Scanner;

public class Main {

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

		int a=Integer.parseInt(str1, 16);
		int b=Integer.parseInt(str2, 16);

		if(a<b)System.out.println("<");
		if(a==b)System.out.println("=");
		if(a>b)System.out.println(">");
	}
}


Measured memory_bytes: 21844
class Graph():  #non-directed
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.edge = edge
        self.indexed = indexed
        self.graph = [[] for _ in range(n)]
        for e in edge:
            self.graph[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.graph[e[1] - indexed].append((e[0] - indexed, e[2]))

    def warshall_floyd(self, INF=10**18):
        dist = [[INF for j in range(self.n)] for i in range(self.n)]
        for i in range(self.n):
            dist[i][i] = 0
        for i in range(self.n):
            for j, cost in self.graph[i]:
                dist[i][j] = cost
        for k in range(self.n):
            for i in range(self.n):
                for j in range(self.n):
                    if dist[i][k] != INF and dist[k][j] != INF:
                        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
        return dist

N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]

E = list()

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        E.append((i, j, A[i][j]))

g = Graph(N, E, 0)
wf = g.warshall_floyd()

flag = False

for i in range(N):
    for j in range(N):
        if A[i][j] != wf[i][j]:
            print(-1)
            flag = True
            break
    if flag:
        break
else:
    res = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            for k in range(N):
                if i == k or j == k:
                    continue
                if A[i][j] == A[i][k] + A[k][j]:
                    break
            else:
                res += A[i][j]

    print(res)

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

int main(){
  int N,M; cin >> N >> M;
  vector<int> h(N);
  for(int i=0; i<N; i++) cin >> h[i];
  
  vector<bool> t(N,true);
  for(int i=0; i<M; i++){
    int a,b; cin >> a >> b;
    a--; b--;
    if(h[a]<=h[b]) t[a]=false;
    if(h[a]>=h[b]) t[b]=false;
  }
  int c=0;
  for(int i=0; i<N; i++) c+=(int)t[i];
  cout << c << endl;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <stdlib.h>
#define INF 100000000
#define NIL -1
#define WHITE 0
#define BLACK 1

main(){
        int n, i, j, u, p, m, k, cost=0, mincost;
	int **G, *tmp;
	int *flag;
	int *d, *pi;

	scanf("%d", &n);
	flag = (int*)malloc(sizeof(int) * n);
	d = (int *)malloc(sizeof(int)*n);
	pi = (int *)malloc(sizeof(int)*n);
	G = (int**)malloc(sizeof(int*) * n);
	tmp = (int*)malloc(sizeof(int) * n * n);
	for (i = 0; i < n; i++){
		G[i] = tmp + i * n;
		flag[i] = WHITE;
		d[i]=INF;
		pi[i]=NIL;
		for (j = 0; j < n; j++){
			G[i][j] = NIL;
		}
	}

	for(i=0; i<n; i++){
	  scanf("%*d%d", &k);
	  for(j=0; j<k; j++){
	    scanf("%d", &p);
	    scanf("%d", &m);
	    G[i][p] = m;
	  }
	}

	u=0;
	d[u]=0;

	while(1){
	  mincost = INF;
	  for(i=0; i<n; i++){
	    if(flag[i]!=BLACK && d[i]<mincost){
	      mincost = d[i];
	      u=i;
	    }
	  }
	  if(mincost == INF) break;
	  flag[u] = BLACK;
	  //cost += mincost;

	  for(i=0; i<n; i++){
	    if(G[u][i]!=NIL && flag[i]!=BLACK && (d[u]+G[u][i])<d[i]){
	      d[i]=d[u]+G[u][i];
	      pi[i] = u;
	    }
	  }  
	}

        for(i=0; i<n; i++){
	  printf("%d %d\n", i, d[i]);
	}

	free(tmp);
	free(G);
	free(flag);
	free(d);
	free(pi);

	return 0;
}

Measured memory_bytes: 640
use std::io::stdin;

fn main() {
    let mut ab = String::new();
    stdin().read_line(&mut ab).unwrap();
    let ab: Vec<isize> = ab.trim().split_whitespace().flat_map(str::parse).collect();
    let (a, b) = (ab[0], ab[1]);
    println!("{}", match a {
        0 | 1 | 2 | 3 | 4 | 5 => 0,
        6 | 7 | 8 | 9 | 10 | 11 | 12 => b / 2,
        _ => b,
    });
}


Measured memory_bytes: 4352
N = int(input())
H = list(map(int, input().split(' ')))

for i in range(len(H)-1, 0, -1):
    if H[i-1] > H[i]:
        H[i-1] -= 1

    if H[i-1] > H[i]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 14396
#include <iostream>
using namespace std;
long long a[1000001]={0};	
int main()
{
	long long n;
	cin>>n;
	a[1]=n;
	for (int i=2;i<=1000001;i++)
	{
		if (a[i-1]%2==0)  a[i]=a[i-1]/2;
		else a[i]=a[i-1]*3+1;
		for (int j=1;j<=i-1;j++)
		{
			if (a[j]==a[i])
			{
				cout<<i<<endl;
				return 0;
			}
		}
	}
	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t w, h, n;
  std::cin >> w >> h >> n;

  int64_t x_min = 0, x_max = w, y_min = 0, y_max = h;

  for (int64_t i = 0; i < n; i++) {
    int64_t x, y, a;
    std::cin >> x >> y >> a;
    switch (a) {
      case 1:
        x_min = std::max(x, x_min);
        break;
      case 2:
        x_max = std::min(x, x_max);
        break;
      case 3:
        y_min = std::max(y, y_min);
        break;
      case 4:
        y_max = std::min(y, y_max);
        break;
    }
  }

  std::cout << std::max<int64_t>(0, x_max - x_min) *
                   std::max<int64_t>(0, y_max - y_min)
            << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
  int n;
  int a[100];

  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];

  bool flg = true;
  for(int i = 0; i < n; i++) {
    if(a[i]%2 == 0) {
      if((a[i]%3 != 0) && (a[i]%5 != 0)) {
        flg = false;
        break;
      }
    }
  }
  if(flg) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
  return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
const ll INF = 1000000000;
ll n, a, b;
ll num[100005];
bool pan(ll x)
{
    ll sum = 0;
    FOR(i,1,n)
    {
        ll s = num[i]-b*x;
        if(s > 0)
        {
            if(s%(a-b) == 0)sum += s/(a-b);
            else sum += s/(a-b)+1;
        }
    }
    if(sum > x)return true;
    else return false;
}
bool pan2(ll x)
{
    ll sum = 0;
    FOR(i,1,n)
    {
        ll s = num[i]-b*x;
        if(s > 0)
        {
            if(s%(a-b) == 0)sum += s/(a-b);
            else sum += s/(a-b)+1;
        }
    }
    if(sum <= x)return true;
    else return false;
}
int main()
{
    ll sum = 0;
    cin >> n >> a >> b;
    FOR(i,1,n){cin >> num[i];sum += num[i];}
    sort(num+1, num+n+1);
    ll l = 1, r = INF;
    while(l+1 < r)
    {
//        cout << l << ' ' << r << endl;
        ll m = (l+r)/2;
        if(pan(m))l = m;
        else r = m;

    }
    if(pan2(r-1))
    {
        r--;
    }
    cout << r << endl;
    return 0;
}


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

#define M ll(1e9 + 7)

#define maxn 2003

using namespace std;
typedef long long ll;

int n, m;

int a[maxn];
int b[maxn];

ll dp[maxn][maxn];

int main(){
   // #define TASK "ABC"
    //freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

    cin >> n >> m;

    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    for (int i = 1; i <= m; ++i)
        cin >> b[i];

    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i)
        dp[i][0] = 1;

    for (int j = 1; j <= m; ++j)
        dp[0][j] = 1;

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - (a[i] == b[j] ? 0 : dp[i - 1][j - 1]) + M) % M;


    cout << dp[n][m];
    return 0;
}


Measured memory_bytes: 31616
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B] = [int(input_raw[0]), int(input_raw[1])]
    print max(A + B, A - B, A * B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
string S, T, U;
int A, B;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> S >> T >> A >> B >> U;
	if (S == U)
	{
		A--;
	}
	else
	{
		B--;
	}
	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
vector <int> v;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c<22){
		cout<<"win";
	}
	else{
		cout<<"bust";
	}
	}

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

using namespace std;

int main() {
    int a,B;
    cin >> a >> B;
    if (a >= 13)
    {
        cout << B << endl;
    } else if (a >= 6 && a <= 12){
        cout << B / 2 << endl;
    } else {
        cout << 0 <<endl; 
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
int a[maxn];

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    int n, l;
    cin >> n >> l;
    forn (i, n)
        cin >> a[i];
    vector<int> res;
    forn (i, n - 1) {
        if (a[i] + a[i + 1] >= l) {
            cout << "Possible\n";
            forn (k, i)
                cout << k + 1 << '\n';
            for (int k = n - 1; k > i; --k)
                cout << k << '\n';
            return 0;
        }
    }
    cout << "Impossible\n";

}


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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

int main() {
    ll A, B, C, D, E, F;
    cin>>A>>B>>C>>D>>E>>F;

    vector<ll> dp(F+1, -1);
    dp[0] = 0;
    for (ll f = 0; f <= F; f++) {
        if (dp[f] == -1) continue;
        dp[f + 100*A] = max(dp[f + 100*A], dp[f]);
        dp[f + 100*B] = max(dp[f + 100*B], dp[f]);
        if ((f - dp[f]) * E >= (dp[f] + C) * 100) dp[f + C] = max(dp[f + C], dp[f] + C);
        if ((f - dp[f]) * E >= (dp[f] + D) * 100) dp[f + D] = max(dp[f + D], dp[f] + D);
    }
    pair<ll, ll> ans(0, 0);
    for (ll f = 0; f <= F; f++) {
        if (dp[f] == -1) continue;
        if (ans.second == 0 || dp[f] * ans.first > f * ans.second) {
            ans.first = f;
            ans.second = dp[f];
        }//dp[f] / f > ans.second / ans.first
    }
    cout<<ans.first<<" "<<ans.second<<endl;
}

Measured memory_bytes: 384
import numpy as np
from random import randint

# ------------------------------------------------
# a.pyで作った部分
# ------------------------------------------------
D=int(input())
c=[int(i) for i in input().split()]
s=[]
for d in range(D):
    s.append([int(i) for i in input().split()])

# ------------------------------------------------
# b.pyで作った部分
# ------------------------------------------------
v = [0]*D
last = [[0 for i in range(26)] for d in range(D)]
t=[0]*D

v_pre=0
for d in range(D):
    
    # 初期化
    idx_best=0
    v=v_pre + s[d][idx_best] - sum([c[j] for j in range(26)]) + c[idx_best]
    
    # d日目の時点で満足度最大となるidxを選ぶ(貪欲法)
    for i in range(1, 26):
        v_tmp = v - s[d][idx_best] + c[idx_best] + s[d][i] - c[i]
        if v < v_tmp:
            v = v_tmp
            
            idx_best=i
    
    v_pre = v
    t[d]=idx_best + 1           # 1 <= t[d] <= 26 のため
    

# tのランダム生成したものよりは1000万くらい満足度UPしてるが, 合計は-1000万くらい.
# t = [randint(1, 26) for _ in range(D)]

for d in range(D):
    print(t[d])

Measured memory_bytes: 27300
import java.util.Scanner;

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

        String str = sc.next();
        int str_length = str.length();

        String first_str = str.substring(0, 1);
        String end_str = str.substring(str_length-1,str_length);

        System.out.println(first_str + (str_length-2) + end_str);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

ll ans = INF;
ll n;
ll a, b, c;
vector<ll> l;

void dfs(int x, int y, int z, int u){
  if (u == n){
    if (x == 0 || y == 0 || z == 0)
      return;
    ll A = 0, B = 0, C = 0;
    ll t = 0;
    for (int i = 0; i < n; i++){
      if ((x >> i) & 1){
        A += l[i];
        t++;
      }
      if ((y >> i) & 1){
        B += l[i];
        t++;
      }
      if ((z >> i) & 1){
        C += l[i];
        t++;
      }
    }
    ans = min(ans, (t-3)*10 + abs(A - a) + abs(B - b) + abs(C - c));
  }
  else {
    dfs(x, y, z, u + 1);
    dfs(x | (1 << u), y, z, u + 1);
    dfs(x, y | (1 << u), z, u + 1);
    dfs(x, y, z | (1 << u), u + 1);
  }
}


int main(void){
  cin >> n >> a >> b >> c;
  
  l = vector<ll>(n);
  for (int i = 0; i < n; i++){
    cin >> l[i];
  }
  
  dfs(0, 0, 0, 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
k = int(input())

a = []
for i in range(1, 10):
    a.append(i)

while True:
    if k <= len(a):
        print(a[k - 1])
        exit(0)
    else:
        k -= len(a)
    old = a
    a = []
    for x in old:
        d = x % 10
        if d > 0:
            a.append(x * 10 + d - 1)
        a.append(x * 10 + d)
        if d < 9:
            a.append(x * 10 + d + 1)


Measured memory_bytes: 10752
N = int(input())
A = []
for i in range(N):
    X,L = map(int,input().split())
    A.append((X,L))
A.sort(key=lambda x:x[0]+x[1])
ans = 0
b = -float("inf")
for a in A:
    if b<=(a[0]-a[1]):
        ans+=1
        b = (a[0]+a[1])
print(ans)

Measured memory_bytes: 21332
n = int(input())

arr = []

for i in range(n):
    a, b = map(int, input().split())
    arr.append([i, a, b])
    
    
left_arr = sorted(arr, key=lambda x: x[2])
right_arr = sorted(arr, key=lambda x: x[1], reverse=True)

ans = 0

f = 0
ok = [0 for i in range(n)]

#if abs(left_arr[0][2]) < abs(right_arr[0][1]):
#    f = 1
    
lp = 0
rp = 0
now = 0
for i in range(n):
    if f == 0:
        while True:
            if ok[left_arr[lp][0]] == 0:
                break
            else:
                lp += 1
        if now >= left_arr[lp][1] and now <= left_arr[lp][2]:
            ans += 0
        elif abs(left_arr[lp][1] - now) < abs(left_arr[lp][2] - now):
            ans += abs(left_arr[lp][1] - now)
            now = left_arr[lp][1]
        else:
            ans += abs(left_arr[lp][2] - now)
            now = left_arr[lp][2]
        ok[left_arr[lp][0]] = 1
        lp += 1
        f = 1
    else:
        while True:
            if ok[right_arr[rp][0]] == 0:
                break
            else:
                rp += 1
        if now >= right_arr[rp][1] and now <= right_arr[rp][2]:
            ans += 0
        elif abs(right_arr[rp][1] - now) < abs(right_arr[rp][2] - now):
            ans += abs(right_arr[rp][1] - now)
            now = right_arr[rp][1]
        else:
            ans += abs(right_arr[rp][2] - now)
            now = right_arr[rp][2]
        ok[right_arr[rp][0]] = 1
        rp += 1
        f = 0
        
ans += abs(now)

temp = ans

ans = 0

f = 1
for i in range(n):
    ok[i] = 0

lp = 0
rp = 0
now = 0
for i in range(n):
    if f == 0:
        while True:
            if ok[left_arr[lp][0]] == 0:
                break
            else:
                lp += 1
        if now >= left_arr[lp][1] and now <= left_arr[lp][2]:
            ans += 0
        elif abs(left_arr[lp][1] - now) < abs(left_arr[lp][2] - now):
            ans += abs(left_arr[lp][1] - now)
            now = left_arr[lp][1]
        else:
            ans += abs(left_arr[lp][2] - now)
            now = left_arr[lp][2]
        ok[left_arr[lp][0]] = 1
        lp += 1
        f = 1
    else:
        while True:
            if ok[right_arr[rp][0]] == 0:
                break
            else:
                rp += 1
        if now >= right_arr[rp][1] and now <= right_arr[rp][2]:
            ans += 0
        elif abs(right_arr[rp][1] - now) < abs(right_arr[rp][2] - now):
            ans += abs(right_arr[rp][1] - now)
            now = right_arr[rp][1]
        else:
            ans += abs(right_arr[rp][2] - now)
            now = right_arr[rp][2]
        ok[right_arr[rp][0]] = 1
        rp += 1
        f = 0
        
        
ans += abs(now)

if temp>ans:
    ans = temp
print(ans)

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

int main(){
	int N;
	cin >> N;
	string s;
	cin >> s;
	if(N%2){
			puts("No");
		return 0; 
	}
	for(int i=0; i<N/2; i++){
		if(s[i] == s[i+N/2]) continue;
		puts("No");
		return 0; 
	}
	puts("Yes");
	return 0;
}

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

class DisjointSet{
  public:
    vector<int> rank, p;

    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size, 0);
        p.resize(size, 0);
        for(int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }
    
    bool unite(int x, int y){
        link(findSet(x), findSet(y));
    }

    void link(int x, int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        }else{
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }

    int findSet(int x){
        if(x != p[x]){
            // path compression
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main(){
    int n, k, l, p, q;
    cin >> n >> k >> l;
    
    DisjointSet road(n), train(n);

    for(int i = 0; i < k; i++){
        cin >> p >> q;
        p--; q--;
        road.unite(p, q);
    }

    for(int i = 0; i < l; i++){
        cin >> p >> q;
        p--; q--;
        train.unite(p,q);
    }

    int a[n], b[n];
    for(int i = 0; i < n; i++)  a[i] = road.findSet(i);
    for(int i = 0; i < n; i++)  b[i] = train.findSet(i);

    map<pair<int,int>, int> ans;
    for(int i = 0; i < n; i++){
        ans[{a[i],b[i]}]++;
    }

    for(int i = 0; i < n; i++){
        if(i)   cout << " ";
        cout << max(1, ans[{a[i],b[i]}]);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define mod 1000000007;

int main (void){
	int n,a;
	cin >> n >> a;
	if(n%500<=a) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int h ,w;
	while (cin >> h >> w) {
		if (h == 0 && w == 0) {
			break;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 || i == h - 1) {
					cout << "#";
					if (j == w - 1) {
						cout << endl;
					}
				}
				else if (j == 0) {
					cout << "#";
				}
				else if (j == w - 1) {
					cout << "#" << endl;
				}
				else {
					cout << ".";
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
n=int(input())
a=list(map(int,input().split()))
a.sort()
alarge=a[n-1]
if a[0]>=alarge/2:
  asmall=a[0]
else:
  j=0
  while a[j]<alarge/2:
    j+=1
  if alarge<=a[j-1]+a[j]:
    asmall=a[j-1]
  else:
    asmall=a[j]
print("{} {}".format(alarge,asmall))

Measured memory_bytes: 14052
import sys
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    ls = []
    for i in range(n):
        x, y = list(map(int, readline().split()))
        ls.append([x, y])
    mt = 0
    cnt = 0
    for v in itertools.permutations([i for i in range(n)], n):
        cnt += 1
        for i in range(1, n):
            mt += ((ls[v[i-1]][0] - ls[v[i]][0]) ** 2 + (ls[v[i-1]][1] - ls[v[i]][1]) ** 2) ** 0.5
    print(mt / cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39408
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;

vector<pair<long long int, long long int>> getPrimeElements(long long int num) {

	long long int firstnum = num;

	vector<pair<long long int, long long int>> result;
	pair<long long int, long long int> wk;

	if (num % 2 == 0) {
		wk.first = 2;
		wk.second = 0;
		while (num % 2 == 0) {
			wk.second++;
			num /= 2;
		}

		result.push_back(wk);
	}

	long long int waru = 3;

	while (true) {

		if (num % waru == 0) {
			wk.first = waru;
			wk.second = 0;
			while (num % waru == 0) {
				wk.second++;
				num /= waru;
			}

			result.push_back(wk);
		}
		waru += 2;

		if (waru * waru > num) break;

	}

	if (num != 1) {
		wk.first = num;
		wk.second = 1;
		result.push_back(wk);

	}

	return result;
}


int getKeta(int num) {

	if (num == 0)return 1;

	int res = 0;

	while (num > 0) {
		num /= 10;
		res++;
	}

	return res;
}

vector<int> bunkai(int num) {

	string str = to_string(num);
	vector<int> res;

	for (int i = 0; i < str.size(); i++) {
		int a = str[i] - '0';
		res.push_back(a);
	}

	return res;

}


int main()
{
    
	long long int n, x;
	cin >> n >> x;

	vector<long long int> a(n);
	for (auto& i : a)cin >> i;
	
	long long int sum = 0;
	for (auto& i : a)sum += i;
	

	sort(a.begin(), a.end());

	long long int ans = 0;
	if (sum < x) {
		ans = n - 1;
	}
	else if (sum == x) {
		ans = n;
	}
	else {

		for (int i = 0; i < a.size(); i++) {
			x -= a[i];
			if (x >= 0)ans++;
		}
	}
	cout << ans << endl;

	return 0;

}




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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        
        int m = 0;
        int n = 0;


        m = N/((D*2)+1);
        n = N%((D*2)+1);

        if(n != 0){
            m+=1;
        }

        if(D >= N){
            m = 1;
        }

        System.out.println(m);
        
    }

}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	string a,b;
	std::cin >> a;
	std::cin >> b;
	reverse(b.begin(),b.end());
	if (a == b) {
		std::cout << "YES" << '\n';
	}
	else{
		std::cout << "NO" << '\n';
	}
	return 0;
}


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

int main() {
  string o, e;
  cin >> o >> e;
  string result = "";
  int i;
  for (i = 0; i < e.length(); i++) {
    result.push_back(o.at(i));
    result.push_back(e.at(i));
  }
  if (o.length() != e.length()) {
    result.push_back(o.at(o.length() - 1));
  }
  cout << result << endl;
  return 0;
}


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

bitset<2500> reach0, reachN;

pair<bool, vector<int64_t>> BellmanFord(int N, int S, vector<pair<int, int>> edges[]){
    vector<int64_t> dist(N, 1e18);
    dist[S] = 0;
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++) for(auto& e : edges[i]){
            int j = e.first, d = e.second;
            if(dist[j] > dist[i] + d){
                dist[j] = dist[i] + d;
            }
        }
    }
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++) for(auto& e : edges[i]){
            int j = e.first, d = e.second;
            if(dist[j] > dist[i] + d){
                dist[j] = dist[i] + d;
                if(reach0[j] && reachN[j]) return {false, {}};
            }
        }
    }
    return {true, dist};
}

void dfs(int i, vector<pair<int, int>> edges[], bitset<2500>& res){
    if(res[i]) return;
    res[i] = 1;
    for(auto& p : edges[i]) dfs(p.first, edges, res);
}

int main(){
    int N, M, P;
    cin >> N >> M >> P;
    vector<pair<int, int>> edges[2500], rev[2500];

    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        edges[a-1].emplace_back(b-1, P-c);
        rev[b-1].emplace_back(a-1, P-c);
    }
    dfs(0, edges, reach0);
    dfs(N-1, rev, reachN);

    auto res = BellmanFord(N, 0, edges);
    if(res.first){
        cout << max(int64_t(0), -res.second[N-1]) << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, X, M;
    cin >> N >> X >> M;
    ll sum = 0;
    vector<pll> hist(M);
    bool f = 0;
    for(ll i = 0; i < N; i++) {
        if(hist[X].first & !f) {
            ll len = i - hist[X].first, cnt = (N - i - 1) / len;
            i += len * cnt;
            sum += (sum - hist[X].second) * cnt;
            f = 1;
        } else {
            hist[X] = MP(i, sum);
        }
        sum += X;
        X = (X * X) % M;
    }
    cout << sum << endl;
}

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

int main()
{
    int n, c = 0, a;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a;
        if(i % 2 == 1 && a % 2 == 1){
            c++;
        }
    }
    cout << c;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
using namespace std;

//no3
int main(){
	int n = 0;
	cin >> n;
	int* vi = new int[n];

	for(int i = 0; i < n; i++){
		cin >> vi[i];
	}
	sort(vi, vi + n);

	//小さい?順に突っこむ
	double sum = vi[0];
	for(int i = 1; i < n; i++){
		sum = (double)(vi[i] + sum)/2.0;
	}

	cout << std::setprecision(6) << sum << endl;

	return 0;
}


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

int main() {
	string s;
	cin >> s;
	for(int i=0;i<3;i++){
	    char ch = s[i];
	    if(ch=='7'){
	        cout << "Yes" << endl;
	        break;
	    }
	    else if(i==2){
	        cout << "No" << endl;
	    }
	}
	return 0;
}


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

int main(){
  long long n, a=1;
  cin >> n;
  
  for(int i=1;i<n+1;i++){
    a = a*i;
    if(a > 1000000007){
      a = a%1000000007;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
struct node { int y,next; } a[3*N];
struct node1 { int y,b,next; } b[N*20];
int an[N],t[N],head[N],Head[N],i,j,k,n,m,z;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void jb(int y,int x)
{
	a[++k]=(node){y,head[x]},head[x]=k;
}

void jbb(int x,int y,int B)
{
	b[++k]=(node1){y,B,Head[x]},Head[x]=k;
}

void mt(int w){ for (;w<=m;w+=w&-w) ++t[w]; }
int qt(int w){ int z=0; for (;w;w-=w&-w) z+=t[w]; return z; }

int main()
{
	n=read(),m=read();
	for (i=1;i<=n;++i) jb(read(),read());
	k=0;
	for (i=1;i<=m;++i)
		for (j=i;j<=m;j+=i)
			jbb(j,min(m,j+i-1),i);
	for (i=1;i<=m;++i)
	{
		for (j=head[i];j;j=a[j].next)
			mt(a[j].y);
		z=qt(i-1);
		for (j=Head[i];j;j=b[j].next)
			an[b[j].b]+=qt(b[j].y)-z;
	}
	for (i=1;i<=m;++i) printf("%d\n",an[i]);
	return 0;
}

Measured memory_bytes: 23296