akhauriyash/Code-Regression huggingface dataset:
/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a%(MOD-7);
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

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

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

pair<int,int> has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=MOD;
		h2*=bases[1];
		h2+=a-'a';
		h2%=MOD2;
	}
	return make_pair(h1,h2);
}

const int N=300010;
int n,h[N],r;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	srand((long long)new char);
	for (int i=0;i<10;++i) bases.push_back(raand()+13893829);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i];
	for (int i=1;i<n;++i) if (h[i]==h[i-1]) h[i]=MOD,++r;
	cout<<r;
}


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

result = 0
moji = {}
for i in range(N):
    val = str(sorted(str(input())))
    if (val in moji):
        moji[val].append(i)
    else:
        moji[val] = [i]

result = 0
for val in moji.values():
    result += int((len(val)*(len(val)-1))/(2))

print(result)

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

ll a[1234567];

int main()
{
   ll n,cur,c=0,i;
   cin>>n>>cur;
   for(i=0; i<n; i++)
   {
       cin>>a[i];
       if(a[i]>=cur)c++;

   }
   cout<<c<<endl;

}


Measured memory_bytes: 1024
from collections import Counter
import math
div = 10**9 + 7

def pf(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n , m = map(int,input().split())
a = Counter(pf(m))

ans = 1
for i in a:
    temp = math.factorial(a[i] + n - 1 ) // ( math.factorial(a[i]) * math.factorial(n-1) )
    ans = ans * temp % div
    
print(ans)

Measured memory_bytes: 114396
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, K] = nextIntArray()
    const a = nextIntArray()
    let map = {}
    for(let el of a){
        if(!map[el]) map[el] = 1
        else map[el]++
    }
    let vals = Object.values(map)
    vals.sort((a,b)=>a-b)
    let cnt = 0
    for(let i = 0; i<vals.length-K;i++){
        cnt += vals[i]
    }
    console.log(cnt)
}
Main()


Measured memory_bytes: 61920
nums = $stdin.read.split(" ")
nums.map! do |element|
	element.to_i
end
q=nums[1]
#p nums
nums.shift(2)
nums.sort!
#p nums
target = nums.last(q)
#p target
sum = 0
target.each do |length|
	sum += length
end
p sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn =300050 ;
typedef long long ll;

