akhauriyash/Code-Regression huggingface dataset:
from collections import deque


def solve(string):
    n, *ab = map(int, string.split())
    next_ = [dict([]) for _ in range(n + 1)]
    queue = deque([1])
    for a, b in zip(*[iter(ab)] * 2):
        next_[a][b] = 0
        next_[b][a] = 0
    while len(queue) > 0:
        c = queue.popleft()
        _next = next_[c]
        use = set(range(1, len(_next.keys()) + 1)) - set(next_[c].values())
        for _n, u in zip((k for k, v in _next.items() if v == 0), use):
            queue.append(_n)
            next_[c][_n] = u
            next_[_n][c] = u
    return str("{}\n{}".format(max(map(lambda x: len(x.keys()), next_)),
                               "\n".join(str(next_[a][b]) for a, b in zip(*[iter(ab)] * 2))))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 50604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    int ret = 1;

    int tmp = min(K, A - 1);
    K -= tmp;
    ret += tmp;

    if (K == 0) {
        cout << ret << endl;
        return 0;
    }

    if (K == 1) {
        cout << ret + 1 << endl;
        return 0;
    }

    if (B - A > 2) {
        int tmp2 = K / 2;
        ret += (B - A) * tmp2;
        K -= tmp2 * 2;
        if (K) ret++;
    } else {
        ret += K;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;

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



Measured memory_bytes: 256
def ll(char, f):
    if char == "l":
        return not f
    return f


def rr(char, f):
    if char == "r":
        return not f
    return f


while True:
    N = int(input())
    if N == 0:
        break
    F = list(input().split())
    c = 0
    lFalg = False
    rFalg = False
    before = F[0]
    lFalg = ll(F[0][0], lFalg)
    rFalg = rr(F[0][0], rFalg)
    for i in range(1, len(F)):
        if not lFalg == rFalg:
            if not before[0] == F[i][0]:
                c += 1
        lFalg = ll(F[i][0], lFalg)
        rFalg = rr(F[i][0], rFalg)
        before = F[i]
    print(int(c))



Measured memory_bytes: 5620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m,l;
	cin>>n>>m>>l;
	vi sum(n);
	vi sc(n);
	int ma=0,mai=0;
	int t=0;
	int a,b,c;
	while(m--){
		cin>>a>>b>>c;
		sum[mai]+=b-t;
		t=b;
		sc[a-1]+=c;
		if(c<0&&a-1==mai){
			ma=-inf;mai=inf;
			rep(i,n)if(ma<sc[i]){
				if(ma==sc[i])mai=min(mai,i);
				else mai=i;
				ma=sc[i];
			}
		}else if(c>=0){
			if(sc[a-1]>ma){
				ma=sc[a-1];mai=a-1;
			}else if(sc[a-1]==ma)mai=min(mai,a-1);
		}
	}
	sum[mai]+=l-b;
	ma=0;
	rep(i,n)if(ma<sum[i]){
		if(ma==sum[i])mai=min(mai,i);
		else mai=i;
		ma=sum[i];
	}
	cout<<mai+1<<endl;
}

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

int c[27], s[366][27], t[366], last[27];
int main()
{
    int D; cin>>D;
    for(int i=1; i<=26; ++i) cin>>c[i];
    for(int i=1; i<=D; ++i)
        for(int j=1; j<=26; ++j)
            cin>>s[i][j];

    auto calc_score=[&](){
        long score=0;
        for(int i=1; i<=26; ++i) last[i]=0;
        for(int d=1; d<=D; ++d) {
            score+=s[d][t[d]];
            last[t[d]]=d;
            for(int i=1; i<=26; ++i) score-=c[i]*(d-last[i]);
        }
        return score;
    };

    for(int i=1; i<=D; ++i) {
        long bestscore=-(1L<<60), typ=1;
        for(int j=1; j<=26; ++j) {
            t[i]=j;
            auto score=calc_score();
            t[i]=0;
            if (bestscore<score) {
                bestscore=score;
                typ=j;
            }
        }
        t[i]=typ;
    }

    mt19937 engine;
    uniform_int_distribution<> rndT(1, 26), rndD(1, 365);
    auto bestscore=calc_score();

    for(int A=100000; A--; ) {
        int d=rndD(engine);
        int q=rndT(engine);
        int x=t[d];
        t[d]=q;
        auto score=calc_score();
        if (bestscore<score) {
            bestscore=score;
        }
        else {
            t[d]=x;
        }
    }
    for(int i=1; i<=D; ++i) cout<<t[i]<<endl;
}


Measured memory_bytes: 3648
$stdin = DATA if $stdin.eof?

gets

score_t = 0
score_h = 0

