akhauriyash/Code-Regression huggingface dataset:
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read_String_Vec();
    let B = read_String_Vec();

    let alen = A.len();
    let blen = B.len();

    if alen > blen {
        println!("GREATER");
    } else if alen < blen {
        println!("LESS");
    } else {
        let mut equal = true;
        for i in 0..alen {
            if A[i] == B[i] {
            } else {
                equal = false;
                if A[i] as u8 > B[i] as u8  {
                    println!("GREATER");
                } else {
                    println!("LESS");
                }
                break;
            }
        }
        if equal {
            println!("EQUAL");
        }
    }

}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	ll t[2],a[2],b[3];
	cin>>t[0]>>t[1]>>a[0]>>a[1]>>b[0]>>b[1];
	a[0]*=t[0];
	b[0]*=t[0];
	a[1]*=t[1];
	b[1]*=t[1];

	if((a[0]+a[1])<(b[0]+b[1]))//a[0]-b[0]+a[1]-b[1]<0
	{
		swap(a[0],b[0]);
		swap(a[1],b[1]);
	}

	ll c[2];
	c[0]=a[0]-b[0];
	c[1]=a[1]-b[1];

	if(c[0]+c[1]==0)
	{
		cout<<"infinity"<<endl;
		return 0;
	}

	if(c[0]>0)
	{
		cout<<0<<endl;
		return 0;
	}

	ll ans=0;
	if(c[0]<0)ans--;

	ans+= c[1]/(c[1]+c[0])*2;
	
	if(c[1]%(c[1]+c[0])==0)ans--;


	cout<<ans<<endl;


	


	return 0;
}

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

bool checkMM(char s[2]){
    int tmp = ((int)s[0] - 48) * 10 + ((int)s[1] - 48);

    if(tmp <= 12 && tmp > 0){
        return true;
    }
    return false;
}

