akhauriyash/Code-Regression huggingface dataset:
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    if(n%2==1){
        cout<<n/2+1<<endl;
    }else{
        cout<<n/2<<endl;
    }
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    int ans = 0;
    rep(i, n)
    {
        cin >> h[i];
        if (k <= h[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <utility>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;

ll a[100000];
ll rui[100001];
bool f[100001];
map<ll,ll> mm;

int main()
{
	int n;
	ll m;
	ll ans=0;
	cin>>n>>m;
	fill(rui,rui+100001,0);
	fill(f,f+100001,false);
	for(int i=0;i<n;i++)
		cin>>a[i];
	rui[0]=0;
	for(int i=1;i<n+1;i++)
		rui[i]=rui[i-1]+a[i-1];
	
	if(rui[n]==m)
	{
		cout<<1<<endl;
		return 0;
	}

	if(rui[n]<m)
	{
		cout<<0<<endl;
		return 0;
	}
	
	for(int i=0;i<n+1;i++)
		rui[i]%=m;

	/*
	for(int i=0;i<n+1;i++)
	{
		cerr<<rui[i]<<endl;
	}*/
	/*
	for(int i=0;i<n+1;i++)
	{
		if(f[i])
			continue;
		
		ll r=rui[i];
		ll cnt=1;
		for(int j=i+1;j<n+1;j++)
		{
			if(r==rui[j])
			{
				cnt++;
				f[j]=true;
			}
		}
		f[i]=true;
		if(cnt>1)
		{
			ans+=cnt*(cnt-1)/2;
		}
	}*/

	for(int i=0;i<n+1;i++)
	{
		mm[rui[i]]++;
	}
	
	for(auto itr=mm.begin();itr != mm.end();++itr)
	{
		ll v=itr->second;
		if(v>=2)
		{
			ans+=v*(v-1)/2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << (char)toupper(a.at(0)) << (char)toupper(b.at(0)) << (char)toupper(c.at(0)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int parent(int);
int left(int);
int right(int);

int main(){
  int h, i, a[MAX+1];

  scanf("%d", &h);
  for(i = 1;i <= h;i++){
    scanf("%d", &a[i]);
  }
  for(i = 1;i <= h;i++){
    printf("node %d: key = %d, ", i, a[i]);
    if(parent(i) >= 1){
      printf("parent key = %d, ", a[parent(i)]);
    }
    if(left(i) <= h){
      printf("left key = %d, ", a[left(i)]);
    }
    if(right(i) <= h){
      printf("right key = %d, ", a[right(i)]);
    }
    printf("\n");
  }
  return 0;
}

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}

Measured memory_bytes: 604
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    bool flag = false;
    /**
     * ケーキとドーナツを(i, j)個ずつ買う場合を全探索する
     * Nと一致すればok 
     */
    for(int i = 0; i <= N/4; i++) {
        for(int j = 0; j <= N/7; j++) {
            if(N == i*4 + j*7) {
                flag = true;
                break;
            }
        }
        if(flag) break;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

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

	int x = stoi(a + b);
	int y = sqrt(x);
	y = y * y;
	cout << (x == y ? "Yes" : "No") << endl;
	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj1173/input.txt"));
			//System.setOut(new PrintStream(new FileOutputStream("src/aoj1172/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String line = sc.nextLine();
			if (line.equals(".")) break;

			if (solve(line))
				System.out.println("yes");
			else
				System.out.println("no");

		}
	}

	boolean solve(String line) {
		char[] str = new char[line.length()];
		int len = 0;
		for (int i = 0; i < line.length(); i++) {
			char cur = line.charAt(i);
			if (cur == '[' || cur == ']' || cur == '(' || cur == ')') {
				if (len == 0) {
					str[len++] = cur;
				} else {
					char last = str[len - 1];
					if ((last == '[' && cur == ']') || (last == '(' && cur == ')')) {
						len--;
					} else {
						str[len++] = cur;
					}
				}
			}
		}
		return len == 0;
	}

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
}

Measured memory_bytes: 13000
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;

    namespace ConsoleApp2
    {
        class Program
        {


            static void Main(string[] args)
            {
            //var S = Console.ReadLine().ToCharArray();
            //var T = Console.ReadLine().ToCharArray();
            var S = Console.ReadLine();
            var ans = new List<char>();
            for (int i = 0; i < S.Length; i++)
            {
                if(S[i] == '1')
                {
                    ans.Add('1');
                }else if (S[i] == '0')
                {
                    ans.Add('0');
                }else if (ans.Count() > 0)
                {
                    ans.DropRight(1);
                }
            }
            
            Console.WriteLine(String.Join("",ans.ToArray()));
           

            
            }
        }

    public static class ListExtensions
    {
        public static void DropRight<T>(this List<T> self, int count)
        {
            self.RemoveRange(self.Count - count, count);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

class Point
{
public:
	explicit Point(int dim)
	{
		m_Values.resize(dim);
	}
	~Point(){}

	void InputValues()
	{
		for (auto& value : m_Values)
		{
			cin >> value;
		}
	}

	float operator-(const Point point) const
	{
		float res = 0.f;
		for (int i = 0; i < static_cast<int>(m_Values.size()); ++i)
		{
			res += pow(point.m_Values[i] - m_Values[i], 2);
		}
		res = pow(res, 0.5f);
		return res;
	}

private:
	vector<int> m_Values;
};

int main()
{
	int N, D;
	cin >> N >> D;

	vector<Point> points;
	int count = 0;
	for (int i = 0; i < N; ++i)
	{
		Point p(D);
		p.InputValues();

		for (const auto& point : points)
		{
			if (ceil(point - p) == float(point - p))
			{
				++count;
			}
		}
		points.push_back(p);
	}

	cout << count << endl;
}

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

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //-----------------------------------------
    int L;
    cin >> L;
    double a=L/3.;
    printf("%.12lf\n", a*a*a);

    return 0;
}


Measured memory_bytes: 256
import statistics
n=int(input())
x=[int(_) for _ in input().split()]
mid=int(statistics.mean(x))
mmid=mid-1
pmid=mid+1
cnt=0
cntm=0
cntp=0
for i in range(len(x)):
  cnt+= (x[i]-mid)**2
  cntm+=(x[i]-mmid)**2
  cntp+=(x[i]-pmid)**2
print(min(cnt,cntm,cntp))
  


Measured memory_bytes: 5144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll n, z, w;
ll a[100100];

int main() {
	cin >> n >> z >> w;
	rep(i, n)cin >> a[i];
	if (n >= 2)cout << max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2])) << endl;
	else cout << abs(a[0] - w) << endl;
}

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

int main() {
	char s[4];
	scanf("%s", s);
	sort(s, s + 4);
	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
	else cout << "No\n";
}

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

int main (){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int cnt=0;
  
  while(true){
    bool odd=false;
    for(int i=0;i<n;i++){
      if(a[i]%2!=0){
        odd=true;
      }
    }
    if(odd){
      break;
    }
    for(int i=0;i<n;i++){
      a[i]/=2;
    }
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string a;
    int l;
    while (cin>>a>>l) {
        if (a=="0"&&l==0) {
            break;
        } else {
            std::deque<int> seq;
            seq.emplace_back(stoi(a));
            int count=1;
            while (1) {
                std::deque<int> tmp;
                if (a.size()<l) {
                    int tmpsize=l-a.size();
                    for (int k=0;k<tmpsize;k++) {
                        a="0"+a;
                    }
                }
                for (int i=0;i<a.size();i++) {
                    int hoge=a.at(i)-48;
                    tmp.emplace_back(hoge);
                }
                sort(tmp.begin(),tmp.end(),greater<int>());
                string max;
                for (int j=0;j<tmp.size();j++) {
                    max=max+to_string(tmp[j]);
                }
                
                //cout<<max<<endl;
                sort(tmp.begin(),tmp.end());
                string min;
                for (int m=0;m<tmp.size();m++) {
                    min=min+to_string(tmp[m]);
                }
                //cout<<min<<endl;
                int piyo=stoi(max)-stoi(min);
                if ( find(seq.begin(),seq.end(),piyo)!=seq.end() ) {
                    int fuga=distance( seq.begin(),find(seq.begin(),seq.end(),piyo) );
                    cout<<fuga<<" "<<piyo<<" "<<count-fuga<<endl;
                    break;
                } else {
                    seq.emplace_back(piyo);
                    count++;
                    a=to_string(piyo);
                    //cout<<piyo<<endl<<endl;
                }
                
            }
        }
    }
}


Measured memory_bytes: 3300
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	int N,tmp;
	stack<int> S;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		while(N != 0){
			tmp = N%(-10);
			N /= -10;
			if(tmp < 0){
				tmp += 10;
				N++;
			}
			S.push(tmp);
		}

		while(!S.empty()){
			printf("%d",S.top());
			S.pop();
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2632
package main

import (
	"fmt"
)

func main() {
	var x1, x2, x3, x4, x5 int
	fmt.Scan(&x1, &x2, &x3, &x4, &x5)

	switch {
	case x1 == 0:
		fmt.Println(1)
	case x2 == 0:
		fmt.Println(2)
	case x3 == 0:
		fmt.Println(3)
	case x4 == 0:
		fmt.Println(4)
	case x5 == 0:
		fmt.Println(5)
	}
}


Measured memory_bytes: 1816
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!(
        n: usize,
        a: [usize; n],
    );

    let mut current_max = 0;
    let mut sum = 0;
    for ai in a {
        if current_max < ai {
            current_max = ai;
        }
        sum += (current_max - ai);
    }
    println!(
        "{}", sum
    );
}


Measured memory_bytes: 5556
#include<stdio.h>
#include<string.h>
int main ()
{
    int x,ma[100001]= {0},n,l,r,count=0,j;
    char s[100001];
    scanf("%d %d",&x,&n);
    scanf("%s",s);
    for( j=0; j<x; j++)
    {
        if(s[j]=='A'&&s[j+1]=='C')
        {
            count++;
        }
            ma[j+1] = count;
    }
    for(int k=0; k<n; k++)
    {
        scanf("%d %d",&l,&r);
        printf("%d\n",ma[r-1]-ma[l-1]);
    }
    return 0;
}


Measured memory_bytes: 1280
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n,k = input_list()
  p = input_list()
  kakus = [0]*(n+1)
  for i in range(1, n+1):
    kaku = (1+p[i-1])/2
    pre = kakus[i-1]
    kakus[i] = kaku+pre
  ans = []
  for i in range(len(p)-k+1):
    ans.append(kakus[i+k]-kakus[i])
  print(max(ans))
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

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

bool primenumber(int num){
		int sq_num,judge;
		sq_num = sqrt(num);

		if(num == 2) return true;
		if(num % 2 == 0) judge++;
		for(int i = 2;i <= sq_num;i++){
				if(num % i == 0) judge++;
		}
		if(judge == 0){
				return true;
		}else{
				return false;
		}
}

int main(){
		int n,n_judge,ans = 0;
		cin >> n;
		for(int i = 0;i < n;i++){
				cin >> n_judge;
				if(primenumber(n_judge) == true) ans++;
		}
		cout << ans << endl;
		return 0;
}

Measured memory_bytes: 1160
n = int(input())
x = [0] * 8
y = [0] * 8
for i in range(n):
    x[i], y[i] = map(int, input().split())

sum = 0
for i in range(n):
    for j in range(n):
        if i != j:
            sum += pow(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2), 0.5)

sum = sum / n
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,a[10000];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=n;i>=2;i--)
        printf("%d ",a[i]);
    printf("%d\n",a[1]);
}



Measured memory_bytes: 3216
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = x/500;
    int b = x - (a*500);
    int c = b/5;

    int ans1 = a*1000;
    int ans2 = c*5;

    System.out.println(ans1+ans2);
  }
}