ARGF.each do |line|
  w1, w2 = line.split.map(&:chomp)
  if w1 == w2
    score_t += 1
    score_h += 1
  elsif (w1 <=> w2) == 1
    score_t += 3
  else
    score_h += 3
  end
end

puts "#{score_t} #{score_h}"

Measured memory_bytes: 6104
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        char[] c = br.readLine().toCharArray();
        int n = c.length;

        boolean ans = true;

        ans &= isPal(c);

        char[] temp = new char[n/2];
        for(int i=0 ; i<n/2 ; i++) {
            temp[i] = c[i];
        }

        ans &= isPal(temp);

        for(int i=n/2+1 ; i<n ; i++) {
            temp[i-(n/2+1)] = c[i];
        }

        ans &= isPal(temp);

        if(ans) {
            pw.println("Yes");
        }
        else {
            pw.println("No");
        }

        
        
        
        
        
        pw.flush();
        pw.close();
    }

    static boolean isPal(char[] c) {
        int n = c.length;
        for(int i=0 ; i<n/2 ; i++) {
            if(c[i] != c[n-1-i]) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 22612
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        int[] nums = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
            sum += nums[i];
        }
        int[] sums = new int[n];
        for (int i = 0; i < n; i++) {
            sums[i] += nums[i];
            if (i > 0) {
                sums[i] += sums[i - 1];
            }
        }
        int value = sum;
        for (int i = 0; i < n; i++) {
            final int abs = Math.abs(sum - sums[i] - sums[i]);
            value = Math.min(value, abs);
        }
        System.out.println(value);
    }
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define pb push_back
#define f(i,a) for(ll i=0;i<a;i++)


int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll l,r,d;
    cin>>l>>r>>d;
    
    ll c=0;
    for(ll i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            c++;
        }
    }
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n;
    cin >> n;
    vi a = {111,222,333,444,555,666,777,888,999};
    int ans = 111;
    rep(i,a.size()){
        if(n  <= a[i]) {ans = a[i]; break;}
    }
    cout << ans << endl;
    return 0;
}
    

Measured memory_bytes: 256
class Union_find:
    def __init__(self,n):
        self.group=[i for i in range(n)]
    
    def root(self,x):
        if(self.group[x]==x):
            return x
        else:
            tmp=self.root(self.group[x])
            self.group[x]=tmp
            return tmp
    
    def make(self,x,y):
        self.group[self.root(x)]=self.root(y)
    
    def judge(self,x,y):
        if(self.root(x)==self.root(y)):
            return True
        else:
            return False


n,m=map(int,input().split())
T=Union_find(n+1)
P=list(map(int,input().split()))

for _ in range(m):
    
    x,y=map(int,input().split())
    T.make(x,y)


ans=0

for i in range(n):
    if(T.judge(P[i],i+1)):
        ans+=1

print(ans)

Measured memory_bytes: 17840
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#N, M = map(int, input().split())
#N = int(input())
#S = str(input())
A = int(input())
B = int(input())

if A > B :
  print ("GREATER")
elif A < B :
  print ("LESS")
else :
  print ("EQUAL")



Measured memory_bytes: 38256
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def eratosthenes_sieve(n):
    """ 素数列挙(エラトステネスの篩) """

    table = [0] * (n + 1)
    prime_list = []
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
    return prime_list

N = 100000
primes = set(eratosthenes_sieve(N+1))

A = [0] * (N+1)
for a in range(1, N+1, 2):
    if a in primes and (a+1)//2 in primes:
        A[a] = 1

acc = [0] + list(accumulate(A))
for i in range(INT()):
    l, r = MAP()
    ans = acc[r+1] - acc[l]
    print(ans)


Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;cin>>n;
    vector<int>l(n);
    for(int &i:l)cin>>i;
    sort(l.begin(),l.end());
    int sum=0;
    for(int i=0;i<n-1;i++)sum+=l.at(i);
    cout<<(l.at(n-1)<sum?"Yes":"No")<<endl;
}

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