int l[maxn], r[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    string st2;
    cin>>st2;
    string st=" ";
    st += st2;
    l[0] = 0;
    l[st.size()+1] = 0;

    for(int i=1;  i<=st.size(); i++)
    {
        if(st[i]=='E')
        {
            l[i] = l[i-1] + 1;
        }
        else
            l[i] = l[i-1];
    }
    for(int i=st.size(); i>0; i--)
    {
        if(st[i]=='W')
        {
            r[i] = r[i+1] + 1;
        }
        else
            r[i] = r[i+1];
    }
    /*for(int i=1;i<=st.size();i++)
        cout<<l[i]<<' '<<r[i]<<endl;*/
    int ans = inf;
    for(int i=1; i<=st.size(); i++)
    {
        int cnt =max(0, i-1 - l[i-1]);
        int cnt2 =  st.size()-i-1-r[i+1];
    cnt2 = max(0,cnt2);
        ans = min(ans,cnt+cnt2);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3332
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t,dp[1005][1005],us[5005][5005];
lo cev;
string s;
vector<lo> v;

inline lo mul(lo x,lo y){
	return (x%mod)*(y%mod)%mod;
}

inline lo add(lo x,lo y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

inline lo fp(lo x,lo y){
	if(y==0)return 1;
	if(y==1)return x%mod;
	lo q=fp(x,y/2);
	q=mul(q,q);
	if(y%2==1)q=mul(q,x);
	return q%mod;
}

inline lo f(lo sira,lo candy){
	lo cevv=0;
	if(candy>k)return 0;
	if(sira>n){
		if(candy==k)return 1;
		return 0;
	}
	if(~dp[sira][candy])return dp[sira][candy];
	for(lo i=0;i<=k-candy;i++){
		cevv=add(cevv,mul(f(sira+1,candy+i),us[b[sira]][i]-us[a[sira]-1][i]));
	}
	return dp[sira][candy]=cevv;
}

int main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%lld %lld",&n,&k);
	for(int i=0;i<=405;i++){
		for(int j=0;j<=405;j++){
			if(i>0)
				us[i][j]=fp(i,j)+us[i-1][j];
			else us[i][j]=fp(i,j);
		}
	}
	FOR{
		scanf("%lld",&a[i]);
	}
	FOR{
		scanf("%lld",&b[i]);
	}
	printf("%lld\n",f(1,0));
	return 0;
}


Measured memory_bytes: 27264
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
Y=[]
for i in range(1,M):
  Y.append(X[i]-X[i-1])

Y.sort()
ikanai = sum(Y[M-1-(N-1):M-1])
#print(Y)
#print(ikanai)

if N>=M:
  print(0)
else:
  print(X[-1]-X[0]-ikanai)

Measured memory_bytes: 13960
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>

using namespace std;

int main() {
	int n;
	while (true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		if (n == 1) {
			cout << 1 << endl;
			continue;
		}
		int i;
		int cnt = 0;
		if (n % 2 == 0) {
			i = n + 1;
		}
		else {
			i = n + 2;
		}
		for (; i <= 2 * n; i += 2) {
			int flag = 0;
			for (int j = 3; j < min(i,500); j++) {
				if (i % j == 0) {
					flag = 1;
					break;
				}
			}
			if (flag == 0) {
				cnt++;
			}
		}
		cout << cnt << endl;
	}

}


Measured memory_bytes: 3092
parseInt(x) = parse(Int,x)

function main()
  (N,K,Q) = map(parseInt,split(readline()))
  x = zeros(Int,N) 
  A = zeros(Int, Q)
  for i = 1:Q
    A[i] = parseInt(readline())
    x[A[i]] += 1 
  end
  for i = 1:N
    x[i] > Q-K ? println("Yes") : println("No")
  end
end

main()

Measured memory_bytes: 137248
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int all_rooms[4][3][10] = {0};

  int b, f, r, v;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    all_rooms[b - 1][f - 1][r - 1] += v;
  }

  for (int kousha = 0; kousha < 4; kousha++) {
    for (int floor = 0; floor < 3; floor++) {
      for (int room = 0; room < 10; room++) {
        cout << " " << all_rooms[kousha][floor][room];
      }
      cout << endl;
    }
    if (kousha < 3) {
      cout << "####################";
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Int32;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        label:
        WriteLine(hoge() ? "No War" : "War");
        //goto label;
    }

    static bool hoge()
    {
        var sp = ReadLine().Split();
        int x = Parse(sp[2]);
        int y = Parse(sp[3]);
        int xMax = ReadLine().Split().Select(Parse).Max();
        int yMin = ReadLine().Split().Select(Parse).Min();
        return xMax < yMin && xMax < y && x < yMin;
    }
}


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

int main() {
  int R;
  cin >> R;
  double pi = 3.1415926;
  cout << setprecision(10) << 2 * pi * R << endl;
  return 0;
}


Measured memory_bytes: 3788
#include<stdio.h>
int main(void){
	int r,c,A[101][101]={0};
	int i,j;
	
	scanf(" %d %d",&r,&c);
	for(i=0; i<r; i++) for(j=0; j<c; j++) scanf(" %d",&A[i][j]);
	for(i=0; i<r; i++) for(j=0; j<c; j++) A[i][c]=A[i][c]+A[i][j];
	for(j=0; j<=c; j++) for(i=0; i<r; i++) A[r][j]=A[r][j]+A[i][j];
	
	for(i=0; i<=r; i++){
		for(j=0; j<=c; j++){
			printf("%d",A[i][j]); 
			if(j!=c) printf(" ");
		} 
		printf("\n"); 
	}
	
	return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m; cin >> n >> m;
	int x, y; cin >> x >> y;
	cout << n * m - (y * n) - ((m - y) * x) << '\n';






}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int a,b,c,x;
	scanf("%d\n%d\n%d\n%d",&a,&b,&c,&x);
	int ans=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(500*i+100*j+50*k==x){
					ans++;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
s = inp.shift()
m = c = 0
for (i=0; i<3; i++) {
    if (s[i] == "R") {
        c++
    } else {
        c = 0
    }
    if (c > m) {
        m = c
    }
}
console.log(m)

Measured memory_bytes: 29688
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, K) = get!(u8, usize);
    let mut n = N;
    let mut v: Vec<u8> = vec![0u8; K];
    for i in 0..K {
        v[i] += 1;
        n -= 1;
    }
    v[0] += n;

    let max = v.iter().max().unwrap();
    let min = v.iter().min().unwrap();
    println!("{}", max - min);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = 0;
    REP(i,S.size()){
        int tmp = 0;
        for(int j=i;j<(int)S.size();j++){
            if(S[j] == 'A' || S[j] == 'T' || S[j] == 'G' || S[j] == 'C') tmp++;
            else{
                chmax(ans, tmp);
                tmp = 0;
            }
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
bill_count, total_money = map(int, input().split())

def search_pattern(bill_count, total_money):
  for x in range(bill_count + 1):
    for y in range(bill_count - x + 1):
      z = bill_count - x - y
      t = 10000 * x + 5000 * y + 1000 * z
      if t != total_money:
        continue
      return (x, y, z)
  return (-1, -1, -1)

answer = search_pattern(bill_count, total_money)
print(" ".join(map(str, answer)))

Measured memory_bytes: 3064
N, M = map(int, input().split())
MOD = (10**9) + 7

a = 10 ** 7 + 10 ** 6
fact = [0] * a
fact[0] = 1
for i in range(1, a):
    fact[i] = fact[i-1] * i % MOD

inv_fact = [0] * a
inv_fact[a-1] = pow(fact[a-1], MOD-2, MOD)
for i in range(a-1, 0, -1):
    inv_fact[i-1] = inv_fact[i] * i % MOD


def nCk(n, k):
    return (fact[n] * inv_fact[k] * inv_fact[n-k]) % MOD


def nPk(n, k):
    return (fact[n] * inv_fact[n-k]) % MOD


ans = 0
for i in range(N+1):
    tmp = nCk(N, i) * nPk(M, i) * (nPk(M-i, N-i))**2 % MOD
    if i % 2 == 0:
        ans += tmp
    else:
        ans -= tmp
print(ans%MOD)

Measured memory_bytes: 267928
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

struct PrimeNumber
{
    //O(sqrt(n))
    bool is_prime(long long n){
        for(long long i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return n != 1;
    }

    //O(sqrt(n))  isn't sorted
    vector<long long> divisor(long long n){
        vector<long long> res;
        for(long long i = 1; i * i <= n; i++){
            if(n % i == 0){
                res.push_back(i);
                if(i != n / i) res.push_back(n / i);
            }
        }
        return res;
    }

    //O(sqrt(n))
    map<long long, long long> prime_factor(long long n){
        map<long long, long long> res;
        for(long long i = 2; i * i <= n; i++){
            while(n % i == 0){
                n /= i;
                res[i]++;
            }
        }
        if(n != 1) res[n] = 1;
        return res;
    }

    //O(n log log n)
    map<long long, ll> eratosthenes(long long n){
        map<long long, ll> prime;
        vector<bool> is_prime(n + 1, true);
        long long p = 0;
        is_prime[0] = false; is_prime[1] = false;
        for(long long i = 2; i <= n; i++){
            if(is_prime[i]) prime[i]++;
            for(long long j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
        return prime;
    }
};

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll Q; cin >> Q;
    PrimeNumber num;
    map<ll, ll> primes = num.eratosthenes(100000);

    vector<ll> like_2017(100000);
    vector<bool> is_like_2017(100000, false);
    ll count = 0;
    
    for(ll i = 1; i <= 100001; i += 2){
        if(primes.count(i) >= 1 && primes.count((i+1) / 2) >= 1){
            count++;
            like_2017[i] = count;
            is_like_2017[i] = true;
        }else{
            like_2017[i] = count;
        }
    }

    rep(q, Q){
        ll l, r; cin >> l >> r;
        if(l == r){
            cout << like_2017[r] - like_2017[l] + is_like_2017[l] << endl;
        }else{
            cout << like_2017[r] - like_2017[l] + is_like_2017[l] << endl;
        }
    }
    

}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		if (k < n) {
			System.out.println(x * k + y * (n - k));
		} else {
			System.out.println(x * n);
		}


		sc.close();

	}

}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin >> a[i];

    for(int i=0;i<n;i++){
        for(int j=i-1;j>=0;j--){
            if(a[j]>a[j+1])swap(a[j],a[j+1]);
        }
        for(int j=0;j<n;j++){
            cout << a[j];
            cout << (j!=n-1?" ":"\n");
        }
    }
}



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

#define MAX 100000
#define INFTY (1 << 30)

/*
4
0 1 2
1 2 1
1 3 3
*/

class Edge {
public:
    int target, weight;
    Edge() { }
    Edge(int _target, int _weight):target(_target), weight(_weight) { }
};

std::vector<Edge> G[MAX];
int n, d[MAX];

bool visited[MAX];
int cnt;


void bfs(int s) {
    for (int i = 0; i < n; i++) { d[i] = INFTY; }
    std::queue<int> Q;
    Q.push(s);

    d[s] = 0;

    int u;

    while( !Q.empty() ) {
        u = Q.front(); Q.pop();

        for (unsigned long i = 0; i < G[u].size(); i++) {
            Edge e = G[u][i];
            if (d[e.target] == INFTY) {
                d[e.target] = d[u] + e.weight;
                Q.push(e.target);
            }
        }
    }
}

void solve() {
    bfs(0); //find longest path from root

    int maxv = 0;
    int tgt = 0; //index of furtest node

    for (int i = 0; i < n; i++) {
        if (d[i] == INFTY) continue;
        if (d[i] > maxv) {
            maxv = d[i];
            tgt = i;
        }
    }

    bfs(tgt); //find longest path from tgt
    maxv = 0;
    for (int i = 0; i < n; i++) {
        if (d[i] == INFTY) continue;
        maxv = std::max(maxv, d[i]);
    }
    std::cout << maxv << std::endl;
}



int main()
{
    int s, t, w; //start, target, weight
    std::scanf("%d", &n);
    for (int i = 0; i < n -1; i++) {
        std::scanf("%d %d %d", &s, &t, &w);
        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }

    solve();

    return 0;
}



Measured memory_bytes: 9992
# 2019/09/18

n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[]
res=[]
last=0

flag=False
for i in range(n-1):
    if flag:
        res.append(i+1)
        continue
    if a[i]+a[i+1]<k:
        ans.append(i+1)
    elif not flag:
        last=i
        flag=True

if not flag:
    print('Impossible')
    exit()
if res:
    for e in res[::-1]:
        ans.append(e)
ans.append(last+1)

print('Possible')
print(*ans,sep='\n')

Measured memory_bytes: 14752
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, z, w;

int main() {
	cin >> n >> z >> w;
	ll a[n];
	for(ll i = 0; i < n; i++){
		cin >> a[i]; 
	}
	ll max;
	if(n == 1){
		max = (a[0]-w > 0)? a[0]-w : w-a[0];
	}
	else{
		ll abs1 = (a[n-1]-w > 0)? a[n-1]-w : w-a[n-1];
		ll abs2 = (a[n-1]-a[n-2] > 0)? a[n-1]-a[n-2] : a[n-2]-a[n-1];
		max = (abs1 > abs2)? abs1 : abs2;
	}
	cout << max;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}

int main(void)
{
    ll n;
    cin >> n;
    vector<P> ab(n);
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(all(ab));
    bool can = true;
    ll tmp = 0;
    rep(i,n){
        tmp += ab[i].second;
        if(tmp > ab[i].first) can = false;
    }
    if(can) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
long long L[100];

int main() {
  L[0] = 2;
  L[1] = 1;
  for (int i = 0; i < 87; ++i) {
	L[i+2] = L[i] + L[i+1];
  }
  while (cin >> N) {
	cout << L[N] << endl;
  }
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n, m;
	cin >> n >> m;
	int i;
	int yobo[3];
	for (i = 0; i < n; i++) {
		yobo[i] = -1;
	}
	for (i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		if (yobo[a] != -1 && yobo[a] != b) {
			cout << -1;
			return 0;
		}
		yobo[a] = b;
	}
	if (n != 1 && yobo[0] == 0 && n!=1) {
		cout << -1;
		return 0;
	}
	for (i = pow(10, n - 1) - 1; i <= pow(10, n) - 1; i++) {
		string s = to_string(i);
		if (s.size() != n) continue;
		bool flag = true;
		for (int j = 0; j < n; j++) {
			if (yobo[j] != -1 && yobo[j] != s[j] - '0') flag = false;
		}
		if (flag) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

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

	vector<bool> is_prime(n + 1);
	std::fill(std::begin(is_prime), std::end(is_prime), true);
	is_prime[0] = is_prime[1] = false;
	for (int32_t i = 2; i * i <= n; i++) {
		if (!is_prime[i])
			continue;
		for (int32_t j = i; i * j <= n; j++)
			is_prime[i * j] = false;
	}

	vector<int64_t> used(n + 1);
	std::fill(std::begin(used), std::end(used), 0);
	for (int32_t i = 1; i <= n; i++) {
		for (int32_t prime = 1; prime <= n; prime++) {
			if (!is_prime[prime] || i % prime != 0)
				continue;
			if (i < prime)
				break;

			int32_t temp = i;
			while (temp % prime == 0) {
				used[prime]++;
				temp /= prime;
			}
		}
	}

	int64_t res = 1;
	for (int32_t i = 1; i <= n; i++) {
		if (used[i] < 1)
			continue;

		res *= used[i] + 1;
		res %= 1000000007;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

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

  if(a[0]==b[2] & a[1]==b[1] & a[2]==b[0]) 
    cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3612
import java.io.*;
import java.util.*;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] args) {
        FastReader scanner = new FastReader();
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }

        int[] DP = new int[N];

        if (K > N) {
            int min = Integer.MAX_VALUE;
            for (int i = 1; i < N; i++) {
                DP[i] = Math.abs(A[i] - A[0]);
                min = Math.min(DP[i], min);
            }
            System.out.println(min);
        } else {
            for (int i = 1; i < K; i++) {
                DP[i] = Math.abs(A[i] - A[0]);
            }
            for (int i = K; i < N; i++) {
                int min = Integer.MAX_VALUE;
                for (int j = 1; j <= K; j++) {
                    min = Math.min(min, DP[i - j] + Math.abs(A[i] - A[i - j]));
                }
                DP[i] = min;
            }
            System.out.println(DP[N - 1]);
        }
    }
}

Measured memory_bytes: 33036
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int a,b; cin >> a >> b;
  if (a<=b){cout << a << endl;}
  else {cout << a-1 << endl;}

  return 0;
}


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

long long a;

int main()
{
	scanf("%lld",&a);
	for(int i=int(sqrt(a));i>=1;--i) {
		if(a%i==0) {
			printf("%lld",(a/i+i-2));
			return 0;
		}
	}
}

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

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

  int x = w + a;
  int y = w + b;
  if (y - a >= 0 && y - a <= 2 * w) {
    cout << 0 << endl;
  } else {
    cout << min(abs(b - x), abs(a - y)) << endl;
  }
}


