akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}

inline void write(int x){
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);putchar(x%10+'0');
}

inline void writeln(int x){
	write(x);puts("");
}
#include <algorithm>
#define Max 200005
int n,l,r,a[Max],b[Max];

int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=b[i]=read();
	sort(b+1,b+n+1);
	l=b[n/2];r=b[n/2+1];
	for(int i=1;i<=n;i++){
		if(a[i]<=l)writeln(r);else writeln(l);
	}
	return 0;
}

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

using namespace std;

#define endl "\n"
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define rrep(i, a, b) for (auto i = (a); i > (b); --i)

void sol(int &n)
{
  vector<string> v(n);
  int IsOp[100];
  int num[100];
  rep(i, 0, n)
  {
    cin >> v[i];
    if (v[i].back() == '*' || v[i].back() == '+')
    {
      IsOp[i] = (v[i].back() == '+' ? 1 : 2);
    }
    else
    {
      IsOp[i] = 0;
      num[i] = v[i].back() - '0';
    }
  }
  vector<int> res[100];
  rrep(i, n - 1, -1)
  {
    int tmp = 0;
    if (IsOp[i] == 1)
    {
      rep(j, 0, (int)res[i].size())
      {
        tmp += res[i][j];
      }
    }
    else if (IsOp[i] == 2)
    {
      tmp = 1;
      rep(j, 0, (int)res[i].size())
      {
        tmp *= res[i][j];
      }
    }
    else
      tmp = num[i];
    if (i == 0)
    {
      cout << tmp << endl;
      return;
    }
    rrep(j, i - 1, -1)
    {
      if (v[i].size() - 1 == v[j].size())
      {
        res[j].push_back(tmp);
        break;
      }
    }
  }
}

int n;

int main()
{
  while (cin >> n, n)
  {
    sol(n);
  }
}


Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		int counter = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputNum = br.readLine().split(" ");
		int a = Integer.parseInt(inputNum[0]);
		int b = Integer.parseInt(inputNum[1]);
		int c = Integer.parseInt(inputNum[2]);

		for(int i = a; i<= b ; i++){
			if(c%i == 0){
				counter++;
			}
		}
		System.out.println(counter);
	}

}

Measured memory_bytes: 17036
#include<bits/stdc++.h>
using namespace std;
const int mxN=2e5+10;
int n;
string s1,s2;
char c;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    if(n%2){
        cout<<"No";
        return 0;
    }
    for(int i=0;i<n/2;i++){
        cin>>c;
        s1+=c;
    }
    for(int i=0;i<n/2;i++){
        cin>>c;
        s2+=c;
    }
    if(s2==s1)cout<<"Yes";
    else cout<<"No";
}

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

#define MAX 44

int F[MAX];

int main() {
    int n;
    cin >> n;
    F[0] = 1;
    F[1] = 1;
    for(int i=2; i<=n; i++) {
        F[i] = F[i-1] + F[i-2];
    }

    cout << F[n] << endl;

    return 0;
}


Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC123B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int n = 5;
            int[] cookingTime = new int[n];
            int[] nextOrderTime = new int[n];
            for (int i = 0; i < n; i++)
            {
                cookingTime[i] = int.Parse(Console.ReadLine());
                nextOrderTime[i] = (cookingTime[i] + 9) / 10 * 10;
                //Console.WriteLine(cookingTime[i]+" "+nextOrderTime[i]);
            }
            int lastOrdersTime = 10;
            int lastOrder = n-1;
            for (int i = 0; i < n; i++)
            {
                if ((lastOrdersTime > cookingTime[i] % 10)&&(cookingTime[i] % 10!=0))
                {
                    lastOrdersTime = cookingTime[i] % 10;
                    lastOrder = i;
                }
            }
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (i != lastOrder)
                {
                    ans += nextOrderTime[i];
                }
            }
            ans += cookingTime[lastOrder];
            Console.WriteLine(ans);
        }
    }
}


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

int n,a,k,ans;

int g(int a){
    if(a < k) return 0;
    if(a%k == 0) return a/k;
    return g(a-((a-a/k*k-1)/(a/k+1)+1)*(a/k+1));
}