int main(void){
    int a,b,c,d,e, k;
    cin >> a >> b >> c >> d >> e;
    cin >> k;

    if(abs(e-a) > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
    
    return 0;
}

Measured memory_bytes: 256
s = input()
word = [0] * 26
for i in s:
    word[ord(i) - ord('a')] = 1

if sum(word) != 26:
    for i in range(26):
        if word[i] == 0:
            c = chr(i + ord('a'))
            break
    print(s + c)
    exit()
else:
    for i in range(25, -1, -1):
        if s[i] == 'z':
            pass
        else:
            now = ord(s[i]) + 1
            for j in range(now, ord('z') + 1):
                if not chr(j) in s[0:i]:
                    print(s[0:i] + chr(j))
                    exit()
print(-1)

Measured memory_bytes: 3064
<?php
  list($k, $n) = explode(" ", trim(fgets(STDIN)));
  $a = explode(" ", trim(fgets(STDIN)));
  
  sort($a);

  $max = 0;
  for($i=1;$i<$n;$i++){
    $distance = abs($a[$i-1]-$a[$i]);
    $max = max($max, $distance);
  }
  $distance = $k-$a[$n-1]+$a[0];
  $max = max($max, $distance);

  echo ($k-$max);

Measured memory_bytes: 19188
import java.util.Scanner;

public class Main {
    static long N;
    static long C;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        long res = 0;
        func(0, 0, res);
        System.out.println(C);
    }

    static void func(long cur, int use, long counter) {
        if(cur > N) return;
        if(use == 0b111) C++;

        // 7 を付け加える
        func(cur * 10 + 7, use | 0b001, counter);

        // 5 を付け加える
        func(cur * 10 + 5, use | 0b010, counter);

        // 3 を付け加える
        func(cur * 10 + 3, use | 0b100, counter);
    }
}


Measured memory_bytes: 35616
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,w;
	cin>>n>>w;
	int a[n];
	for(int x=0;x<n;x++){
		cin>>a[x];
	}
	int i=0;
	int sum[n]={0};
	sum[0]=a[0];
	for(int x=1;x<n;x++){
		sum[x]=a[x]+sum[x-1];
	}
	int ans=1;
	for(int x=0;x<n;x++){
		if(sum[x]<=w){
			ans++;
		}else{
			ans=x+1;
			break;
		}
	}
	cout<<ans;
	
	
	
		
	






	
	
return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  int a, b;
  cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9)
  {
    cout << a * b << endl;
  }
  else cout << "-1" << endl;
}


Measured memory_bytes: 256
def rec(N):
    tmp = str(N)
    if tmp[-1] == "0":
        tmp__ = int(tmp[-1])
        tmp___ = int(tmp[-1]) + 1
        yield tmp + str(tmp__)
        yield tmp + str(tmp___)
    elif tmp[-1] == "9":
        tmp_ = int(tmp[-1]) - 1
        tmp__ = int(tmp[-1])
        yield tmp + str(tmp_)
        yield tmp + str(tmp__)
    else:
        tmp_ = int(tmp[-1]) - 1
        tmp__ = int(tmp[-1])
        tmp___ = int(tmp[-1]) + 1
        yield tmp + str(tmp_)
        yield tmp + str(tmp__)
        yield tmp + str(tmp___)
        
K = int(input())
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
count = 0
while(True):
    if len(A) > K:
        break
    for i in rec(A[count]):
        A.append(i)
    count += 1
print(A[K - 1])

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

int main(){
    // input
    int N, tmp;
    cin >> N;

    //
    bool ans = false;
    for( int a=1; a<10; a++ ){
        for( int b=1; b<10; b++ ){
            if( a*b == N ) ans = true;
        }
    }

    // output
    printf( ans ? "Yes" : "No" );

} 

Measured memory_bytes: 256
A,B,C,D = 0, 0, 0, 0
Sum = 0
while True:
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    if (A or B or C or D) >= 0 and (A or B or C or D) <= 1000:
        if A >= B:
            Sum = Sum + B
        if B > A:
            Sum = Sum + A
        if C >= D:
            Sum = Sum + D
        if D > C:
            Sum = Sum + C
        break
    else:
        continue
print(Sum)


Measured memory_bytes: 3060
def main():
    ll = []
    rl = []
    n,m = map(int,input().split())
    for _ in range(m):
        l,r = map(int, input().split())
        ll.append(l)
        rl.append(r)
    l = max(ll)
    r = min(rl)
    print(max(0,r-l+1))

if __name__ == '__main__':
  main()

Measured memory_bytes: 11016
n = int(input())
a = list(map(int,input().split()))

ans = [0 for _ in range(n)]
for i in reversed(range(n)):
  tmp = 0
  for j in range((i+1)*2-1,n,i+1):
    if ans[j] == 1:
      tmp += 1
  if a[i] == 0 and tmp % 2 == 1:
    ans[i] = 1
  elif a[i] == 1 and tmp % 2 == 0:
    ans[i] = 1

c = 0
l = []
for i in range(n):
  if ans[i] == 1:
    l.append(i+1)
    c += 1
if c == 0:
  print(0)
else:
  l = [str(i) for i in l]
  l = " ".join(l)
  print(c)
  print(l)