Measured memory_bytes: 256
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "numeric"
#include "iomanip"
using namespace std;
typedef long long ll;

int main() {
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,a,z,s,max=0,i;
	scanf("%d %d", &n, &m);
	s=m;
	for(i=0; i<n; i++)
	{
		scanf("%d %d", &a, &z);
		s+=a-z;
		if(s<0)
		{
			max=0;
			break;
		}
		if(max<s)
		max=s;
	}
	printf("%d\n", max);
	
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <math.h>
using namespace std;

int main(){

	long long int n;
	cin >> n;

	long long int a[5];
	long long int min = 9999999999999999, min_i = 0;
	for(int i=0; i<5; i++){
		cin >> a[i];	
		if( a[i] <= min ){
				min = a[i];
				min_i = i;
		}		
	}

	long long int time=4;
	time += n / a[min_i];
	if(n % a[min_i] != 0)
      time++;
  
	cout << time << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *X = list(map(int, read().split()))

X = np.array(X)
P = X.sum() // N

ans = 10**8 + 7

for i in range(-1, 2):
    acc = X - (P + i)
    acc = acc**2
    acc = acc.sum()

    ans = min(ans, acc)

print(ans)


Measured memory_bytes: 12632
def main():
    cnt = 0
    for _ in range(m):
        x, y = map(int, input().split())
        unite(x, y)
    for i in range(1, n+1):
        if same(i, p[i]):
            cnt += 1
    print(cnt)
        
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if x != y:
        par[x] = y

if __name__ == "__main__":
    n, m = map(int, input().split())
    p = [0] + list(map(int, input().split()))
    par = list(range(n+1))
    main()


Measured memory_bytes: 125676
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a;
  int s[51];
  cin>>a;
  for(int i=0;i<a;i++)
  {cin>>s[i];
  }
  int sum=0;
for(int i=0;i<a-1;i++)
{
for(int j=i+1;j<a;j++)
{
sum=sum+s[i]*s[j];
}






}
  
  cout<<sum;
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vi a,ans;
vvi adj;
multiset<ll> lis;

void dfs(int v=0,int p=-1){
	lis.insert(a[v]);
	ll del = -1;
	auto it = lis.lower_bound(a[v]);
	it++;
    if(it != lis.end()){
    	del = *it;
        lis.erase(it);
    }
    ans[v] = lis.size();
    for(auto x: adj[v]){
        if(x!=p){
        	dfs(x,v);
        }
    }
    it = lis.find(a[v]);
    lis.erase(it);
    if(del!=-1){
    	lis.insert(del);
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m,y;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		a.pb(x);
	}
	adj.resize(n);ans.resize(n);
	for(int i=0;i<n-1;i++){
	    cin>>x>>y;
	    x--;y--;
	    adj[x].pb(y);
	    adj[y].pb(x);
	}
	dfs();
	for(int i=0;i<n;i++){
	    cout<<ans[i]<<endl;
	}
	
	


	return 0;
}







Measured memory_bytes: 31616
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>


using namespace std;
typedef long long ll;
const int mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


vector<int> leastPrimeFactors(int n)
{
    vector<int> spf(n + 1);

    //初期化
    reple(i, 0, n) spf[i] = i;

    for (int i = 2; i * i <= n; i++)
    {
        if (spf[i] != i) continue;

        // 素数だったら  
        for (int j = i * i; j <= n; j += i)
        {
            // iを持つ整数かつまだ素数が決まっていないなら  
            if (spf[j] == j) spf[j] = i;
        }
    }

    return spf;
}

map<int, ll> factorize(int x, vector<int>& spf)
{
    map<int, ll> factors;
    while (x != 1)
    {
        factors[spf[x]]++;
        x /= spf[x];
    }

    return factors;
}


ll pmod(ll n, ll p) {
    ll m = n % mod;
    if (p == 0) return 1;
    ll rtn = pmod((m * m) % mod, p / 2) % mod;
    if (p % 2 == 1) rtn = rtn * m % mod;
    return rtn;
}


int main() {

    const int MAX = 1000000;

    auto spf = leastPrimeFactors(MAX);

    int N;
    cin >> N;


    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }


    map<int, map<int, ll>> AFactors;

    rep(i, N)
    {
        int a = A[i];

        if (AFactors.count(a) == 0)
        {
            AFactors[a] = factorize(a, spf);
        }
    }

    //最小公倍数の計算
    map<int, ll> tmp;
    for (auto a : AFactors)
    {
        for (auto x : a.second)
        {
            tmp[x.first] = max(tmp[x.first], x.second);
        }
    }


    ll lcm = 1;
    for (auto x : tmp)
    {
        rep(i, x.second)
        {
            lcm *= x.first;
            lcm %= mod;
        }
    }


    //Bの合計値の計算
    ll b = 0;
    rep(i, N)
    {
        b += (lcm * pmod(A[i], mod - 2)) % mod;
        b %= mod;
    }

    cout << b << endl;

    return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
ll a[1001001];

int main(int argc, char const *argv[]) {
    ll k, n;
    ll min=INF;
    cin >> k >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for(int i=0;i<n;i++){
        a[i+n]=a[i]+k;
    }
    for(int i=0;i<n;i++){
        chmin(min, a[n-1+i]-a[i]);
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 4352
import math
n, p = map(int, input().split())
cnt = [0] * math.ceil(math.sqrt(p))
tmp = p
for i in range(2, math.ceil(math.sqrt(p))):
    while p % i == 0 and p != 0:
        p //= i
        cnt[i] += 1
ans = 1
for i in range(2, math.ceil(math.sqrt(tmp))):
    ans *= i ** (cnt[i] // n)
ans *= p ** (1 // n)
print(ans)

Measured memory_bytes: 10868
from collections import deque
import bisect

N = int(input())

S = input()

Ws = deque([])
Rs = deque([])

for i in range(N):
  if S[i] == 'W':
    Ws.append(i)
  else:
    Rs.append(i)
    
cnt = 0
for i in range(len(Rs)-1,-1,-1):
  j = bisect.bisect_left(Ws, Rs[i])
  if j > 0:
    Ws.popleft()
    cnt += 1
    
print(cnt)

Measured memory_bytes: 74440
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n;

bool C(ll k){
    ll sum = k * (k + 1) / 2;
    return sum >= n;
}

int main(){
    cin >> n;

    ll ok = n, ng = 0;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if (C(mid)) ok = mid;
        else ng = mid;
    }

    ll s = ok * (ok + 1) / 2;
    for (int i = 1; i <= ok; ++i) {
        if (i == s - n) continue;
        cout << i << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,m;
queue<char> q;
string s;
int main()
{
    cin>>s;
    int sz=s.size();
    vector<char> v;
    for(int i=0;i<sz;i++)
    {
        if(s[i]=='B')
        {
            if(v.size())
                v.pop_back();
        }
        else
            v.push_back(s[i]);
    }
    for(auto x:v)
        cout<<x;
    cout<<endl;
    return 0;
}


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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var s = GetStrArray();
            var n = int.Parse(s[0] + s[1]);
            var ans = Math.Sqrt(n) % 1.0 == 0 ? "Yes" : "No";

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 11092
n = input()
a = [int(x) for x in input().split(" ")]
lis = []

for b in a:
  if b % 2 == 0:
    lis.append(b)

count = 0
for c in lis:
  if c % 3 == 0 or c % 5 == 0:
    count += 1

if count == len(lis):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (a, b) = InputLine.to_ia

  c = -1
  (1..10000).each do |x|
    (s, t) = [x.to_f * 0.08, x.to_f * 0.1].map(&:floor)
    if ((a == s) and (b == t)) then
      c = x
      break
    end
  end

  puts c.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
#AGC002A
import sys

#n= int(input())
tmp = input().split()
h,w = list(map(lambda a: int(a), tmp))


map = [[0 for i in range(w+2)] for j in range(h+2)]

for i in range(0,h):
	hoge = input()
	for j in range(0,w):
		map[i+1][j+1]=hoge[j]

for i in range(1,h+1):
#	print(i)
	for j in range(1,w+1):
		if(map[i][j]=="#"):
			if(((map[i+1][j]=="#")and(map[i][j+1]=="#")) or ((map[i+1][j]==".")and(map[i][j+1]=="."))):
#				print("hoge {} {}".format(i,j))
				if(i!=h or j!=w):
					print("Impossible")
					sys.exit()
			if(((map[i-1][j]=="#")and(map[i][j-1]=="#")) or ((map[i-1][j]==".")and(map[i][j-1]=="."))):
#				print("hoga {} {}".format(i,j))
				if(i!=1 or j!=1):
					print("Impossible")
					sys.exit()
print("Possible")

#print(map)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		
		String in = scanner.nextLine();
		int a = Integer.parseInt(in);
		
		int base = a;
		int sum = 0;
		int dig = 0;
		while (a > 0) {
			dig = a % 10;
			sum += dig;
			a = a / 10;
		}
		
		if (base % sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
		
}


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

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b == c || b+c == a || c + a == b)
  cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3612
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b;
  cin >> a >> b;

  if(a * b % 2 == 0) cout << "No" ;
  else cout << "Yes";


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int r,s,d;
			r = sc.nextInt();
			s = sc.nextInt();
			d = sc.nextInt();
			if (r == 1 && s == 1 && d == 0) {
				System.out.println("Open");
			} else if (r == 0 && s == 0 && d == 1){
				System.out.println("Open");
			} else System.out.println("Close");
	}
}

Measured memory_bytes: 17324
N, Y = map(int,input().split())

for i in range(N+1):
  for j in range(N+1):
    k = N-i-j
    if(k >= 0):
      if(10000*i+5000*j+1000*k == Y):
        print(i,j,k)
        exit()
print(-1,-1,-1)

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

int main(){
  long long n, k, q; cin >> n >> k >> q;
  vector<long long> a(n,k-q);
  for (int i = 0; i < q; i++)
  {
    int tmp; cin >> tmp;
    tmp--; //zero indexed
    a.at(tmp)++;
  }
  
  for (auto &&i : a)
  {
    if(i > 0)cout << "Yes" << endl;
    else cout <<"No" <<endl;
  }
  
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct edge
{
	int cost, to;
};

void WarshallFroyd(vector<vint>& d)
{
	int n = d.size();

	rep(k, n) rep(i, n) rep(j, n)
		chmin(d[i][j], d[i][k] + d[k][j]);
}

const int INF = 1 << 28;
int main()
{
	int n, m;
	while(cin >> n >> m && (n || m))
	{
		vector<vint> time(m, vint(m, INF)), cost(m, vint(m, INF));

		rep(i, n)
		{
			int s, t, ti, co;
			cin >> s >> t >> co >> ti; s--, t--;

			cost[s][t] = cost[t][s] = co;
			time[s][t] = time[t][s] = ti;
		}

		WarshallFroyd(time);
		WarshallFroyd(cost);

		int k;
		cin >> k;
		rep(i, k)
		{
			int s, t, f;
			cin >> s >> t >> f; s--, t--;

			cout << (f ?time[s][t] : cost[s][t]) << endl;
		}
	}
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n;cin>>n;
    vll a(n); map<ll,ll> mp;
    REP(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans =0;
    for(auto p:mp){
        ans += p.second * (p.second-1) /2;
    }
    REP(i,n){
        ll sub = ans - mp[a[i]] * (mp[a[i]]-1)/2 + (mp[a[i]]-1)*(mp[a[i]]-2)/2;
        cout<<sub<<endl;
    }
    return 0;
}


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

int main()
{
  string S, T;
  cin >> S >> T;
  bool OK = true;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] != T[i])
    {
      OK = false;
      break;
    }
  }
  if (OK) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624