Measured memory_bytes: 35616
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];
    static int a[] = new int[MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        for(int i=0;i<n;i++) a[i] = sc.nextInt();

        int x1 = 0;
        for (int i=0;i<n;i++) {
            if ((i&1)==0) x1+=a[i];
            else x1 -= a[i];
        }
        out.printf("%d ", x1);
        int last=x1;
        for (int i=0;i<n-2;i++) {
            last = 2*a[i] - last;
            out.printf("%d ", last);
        }
        out.println(2*a[n-1]-x1);
    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
}


Measured memory_bytes: 79380
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAX5];ll visit[]={};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,q,m;
string s,t,d;
ll sum = 0;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s>>t;
	map<char,ll> ms,mt;
	n = s.length();

	for(ll i=0;i<n;i++) {
		ms[s[i]]++;
		mt[t[i]]++;
	}
	
	if(ms.size() == mt.size()) {
		for(ll i=0;i<n;i++) {
			if(ms[s[i]]!=mt[t[i]]) {
				cout<<"No\n";
				return;
			}
		}
		cout<<"Yes\n";
		return;
	}
	
	cout<<"No\n";

}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int s,a,b,c,d,e=1000000000;

signed main() {
    cin >> s;
    int tmp = sqrt(s);
    a = b = tmp;
    while (a*b < s) {
        a++;
        swap(a,b);
    }
    tmp = a*b;
    cout << "0 0 " << a << " " << 1 << " " << (tmp-s) << " " << b << endl;
}