Measured memory_bytes: 19768
use std::io::stdin;
use std::time::SystemTime;

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr
{
    read_line().parse::<T>().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T>() -> Vec<T>
where T: std::str::FromStr
{
    read_line().split(" ").map(|n| n.parse::<T>().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_chars() -> Vec<char>
{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn print_time() -> () {
    println!("{:?}", SystemTime::now());
}

#[allow(unused_variables)]
fn main() {
    let n: Vec<usize> = read_vec();
    let mut v: Vec<usize> = vec![];
    for _ in 0..n[0] {
        v.push(read());
    }
    
    let c = v[0];
    if v.iter().all(|p| p == &c) {
        println!("{}", v.len());
        std::process::exit(0);
    }
    
    let mut data = vec![];
    data.push(v[0]);
    
    for i in 1..n[0] {
        let result = data.binary_search_left(&v[i]);
        let index = match result {
            Ok(index) => index,
            Err(index) => index,
        };
        
        if data.get(index) == None {
            if data[index - 1] < v[i] {
                data[index - 1] = v[i];
            } else {
                data.insert(index, v[i]);
            }
        } else {
            if data[index] < v[i] {
                data[index] = v[i];
            } else if index > 0 && data.get(index - 1).map(|n| n < &v[i]).unwrap_or(false) {
                data[index - 1] = v[i];
            } else {
                data.insert(index, v[i]);
            }
        }
    }
    
    println!("{}", data.len());
}

trait BinarySearchLeft<T> {
    fn binary_search_left(&self, x: &T) -> Result<usize, usize>;
}

impl<T> BinarySearchLeft<T> for Vec<T>
where T: std::cmp::Ord + std::fmt::Debug
{
    fn binary_search_left(&self, x: &T) -> Result<usize, usize> {
        let index = self.binary_search(x);
        match index {
            Ok(index) => {
                for i in (1..index+1).rev() {
                    if self[i] != self[i - 1] {
                        return Ok(i - 1)
                    }
                }
                
                Ok(index)
            },
            _ => index,
        }
    }
}

Measured memory_bytes: 6396
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;



int main() {
	int a,b;
	cin >> a >> b;
	if (a <= 9 && b <= 9)cout << a * b << endl;
	else cout << "-1" << endl;


	return 0;
}

Measured memory_bytes: 888
<?php

$input = trim(fgets(STDIN));
$As = explode(' ', $input);
rsort($As);

$cost1 = abs($As[1] - $As[0]);
$cost1 += abs($As[2] - $As[1]);

$cost2 = abs($As[2] - $As[0]);
$cost2 += abs($As[1] - $As[2]);

echo min($cost1, $cost2);


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

#define ll long long
int main()
{
	ll N,A=0,m=9999999999999,t=0;
	cin>>N;
	for(int i=sqrt(N);i>=2;i--)
	{
		if(N%i==0)
		{
			A=i+N/i;
			m=min(m,A);
			cout<<m-2<<endl;		 
			return 0;
		}
	}
	//t!=1?cout<<N-1:cout<<m-2;
	cout<<N-1;

}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,m; cin >> n >> m;
  vector<int> a(n),b(n); rep(i,n) cin >> a[i] >> b[i];
  vector<int> c(m),d(m); rep(i,m) cin >> c[i] >> d[i];
  
  rep(i,n){
    vector<pair<int,int>> dist(m);
    rep(j,m){
      int tmp = abs(c[j]-a[i])+abs(d[j]-b[i]);
      dist[j] = make_pair(tmp,j+1);
    }
    sort(dist.begin(),dist.end());
    
    int mini = dist[0].first;
    int check = INF;
    for(auto x : dist)
      if(x.first == mini) check = min(check,x.second);

    cout << check << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
	int i, a[105], n, j, v;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for(i = 1; i < n; i++)
	{
		for(j = 0; j < n; j++)
		{
			if(j > 0)
			{
				cout << " ";
			}
			cout << a[j];
		}
		cout << endl;
		v = a[i];
		j = i - 1;
		while(j >= 0 && a[j] > v)
		{
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
	for(i = 0; i < n; i++)
	{
		if(i > 0)
		{
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	
	return 0;
}


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

using namespace std;
vector<pair<pair<int, int>, int>> edges;

void brute(int x, int len) {
  if(x == 19) {
    cout << "yeh: " << len << endl;
    return;
  }

  for(auto &e : edges) if(e.first.first == x) {
    brute(e.first.second, len + e.second);
  }
}

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

  int L; cin >> L;
  L--;


  vector<int> before(20, -1);

  for(int i = 0; i + 1 < 20; ++i) {
    int c = 20 - i - 2;
    edges.emplace_back(make_pair(i, i + 1), 0);
    if((1 << (c + 1)) <= L) {
      edges.emplace_back(make_pair(i, i + 1), (1 << c));
      before[c] = i;
    }
  }

  if(__builtin_popcount(L) == 1) {
    edges.emplace_back(make_pair(0, 19), L);
  }
  else {

    int last_bit = -1, last_vertex = 0, sum = 0;
    for(int i = 20; i >= 0; --i) {
      if(L & (1 << i)) {
        if(last_bit != -1) {
          if(i > 0) edges.emplace_back(make_pair(0, before[i - 1]), sum);
          else edges.emplace_back(make_pair(0, 19), L - 1);
        }
        sum += 1 << i;
        last_bit = i;
      }
    }
    edges.emplace_back(make_pair(0, 19), L);
  }

  cout << 20 << " " << edges.size() << endl;
  for(auto &e : edges) {
    cout << e.first.first + 1 << " " << e.first.second + 1 << " " << e.second << endl;
  }

  //brute(0, 0);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
ll n,m=LLONG_MAX; std::vector<ll> a(5);
int main(){
  cin >> n;
  for (size_t i = 0; i < 5; i++) {
    cin >> a[i];
    if(m > a[i]){
      m = a[i];
    }
  }
  cout << roundup(n,m)+4 << endl;
}


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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int ans = 0;
  for (int i = 0; i < N - 2; i++) {
    if (A.at(i) < A.at(i + 1) && A.at(i + 1) < A.at(i + 2)) ans++;
    if (A.at(i) > A.at(i + 1) && A.at(i + 1) > A.at(i + 2)) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>v(n + 3);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            for(int k = j + 1; k <= n; k++){
                set<long long>st;
                st.insert(v[i]);
                st.insert(v[j]);
                st.insert(v[k]);
                if(st.size() < 3){
                    continue;
                }
                if((v[i] + v[j] > v[k]) && (v[i] + v[k] > v[j]) && (v[j] + v[k] > v[i])){
                    ans++;
                }
            }
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
#define fir first
#define sec second

int n;
int a[300]; 

int main() {
	cin>>n; 
	for (int i = 1; i <= n*2; ++i) cin>>a[i]; 
	sort(a+1,a+n*2+1); 
	int ans = 0; 
	for (int i = 1; i <= n; ++i) ans += a[i*2-1]; 
	cout<<ans<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int mod=1000000007;


long long int h,w,wei[205],v[205],res[4][105]={},fin=0;
int main() {
    const long long int INF=99999999999999;
	map<long long int, long long int>mp;
    string str[550],red[550],blue[550];
    priority_queue<long long int>pq[4];
    priority_queue<long long int>tmp[4];
	cout << fixed << setprecision(10);
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>str[i];
        
    }
    for(int i=0;i<h;i++){
        red[i].push_back('#');
        blue[i].push_back('.');
        if(i%2==0){
            for(int j=1;j<w-1;j++){
                red[i].push_back('#');
                blue[i].push_back('.');
            }
        }else{
            for(int j=1;j<w-1;j++){
                blue[i].push_back('#');
                red[i].push_back('.');
            }
        }
        
        red[i].push_back('.');
        blue[i].push_back('#');
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(str[i][j]=='#'){
                if(i%2==0){
                    blue[i][j]='#';
                }else{
                    red[i][j]='#';
                }
            }
        }
    }

    for(int i=0;i<h;i++){
        cout<<red[i]<<endl;
    }
    cout<<endl;
    for(int i=0;i<h;i++){
        cout<<blue[i]<<endl;
    }
} 


Measured memory_bytes: 1536
#include <stdio.h>

int main()
{
        int a, b, c, d, e, f;
        double x, y;

        while (scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f) > 0) {
                x = (double)(e*c-b*f)/ (a*e-d*b);
                y = (double)(a*f-d*c)/ (a*e-d*b);
                x == -0.0 ? x = 0.0 : x;
                y == -0.0 ? y = 0.0 : y;
                printf("%.3f %.3f\n", x, y);
        }
        return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	

    int counter[4];
    REP(i,4)
    {
        counter[i] = 0;
    } 

    REP(i,4)
    {
        int tmp;
        cin >> tmp;
        if(tmp == 1)
        {
            counter[0] = 1;
        }

        if(tmp == 4)
        {
            counter[1] = 1;
        }

        if(tmp == 7)
        {
            counter[2] = 1;
        }

        if(tmp == 9)
        {
            counter[3] = 1;
        }
    }

    if(counter[0] && counter[1] && counter[2] && counter[3])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N]; 
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int result=100000;
  for(int i=1;i<=N;i++){
    int sum1=0, sum2=0, temp=0;
    for(int j=0;j<i;j++){
      sum1 += a[j];
    }
    for(int k=i;k<N;k++){
      sum2 += a[k];
    }
    if(sum1-sum2 > 0) temp = sum1-sum2;
    else              temp = sum2-sum1;
    result=min(result, temp);
  }
  cout << result << endl;
}

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

ll N,M;

int main(void){

    priority_queue <double> A;
    cin >> N >> M;
    rep(i,N){
        double a;
        cin >> a;
        A.push(1.0*a);
    }
    rep(i,M){
        double temp = A.top()/2;
        A.pop();
        A.push(temp);
    }
    ll ans=0;
    while(!A.empty()){
        ans +=(ll)A.top();
        A.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(void){
    int N,K,Q;
    cin >> N >> K >> Q;
    int pt[N];
    rep(i,N){
        pt[i]=0;
    }
    rep(i,Q){
        int tmp;
        cin >> tmp;
        pt[tmp-1]++;
    }
    rep(i,N){
        if(Q-pt[i]<K) cout  << "Yes"<<endl;
        else cout  <<"No"<<endl;
    }
    return 0;
}

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

int main(){
  int n;
  char a;
  cin >> n;
  vector<string> s(n);
  
  cin >> s.at(0);
  a = s.at(0).at(s.at(0).size()-1);
  
  for(int i = 1; i < n; i++){
    cin >> s.at(i);
    if(s.at(i).at(0) != a){
      cout << "No";
      return 0;
    }
    
    for(int j = 0; j < i; j++){
      if(s.at(j) == s.at(i)){
        cout << "No";
        return 0;
      }
    }
    
    a = s.at(i).at(s.at(i).size()-1);
    
  }
  cout << "Yes";
}

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

using namespace std;
typedef long long ll;

template <int MD>
struct ModInt {
    typedef ModInt M;
    int v;
    ModInt(int _v = 0) : v(_v) {}
 
    M& operator += (const M &r) {
        if ((v += r.v - MD) < 0) v += MD;
        return *this;
    }
    M& operator -= (const M &r) {
        if ((v -= r.v) < 0) v += MD;
        return *this;
    }
    M& operator *= (const M &r) {
        v = ll(v) * r.v % MD;
        return *this;
    }
 
    M operator + (const M &r) const { return M(*this) += r; }
    M operator - (const M &r) const { return M(*this) -= r; }
    M operator * (const M &r) const { return M(*this) *= r; }
 
    M pow(int n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return this->pow(MD - 2); }
};
typedef ModInt<1000000007> Mint;

const int MN = 123;
const int MK = 123456;
int n, k;
Mint dp[MN][MK];
Mint fac[MK], ifac[MK];

void first() {
    fac[0] = 1;
    for (int i = 1; i < MK; i++) {
        fac[i] = fac[i - 1] * Mint(i);
    }
    ifac[MK - 1] = fac[MK - 1].inv();
    for (int i = MK - 2; i >= 0; i--) {
        ifac[i] = ifac[i + 1] * Mint(i + 1);
    }
}

Mint binom(int n, int r) {
    return fac[n] * ifac[r] * ifac[n - r];
}

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

    first();
    cin >> n >> k;
    if (k == 0) {
        cout << 1 << endl;
        return 0;
    }
    dp[0][k] = 1;
    for (int ph = 0; ph < n; ph++) {
        int a;
        cin >> a;
        for (int j = 0; j <= k; j++) {
            dp[ph + 1][j] += dp[ph][j];
            if (j >= a + 1) {
                dp[ph + 1][j - a - 1] -= dp[ph][j];
            }
        }
    }

    Mint sm = 0;
    for (int i = 0; i <= k; i++) {
        sm += binom(i - 1 + n, n - 1) * dp[n][i];
    }
    cout << sm.v << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 3e3 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, m;
ll dp[maxn][maxn][2];

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

	cin >> n >> m;

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

	for (int i = 0; i < m; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k < 2; k++) {
				if (k) {
					if (j != n) {
						dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % mod;
						dp[i + 1][j + 1][k] = (dp[i + 1][j + 1][k] + dp[i][j][k]) % mod;
					}

					if (j) {
						dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % mod;
						dp[i + 1][j - 1][k] = (dp[i + 1][j - 1][k] + dp[i][j][k]) % mod;
					}
				}
				else {
					if (j != n) {
						dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % mod;
						dp[i + 1][j + 1][k] = (dp[i + 1][j + 1][k] + dp[i][j][k]) % mod;
					}

					if (j) {
						if (j == 1) {
							dp[i + 1][j][1] = (dp[i + 1][j][1] + dp[i][j][k]) % mod;
						}
						else {
							dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % mod;
						}

						if (j == 1) {
							dp[i + 1][j - 1][1] = (dp[i + 1][j - 1][1] + dp[i][j][k]) % mod;
						}
						else {
							dp[i + 1][j - 1][k] = (dp[i + 1][j - 1][k] + dp[i][j][k]) % mod;
						}
					}
				}
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = (ans + dp[m][i][1]) % mod;
	}
	cout << ans << endl;
}



Measured memory_bytes: 148852
#include<iostream>
using namespace std;
int main() 
{
    int i=0; 
	int num[10]; 
	for(;i<10;i++)
	cin>>num[i]; 
	int temp=0,temp1=0,j=0,k=0; 
	for(;j<3;j++)
	 { 
	  for(i=0;i<10;i++) 
	   { 
	    temp1=temp; 
	    temp=temp<num[i]?
	    num[i]:temp;
		if(temp>temp1) 
		k=i; 
		} 
		cout<<num[k]<<endl; 
		temp=0; 
		num[k]=0; 
	 } 
	 return 0;
}

Measured memory_bytes: 1160
#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,string>;

int main(){

  int N;
  cin >> N;
  vector<int>p(N),q(N);
  
  
  rep(i,N){
    cin >> p[i];
    p[i]--;
  }
  rep(i,N){
    cin >> q[i];
    q[i]--;
  }
  
  //各順列が何番目かmapで記録する
  map<vector<int>,int> ord;
  int iter = 0;
  
  //next_permutationを使うのでスタートになる配列を用意する
  vector<int> v(N); //N個の要素
  rep(i,N)v[i] = i;
  //スタートの配列は[1,2,3...N]
  
  //map:ordはkeyが配列v,valueが何番目か
  do{
    ord[v] = iter++; //keyがvの値にiterを+1して追加
  }while(next_permutation(v.begin(),v.end()));
  //next_pemutationの処理は、配列の順列をすべて並べたときに、
  //その配列を辞書順で次のものに「置き換える」のでordのkeyは配列vでいい
  
  cout << abs(ord[p] - ord[q]) << endl;
  
}


Measured memory_bytes: 8584
#include <bits/stdc++.h>
 
using namespace std;
typedef pair<int,int> pii;
 
char board[8][8];
 
int dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};
 
int mami_dfs(int x,int y,int cnt,int idx){
  int nx=x+dx[idx],ny=y+dy[idx];
  if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]=='x'){
    cnt++;
    return mami_dfs(nx,ny,cnt,idx);
  }
  else if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]=='o'){
    return cnt;
  }
  else if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]=='.'){
    return 0;
  }
  return 0;
}
 