int main(){
    std::string S, ans;
    std::cin >> S;
    char s1[2] = {S[0], S[1]};
    char s2[2] = {S[2], S[3]};

    bool check1 = checkMM(s1);
    bool check2 = checkMM(s2);

    if(check1 && check2){
        ans = "AMBIGUOUS";
    }
    else if(!check1 && check2){
        ans = "YYMM";
    }
    else if(check1 && !check2){
        ans = "MMYY";
    }
    else{
        ans = "NA";
    }

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  vector<ll> vec(n);
  REP(i,n) cin >> vec[i];

  ll q;
  cin >> q;
  REP(i,q){
    ll k;
    cin >> k;
    ll lb, ub;

    ll lef = -1, rig = n;
    while(rig - lef > 1){
      ll mid = (lef + rig) / 2;
      if(vec[mid] >= k) rig = mid;
      else lef = mid;
    }
    lb = rig;

    lef = -1; rig = n;
    while(rig - lef > 1){
      ll mid = (lef + rig) / 2;
      if(vec[mid] > k) rig = mid;
      else lef = mid;
    }
    ub = rig;

    cout << !!(ub-lb) <<endl;
  }

  return 0;
}




Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int N;
int main(void){
	cin >> N;
	int pret, prex, prey;
	pret = prex = prey = 0;

	for(int i=0; i<N; i++){
		int x, y, t;
		cin >> t >> x >> y;
		int difft = abs(t - pret);
		int diffx = abs(x - prex);
		int diffy = abs(y - prey);
		if(diffx + diffy > difft || (diffx + diffy) % 2 != difft % 2){
			cout << "No" << endl;
			return 0;
		}
		pret = t; prex = x; prey = y;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readInt
  val f = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val p = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray

  var ans = Int.MinValue
  val a = Array.ofDim[Int](10)

  def evaluate():Unit = {
    if(!a.forall(_ == 0)) {
      val score = 
        for(i <- 0 until n) yield {
          val itf = f(i).iterator
          val s = a./:(0)((acc, e) => {
            if((e & itf.next) == 1) acc+1
            else acc
          })
          p(i)(s)
        }
      ans = math.max(ans, score.sum)
    }
  }

  def dfs(pos:Int):Unit = {
    if(pos == 10) evaluate()
    else {
      a(pos) = 0; dfs(pos+1)
      a(pos) = 1; dfs(pos+1)
    }
  }

  dfs(0)
  println(ans)
}

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

#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; ++i)

int main() {
    int N; cin >> N;
    string S; cin >> S;
    if(N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    string ans = "Yes";
    for(int i=0; i<N/2; i++){
        if(S[i] != S[i+N/2]){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}ll a,b,l,r; string s;
int main() {
	cin >> a >> b;
	vector<ll> t(b + 10, 0);
	rep(i, a) {
		cin >> l >> r;
		t[l]++; t[r]--;
	}ll ans = 0;
	rep(i, b + 9) t[i + 1] += t[i];
	rep(i, b+10) ans = max(t[i], ans);
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define newline cout << endl;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(),v.end()
using namespace std;

template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
{
	out << '(' << p.ff << ", " << p.ss << ')';
	return out;
}

template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
{
	int l = v.size();
	for (int i = 0; i < l - 1; i++)
		out << v[i] << ' ';
	if (l > 0)
		out << v[l - 1];
	return out;
}

template <typename T> void trace(const char* name, T&& arg1) {
	cout << name << " : " << arg1 << endl;
}

template <typename T, typename ... Args> void trace(const char* names, T&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	trace(comma + 1, args ...);
}

/*Input*/
const ll rows = 1e5+10;
const ll cols = 3;
ll activity[rows][cols], dp[rows][cols];
ll n;
/*Input*/

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	clock_t tStart = clock();
	int test;
	test = 1;
	/* cin >> test; */
	while (test--) {
		cin >> n;
		for(int i = 0; i < n; i++) {
			cin >> activity[i][0];
			cin >> activity[i][1];
			cin >> activity[i][2];
		}

		for(int i = 0; i < n; i++) {
            if(i == 0) {
                dp[i][0] = activity[i][0];
                dp[i][1] = activity[i][1];
                dp[i][2] = activity[i][2];
            } else {
                dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + activity[i][0];
                dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + activity[i][1];
                dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + activity[i][2];
            }
		}

        cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";


	}
#ifdef LOCAL_DEFINE
	printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
	return 0;
}








Measured memory_bytes: 8240
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N, A, x;
      cin >> N >> A;
      x = N % 500;
        if(A - x >= 0){
         cout << "Yes" << endl;
        }
            else{
              cout << "No" << endl;
            }
    }
      

Measured memory_bytes: 256
/*input
52
RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn
RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn

*/
#include <bits/stdc++.h>
#define ll long long int
#define lld long double
using namespace std;
#define mod 1000000007
int main(){
	ios::sync_with_stdio(false);
	int n;cin>>n;
	string str1,str2;
	cin>>str1>>str2;
	ll ans=1;int i;int dp[100001]={0};
	if(str1[0]==str2[0]){
		ans=3;
		i=1;
		dp[0]=1;
	}
	if(str1[0]==str1[1]){
		ans=6;
		i=2;
		dp[1]=2;
	}
	for(;i<n;){
		//cout<<ans<<" "<<i<<endl;
		if(str1[i]==str2[i]){
			if(dp[i-1]==1){
				ans=((ans%mod)*(2%mod))%mod;
				dp[i]=1;
			}
			if(dp[i-1]==2){
				ans=((ans%mod)*(1%mod))%mod;
				dp[i]=1;
			}
			i++;
		}
		else if(str1[i]==str1[i+1]){
			if(dp[i-1]==1){
				ans=((ans%mod)*(2%mod))%mod;
				dp[i+1]=2;
			}
			if(dp[i-1]==2){
				ans=((ans%mod)*(3%mod))%mod;
				dp[i+1]=2;
			}
			i+=2;
		}
	}
	cout<<ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int n,p[100],m=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&p[i]);
	for(int i=2;i<=n-1;i++)
	{
		if(p[i]>p[i-1]&&p[i]<p[i+1]||p[i]<p[i-1]&&p[i]>p[i+1])
		m++;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

class P
{
    static void Main()
    {
        var hw = Console.ReadLine().Split().Select(int.Parse).ToList();
        var ab = Console.ReadLine().Split().Select(int.Parse).ToList();
        Console.WriteLine(hw[0] * hw[1] - (((hw[0] / ab[0]) * ab[0]) * ((hw[1] / ab[1]) * ab[1])));
    }
}



Measured memory_bytes: 18404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

typedef pair<int, int> Range;
typedef pair<Range, int> Record;

struct Comp {
	bool operator() (Range a, Range b) {
		return a.first > b.first;
	}
};

int main()
{
	while (1)
	{
		int n; cin >> n;
		if (n == 0) return 0;

		priority_queue<Range, vector<Range>, Comp> empty;
		empty.push(Range(0, INF));

		set<Record> used;

		rep(i, 0, n)
		{
			char c; cin >> c;
			int l, S, P;
			set<Record> eraselist;

			switch (c)
			{
			case 'W':
				cin >> l >> S;
				while (0 < S)
				{
					Range r = empty.top(); empty.pop();
					int range_len = r.second - r.first + 1;
					if (S < range_len)
					{
						empty.push(Range(r.first + S, r.second));
						used.insert(Record(Range(r.first, r.first + S - 1), l));
					}
					else
					{
						used.insert(Record(Range(r.first, r.second), l));
					}
					S -= range_len;
				}
				break;

			case 'D':
				cin >> l;
				eraselist.clear();
				for (auto p : used)
				{
					if (p.second == l)
					{
						empty.push(p.first);
						eraselist.insert(p);
					}
				}
				for (auto p : eraselist) used.erase(p);
				break;

			case 'R':
				cin >> P;
				int ret = -1;
				for (auto p : used)
				{
					if (p.first.first <= P && P <= p.first.second) ret = p.second;
				}
				cout << ret << endl;
				break;
			}

			//printf("w");
		}
		cout << endl;
	}
}

Measured memory_bytes: 3476
# -*- coding: utf-8 -*-
def CountingSort(A, k):
    count = [0] * k
    offset = [0] * k
    for x in A:
        count[x] += 1
    offset[0] = 0
    for i in xrange(1, k):
        offset[i] = offset[i-1] + count[i-1]

    R = [0] * len(A)
    for i in xrange(len(A)):
        target = A[i]
        R[offset[target]] = target
        offset[target] += 1
    return R

n = int(raw_input())
A = map(int, raw_input().split())
B = CountingSort(A, 10000)
print ' '.join(map(str, B))

Measured memory_bytes: 202168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N, long long x, std::vector<long long> a)
{
    SORT(a);
    ll tmp = x;
    ll ans = 0;
    for (size_t i = 0; i < N; i++)
    {
        x -= a[i];
        if (x < 0)
        {
            break;
        }
        else
        {
            if (i == N - 1)
            {
                if(x==0)
                    ans++;
            }
            else
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long x;
    scanf("%lld", &x);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(N, x, std::move(a));
    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define f(i,a, b) for (int i = a; i < b; i++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ld float
#define fd(i,a, b) for (ll i = a; i >= b; i--)

 /*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
     typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
bool chk(string ss){

   int sz=ss.size();
   f(i,0,sz/2)if(ss[i]!=ss[sz-1-i])return false;
   return true;

}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  int n;
  cin>>n;
  ll aa[n];
  ll cnt[n+1]={0};
    f(i,0,n) { cin>>aa[i];  cnt[aa[i]]++; }

    ll sm=0;
    f(i,0,n+1){
      ll val=(cnt[i]*(cnt[i]-1));
      sm+=(val/2);
    }

    f(i,0,n){

      cout<<sm-cnt[aa[i]]+1<<endl;

    }



}


Measured memory_bytes: 5760
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> y(N);
  vector<int> x;
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    int X;
    cin >> X;
    x.emplace_back(X);
    y[i] = x[i];
  }

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

  for (int i = 0; i < N; i++) {
    auto l = lower_bound(y.begin(), y.end(), x[i]);
    size_t pos = distance(y.begin(), l);
    if (pos <= (N - 1) / 2)
      cout << y[(N - 1) / 2 + 1] << endl;
    else
      cout << y[(N - 1) / 2] << endl;
  }
  return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N,K;
    cin >> N>>K;
    vector<int> vec(N);
    vector<int> vec2(N+1-K);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

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

    for (int i = 0; i < N-K+1; i++) {
        vec2.at(i) = vec.at(i + K - 1) - vec.at(i);
    }
    sort(vec2.begin(), vec2.end());
    cout << (vec2.at(0)) << endl;
}

Measured memory_bytes: 1024
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
/*#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);
#endif*/
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e6 + 15;
int dx[8] = { -1, 0, 0, 1, 1, -1, 1, -1 };
int dy[8] = { 0, -1, 1, 0, 1, -1, -1, 1 };

int main()
{
	fast();
	int n, l;
	cin >> n >> l;
	map<int, int> mp;
	for (int i = 0; i < l; i++)
	{
		int x;
		cin >> x;
		mp[x]++;
	}
	while (1)
	{
		int x = n;
		bool f = 0;
		while (x>0)
		{
			if (mp[x % 10])
			{
				f = 1;
				break;
			}
			x /= 10;
		}
		if (!f)
		{
			cout << n << endl;
			break;
		}
		n++;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

a,b=map(int,input().split())

for i in range(100000):
    tmp=int(i*0.08)
    tmp2=int(i*0.1)
    if a==tmp and b==tmp2:
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 65388
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

bool solve() {
    int a = 0, b = 0, c = 0;
    for (char v : s) {
        switch(v) {
        case 'a': a++; break;
        case 'b': b++; break;
        case 'c': c++; break;
        }
    }

    int m = max(a, max(b, c));
    return m-a<=1 && m-b<=1 && m-c<=1;
}

void input() {
    cin >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

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


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

    ll res = 0;
    for (ll i = 1; i <= n; ++i) {
        if (i % 3 > 0 && i % 5 > 0) res += i;
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, Q;
string S;
char T[212345], D[212345];

bool check(int pos) {
	REP(i, Q) if (S[pos] == T[i]) {
		pos = pos + (D[i] == 'R' ? 1 : -1);
		if (pos < 0 || pos >= N) break;
	}
	return pos < 0;
}

int solve() {
	// [l, r) 落ちる最右を知りたい
	if (!check(0)) return -1;
	
	int l = 0, r = N;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (check(m)) l = m;
		else r = m;
	}
	return l;
}

int main() {
	cin >> N >> Q;
	cin >> S;
	
	REP(i, Q) {
		string t, d;
		cin >> t >> d;
		T[i] = t[0];
		D[i] = d[0];
	}
	
	int p = solve();
	reverse(ALL(S));
	REP(i, Q) D[i] = (D[i] == 'R' ? 'L' : 'R');
	int q = N - solve() - 1;
	
	int ans = q - p - 1; // 必ずp < q, 反対側で先に落ちる場合落ちないと判定されるため
	cout << ans << endl;
	
	return 0;
}


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

#define ll long long 
ll A, B, N;

ll ok(ll m) {
    ll a = A * 1.0 * m / B;
    ll b = A * (long long)(m * 1.0 / B);
    // cout << "( " << a - b << endl;
    return (a - b);
}

int main() {

    cin >> A >> B >> N;
    ll l = 0, r = B;
    ll m = min(B - 1, N);
    ll ans = ok(m);
    cout << ans << endl;

}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

void solve(){
    string S; cin >> S;
    int a[26] = {0};
    for(auto c:S) a[c-'a']++;
    if(S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl; return;
    }
    
    string ans(26,'z');
    for(int i = 0; i < 26;i++){
        if(a[i] == 0){
            char c = i + 'a';
            ans = min(ans,S+c);
        }
    }
    for(int i = (int)S.length()-1;i>=0;i--){
        int x = S[i] - 'a';
        for(int j = x+1; j < 26;j++){
            if(a[j] == 0){
                char c = j + 'a';
                ans = min(ans,S.substr(0,i)+c);
                break;
            }
        }
        a[x]--;
    }
    cout << ans << endl;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

long long int dpe[110][110],dpn[110][110],dpem[110][110],dpnm[110][110];

int main(){
	int W,H;
	while(1){
		cin>>W>>H;
		if(W==0&&H==0) break;

		for(int i=0;i<=W;i++){
			for(int j=0;j<=H;j++){
				dpe[i][j]=dpn[i][j]=dpnm[i][j]=dpem[i][j]=0;
			}
		}
		
		for(int i=1;i<=W;i++){
			for(int j=1;j<=H;j++){
				if(i!=1||j!=1){
					dpe[i][j]=dpe[i-1][j]+dpem[i-1][j];
					dpn[i][j]=dpn[i][j-1]+dpnm[i][j-1];
					dpem[i][j]=dpn[i-1][j];
					dpnm[i][j]=dpe[i][j-1];
				}
				else{
					dpe[i][j]=dpn[i][j]=0;
					dpem[i][j]=dpnm[i][j]=1;
				}
				dpe[i][j]%=100000;
				dpem[i][j]%=100000;
				dpn[i][j]%=100000;
				dpnm[i][j]%=100000;
			}
		}
		cout<<(dpe[W][H]+dpn[W][H]+dpem[W][H]+dpnm[W][H])%100000<<endl;
		/*
		for(int i=1;i<=W;i++){
			for(int j=1;j<=H;j++){
				cout<<"["<<i<<","<<j<<"]"<<" ";
				cout<<"dpe"<<dpe[i][j]<<" dpem"<<dpem[i][j]<<" dpn"<<dpn[i][j]<<" dpnm"<<dpnm[i][j]<<" ";
			}
			cout<<endl;
		}
		*/
		
	}
	return 0;
}

Measured memory_bytes: 1512
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	string s;
	cin >> s;
	cout << (s == "ABC" ? "ARC" : "ABC");
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 3640
#include<algorithm>
#include<typeinfo>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#define eps 0.01
#define pi acos(-1)
#define e exp(1)
using namespace std;
typedef long long ll;
string s;
int main() {
    while (cin >> s) {
        int cnt = 0;
        for (int i = 0; s[i]; ++i) {
            if (s[i] == '+')
                cnt++;
            else
                cnt--;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		uf d=new uf(s[0]+1);
		uf t=new uf(s[0]+1);
		for(int i=0;i<s[1];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			d.union(q[0],q[1]);
		}
		for(int i=0;i<s[2];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			t.union(q[0],q[1]);
		}
		var hs=new Dictionary<string,int>();
		for(int i=1;i<=s[0];i++){
			if(hs.ContainsKey(d.root(i)+" "+t.root(i))){hs[d.root(i)+" "+t.root(i)]++;}
			else{hs.Add(d.root(i)+" "+t.root(i),1);}
		}
		Console.Write("{0}",hs[d.root(1)+" "+t.root(1)]);
		for(int i=2;i<=s[0];i++){Console.Write(" {0}",hs[d.root(i)+" "+t.root(i)]);}
		Console.WriteLine();
	}
}
public class uf{
	private int[] arr;
	private int[] hi;
	public uf(int n){
		arr=new int[n];
		hi=new int[n];
		for(int i=0;i<n;i++){arr[i]=-1;}
	}
	public void union(int a,int b){
		a=root(a);
		b=root(b);
		if(a!=b){
			if(hi[a]<hi[b]){
				int v=b;
				b=a;
				a=v;
			}
			arr[a]+=arr[b];
			hi[a]=Math.Max(hi[a],hi[b]+1);
			arr[b]=a;
		}
	}
	public bool same(int a,int b){return root(a)==root(b);}
	public int root(int a){return arr[a]<0?a:arr[a]=root(arr[a]);}
}

Measured memory_bytes: 41392
#include<stdio.h>
#include<string.h>
int main(void){
    char c[10000];
    int i, Jcount, Icount;
    while ( scanf("%s", c) != EOF ){
        Jcount = Icount = 0;
        for ( i = 0; i < strlen(c) - 2; i++ ) {
            if ( c[i] == 'J' && c[i + 1] == 'O' && c[i + 2] == 'I' ) Jcount++;
            if ( c[i] == 'I' && c[i + 1] == 'O' && c[i + 2] == 'I' ) Icount++;
        }
        printf("%d\n%d\n", Jcount, Icount);
    }
    return 0;
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
using namespace std;
const long long M=1000000007;
long long se[3];
int main(){
	long long sum=1;
	long long n;
	cin >>n;
	for(long long i=1;i<=n;i++){
		long long a;
		cin >> a;
		long long t=0;
		for(long long j=0;j<=2;j++){
			if(se[j]==a)
			t++;
		}
		sum=(sum*t)%M;
		for(long long j=0;j<=2;j++){
			if(se[j]==a){
				se[j]++;
				break;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
    cout << a << "\n";
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	// source code
    string s;
    cin >> s;
    if(s=="Sunny")
        cout << "Cloudy" << endl;
    else if (s=="Cloudy")
        cout << "Rainy" << endl;
    else 
        cout << "Sunny" << endl;

	return 0;
}


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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
}

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
  long long n;
  cin>>n;

  long double res=0;

  for(int i=1;i<=n;i++){

    long double item;
    cin>>item;

    res+=(long double)1.00/item;
  }

  debug(res);

  res=(long double)1.00/res;

  cout<<res<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
N,X = gets.chomp.split(" ").map(&:to_i)
M = []
for i in 1..N
  M.push(gets.chomp.to_i)
end
m_sum = M.inject(:+)
flag = X - m_sum
if flag > 0
  M.sort!
  max = N + (flag/M[0])
end
if flag == 0
  max = N
end

print(max)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    ll ans = 0;
    bool z = true;
    while (z){
        z = false;
        bool z1 = false;
        rep(i, n){
            if(h[i]==0&&z1){
                ans++;
                z1 = false;
            }
            else if(h[i]==0&&!z1)continue;
            else if(h[i]!=0&&i==n-1){
                h[i]--;
                z = true;
                ans++;
            }
            else{
                z = true;
                z1 = true;
                h[i]--;
            }
        }
    }
    print(ans);
}

Measured memory_bytes: 256
import math

s=input().split()
for i in range(len(s)):
    s[i]=int(s[i])
a,b,h,m=s[0],s[1],s[2],s[3]
if(h>12):h-=12

radh=h/12*360+m/2;
radm=m*6;
radh=radh/180*math.pi
radm=radm/180*math.pi

theta=abs(radh-radm)
ans=math.sqrt(a*a+b*b-2*a*b*math.cos(theta))
print(ans)


Measured memory_bytes: 9440
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b; cin >> a >> b;
	int x, y, z;
	int ans = max({ a + b,a - b,a*b });
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  string s;
  cin >> s;
  int k = 0, ans = 0;
  rep(i, 0, s.length()) {
    if(s[i] == 'B') k++;
    else {
      ans += k;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 848
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
    long long int L,R;
    scanf("%lld %lld",&L,&R);
    if(R-L>3000){
        printf("0\n");
    }else{
        //L=L%2019;
        //R=R%2019;
        long long int min=2018;
        for(long long int i=L;i<R;i++){
            for(long long int j=L+1;j<R+1;j++){
                if(min > ((i*j)%2019))min=((i*j)%2019);
            }
        }
        printf("%d",min);
    }

}

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

using namespace std;

int P,N[6];
const int coin[6] = {1,5,10,50,100,500};

int calc(int x){
  int res = 0;
  for(int i = 5 ; i >= 0 ; i--){
    if(x >= coin[i]){
      res += x/coin[i];
      x %= coin[i];
    }
  }
  return res;
}

int c(int x){
  int res = 0;
  for(int i = 5 ; i >= 0 ; i--){
    int use = x/coin[i];
    if(use > N[i]){
      res += N[i];
      x -= N[i]*coin[i];
    }else{
      res += use;
      x %= coin[i];
    }
  }
  return res;
}

int main(){
  while(cin >> P){
    int end = P;
    for(int i = 0 ; i < 6 ; i++){
      cin >> N[i];
      end += N[i];
    }
    if(end == 0){ break; }
    int res = (1<<29);
    for(int i = P ; i <= P+500 ; i++){
      int x = c(i);
      res = min(res,x+calc(i-P));
    }
    cout << res << endl;
  }
  return 0;
}

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

int main(){
  int n;
  cin>> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  int ans=0;
  for(int i=2;i<n;i++){
    int mi=min(p.at(i-2),min(p.at(i-1),p.at(i)));
    int ma=max(p.at(i-2),max(p.at(i-1),p.at(i)));
    if(!((p.at(i-1)==mi)||(p.at(i-1)==ma))){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int A[3];
	for (int i = 0; i < 3; ++i) scanf("%d", A + i);
	sort(A, A + 3);
	printf("%d\n", A[0]*A[1] >> 1);
	return 0;
}

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

const int maxn=(int)1e5;
const int inf=(int)1e9+696969;
int dp[maxn+10];

int main()
{
	int n,w;
	scanf("%d %d",&n, &w);
	for(int i=1;i<=maxn;i++)
		dp[i]=inf;
	while(n--)
	{
		int a,b;
		scanf("%d %d",&a, &b);
		for(int i=maxn;i>=b;i--)
			dp[i]=min(dp[i],dp[i-b]+a);
	}
	for(int i=maxn;i>=0;i--)
		if(dp[i]<=w)
			{ printf("%d",i); return 0; }
}

Measured memory_bytes: 640
N = int(input())

result = False
count = 0

for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        count += 1
    else:
        count = 0

    if count > 2:
        result = True
        break

if result:
    print('Yes')
else:
    print('No')


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

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

int s=0,t=0;
for(int i=0;i<b;i++){
  s=s*10+a;
}
for(int i=0;i<a;i++){
  t=t*10+b;
}
string S=to_string(s),T=to_string(t);
cout<<min(S,T)<<endl;
}


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

int kaijo(int n){
    int i;
    int sum=1;
    for(i=1; i<=n; i++){
        sum =sum*i;
    }
    return sum;
}

int main(void){
    int n;
    cin >>n;
    int i,j;
    double x[n],y[n];
    for(i=0; i<n; i++){
        cin >> x[i] >> y[i];
    }
    double L=0;
    for(i=0; i<n-1; i++){
        for(j=i+1; j<n; j++){
            L+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    
    int k;
    k=kaijo(n);
    int a;
    a=kaijo(n-1);
    double ans;
    ans=L*a*2/k;
    
    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 384
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    int tm = (n - m) * 100 + m * 1900;
    cout << tm * (1 << m);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

signed main()
{
  cout << fixed << setprecision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  priority_queue<double, vector<double>, greater<double>> que;
  for (int i = 0; i < n; ++i) {
    int v;
    cin >> v;
    que.emplace(v);
  }

  while (que.size() != 1) {
    auto p = que.top(); que.pop();
    auto q = que.top(); que.pop();

    que.emplace((p + q) / 2.0);
  }

  cout << que.top() << '\n';
  que.pop();

  return (0);
}


Measured memory_bytes: 3836
n, m = list(map(int,input().split()))
h = list(map(int,input().split()))
flags = [1]*n
for i in range(m):
    a, b = list(map(int,input().split()))
    if h[a-1] > h[b-1]:
        flags[b-1] = 0
    elif h[a-1] < h[b-1]:
        flags[a-1] = 0
    else:
        flags[a-1] = 0
        flags[b-1] = 0
print(sum(flags))

Measured memory_bytes: 20116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
ll a[N],b[N],num[N];
int x[100][100];
int n,m,k;
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    for(int i=1; i<=n; i++)
    {
        if(i%2==1)
            b[1]+=a[i];
        else
            b[1]-=a[i];
    }
    for(int i=2;i<=n;i++)
	{
		b[i]=2*a[i-1]-b[i-1];
	}
	 for(int i=1;i<=n;i++)
	{
		cout<<b[i]<<" ";
	}
	
 
    
    return 0;
}

Measured memory_bytes: 5300
from collections import Counter

N, P = map(int, input().split())

def Primefac(N):
    x = []
    while N % 2 == 0:
        N //= 2
        x.append(2)     
    i = 3
    while i * i <= N:
        if N % i == 0:
            N //= i
            x.append(i)
        else:
            i += 2
    if N != 1:
        x.append(N)
    return x

a = list(Counter(Primefac(P)).items())

ans = 1
for i in range(len(a)):
    if a[i][1] // N >= 1:
        ans *= (a[i][0] ** (a[i][1] // N))
        
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


int main(){
    double N;cin>>N;
    int min=floor(N/1.08);
    int max=ceil(N/1.08);
    for(int i=min;i<=max;i++){
        if(floor(i*1.08)==N){
            cout<<i<<endl;return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int N;
ll A[200005];
ll B[200005];
ll C[200005];
ll D[35];

//! under以上になる最小のindex
inline int getUnder(ll under)
{
    if (under <= 0)
        return 0;
    int ok = N, ng = -1;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (C[mid] >= under)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    return ok;
}
//! top未満になる最大のindex
inline int getTop(ll top)
{
    int ok = -1, ng = N;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (C[mid] < top)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    return ok;
}

int main()
{
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N)
    {
        cin >> B[i];
    }
    REP(i, 30)
    {
        D[i] = 0;
        ll u = pow((ll)2, i);
        ll t = pow((ll)2, (i + 1));
        REP(j, N)
        {
            C[j] = (B[j] % t);
        }
        sort(C, C + N);
        REP(j, N)
        {
            ll a = A[j] % t;
            {
                int ui = getUnder(u - a);
                int ti = getTop(t - a);
                if (ui <= ti)
                {
                    D[i] += (ti - ui + 1);
                }
            }
            {
                int ui = getUnder(u + t - a);
                int ti = getTop(2 * t - a);
                if (ui <= ti)
                {
                    D[i] += (ti - ui + 1);
                }
            }
        }
    }

    ll ans = 0;
    REP(i, 30)
    {
        ans |= ((D[i] % 2) << i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))
ans = 1
l = 1000000000000000000
for i in range(n):
  if a[i] == 0:
    ans = 0
    break
if ans < 1:
  print(ans)
  exit()
for i in range(n):
  ans *= a[i]
  if ans > l:
    ans = -1
    break
print(ans)

Measured memory_bytes: 21532
package main

import "fmt"

func main() {
	var n, ma, mb int
	fmt.Scanf("%d %d %d", &n, &ma, &mb)

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	var abMax, cMax int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d", &a[i], &b[i], &c[i])

		if a[i] > abMax {
			abMax = a[i]
		}

		if b[i] > abMax {
			abMax = b[i]
		}

		if c[i] > cMax {
			cMax = c[i]
		}
	}

	// Initialize.
	dp := make([][][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([][]int, n*abMax+1)
		for j := 0; j < n*abMax+1; j++ {
			dp[i][j] = make([]int, n*abMax+1)
			for k := 0; k < n*abMax+1; k++ {
				dp[i][j][k] = n*cMax + 1
			}
		}
	}

	dp[0][0][0] = 0

	for i := 0; i < n; i++ {
		for ca := 0; ca < n*abMax+1; ca++ {
			for cb := 0; cb < n*abMax+1; cb++ {
				if dp[i][ca][cb] == n*cMax+1 {
					continue
				}

				dp[i+1][ca][cb] = selectMin(dp[i+1][ca][cb], dp[i][ca][cb])
				dp[i+1][ca+a[i]][cb+b[i]] = selectMin(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i])
			}
		}
	}

	ans := n*cMax + 1
	for ca := 1; ca < n*abMax+1; ca++ {
		for cb := 1; cb < n*abMax+1; cb++ {
			if ca*mb == cb*ma {
				ans = selectMin(ans, dp[n][ca][cb])
			}
		}
	}

	if ans == n*cMax+1 {
		ans = -1
	}

	fmt.Println(ans)
}

func selectMin(x, y int) int {
	if x < y {
		return x
	}

	return y
}

Measured memory_bytes: 59520