Measured memory_bytes: 256
import fractions

a,b=map(int,input().split())
g=fractions.gcd(a,b)
#print(g)
ans=1
i=2
while i*i<=g:
    if(g%i==0):
        ans+=1
        while g%i==0:
            g/=i
    i=i+1
if(g!=1):ans+=1
print(ans)

Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 15;
const int MAX_M = 225;

int n,m;
ll dp[1 << MAX_N][MAX_N];
ll d[MAX_N][MAX_N];
int s[MAX_M];
int t[MAX_M];
int D[MAX_M];

ll solve()
{
	rep(S,1<<n){
		fill(dp[S],dp[S]+n,INF);
	}
	dp[(1<<n)-1][0] = 0;
	for(int S=(1<<n)-2;S>=0;S--){
		rep(v,n){
			rep(u,n){
				if(!(S>>u&1)){
					dp[S][v] = min(dp[S][v],dp[S|1<<u][u] + d[v][u]);
				}
			}
		}
	}
	return dp[0][0];
}

int main()
{
	ll ans=INF-1;
	cin >> n >> m;
	rep(i,m){
		cin >> s[i] >> t[i] >> D[i];
	}
	rep(i,n){
		fill(d[0],d[n],INF);
		rep(j,m){
			d[(s[j]+n-i)%n][(t[j]+n-i)%n] = D[j];
		} 
		ans = min(ans,solve());
	}
	if(ans > 16000){
		cout << "-1\n";
	}else{
		cout << ans << "\n";
	}
}