int magi_dfs(int x,int y,int cnt,int idx){
  int nx=x+dx[idx],ny=y+dy[idx];
  if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]=='o'){
    cnt++;
    return magi_dfs(nx,ny,cnt,idx);
  }
  else if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]=='x'){
    return cnt;
  }
  else if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]=='.'){
    return 0;
  }
  return 0;
}
 
int mami_count(int x,int y){//(x,y)???????????????¨??????????????????°
  int res=0;
  for(int i=0;i<8;i++) res+=mami_dfs(x,y,0,i);
  return res;
}
 
int magi_count(int x,int y){//(x,y)???????????????¨??????????????????°
  int res=0;
  for(int i=0;i<8;i++) res+=magi_dfs(x,y,0,i);
  return res;
}
 
int mami_solve(){//????????????????????????¶???
  int ma=-1,x,y;
  for(int i=0;i<8;i++)for(int j=0;j<8;j++){
    if(board[i][j]=='.' && mami_count(i,j)>ma){
      ma=mami_count(i,j);
      x=i;y=j;
    }
  }//??????§??????????????????´???
  if(ma<1) return false;
  board[x][y]='o';
  for(int i=0;i<8;i++){
    int tmp=mami_dfs(x,y,0,i);
    for(int j=1;j<=tmp;j++){
      board[x+dx[i]*j][y+dy[i]*j]='o';
    }
  }
  return true;
}
 