int main(){
    cin >> n;
    while(n--) { cin >> a >> k; ans ^= g(a); }
    cout << (ans ? "Takahashi" : "Aoki") << endl;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

using namespace std;

pair<int, int> a[50+2];
int n;

class UF {
  int *id, cnt, *sz;
  public:
// Create an empty union find data structure with N isolated sets.
UF(int N) {
    cnt = N; id = new int[N]; sz = new int[N];
    for (int i = 0; i<N; i++)  id[i] = i, sz[i] = 1; }
~UF() { delete[] id; delete[] sz; }

// Return the id of component corresponding to object p.
int find(int p) {
    int root = p;
    while (root != id[root])    root = id[root];
    while (p != root) { int newp = id[p]; id[p] = root; p = newp; }
    return root;
}
// Replace sets containing x and y with their union.
void merge(int x, int y) {
    int i = find(x); int j = find(y); if (i == j) return;
    // make smaller root point to larger one
    if (sz[i] < sz[j]) { id[i] = j, sz[j] += sz[i]; }
    else { id[j] = i, sz[i] += sz[j]; }
    cnt--;
}
// Are objects x and y in the same set?
bool connected(int x, int y) { return find(x) == find(y); }
// Return the number of disjoint sets.
int count() { return cnt; }
};

int solve(int p, int q) {
    auto uf = UF(n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            if (a[j].first - a[i].first == p && a[j].second - a[i].second == q)
                uf.merge(i, j);
        }
    return uf.count();
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i].first >> a[i].second;
    int sol = n;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            int p = a[j].first - a[i].first;
            int q = a[j].second - a[i].second;
            if (!p && !q)
                continue;
            sol = min(sol, solve(p, q));
        }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b>16)
    {
        cout<<":(";
    }
    else if(a>8||b>8)
    {
        cout<<":(";
    }
    else
    {
        cout<<"Yay!";
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: i64,
        a: i64, b: i64,
    }
    let n = n % 12;
    let mut a = a;
    let mut b = b;
    for i in 0..n {
        if i % 2 == 0 {
            a -= b;
        } else {
            b += a
        }
    }
    puts!("{} {}\n", a, b);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 1176
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
pair <long long, long long> LR[100000];
long long R_right_min[100000];
long long R_left_min[100000];
int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> LR[i].first >> LR[i].second;
  }
  sort(LR, LR + N);
  R_right_min[N - 1] = LR[N - 1].second;
  for(int i = N - 2; i >= 0; i--){
    R_right_min[i] = min(LR[i].second, R_right_min[i + 1]);
  }
  R_left_min[0] = LR[0].second;
  for(int i = 1; i < N; i++){
    R_left_min[i] = min(LR[i].second, R_left_min[i - 1]);
  }

  long long ans = 0;
  for(int i = 0; i < N - 1; i++){
    long long L1 = LR[i].first;
    long long R1 = LR[i].second;
    long long L2 = LR[N - 1].first;
    long long R2 = R_right_min[i + 1];
    if(i == 0){
      ans = max(ans, max((long long) 0, R1 - L1 + 1) + max((long long) 0, R2 - L2 + 1));
    } else {
      ans = max(ans, max((long long) 0, min(R1, R_left_min[i - 1]) - L1 + 1) 
            + max((long long) 0, R2 - L2 + 1));
      ans = max(ans, max((long long) 0, R1 - L1 + 1) 
            + max((long long) 0, min(R2, R_left_min[i - 1]) - L2 + 1));
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){

  string a,t;
  cin>>a >>t;
  int s1,s2,w=0;
  
  s1=a.length();
  s2=t.length();
  
  for(int i=0;i<s1;i++)
  {
  	 if( (a.at(i) - t.at(i)) )
        {
        	w=1;
        }
  }
        
     if(w ==1)
        {
        	cout<<"No"<<endl;
        }
        else
        {
        	cout<<"Yes"<<endl;
        }
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	int ans = 1;
  	for(int i = 2; i<n; i++){
		int t = i*i;
    	while(t<=n){
			if(ans<t)ans = t;
			t*=i;
  		}
    }
  	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  N = int(input())
  A = int(input())
  if N % 500 <= A:
    print('Yes')
  else:
    print('No') 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include<stdio.h>
#define INF (1 << 30)
#define max(x, y) ((x) > (y) ? (x) : (y))
int main(){
  int sums[5005], n, i, j, a, ans;
  while(1){
    ans = -INF;
    scanf("%d", &n);
    if(n == 0)return 0;
    sums[0] = 0;
    for(i = 1;i <= n;i++){
      scanf("%d" , &a);
      sums[i] = sums[i - 1] + a;
    }
    for(i = 1;i <= n;i++){
      for(j = i;j <= n;j++){
	ans = max(ans, sums[j] - sums[i - 1]);
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 616
#include<iostream>
using namespace std;
int main(){
  int array[1005]={0};
  long long int n;
  cin>>n;
  array[1]=1;
  


  for(int j=n;j>1;j--){
    int i=2;
    long long temp=j;
    while(temp>1){
      if(temp%i==0){
	array[i]++;
	temp/=i;
      }else{
	i++;
      }
    }
  }
  
  long long int cnt=1;
  for(int i=2;i<=n;i++){
    if(array[i]!=0){
      cnt=(cnt*(array[i]+1))%1000000007;
    }
  }
  
  cout<<cnt<<endl;
  return(0);
}
 

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


int Ki (vector<vector<int>> &S, vector<bool> &T, vector<int> &ans, stack<int> &U){
    if (U.size() == 0) {
        for (int i = 0; i < ans.size(); i++) {
            cout << ans.at(i) << " ";
        }
        return 0;
    }
    if (!T.at(U.top())) {
        int c;
        c = U.top();
        U.pop();
        T.at(c) = true;
        for (int i = 0; i < S.at(c).size(); i++) {
            if (!T.at(S.at(c).at(i))){
            U.push(S.at(c).at(i));
            ans.at(S.at(c).at(i)) += ans.at(c);
            }
        }
        Ki (S, T, ans, U);
    }
    return 0;
}

int main() {
    stack<int> U;
    U.push(0);
    int N, Q;
    cin >> N >> Q;
    vector<int> ans(N, 0);
    vector<bool> T(N, false);
    vector<vector<int>> S(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        S.at(a).push_back(b);
        S.at(b).push_back(a);
    }
    for (int i = 0; i < Q; i++) {
        int d, e;
        cin >> d >> e;
        ans.at(d - 1) += e;
    }
    Ki (S, T, ans, U);
}


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

int main() {
	int am,pm;
	int max,max_s;
	
	while(cin>>am>>pm,am||pm){
		max = am + pm;
		max_s = 0;
		for(int i=1;i<5;++i){
			cin>>am>>pm;
			if(max < am + pm){
				max = am + pm;
				max_s = i;
			}
		}
		cout<<(char)('A'+max_s)<<" "<<max<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,s,a[1000000],z=0;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>=s){
      z++;
    }
  }
  cout<<z<<"\n";
}


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

int main(){
  int N; cin>>N;
  vector<int> L(2*N);
  rep(i,2*N) cin>>L[i];
  sort(L.begin(),L.end());
  int ans = 0;
  rep(i,N) ans += L[2*i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

from collections import deque

N,M,Q = map(int,input().split())

abcd = []
for i in range(Q):
    abcd.append([int(x) for x in input().split()])

d = deque([1]*N)

total_max = 0

while True:
    A = list(d)

    total = 0
    
    for i in range(Q):
        if A[abcd[i][1]-1]-A[abcd[i][0]-1] == abcd[i][2]:
            total += abcd[i][3]

    total_max = max(total_max,total)

    cnt = 1

    if A == [M]*N:
        break

    while True:
        ai = d.pop()
        if ai != M:
            for j in range(cnt):
                d.append(ai+1)
            break
        cnt += 1


print(total_max)


Measured memory_bytes: 9476
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b = (_ for _ in input().split())
    num = math.sqrt(int(a+b))
    if num.is_integer():        
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, m;
long l[100005], r[100005], c[100005];
std::vector<long> ind;

struct SegmentTree {
private:
    long n;
    std::vector<long> node;

public:
    SegmentTree(std::vector<long> v) {
        long sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, LINF);
        for(long i=0; i<sz; i++) node[i+n-1] = v[i];
        for(long i=n-2; i>=0; i--) node[i] = std::min(node[2*i+1], node[2*i+2]);
    }

    void update(long x, long val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = std::min(node[2*x+1], node[2*x+2]);
        }
    }

    long getmin(long a, long b, long k=0, long l=0, long r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return LINF;
        if(a <= l && r <= b) return node[k];

        long vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        long vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return std::min(vl, vr);
    }
};

int main(){
    scanf("%ld%ld", &n, &m);
    for(int i = 0; i < m; i++){
        scanf("%ld%ld%ld", l+i, r+i, c+i);
        l[i]--;
        r[i]--;
        ind.push_back(i);
    }
    std::sort(ind.begin(), ind.end(), [&](long a, long b){
        return l[a] < l[b];
    });
    /*
    for(int i = 0; i < m; i++){
        long in = ind[i];
        printf("  %ld %ld %ld\n", l[in], r[in], c[in]);
    }
    //*/
    std::vector<long> v(n);
    for(int i = 0; i < n; i++){
        v[i] = LINF;
    }
    SegmentTree seg(v);
    seg.update(0, 0);
    for(long x = 0; x < m; x++){
        long i = ind[x];
        seg.update(r[i], std::min(seg.getmin(r[i], n), seg.getmin(l[i], n) + c[i]));
    }
    /*
    for(long i = 0; i < n; i++){
        printf(" %2ld", i);
    }
    printf("\n");
    for(long i = 0; i < n; i++){
        printf(" %2ld", seg.getmin(i, n));
    }
    printf("\n");
    //*/
    long ans = seg.getmin(n-1, n);
    if(ans >= LINF){
        printf("-1\n");
    }else{
        printf("%ld\n",ans);
    }
}


Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
int main(){
 
 int H,R;cin>>H>>R;
 int ans;

  if(H+R == 0){
      ans =0;
  }
  if(H+R >0){
      ans = 1;
  }
  if(H+R <0){
      ans = -1;
  }
  std::cout << ans << std::endl;
 
}


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

void printArray(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N) {
    printArray(A, N);
    for (int i = 1; i <= N - 1; i++) {
        int v = A[i];
        int j;
        for (j = i - 1; j >= 0 && A[j] > v; j--) {
            A[j + 1] = A[j];
        }
        A[j + 1] = v;
        printArray(A, N);
    }

}

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    insertionSort(A, N);
}



Measured memory_bytes: 3124
n=int(input())
a=[int(i) for i in input().split()]
x,y,z=0,0,0
for i in range(n):
    if a[i]%4==0:
        x+=1
    elif a[i]%2==0:
        y+=1
    else:
        z+=1
if y>0:
    if z<=x:
        print("Yes")
    else:
        print("No")
else:
    if z<=x+1:
        print("Yes")
    else:
        print("No")


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

const int mod = 1000000007;

struct mint {
    ll x;

    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};

vector<int> res;
vector<int> sieve(int n) {
  res.resize(n);
  iota(res.begin(),res.end(), 0);
  for (int i = 2; i * i < n; i++) {
    if (res[i] < i) continue;;
    for (int j = i * i; j < n; j += i) {
      if (res[i] == j) res[j] = i;
    }
  }
  return res;
}


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

  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }

  sieve(1010);

  mint ans = 0;
  mint LCM = 1;

  for (int i = 2; i < 1010;) {
    if(i != res[i]) continue;
    bool flag = false;
    int one = 0;
    for (int j = 0; j < n; j++) {
      if(a[j] == 1) one++;
      if(a[j] % i == 0) {
        flag = true;
        a[j] /= i;
      }
    }
    if(one == n) break;
    if(flag) LCM *= i;
    else i++;
  }

  map<int,int> mp;
  for (int i = 0; i < n; i++) {
    if(a[i] != 1) mp[a[i]] = 1;
  }

  for (auto it : mp) {
    LCM *= it.first;
  }

  for (int i = 0; i < n; i++) {
    mint val = LCM / b[i];
    ans += val;
  }
  cout << ans.x << '\n';
}

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

using namespace std;

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

    int n;
    cin >> n;

    vector<long long> h(n);
    for(int i = 0; i < n; ++i)
        cin >> h[i];

    long long v1 = abs(h[n - 1] - h[n - 2]), v2 = 0, temp;
    for(int i = n - 3; i >= 0; i--){
        temp = min(v1 + abs(h[i] - h[i + 1]), v2 + abs(h[i] - h[i + 2]));
        v2 = v1;
        v1 = temp;
    }

    cout << v1 << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int r[200001]={0},d,a,n,A[200000],p;
set<int> C[200001];
int search(int x,int y){
  r[x]=1;
  if(y){
      if(p-1==d){
          a=x;
          return 0;
      }
  }
  for(auto i:C[x]){
      if(x+2>i) d++;
      if(x==n-1&&i==0) d++;
      if(!r[i])search(i,y);
  }
}
int ans(int x){
    if(x==n-1) {cout<<A[x];return 0;}
    if(*C[x].begin()==0) return 0;
    if(*C[x].begin()>x+1) ans(*C[x].begin());
    else cout<<A[x]<<" ",ans(x+1);
}
int main(){
    ll k;
    cin>>n>>k;
    rep(i,n) cin>>A[i];
    set<int> B[200001];
    rep(i,n) B[A[i]].insert(i);
    rep(i,200000){
        int D[200001],k=0;
        for(auto j:B[i+1]) D[k]=j,k++;
        rep(j,k) C[D[j]].insert((D[(j+1)%k]+1)%n);
    }
    d=0;
    search(0,0);
    p=k%d;
    d=0;
    rep(i,200001) r[i]=0;
    search(0,1);
    if(p) ans(a);
}

Measured memory_bytes: 50304
#include <iostream>

using namespace std;

int main() {
  int A, B;
  cin >> A;
  cin >> B;

  for(int i = B * 10, l = (B + 1) * 10; i < l; i++) {
    if((i * 8 / 100) == A) {
      cout << i;
      return 0;
    }
  }

  cout << -1;
  return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)

int main(){
    int a, b, c, ans = 0;
    scanf("%d %d %d", &a, &b, &c);
    rep(i, a, b + 1){
        if(!(c % i)) ans++;
    }

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

    return 0;
}



Measured memory_bytes: 2044
X, N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
else:
  print(X)
  quit()
  
b = True
i = 0
while b:
  if X - i not in p:
    print(X - i)
    quit()
  elif X + i not in p:
    print(X + i)
    quit()
  i += 1


Measured memory_bytes: 9184
def main():
    N = int(input())
    s = input()
    t = input()

    ans = 2 * N
    for i in range(N):
        s_ = s[i:]
        t_ = t[:len(t) - i]

        if s_ == t_:
            tmp = s + t[len(t) - i:]
            ans = min(ans, len(tmp))

    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    int A,B,C,D;
    int shicha;
    cin>>A>>B>>C>>D;
    int m=(A>C)?A:C;
    int n=(B>D)?D:B;
    if(n-m<=0)
        shicha = 0;
    else
        shicha = n-m;
    cout<<shicha<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
long long n,p,cnt[10101],ans;
int main()
{
	cin>>n>>p>>s;
	if(p==2 || p==5)
	{
		for(int i=0;i<n;i++)
		{
			if((s[i]-'0')%p==0)
			{
				ans+=i+1;
			}
		}
		cout<<ans<<endl;
	}
	else
	{
		int nw=0,pw=1;
		for(int i=n-1;i>=0;i--)
		{
			cnt[nw]++;
			nw+=(s[i]-'0')*pw;
			nw%=p;
			pw=pw*10;
			pw%=p; 
			ans+=cnt[nw];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 644
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        
        if(sc.nextInt()+sc.nextInt()>=sc.nextInt()){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int dp[1005][1<<12];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    vector<int> a(m), b(m), k(m, 0);
    inc(i, 0, m){
        cin >> a[i] >> b[i];
        inc(j, 0, b[i]){
            int c;cin >> c;c--;
            k[i] |= (1 << c);
        }
    }
    int inf = 1000000000;
    inc(i, 0, m+1) inc(j, 0, 1<<n) dp[i][j] = inf;
    dp[0][0] = 0;
    inc(i, 0, m){
        inc(j, 0, 1 << 12){
            if(dp[i][j] != inf){
                dp[i+1][j|k[i]] = min(dp[i+1][j|k[i]], dp[i][j] + a[i]);
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            }
        }
    }
    //inc(i, 0, m+1){
        //inc(j, 0, 1<<n){
            //cout << dp[i][j] << " ";
        //}
        //cout << endl;
    //}
    int ans = dp[m][(1<<n)-1];
    if(ans == inf){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 16256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	rep(i,s.size()){
		if(s[i]=='+'){
			ans++;
		}else{
			ans--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	while(1){
		b=1150;
		scanf("%d",&a);
		if(a==-1){
			break;
		}
		if(a>30){
			b=b+160*(a-30);
			a=30;
		}
		if(a>20){
			b=b+140*(a-20);
			a=20;
		}
		if(a>10){
			b=b+125*(a-10);
			a=10;
		}
		b=4280-b;
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 600
def evenstring(s) : 
  while len(s) > 0 : 
    s = s[ : -2]
    t1 = s[ : int(len(s) / 2)]
    t2 = s[int(len(s) / 2) : ]
    if t1 == t2 : 
      return len(t1) + len(t2)
  

s = input()

print(evenstring(s))


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

int main(){
    int i,ex1,ex2,ex3,ex4,a,b;
    int dice[7],dice2[7];
    int command;

    for(i=1; i<=6; i++){
        scanf("%d",&dice[i]);
    }
    for(i=1; i<=6; i++){
        scanf("%d",&dice2[i]);
    }
    for(i=0; i<100; i++){
            command = rand() % 4;
            if(command == 0){
                ex1 = dice[1];
                ex2 = dice[2];
                ex3 = dice[5];
                ex4 = dice[6];
                dice[1] = ex3;
                dice[2] = ex1;
                dice[5] = ex4;
                dice[6] = ex2;
            }else if(command == 1){
                ex1 = dice[1];
                ex2 = dice[2];
                ex3 = dice[5];
                ex4 = dice[6];
                dice[1] = ex2;
                dice[2] = ex4;
                dice[5] = ex1;
                dice[6] = ex3;
            }else if(command == 2){
                ex1 = dice[1];
                ex2 = dice[3];
                ex3 = dice[4];
                ex4 = dice[6];
                dice[1] = ex3;
                dice[3] = ex1;
                dice[4] = ex4;
                dice[6] = ex2;
            }else if(command == 3){
                ex1 = dice[1];
                ex2 = dice[3];
                ex3 = dice[4];
                ex4 = dice[6];
                dice[1] = ex2;
                dice[3] = ex4;
                dice[4] = ex1;
                dice[6] = ex3;
            }
            for(a = 1;a <= 6;a++)
                if(dice[a] != dice2[a])
                    break;
            if(a == 7){
                printf("Yes\n");return 0;
            }
    }
    printf("No\n");
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
int q[100010];
bool F(int l,int r,int q[],int x)
{
    int m=(l+r)/2;
    if(q[m]==x)
        return true;
    if(l+1==r)
        return false;
    if(x<q[m])
        F(l,m,q,x);
    else
        F(m,r,q,x);

}
int main()
{
    int n,x,j=0,y;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>q[i];
    cin>>y;
    for(int i=1;i<=y;i++)
    {
        cin>>x;
        if(((F(1,n,q,x))||(q[1]==x)||(q[n]==x)))
            j++;
    }
    cout<<j<<"\n";
    return 0;
}



Measured memory_bytes: 3468
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	int N;
	vector<pair<long long, long long>> point;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		long long x, y;
		cin >> x >> y;
		point.push_back(make_pair(x, y));
	}
	map<pair<long long, long long>, long long> mp;
	for (int i = 0; i < N; ++i) {
		long long x, y;
		x = point[i].first;
		y = point[i].second;
		for (int j = 0; j < N; ++j) {
			long long prex, prey;

			prex = point[j].first;
			prey = point[j].second;

			if (i == j)continue;
			long long p, q;
			p = x - prex;
			q = y - prey;
			mp[make_pair(p, q)] += 1;
			mp[make_pair(-p, -q)] += 1;
		}
	}

	long long ansx = 0, ansy = 0;
	long long maxValue = 0;
	for (auto i = mp.begin(); i != mp.end(); ++i) {
		long long keyx = (i->first.first);
		long long keyy = (i->first.second);

		//cout << keyx << "\t" << keyy << "\t" << mp[make_pair(keyx, keyy)]  << endl;

		if (maxValue < mp[make_pair(keyx, keyy)]) {
			ansx = keyx;
			ansy = keyy;
			maxValue = mp[make_pair(keyx, keyy)];
		}
	}
	//cout << ansx << "\t" << ansy << "\t" << maxValue << endl;
	cout << N - maxValue / 2<< endl;

	return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

ll dp[18][2];

int main() {
    string N; cin >> N;
    memset(dp, 0, sizeof(dp));
    
    ll n = N.length();
    REP(i, n) {
        ll x = N[i] - '0';
        REP(j, 2) REP(d, j ? 10 : x + 1) {
            if (i != 0) {
                dp[i+1][j || d < x] = max(dp[i+1][j || d < x], dp[i][j] + d);
            } else if (j != 1) {
                dp[i+1][d < x] = max(dp[i+1][d < x], d);
            }
        }
    }
    cout << max(dp[n][0], dp[n][1]) << endl;
    
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

//const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


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

	int a, b, c, d; cin >> a >> b >> c >> d;
	if (c != -1 && d != -1) {
		if (c == d) {
			print("Draw");
		}
		else if (c > d) {
			print("Alice");
		}
		else print("Bob");
	}
	else {
		if (a < b) {
			print("Alice");
		}
		else if (b < a) {
			print("Bob");
		}
		else print("Draw");
	}
}



Measured memory_bytes: 3212
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

using E = tuple<int, int>;
vector<vector<E>> edge;
vector<int> color;
vector<bool> isVisited;

void dfs(int node, int c)
{
    isVisited[node] = true;

    int curr = 1;
    for (E e : edge[node]) {
        int v, i;
        tie(v, i) = e;
        if (!isVisited[v]) {
            if (curr == c) {
                curr++;
            }
            color[i] = curr;
            dfs(v, curr);
            curr++;
        }
    }
}

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

    edge.resize(n);
    color.resize(n - 1);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        edge[a].push_back(E(b, i));
        edge[b].push_back(E(a, i));
    }

    isVisited.resize(n, false);
    dfs(0, 0);

    int k = 0;
    rep(i, n - 1)
    {
        k = max(k, color[i]);
    }

    cout << k << endl;
    rep(i, n - 1)
    {
        cout << color[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6912
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A, B, C;

  cin >> A >> B >> C;

  if (A + B + C >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;

  return 0;
}


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

using namespace std;


int main()
{
    string S, T, U;
    int A, B;


    //double K, S;
    //double x, y, z;


    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    
    if (S == U) {
        A = A - 1;
    }

    if (T == U) {
        B = B - 1;
    }
    
    
    cout << A << " " << B << endl;


 

     return 0;

}



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

int H = 0;

int parent(int i) { return (i - 1) / 2; }
int left(int i) { return (i + 1) * 2 - 1; }
int right(int i) { return (i + 1) * 2; }

void maxHeapify(int N, int A[], int i) {
    if (i >= N) {
        return;
    }
    int l = left(i);
    int r = right(i);
    int largest = i;
    if (l < N && A[l] > A[i]) {
        largest = l;
    }
    if (r < N && A[r] > A[largest]) {
        largest = r;
    }
    
    if (largest != i) {
        int temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxHeapify(N, A, largest);
    }
}

int extractMax(int A[]) {
    int max = A[0];
    A[0] = A[H - 1];
    maxHeapify(H - 1, A, 0);

    H--;
    return max;
}

void insert(int A[], int key) {
    A[H] = key;
    int parentK = parent(H);
    int childK = H;
    
    while (parentK >= 0 && A[parentK] < A[childK]) {
        swap(A[parentK], A[childK]);
        childK = parentK;
        parentK = parent(parentK);
    }
    
    H++;
    return;
}

int main() {
    int A[2000000];
    char cmd[20];
    int key;
    
    while(true) {
        scanf("%s", cmd);
        
        if (cmd[0] == 'i') {
            scanf("%d", &key);
            insert(A, key);
            continue;
        }

        if (cmd[0] == 'e' && cmd[1] == 'x') {
            cout << extractMax(A) << endl;
            continue;
        }

        if (cmd[0] == 'e' && cmd[1] == 'n') {
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 7044
import bisect
N = int(input())

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

A.sort()
B.sort()
C.sort()

ans = 0
for i in range(len(B)):
    ans += bisect.bisect_left(A, B[i]) * (N - bisect.bisect_right(C, B[i]))
    
print(ans)

Measured memory_bytes: 23360
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

def main():
    N = int(input())
    XY = [tuple(map(int,input().split())) for _ in range(N)]

    ans = 0
    for i in range(N):
        xi,yi = XY[i]
        for j in range(i+1,N):
            xj,yj = XY[j]
            ans += ((xi-xj)**2 + (yi-yj)**2)**.5
    
    print(ans*2/N)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9460
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

#include<iostream>
using namespace std;
int t[10001];
int n,m,a,b,ans=0;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    t[n]=a;
    for(b=0;t[b]!=a;b++);
    if(b!=n)ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3128
import math

if __name__ == "__main__":
    N = int(input())
    n = len(str(N))
    for i in xrange(int(math.sqrt(N)), 1, -1):
        if N % i == 0:
            ii = N/i
            n = max(len(str(i)), len(str(ii)))
            break
    print(n)

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

using namespace std;

int safe_el(const vector<vector<int>> &rows, const int row, const int col) {
    return (row >= 0 && col >= 0) ? rows[row][col] : 0;
}

string solve(const string &s1, const string &s2) {
    const int sz1 = s1.size();
    const int sz2 = s2.size();
    
    // max-length [up to this index in s1][up to this index in s2]
    vector<vector<int>> dp(sz1, vector<int>(sz2, 0));

    // which cell {row, col} led to the cell [i][j] in dp 
    vector<vector<pair<int, int>>> origins(sz1, vector<pair<int, int>>(sz2, {-1, -1}));
    
    for (int i = 0; i != sz1; ++i) {
        for (int j = 0; j != sz2; ++j) {
            if (s1[i] == s2[j]) {
                dp[i][j] = safe_el(dp, i - 1, j - 1) + 1;
                origins[i][j] = {i - 1, j - 1};
            } else {
                const int a = safe_el(dp, i, j - 1);
                const int b = safe_el(dp, i - 1, j);

                dp[i][j] = max(a, b);
                origins[i][j] = a >= b ? pair<int, int>{i, j - 1} : pair<int, int>{i - 1, j};
            }
        }
    }
    
    vector<pair<int, int>> path{{sz1 - 1, sz2 - 1}};
    auto coord = origins.back().back();
    
    for (;;) {
        path.push_back(coord);
        if (coord.first < 0 || coord.second < 0) break;
        coord = origins[coord.first][coord.second];
    }
    
    reverse(path.begin(), path.end());
    
    string ans;
    
    for (auto i = 1U; i < path.size(); ++i) {
        const auto p = path[i - 1];
        const auto q = path[i];
        
        if (q.first == p.first + 1 && q.second == p.second + 1) {
            ans += s1[q.first];
        }
    }

    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s1, s2;
    cin >> s1 >> s2;
    cout << solve(s1, s2) << endl;
    
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n;
int a[112345];
ll ans[112345];

int main() {
	cin >> n;
	REP(i, n) scanf("%d", a + i);
	
	priority_queue<pii> pq;
	
	REP(i, n) pq.push(pii(a[i], -i));
	pq.push(pii(0, 1));
	
	pii ma(INF, INF);
	int cnt = 0;
	
	while (!pq.empty()) {
		pii now = pq.top(); pq.pop();
		now.second = -now.second;
		
		if (now == pii(0, -1)) break;
		
		ma.first = now.first;
		chmin(ma.second, now.second);
		cnt++;
		
		while (pq.top().first == ma.first) {
			chmin(ma.second, -pq.top().second);
			cnt++;
			pq.pop();
		}
		
		ans[ma.second] += (ll)(ma.first - pq.top().first) * cnt;
	}
	
	REP(i, n) printf("%lld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
string a,b;
long long n,ans,k;
long long ds(int uke)
{
    int now=0;
    for(int s=uke;s<n;s++)
    {
        if(a[s]!=b[now])break;
        now++;
    }
    return now;
}
int main()
{
    cin>>n>>a>>b;
    ans=n*2;
    for(int s=0;s<n;s++)
    {
        k=ds(s);
        ans=min(ans,n*2-k);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
    int n,k; cin >> n >> k;
    ll ans = 1;
    for(int i=0;i<n;i++){
        if(ans < k){
            ans *= 2;
        }else{
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, q = map(int,input().split())
C = [list(map(int,input().split())) for i in range(q)]

# ACLに伴い0-indexedに直した
class Bit:  # Fenwick Tree と同じ
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, l, r):  # [l,r)の合計を求める
        # 内部的には[l+1,r+1)の合計つまり(rまでの合計-lまでの合計)
        s = 0
        while r > 0:
            s += self.tree[r]
            r -= r & -r
        while l > 0:
            s -= self.tree[l]
            l -= l & -l
        return s
  
    def add(self, i, x):  # i番目にxを足す
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

# Bitの内部状態をindex順に出力
def print_bit(B):
    n = B.size
    ANS = []
    for i in range(n):
        ANS.append(B.sum(i, i+1))
    print(*ANS)

A = Bit(n)
B = Bit(n)
A.add(0, n-2)
B.add(0, n-2)
AC = [0] * n
BC = [0] * n
ans = 0
minac = n-1
minbc = n-1

# print("A",[A.sum(0,i+1) for i in range(n)])
# print("B",[B.sum(0,i+1) for i in range(n)])
for i in range(q):
    c1 = C[i][1]-1
    if C[i][0] == 1:
        BC[c1] = 1
        if minbc > c1:
            # print(1,c1)
            minbc=c1
            # print("A",[A.sum(0,i+1) for i in range(n)])
            oku = B.sum(0,c1+1)
            # print("oku",oku)
            a0 = A.sum(0,1)
            aoku = A.sum(0, oku+1)
            A.add(0, -a0+c1-1)
            A.add(oku+1, aoku-A.sum(0,1))
            # print("A",[A.sum(0,i+1) for i in range(n)])
    elif C[i][0] == 2:
        AC[c1] = 1
        if minac > c1:
            # print(2,c1)
            minac = c1
            # print("B",[B.sum(0,i+1) for i in range(n)])
            oku = A.sum(0,c1+1)
            a0 = B.sum(0,1)
            aoku = B.sum(0, oku+1)
            B.add(0, -a0+c1-1)
            B.add(oku+1, aoku-B.sum(0,1))

            # print("B",[B.sum(0,i+1) for i in range(n)])


# print("FINAL")
# print("A",[A.sum(0,i+1) for i in range(n)])
# print("B",[B.sum(0,i+1) for i in range(n)])
# print("AC",AC)
# print("BC",BC)
for i in range(1, n-1):
    if AC[i] == 0:
        # print(i,A.sum(i,i+1))
        ans += A.sum(0,i+1)
for i in range(1, n-1):
    if BC[i] == 0:
        ans += B.sum(0,i+1)

for i in range(1, minac):
    ans -= A.sum(0,i+1)

print(ans)

Measured memory_bytes: 106200
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s;
  cin>>t;
  for(int i=0;i<t.length();i++)
  {
    cout<<t[i];
  }
  cout<<"";
   for(int i=0;i<s.length();i++)
  {
    cout<<s[i];
  }
  
  return 0;
}


Measured memory_bytes: 256