Measured memory_bytes: 6908
from collections import deque
n = int(input())
a = [int(i) for i in input().split()]
b = deque()
if n % 2 == 0:
    for i, j in enumerate(a):
        if (i + 1) % 2 == 0:
            b.appendleft(j)
        else:
            b.append(j)
else:
    for i, j in enumerate(a):
        if (i +1) % 2 == 0:
            b.append(j)
        else:
            b.appendleft(j)
print(*b)

Measured memory_bytes: 25416
/*
 * main.cpp
 *
 *  Created on: 2018/04/26
 *      Author: mac
 */

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>


using namespace std;

int main(){

	int N,K;

	cin >> N >> K;

	int ans = K;

	for(int i = 1;i < N;i++){
		ans *= (K-1);
	}

	cout << ans;

    return 0;

}


Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

def bom_count(S, x, y):
    dx = [-1,-1,-1,0,0,0,1,1,1]
    dy = [-1,0,1,-1,0,1,-1,0,1]
    cnt = 0
    for i in range(len(dx)):
        if 0 <= x + dx[i] < H and 0 <= y + dy[i] < W and S[x + dx[i]][y + dy[i]] == '#':
            cnt += 1
    return str(cnt);


for x in range(H):
    for y in range(W):
        if S[x][y] != '.':
            continue
        S[x][y] = bom_count(S, x, y)

for i in range(H):
    print(''.join(S[i]))


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main(){
    int n,m;
    cin >> n >> m;
    int ans = n;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        if(uf.same(a,b))continue;
        else{
            ans--;
            uf.unite(a, b);
        }
    }
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed compare(const void *a, const void *b){
	int sub = *(int *)a - *(int *)b;
	if(sub < 0){
		return -1;
	}
	else if(sub > 0){
		return 1;
	}
	else{
		return 0;
	}
}