bool magi_solve(){//????????????????????????¶???
  int ma=-1,x,y;
  for(int i=7;i>=0;i--)for(int j=7;j>=0;j--){
    if(board[i][j]=='.'&&magi_count(i,j)>ma){
      ma=magi_count(i,j);
      x=i;y=j;
    }
  }//??????§??????????????????´???
  if(ma<1) return false;
  board[x][y]='x';
  for(int i=0;i<8;i++){
    int tmp=magi_dfs(x,y,0,i);
    for(int j=1;j<=tmp;j++){
      board[x+dx[i]*j][y+dy[i]*j]='x';
    }
  }
  return true;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  for(int i=0;i<8;i++)for(int j=0;j<8;j++) cin>> board[i][j];
  bool mami_flag=true,magi_flag=true;
  while(mami_flag || magi_flag){
    mami_flag=mami_solve();
    magi_flag=magi_solve();
  //  cout<<mami_flag<<" "<<magi_flag<<endl;
  }
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      cout<< board[i][j];
    }
    cout<<endl;
  }
}

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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        for(int j=i+1;j<s.size();j++){
            if(s[i] == s[j]){
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int ans = 0;
	vector<int> d(5, 0), t(5, 0);
	for (int i = 0; i < 5; i++) {
		cin >> d.at(i);
	}
	for (int i = 0; i < 5; i++) {
		ans += d.at(i) / 10 * 10;
	}
	for (int i = 0; i < 5; i++) {
		t.at(i) = d.at(i) % 10;
	}
	int count = 0;
	for (int i = 0; i < 5; i++) {
		if (t.at(i) == 0) {
			count++;
		}
	}
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	for (int i = 0; i < count; i++) {
		t.pop_back();
	}
	for (int i = 0; i < t.size(); i++) {
		if (i + 1 == t.size()) {
			ans += t.at(i);
			break;
		}
		ans += 10;
	}
	cout << ans << endl;
	system("pause");
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
int main( void ){
	// initialize();
	int A, B;
	cin >> A >> B;
	rep(i,1,1001){
		int a = floor(0.08*i), b = floor(0.1*i);
		if (a < 1 || b < 1)
			continue;
		if (a == A && b  == B){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 256
n=int(input())
s=input()
li=[]
w,e=0,0
wli,eli=[],[]
ans=[]

for i in range(n):
    if s[i]=="W":
        w+=1
    wli.append(w)
for i in reversed(range(n)):
    if s[i]=="E":
        e+=1
    eli.append(e)
for i in range(n):
    if i!=0 and i!=n-1:
        ans.append(wli[i-1]+eli[n-i-2])
    elif i==0:
        ans.append(eli[n-2])
    elif i==n-1:
        ans.append(wli[n-2])

print(min(ans))

Measured memory_bytes: 29720
# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools

# 標準入力を取得
N = int(input())

# 結果出力
ans = "No"
for i, j in itertools.product(range(1, 10), range(1, 10)):
    n = i * j
    if n == N:
        ans = "Yes"
        break

# 結果出力
print(ans)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
int n,a[200];
int main(){
	int i,j;
	cin>>n;
	for(i=1,a[0]=-1;i<=n;i++)cin>>a[i];
	for(i=1,j=0;i<=n;i++){
		if(a[i]==a[i-1]){
			a[i]=-1;
			j++;
		}
	}
	cout<<j<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(void) {
	int x, y;
	while (cin>>x>>y && (x!=0 || y!=0))
	{
		for (int i = 0; i < x; i++) {
			for (int j = 0; j < y; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 3080
#include<stdio.h>
int main(){

  int A,B,C,mid,result;

  scanf("%d %d %d",&A,&B,&C);

  if(A>B){
    mid=A;
    A=B;
    B=mid;
  }
  if(B>C){
    mid=B;
    B=C;
    C=mid;
  }
  if(A>B){
    mid=A;
    A=B;
    B=mid;
  }//A<B<Cにソート

  result=C-B;
  if((C-(A+result))%2==0)
    result+=(C-(A+result))/2;
  else
    result+=(C-(A+result))/2+2;

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

  return 0;
}


Measured memory_bytes: 128
import sys
import bisect
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ls = [i * 400 - 1 for i in range(1, 9)]
_set = set()
n_max = 0
for a in a_ls:
    ind = bisect.bisect_left(ls ,a)
    if ind == 8:
        n_max += 1
    else:
        _set.add(ind)
_min = len(_set) if len(_set) > 0 else len(_set) + (n_max > 0)
print(_min, len(_set) + n_max)

Measured memory_bytes: 3444
#!/usr/bin/env ruby

require 'set'

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

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

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

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

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

def get_int
  gets.chomp.to_i
end

N, K, Q = get_ints
A = []
Q.times do |i|
  A[i] = get_int
end

points = Array.new(N, 0)

A.each do |a|
  points[a - 1] += 1
end

points.each do |p|
  puts Q - p >= K ? 'No' : 'Yes'
end


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

int main(void){
    string o, e;
    cin >> o >> e;
    for (int i=0; i<o.size(); i++){
        cout << o[i];
        if (i < e.size()) cout << e[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI acos(-1.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define mod 1000000007
#define dbg(a) cout << #a << " = " << a << " ";
int main()
{
    ///freopen("input.txt","r",stdin);
    ///freopen("input15.txt","w",stdout);
    FIO;
    int n;
    cin>>n;
    vll dp(n+1);
    ll i,j;
    dp[0]=1LL;
    for(i=3; i<=n; i++)
    {
        for(j=3; j<=i; j++)
        {
            dp[i] += dp[i-j];
            dp[i] %= mod;
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 3560
#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 A, B;
    cin >> A >> B;
    if ((A == 1 && B == 2) || (A == 2 && B == 1))
    {
        cout << 3 << endl;
    } else if ((A == 1 && B == 3) || (A == 3 && B == 1))
    {
        cout << 2 << endl;
    } else
    {
        cout << 1 << endl;
    }
    
    
    
  return 0;
}


Measured memory_bytes: 256