signed main(){
	int N, M, i, j, ans = 0;
	scanf("%lld%lld", &N, &M);
	int *A = (int *)malloc(sizeof(int) * (N + 1));
	int *B = (int *)malloc(sizeof(int) * (N + 1));
	A[0] = 0;
	for(i = 1; i <= N; i++){
		scanf("%lld", &A[i]);
	}
	for(i = 1; i <= N; i++){
		A[i] = (A[i] + A[i - 1]) % M;
	}
	qsort(A, N + 1, sizeof(int), compare);
	B[0] = 1;
	for(i = 1, j = 0; i <= N; i++){
		if(A[i] == A[i - 1]){
			B[j]++;
		}
		else{
			j++;
			B[j] = 1;
		}
	}
	for(i = 0; i <= j; i++){
//		printf("B[%lld] = %lld\n", i, B[i]);
		ans += (B[i] * (B[i] - 1)) / 2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	long int box[100001] = {0},n,i,k,pos,val;
	cin >> n >> k;
	for(i = 0;i < n;i++){
		cin >> pos;
		cin >> val;
		box[pos] += val;
	}
	for(i  = 1;k > 0;i++){
		k -= box[i];
	}
	printf("%ld\n",i-1);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

signed main() {
    int N;
    cin>>N;
    for (int h = 1; h <= 3500; h++) {
        for (int w = 1; w <= 3500; w++) {
            if ((4 * h * w - N * w - N * h) == 0) continue;
            if ((N * h * w) % (4 * h * w - N * w - N * h) == 0 && (N * h * w) / (4 * h * w - N * w - N * h) > 0) {
                int n = (N * h * w) / (4 * h * w - N * w - N * h);
                cout<<h<<' '<<n<<' '<<w<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
S = input()
a = 0
b = 0
c = 0
for i in S:
  if i == 'a':
    a += 1
  if i == 'b':
    b += 1
  if i == 'c':
  	c += 1
    
if a == 1 and b == 1 and c == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
'''ika tako
先頭から貪欲に残せる要素を拾っていって、
残る要素数を  N  から引いた値が答え
'''
n = int(input())
aaa = list(map(int, input().split()))
 
if 1 not in aaa:#'1'がどこにも無ければ不可能なので'-1'を出力して終了
    print(-1)
    exit()
 
i = 0
a = 1
while True:
    try:
        j = aaa.index(a, i)
        #文字列.index(検索する文字列 [,開始の位置 [,終了の位置]])
    except ValueError:#指定する文字列がない場合ValueError
        break
    i = j + 1
    a += 1
 
print(n - a + 1)

Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 998244353
#define N 3005
int n;
double dp[N][N];
double ara[N];
double solve(int i,int cnt)
{
    if(i==n) return (cnt>n-cnt);
    if(dp[i][cnt]!=-1) return dp[i][cnt];
    double ans1=ara[i]*solve(i+1,cnt+1)+(1-ara[i])*solve(i+1,cnt);
    return dp[i][cnt]=ans1;
}
int main()
{
    fastio;
    cin>>n;
    for(int i=0;i<n;i++) cin>>ara[i];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++) dp[i][j]=-1;
    }
    cout<<setprecision(11)<<fixed<<solve(0,0);

}


Measured memory_bytes: 70912
#include <stdio.h>
int main() {
	while(1){
		int h,m,i,j;
		scanf("%d %d",&h,&m);
		if(h == 0 && m == 0) break;
		for(i=0;i<h;i++){
			if(i%2 == 0){
				for(j=0;j<(m/2);j++)printf("#.");
				if(m%2 != 0)printf("#");
			}
			else{
				for(j=0;j<(m/2);j++)printf(".#");
				if(m%2 != 0)printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2056
#include <stdio.h>
#include<math.h>
int main(void){
    
    int e1,e2,e3,e4;
    scanf("%d %d %d %d",&e1,&e2,&e3,&e4);
    if(e1==e2&&e3==e4){
        printf("yes\n");
    }
    else if(e1==e3&&e2==e4){
        printf("yes\n");
    }
    else if(e1==e4&&e2==e3){
        printf("yes\n");
    }
    else {
        printf("no\n");
    }
    
    
    
    
    
}



Measured memory_bytes: 2108
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt=0

for i in range(N):
  #print(i,a[i],x)
  if a[i]<=x:
    if i==N-1:
      if x==a[i]:
        cnt += 1
    else:
      x -= a[i]
      cnt += 1
  else:
    break

print(cnt)

Measured memory_bytes: 3060
n,k=map(int,input().split())
ans=[[] for _ in range(n//2)]
if n%2==1:
  for i in range(1,k+1):
    ans[i-1].append(i)
  for i in range(1,k+1):
    ans[i-1].append(n-i+1)
  for i in range(k):
    print(*ans[i])
else:
  if n%4==0:
    for i in range(1,k+1):
      ans[i-1].append(i)
    for i in range(1,k+1):
      if i<=k//2+1:
        ans[i-1].append(n-i+1)
      else:
        ans[i-1].append(n-i)
  else:
    for i in range(1,k+1):
      ans[i-1].append(i)
    for i in range(1,k+1):
      if i<=k//2:
        ans[i-1].append(n-i+1)
      else:
        ans[i-1].append(n-i)
  for i in range(k):
    print(*ans[i])

Measured memory_bytes: 24084
#include <bits/stdc++.h>
#define inf (long long)(1e18)
using namespace std;

using P = pair<long long, long long>;

int n;
vector<vector<int>> g;
P res(inf, inf);

void solve();

int main() {
  cin >> n;
  g.resize(n);
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    g[--a].push_back(--b);
    g[b].push_back(a);
  }
  solve();
  cout << res.first << " " << res.second << endl;
  return 0;
}

void solve() {
  for (int root = 0; root < n; ++root) {
    vector<int> dist(n, -1);
    vector<int> cnt(n, 0);
    queue<int> qu;
    P np(0, 1);
    dist[root] = 0;
    cnt[0] = g[root].size();
    qu.push(root);
    while (qu.size()) {
      int now = qu.front();
      qu.pop();
      cnt[dist[now]] = max(cnt[dist[now]], (int)g[now].size() - 1);
      np.first = dist[now] + 1;
      for (auto to : g[now])
        if (dist[to] == -1) {
          dist[to] = dist[now] + 1;
          qu.push(to);
        }
    }
    for (int i = np.first - 2; i >= 0; --i) {
      long long tmp = np.second * cnt[i];
      if (tmp < np.second || tmp >= inf) tmp = inf;
      np.second = tmp;
    }
    res = min(res, np);
  }
  for (int r1 = 0; r1 < n; ++r1)
    for (auto r2 : g[r1]) {
      vector<int> dist(n, -1);
      vector<int> cnt(n, 0);
      queue<int> qu;
      P np(0, 2);
      dist[r1] = dist[r2] = 0;
      qu.push(r1);
      qu.push(r2);
      while (qu.size()) {
        int now = qu.front();
        qu.pop();
        cnt[dist[now]] = max(cnt[dist[now]], (int)g[now].size() - 1);
        np.first = dist[now] + 1;
        for (auto to : g[now])
          if (dist[to] == -1) {
            dist[to] = dist[now] + 1;
            qu.push(to);
          }
      }
      for (int i = np.first - 2; i >= 0; --i) {
        long long tmp = np.second * cnt[i];
        if (tmp < np.second || tmp >= inf) tmp = inf;
        np.second = tmp;
      }
      res = min(res, np);
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
int main() {

    ll x, y, z;
    L3(x, y, z);
    if(y * z >= x) {
        cout<<"Yes"<<endl;
    }else {
        cout<<"No"<<endl;
    }

    return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n;
    cin >> n;
    cout << (n - 1) / 2 << '\n';
    return 0;
}

Measured memory_bytes: 256
package main

/*
完全2分木で表されたヒープ
*/

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func printNode(n int, heap []int) {
	var parent, left, right string
	if n != 1 {
		parent = fmt.Sprintf(" parent key = %d,", heap[n/2])
	}
	leftID := n * 2
	if leftID <= len(heap)-1 {
		left = fmt.Sprintf(" left key = %d,", heap[leftID])
	}
	rightID := n*2 + 1
	if rightID <= len(heap)-1 {
		right = fmt.Sprintf(" right key = %d,", heap[rightID])
	}

	fmt.Printf("node %d: key = %d,%s%s%s \n", n, heap[n], parent, left, right)
}

func main() {
	scanner := makeScanner(8192)
	eGetInt(scanner)
	elements := eGetInts(scanner)
	heap := append([]int{0}, elements...)
	for i := 1; i < len(heap); i++ {
		printNode(i, heap)
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	buf.WriteString("[")
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = ", "
	}
	buf.WriteString("]")
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func min(a []int) int {
	m := a[0]
	for _, v := range a {
		if v < m {
			m = v
		}
	}
	return m
}

func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}
func find(n int, a ints) int {
	for i, v := range a {
		if n == v {
			return i
		}
	}
	return -1
}



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

int main()
{
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') {
    //    printf("%d\n", a+b);
    cout << a+b << "\n";
  }else {
    cout << a-b << "\n";
    //printf("%d\n", a-b);
  }
  return 0;
}


Measured memory_bytes: 256
#-------------------------------------------------------------------------------
# coding: utf-8
# Created:     16/12/2015
import sys

io = sys.stdin

op = { "+" : lambda x, y:  x + y,
        "-": lambda x,y: x - y,
        "/": lambda x,y: x/y,
        "*": lambda x,y: x*y }


while True:
    a, op_, b = io.readline().split()
    if op_ == "?" : break
    a1, b1 = int(a), int(b)

    print op[op_](a1, b1)

Measured memory_bytes: 6380
#include <stdio.h>
#include <math.h>
static double g_cos_pi_3, g_sin_pi_3;
static int g_flag = 1;
 
void koch_curve(double x1, double y1, double x2, double y2, int n) {
    double x, y, ax, ay, bx, by, cx, cy;
 
    if (!n) {
        if (g_flag) {
            printf("%.8lf %.8lf\n", x1, y1);
            g_flag = 0;
        }
        printf("%.8lf %.8lf\n", x2, y2);
        return;
    }
    x = (x2-x1) / 3.0;
    y = (y2-y1) / 3.0;
    ax = x1 + x;
    ay = y1 + y;
    bx = x*g_cos_pi_3 - y*g_sin_pi_3 + ax;
    by = x*g_sin_pi_3 + y*g_cos_pi_3 + ay;
    cx = x2 - x;
    cy = y2 - y;
 
    koch_curve(x1, y1, ax, ay, n-1);
    koch_curve(ax, ay, bx, by, n-1);
    koch_curve(bx, by, cx, cy, n-1);
    koch_curve(cx, cy, x2, y2, n-1);
}
 
int main(void) {
    int n;
 
    g_cos_pi_3 = cos(M_PI / 3.0);
    g_sin_pi_3 = sin(M_PI / 3.0);
    scanf("%d", &n);
    koch_curve(0.0, 0.0, 100.0, 0.0, n);
    return 0;
}




Measured memory_bytes: 2128
#include<iostream>
#include<string>
#include <cstring>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<time.h>
#include<limits.h>
#include<unordered_map>
#include<set>
#include<queue>
#include<stack>
#include <iomanip>

using namespace std;
#define inf LLONG_MAX
const int N = 201;
#define int long long


void solve() {
    string s; cin >> s;
    long long xx = 0;
    for (auto x: s) {
        xx += (x - '0');
    }
    if (xx % 9 == 0) cout << "Yes\n";
    else cout <<"No\n";

}


int32_t main() {
    solve();
}

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

int main() {
	string S;
	cin >> S ;
	
	if (S =="Sunny"){
	cout << "Cloudy"<< endl;
	} else if (S =="Cloudy") {
		cout << "Rainy" << endl;
	} else if (S == "Rainy"){
		cout << "Sunny" << endl;
	}
	// your code goes here
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#define _ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

int main()
{_
    unsigned long long k; cin >> k;
    unsigned long long div = 7;
    int i = 1;
    if (k % 2 == 0 || k % 5 == 0)
    {
        cout << -1;
        return 0;
    }
    {
        for (int i = 1;; ++i)
        {
            if (div % k == 0)
            {
                cout << i;
                return 0;
            }
            div = (div % k) * 10 + 7;
        }
    }
}


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

struct E{
	int c,n;
	bool operator<(const E& e1)const{
		return c>e1.c;
	}
};

int ds[100003];
std::map<int,int> ms1,ms2;
vector<E> vec1,vec2;

int main() {
	int n;
	
	cin>>n;
	int n2=n/2;
	for(int i=0;i<n;i++){
		cin>>ds[i];
	}
	for(int i=0;i<n;i++){
		int t=ds[i];
		if(i%2==0){
			ms1[t]++;
		}else{
			ms2[t]++;
		}
	}
	for( auto i = ms1.begin(); i != ms1.end() ; ++i ) {
      E e1;
      e1.n=i->first;
      e1.c=i->second;
      vec1.push_back(e1);
	}
	for( auto i = ms2.begin(); i != ms2.end() ; ++i ) {
      E e1;
      e1.n=i->first;
      e1.c=i->second;
      vec2.push_back(e1);
	}
	sort(vec1.begin(),vec1.end());
	sort(vec2.begin(),vec2.end());
	int ans=n;
	for(int i=0;i<10&&i<vec1.size();i++){
		E e1=vec1[i];
		for(int j=0;j<10&&j<vec2.size();j++){
			E e2=vec2[j];
			if(e1.n==e2.n){
				ans=min(ans,min(n-e2.c,n-e1.c));
				//cout<<min(n-e2.c,n-e1.c);
			}else{
				ans=min(ans,n2-e1.c+n2-e2.c);
				//cout<<n2-e1.c+n2-e2.c;
			}
			//cout<<" "<<ans<<" "<<e1.n<<" "<<e1.c<<" "<<e2.n<<" "<<e2.c<<"\n";
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 6520
#include<stdio.h>
int a[5],b[5];
int main()
{
    int i,j,r,t,t1,t2,m,d,max;
    for(i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
    }
     t=0;j=0;t1=0;
     for(i=0;i<5;i++)
    {
        if(a[i]%10==0)
        {
            t=t+a[i];
        }
        else
        {
            r=a[i]%10;
             t1=t1+(a[i]+(10-r));
             d=a[i]/10;
           b[j]=((d+1)*10)-a[i];

            j++;


        }
    }

    max=b[0];
     for(i=0;i<j;i++)

     {

        if(b[i]>max)
        {
            max=b[i];
        }

     }

    printf("%d\n",(t+t1)-max);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s, t;
    cin >> s >> t;
    if(t.substr(0,(t.length()-1)) == s)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3616
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N, K = [int(x) for x in input().strip().split()]
    A = [int(x) for x in input().strip().split()]
    l, r = 0, max(A)
    def f(m):
        ret = 0
        # print('m={}'.format(m))
        for a in A:
            ret += (a // m) - 1 + (a % m > 0)
            if ret > K:
                return False
        return True

    while l + 1 < r:
        m = (l + r) // 2
        if not f(m):
            l = m
        else:
            r = m
    
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 30860
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int H,W; cin>>H>>W;
    char m[H][W];
    rep(i,H)rep(j,W)cin>>m[i][j];
    rep(i,W+2)cout<<'#';
    cout<<endl;
    rep(i,H){
        cout<<'#';
        rep(j,W)cout<<m[i][j];
        cout<<'#'<<endl; 
    }
    rep(i,W+2)cout<<'#';cout<<endl ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  set<char> g;
  rep(i,sz(s)){
    g.insert(s[i]);
  }
  if(sz(g)==1){
    COUT("No");
  }
  else COUT("Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define mod 1000000007
#define mod 998244353
#define N 1000001
#define ll long long int
#define pr pair<ll,ll>
#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define r(i,a,b) for(ll i=a;i>=b;i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define line cout<<'\n'
#define all(v) v.begin(),v.end()
#define rev(s) reverse(all(s))
using namespace std;

const ll INF = LLONG_MAX;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll tt = 1;
    //cin>>tt;
    f(tc,1,tt){
        ll h1,m1,h2,m2,k;
        cin>>h1>>m1>>h2>>m2>>k;
        ll len = 0;
        if(m1!=0){
            len += (60 - m1);
            h1++;
        }
        len += 60*(h2-h1) + m2;
        ll zero = 0;
        cout<<max(zero,len - k);
    }
    return 0;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

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

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


////////////////////////////////////////////////////////////////////////////////////////
int main(){
    
    int k,x;
    cin >> k >> x;

    if (k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const int MAXN = 1e6+5;
const ll p = 1e9+9, x = 12345678, inv = 736263742;

ll fact[MAXN], invfact[MAXN], inv1[MAXN], n;
vector<int> f[MAXN];
ll pinv[MAXN], px[MAXN], h[MAXN];

string w;

ll comb(int x, int y) {
	if (x < 0 || y < 0 || x < y)
		return 0;
	return fact[x]*invfact[y]%p*invfact[x-y]%p;
}

ll exp(ll x, ll k) {
	if (k == 0)
		return 1;
	ll y = exp(x, k/2);
	return (k%2 == 0) ? y*y%p : y*y%p*x%p;
}

ll inve(ll x) { return exp(x, p-2); }

ll get(int l, int r) {
    // cout << l << ' ' << r << ' ' << h[l] << ' ' << h[r+1] << ' ' << pinv[l] << endl;
    return ((h[r+1]-h[l] + p)*pinv[l])%p;
}

ll inithash(string s) {
    pinv[0] = px[0] = 1; 

    for (int i = 1; i <= n; ++i) {
        pinv[i] = inv*pinv[i-1]%p;
        px[i] = x*px[i-1]%p;
    }

    h[0] = 0;

    for (int i = 0; i < n; ++i)
        h[i+1] = (px[i]*(s[i] + 1) + h[i])%p;
}

void init() {
	inv1[1] = fact[0] = fact[1] = invfact[0] = invfact[1] = 1;
	for (int i = 2; i < MAXN; ++i) {
		inv1[i] = (p - (p/i) * inv1[p%i] % p) % p;
		fact[i] = i*fact[i-1]%p;
		invfact[i] = inv1[i]*invfact[i-1]%p;
	}
}

bool period(int l, int r) {
	for (int x : f[r-l+1]) {
		if (get(l, r - (r-l+1)/x) == get(l+(r-l+1)/x, r))
			return false;
	}

	return true;
}

int main() {
	cin >> w;
	n = w.length();
	bool y = true;
	for (int i = 1; i < n; ++i)
		if (w[i] != w[0])
			y = 0;
	if (y) {
		cout << n << "\n1\n";
		return 0;
	}

	for (int i = 2; i < MAXN; ++i) {
		if (f[i].size() == 0)
			for (int j = i; j < MAXN; j += i)
				f[j].push_back(i);
	}

	inithash(w);

	if (period(0, n-1)) {
		cout << "1\n1\n"; return 0;
	}
	
	cout << "2\n";
	ll tot = 0;
	for (int i = 0; i < n-1; ++i) {
		tot += (period(0, i)&period(i+1, n-1));
	}

	cout << tot << endl;
}

Measured memory_bytes: 68356