akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int A = reader.nextInt();
        int B = reader.nextInt();
        int X = reader.nextInt();
        if (X < A || A+B < X) System.out.println("NO");
        else System.out.println("YES");
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACantWaitForHoliday solver = new ACantWaitForHoliday();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACantWaitForHoliday {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s[] = new String[]{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
            String inp = in.next();
            for (int i = 0; i < s.length; i++)
                if (inp.equals(s[i])) {
                    out.println(7 - i);
                }
        }

    }
}



Measured memory_bytes: 21588
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int[] a = new int[N];
        long sum = 0;

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            sum += a[i];
        }
        long x = 0;
        long min = 1000000000000000L;
        for(int i=0; i<N-1; i++){
             x += a[i];
             min = Math.min(Math.abs(2 * x - sum), min);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 65428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#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 ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
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]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


std::vector<std::vector<long long>> comb(int n, int r)
{
    std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
    for (int i = 0; i < v.size(); i++)
    {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++)
    {
        for (int k = 1; k < j; k++)
        {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % MOD;
        }
    }
    return v;
}
void solve(long long N, long long K)
{

    vector<vector<ll>> combination = comb(2010, 2010);
    for (int i = 1; i <= K; i++)
    {
        int balls = N - K + i;
        int sukima = N - K + 1;
        cout << combination[sukima][i] * combination[K - 1][i - 1] % MOD << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 32000
N, M = map(int, input().split())
counts = {}
for i in range(M):
    a, b = map(int, input().split())
    if a not in counts:
        counts[a] = 1
    else:
        counts[a] += 1
    
    if b not in counts:
        counts[b] = 1
    else:
        counts[b] += 1
        
yes = True
for val in counts.values():
    if val % 2 != 0:
        yes = False
        break
        
if yes:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9064
/*THERE'S ALWAYS SOMETHING , NOT THAT YOU WOULD UNDERSTAND . YOU ARE LIKE MY SISTER , EVERYTHING ALWAYS CAME EASY TO HER .
 SHE'S A FIRE BENDING PRODIGY AND EVERY ONE ADORE HER . MY FATHER SAYS SHE WAS BORN LUCKY , HE SAYS I WAS LUCKY TO BE BORN . I DON'T NEED LUCK THOUGH .
 I DON'T WANT IT . I'VE ALWAYS HAD TO STRUGGLE AND FIGHT AND THAT'S MADE ME STRONG . IT MADE ME WHO I AM . WHATEVER DOESNT KILL ME ONLY MAKES ME STRONGER .*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define MAX 3000
int dp[MAX+1][MAX+1];
string getlcs(int len,string& s,string& t)
{
            string lcs;
            int i=0,j=0;
            while(len>0)
            {
                if(s[i]==t[j])
                {
                    lcs.push_back(s[i]);
                    i++;
                    j++;
                    len--;

                }
                else
                {
                    if(dp[i][j+1]>dp[i+1][j])
                    {
                        j++;
                    }
                    else
                    {
                        i++;
                    }

                }
            }
            return lcs;
}
int lenlcs(string &s,string &t,int i,int  j)
{
    if(i >= s.size() || j >= t.size())return 0;

   if(dp[i][j]!=-1)
    return dp[i][j];
   if(s[i]==t[j])
    return dp[i][j]=1+lenlcs(s,t,i+1,j+1);
   else
   {
     return   dp[i][j]=max(lenlcs(s,t,i,j+1),lenlcs(s,t,i+1,j));
   }

}
string solve(string s,string t)
{
    memset(dp, -1, sizeof dp);
    int len=lenlcs(s,t,0,0);
    return getlcs(len,s,t);
}
main()
{
    string s,t;
    cin>>s>>t;
    cout<<solve(s,t);
}


Measured memory_bytes: 74348
import sys
input=sys.stdin.readline
from bisect import bisect_right
n=int(input())
A=[-int(input()) for _ in range(n)]
LIS=[]
for a in A:
    idx=bisect_right(LIS,a)
    if idx==len(LIS):
        LIS.append(a)
    else:
        LIS[idx]=a
print(len(LIS))

Measured memory_bytes: 47836
n = int(input())
h = list(map(int, input().split()))
cnt = 0
score = 0
lower = 0
for i in range(n-1):
    if h[i] < h[i + 1]:
        score = max(score, cnt)
        cnt = 0
    else:
        cnt += 1
score = max(score, cnt)
print(score)

Measured memory_bytes: 14252
import java.util.*;
import java.lang.*;

import static java.lang.StrictMath.abs;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] w = new String[4];
        w = s.split("");
        int count=0;
        for(int i =0;i < 4;i++){
            for(int k=i+1;k < 4; k++ )
            if(w[i].equals(w[k])){
                count++;
            }

        }
        if(count == 2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}



Measured memory_bytes: 24020
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = 0
dist = [[0] * w for _ in range(h)]
dist[0][0] = 1
queue = [(0, 0)]
cnt = 0
while len(queue) > 0:
    n_h, n_w = queue.pop(0)
    for i, j in ([0, 1], [1, 0], [0, -1], [-1, 0]):
        y, x = n_h + i, n_w + j
        if 0 <= x < w and 0 <= y < h:
            if s[y][x] == "." and dist[y][x] == 0:
                dist[y][x] = dist[n_h][n_w] + 1
                queue.append([y, x])

if dist[-1][-1] == 0:
    print(-1)
    exit()
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            ans += 1
    
print(ans - dist[h - 1][w - 1])


Measured memory_bytes: 3188
/* author :: eSeF */
using System;
using System.Linq;
using System.Collections.Generic;
class AC
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
        Array.Sort(A);
        Array.Reverse(A);
        var rec = new Dictionary<long, int>();
        for(var i = 0; i < N; i++)
        {
            if (rec.ContainsKey(A[i])) rec[A[i]]++;
            else rec[A[i]] = 1;
        }

        int ans = 0;
        for(var i = 0; i < N; i++)
        {
            if (rec[A[i]] == 0) continue;
            for(var j = 31; j >= 0; j--)
            {
                long now = (1L << j) - A[i];
                if (rec.ContainsKey(now))
                {
                    if (now == A[i] && rec[now] >= 2) 
                    {
                        ans++;
                        rec[now] -= 2;
                        break;
                    }
                    if (now != A[i] && rec[now] >= 1)
                    {
                        ans++;
                        rec[now]--;
                        rec[A[i]]--;
                        break;
                    }
                }
            }
        }
        Console.WriteLine(ans); 
    }
}
/* for input */
static class Csin
{
    public static string[] StrArray() => Console.ReadLine().Split();
    public static string[] StrArray(char separator) => Console.ReadLine().Split(separator);

    private static T Conv<T>(string value) => (T)Convert.ChangeType(value, typeof(T));
    public static (T, U) ReadTuple<T, U>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]));
    public static (T, U, V) ReadTuple<T, U, V>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]));
    public static (T, U, V, W) ReadTuple<T, U, V, W>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]), Conv<W>(input[3]));
    public static (T, U, V, W, X) ReadTuple<T, U, V, W, X>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]), Conv<W>(input[3]), Conv<X>(input[4]));

    public static (T, U) Input<T, U>() => ReadTuple<T, U>(StrArray());
    public static (T, U, V) Input<T, U, V>() => ReadTuple<T, U, V>(StrArray());
    public static (T, U, V, W) Input<T, U, V, W>() => ReadTuple<T, U, V, W>(StrArray());
    public static (T, U, V, W, X) Input<T, U, V, W, X>() => ReadTuple<T, U, V, W, X>(StrArray());
}


Measured memory_bytes: 53216
use std::collections::HashSet;
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let mut s: usize = iter.next().unwrap().parse().unwrap();
    let mut h = HashSet::new();

    while !h.contains(&s) {
        h.insert(s);
        if s % 2 == 0 {
            s /= 2;
        } else {
            s = 3 * s + 1;
        }
    }

    println!("{}", h.len() + 1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vs a(n);
		vi b(n),c(n);
		for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
		for(int i=0;i<m;i++){
			int x;
			cin>>x;
			bool B=0;
			for(int j=0;j<n;j++){
				if(x>c[j]-b[j]&&x<=c[j]){
					cout<<a[j]<<' '<<x-c[j]+b[j]<<endl;
					B=1;
				}
			}
			if(!B) cout<<"Unknown"<<endl;
		}
	}
}


Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while(true){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                cout << "#" ;
            }
            cout << endl;
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 3088
#include<stdio.h>
int main(void) {
	int h, w, a, b;
	scanf("%d", &h);
	scanf("%d", &w);
	scanf("%d", &a);
	scanf("%d", &b);
	int ans;
	int ans1;
	if (h > a) {
		ans = h - a;
	}
	else {
		ans = a - h;
	}
	if (w < b) {
		ans1 = b - w;
	}
	else {
		ans1 = w - b;
	}

	printf("%d\n", ans*ans1);
	return 0;
}

Measured memory_bytes: 128
n = int(input())

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

ans = 1

for i in range(n):
   if a[i] == 0:
        print(0)
        exit()

for i in range(n):
    ans *= a[i]
    if ans > 1e18:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 88128
import sys
readline = sys.stdin.readline

# dp[i][j] = i個目までのコインで、表の個数がj個である確率
# dp[i][j] = dp[i - 1][j] * (1 - P[i]) + dp[i - 1][j - 1] * P[i]
# dp[0][0] = 1 # 0個目までのコインで、表の個数が0個である確率は1

N = int(readline())
P = list(map(float,readline().split()))

dp = [[0] * (N + 1) for i in range(N + 1)]
dp[0][0] = 1
for i in range(len(P)):
  for j in range(i + 2):
    if j - 1 >= 0:
      dp[i + 1][j] = dp[i][j] * (1 - P[i]) + dp[i][j - 1] * P[i]
    else:
      dp[i + 1][j] = dp[i][j] * (1 - P[i])
  
ans = 0
for i in range((N // 2) + 1, len(dp[-1])):
  ans += dp[-1][i]
  
print(ans)

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll k, n;
    ll p[200010];

    cin >> k >> n;

    REP(i, n){
      cin >> p[i];
    }

    p[n] = k+p[0];

    ll mx = 0;
    REP(i, n){
      mx = max(mx, abs(p[i+1]-p[i]));
    }
 
  	cout << k - mx << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
	ll H, W, N;
	cin >> H >> W >> N;
	vector<pll> AB(N);
	ll ans[10] = {0};
	int i, j, k;
	int a, b;
	for (i = 0; i < N; i++){
		cin >> a >> b;
		AB[i].first = a;
		AB[i].second = b;
	}
	sort(AB.begin(), AB.end());
	ans[0] = (H - 2)*(W - 2);
	pll pos[9] = { pll(-1, -1), pll(-1, 0), pll(-1, 1), pll(0, -1), pll(0, 0), pll(0, 1), pll(1, -1), pll(1, 0), pll(1, 1) };
	for (i = 0; i < N; i++){
		for (j = 0; j < 9; j++){
			pll ab;
			pll cent = AB[i];
			cent.first += pos[j].first;
			cent.second += pos[j].second;
			if ((cent.first<2) | (cent.first>H - 1) | (cent.second<2) | (cent.second>W - 1)){
				continue;
			}
			int count = 0;
			for (k = 0; k < 9; k++){
				ab.first = cent.first + pos[k].first;
				ab.second = cent.second + pos[k].second;
				if (binary_search(AB.begin(), AB.begin() + i, ab)){
					count += 1;
				}
			}
			ans[count]--;
			ans[count + 1]++;
		}
	}
	for (i = 0; i < 10; i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;
char type;

int main(){
	while (cin >> s >> type){
		string ans = "";
		if (type == 'X')break;
		if (type == 'L'){
			REP(i, s.size()){
				if (i == 0)ans += tolower(s[i]);
				else {
					if (s[i] == '_'){
						i++;
						ans += toupper(s[i]);
					}
					else ans += s[i];
				}
			}
		}
		else if (type == 'U'){
			REP(i, s.size()){
				if (i == 0)ans += toupper(s[i]);
				else{
					if (s[i] == '_'){
						i++;
						ans += toupper(s[i]);
					}
					else ans += s[i];
				}
			}
		}
		else{
			REP(i, s.size()){
				if (i != 0 && s[i] >= 'A'&&s[i] <= 'Z')ans += '_';
				ans += tolower(s[i]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz size()
#define ll long long

using namespace std;

const int maxn = 1e4 + 12;
const int mod = 1e9 + 7;

int n, a[maxn], ans, mn = 1e9 + 7;

void Speed() {
    ios_base::sync_with_stdio (0);
    cin.tie (0); 
    cout.tie (0);
}

int main() {
    Speed();
    cin >> n;
    for (int i = 1; i <= n; ++ i) {
        cin >> a[i];
        ans += a[i];
        if (a[i] % 10 != 0) {
            mn = min(a[i], mn);
        }
    }
    sort(a + 1, a + n + 1);
    int res = ans;
    for (int i = 1; i <= n; ++ i) {
        if (ans % 10 == 0) {
            ans -= a[i];
        } else {
            break;
        }
    }
    if (mn != mod) {
        cout << max(ans, res - mn);
    } else {
        cout << ans;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <regex>
#include <string>
#include <stack>
#include <utility>
#include <vector>

#include <random>

using namespace std;
using ll = long long;


int main()
{
	int K, S;
	cin >> K >> S;

	ll ans = 0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			if (0 <= S - (i + j) && S - (i + j) <= K) ans++;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def tax_exclude(price, tax)
  return nil if ((price + 1) * 100) % (100 + tax) == 0
  possible_price = ((price + 1) / ((100 + tax) / 100.0)).to_i
  return nil if possible_price < ((price) / ((100 + tax) / 100.0))
  possible_price
end

while true
  old_tax, new_tax, sum = gets.split(" ").map(&:to_i)
  break if [old_tax, new_tax, sum] == [0, 0, 0]
  max_price = 0
  for i in 1..(sum / 2) do
    low_price = tax_exclude(i, old_tax)
    high_price = tax_exclude(sum - i, old_tax)
    next unless low_price && high_price
    new_tax_total = (low_price * (100 + new_tax) / 100.0).to_i + (high_price * (100 + new_tax) / 100.0).to_i
    max_price = new_tax_total if new_tax_total > max_price
  end
  puts max_price
end

Measured memory_bytes: 8848
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
inline int read(){
	int x;
	scanf("%d",&x);
	return x;
}

const int N=2e5+5;
const int M=2e5+5;

struct Edge{
	int v,nxt;
}e[M];
int first[N],Ecnt=0;
#define go(u) for(register int i=first[u],v=e[i].v;i;v=e[i=e[i].nxt].v)
inline void Add_edge(int u,int v){
	e[++Ecnt]=(Edge){v,first[u]};
	first[u]=Ecnt;
}

int fa[N];
int n,K,ans;

inline int dfs(int u,int dep){
	int maxdep=dep;
	go(u) maxdep=max(maxdep,dfs(v,dep+1));
	if(fa[u]!=1&&maxdep-dep==K-1) ans++,maxdep=0;
	return maxdep;
}

inline void solve1(){
	for(int i=1;i<=n;i++) ans+=(read()!=1);
	printf("%d",ans);
	exit(0);
}

int main(){
	n=read(),K=read();
	if(K==1) solve1();
	fa[1]=read();
	ans+=(fa[1]!=1);
	fa[1]=1;
	for(int i=2;i<=n;i++){
		fa[i]=read();
		Add_edge(fa[i],i);
	}
	dfs(1,0);
	printf("%d",ans);
}

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

using namespace std;
using ll = long long;

int main() {
    cout.precision(20);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int z = 1; z <= n; z++) {
                ans += __gcd(i, __gcd(j, z));
            }
        }
    }
    cout << ans;
}

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

int main(){
  int N;
  int tmp,cnt = 0;
  map<int,int> num_cnt;
  vector<int> num;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> tmp;
  	if(num_cnt.count(tmp))
       num_cnt.at(tmp)++;
    else{
       num.push_back(tmp);
       num_cnt[tmp] = 1;
    }
  }
  for(int i = 0; i < num_cnt.size(); i++){
    int suuzi = num[i];
      if(num_cnt[suuzi] < suuzi)
        cnt += num_cnt[suuzi];
      else if(num_cnt[suuzi] > suuzi)
        cnt += num_cnt[suuzi] - suuzi;
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 7916
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define vp vector <pi>
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1n(x,n) for(int x = 1; x <= n ;++ x)
#define forn1(x,n) for(int x = 1; x < n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
ll n,k;
vl a;
vl f;

bool check(ll mid)
{
	ll cnt = 0;
	for(int i=0;i<n;i++)
	{
		if(a[i]*f[i]>mid)
			cnt += a[i] - (mid/f[i]);
	}

	return cnt>k;
}
int main(){
	IOS

	
	cin>>n>>k;
	a.resize(n);
	f.resize(n);

	cin>>a;
	cin>>f;
	sort(all(a));
	sort(all(f),greater<int>());
	ll l=0,r=INT_MIN;

	for(int i=0;i<n;i++)
	{
		r = max(r,a[i]*f[i]);
	}
	//debug(l,r);
	while(l<r)
	{
		ll mid = l + (r-l)/2;

		bool pred = check(mid);
		//debug(mid,pred);
		if(pred)
			l = mid+1;
		else
			r = mid;
	}
	cout<<r;
	return 0;	
}

Measured memory_bytes: 3328
H,W = map(int,input().split())
A = [input().split() for i in range(H)]


X = "#"*(W+2)

#print(H,W,A)


for i in range(H):
	A[i][0] = "#" + A[i][0] +"#"

print(X)
for i in range(H):
	print(A[i][0])
print(X)


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

using namespace std;

int main()
{   int A,B,K;
    cin>>A>>B>>K;
    int cnt = 0;
    for(int i = 1000;i >= 0;i--){
        if(A%i == 0 && B%i == 0){
            cnt++;
        }
        if(cnt == K){
            cout<<i<<endl;
            break;
        }
    }

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::string str;
	std::cin >> str;
	const int MOD = 998244353;
	std::vector<int> groups(8, 0);
	groups[0] = n;
	int ans = 1;
	for(auto c : str) {
		int bit;
		if(c == 'R') {
			bit = 1;
		} else if(c == 'G') {
			bit = 2;
		} else {
			bit = 4;
		}
		for(int i = 7; i >= 0; i--) {
			if(bit & i) continue;
			if(groups[i]) {
				ans = (long long) ans * groups[i] % MOD;
				groups[i]--;
				groups[i|bit]++;
				break;
			}
		}
	}
	std::cout << ans << '\n';
}

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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	int mp = 0;
	int mn = 11;
	rep(i,n){
		cin >> p[i];
		if(mp < p[i]){
			mp = p[i];
			mn = i;
		}
	}
	int sum = 0;
	rep(i,n){
		if(i == mn) sum += p[i]/2;
		else sum += p[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお


int main() {
	string s; cin >> s;
	ll cnt = 0 , ans = 0;
	rep(i,s.size()-1) {
		if(s[i]=='A')
			cnt++;
		else if(s[i]=='B' && s[i+1]=='C')
			ans += cnt , i++;
		else
			cnt = 0;
	}
	cout << ans << endl;;
	return 0;
}

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

using namespace std;

int main()
{
    char a, b;
    cin >> a >> b;
    if(a == 'H' and b == 'H')
    {
        cout << "H" << endl;
    }
    else if(a == 'D' and b == 'D')
    {
        cout << "H" << endl;
    }
    else if(a == 'D' and b == 'H')
    {
        cout << "D" << endl;
    }
    else if(a == 'H' and b == 'D')
    {
        cout << "D" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    string n;
    cin>>n;
    int k;
    cin>>k;
    int d[k];
    for(int i=0;i<k;i++){
        cin>>d[i];
    }
    int l[10-k];
    int j=0;
    int m=0;
    for(int i=0;i<10-k;i++){
        while(true){
            if(j==d[m]){
                j++;
                m++;
            }else{
                break;
            }
        }
        l[i]=j;
        //m++;
        j++;
    }
   
    //
      //  for(int i=0;i<10-k;i++){
       // cout<<l[i]<< " ";
   // }
    //cout<<endl;
    //
   
   int ans=0;
   for(int i=0;i<n.length();i++){
       //ans+=l[9-k]*pow(10,i);
       int di=1; 
       for(int p=0;p<i;p++){
           di*=10;
       }
      ans+=l[9-k]*di;
    


       //
       //cout<< "debA "<<l[9-k]*pow(10,i)<<endl;
       //cout<< "debB "<<ans<<endl;
       //
   
   }
   //cout<<"ans="<<ans<<endl;




   //
   //cout<<"deb1 "<<ans<<endl;
   //
   
   if(ans<stoi(n)){
   
       //
       //cout<< "deb2 ";
       //
   
       if(l[0]==0){
           cout<<l[1];
       }else{
           cout<<l[0];
       }
       for(int i=0;i<n.length();i++){
               cout<<l[0];
       }
   }else{
       int min=0;
       for(int i=n.length()-1;i>=0;i--){

           for(int o=9-k;o>0;o--){
               //min=(l[o]-l[o-1])*pow(10,i);
               int di=1;
               for(int p=0;p<i;p++){
                   di*=10;
               }
               min=(l[o]-l[o-1])*di;
               //
               if(ans-min<stoi(n)){
                   break;
               }
               ans-=min;
               //cout<<"deb "<<ans<<endl;
           }
       }
       
       //
       //cout<<endl<<"deb3 ";
       //

       cout<<ans;
    }

}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
typedef struct aaaaa{
  int x,y,t;
}Grid;
using namespace std;
int main(){
  ll n,p;
  cin>>n>>p;
  vector<pair<ll,ll> >prime;
  prime.pb(mp(2,0));
  for(ll i=3;i<=sqrt(1000000100000LL);i+=2){
    bool flag=true;
    for(ll j=2;j<=sqrt(i);j++){
      if(i%j==0){flag=false;break;}
    }
    if(flag)prime.pb(mp(i,0));
  }

  ll pp=p;
  ll cnt=0;
  while(pp>1){
    while(pp%prime[cnt].F==0){
      prime[cnt].S++;
      pp/=prime[cnt].F;
    }
    cnt++;
    if(cnt==prime.size())break;
  }
  ll ans=1;
  if(n==1){
    ans*=pp;
  }
  for(ll i=0;i<prime.size();i++){
    if((ll)(prime[i].F)*((ll)(prime[i].S)/n)!=0)
      ans*=pow((ll)(prime[i].F),((ll)(prime[i].S)/n));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

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

// const ll INF = 1LL << 60;

bool kaibun(string str)
{
  string str1 = str;
  reverse(str1.begin(), str1.end());
  if (str == str1)
  {
    return true;
  }
  else
  {
    return false;
  }
}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  string s_1, s_2;
  s_1 = S.substr(0, (N - 1) / 2);
  s_2 = S.substr((N + 3) / 2 - 1, (N - 1) / 2);
  if (kaibun(S) && kaibun(s_1) && kaibun(s_2))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
int n;
cin >> n;
int cnt  = 0;
for(int i = 1; i<=n; i++){
  int a ;
  cin >> a;
  if(i%2!=0 && a%2!=0)cnt++;
}
cout << cnt << endl;
}

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







int main()
{
    int n,m;
    cin>>n>>m;
    int a;
    int count=0;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a>=m)
            count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
n=io.read("*n")
a={}
for i=1,n do
    number=io.read("*n")
    if not a[number] or a[number]==0 then
        a[number]=1
    else
        a[number]=0
    end
end

counter=0
for _,v in pairs(a) do
    counter=counter+v
end
print(counter)

Measured memory_bytes: 6508
#include <iostream>
#include <cstdint>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;
using u8 = uint64_t;
using u4 = uint32_t;


bool compare(const tuple<u4, u4> &a, const tuple<u4, u4> &b) {
    return get<1>(a) < get<1>(b);
}

int main() {
    u4 n;
    cin >> n;
    vector<tuple<u4, u4>> a(n);
    
    tuple<u4, u4> tmp;
    u4 tmp_in;
    for (u4 i=0; i < n; i++) {
        cin >> tmp_in;
        tmp = make_tuple(i, tmp_in);
        a[i] = tmp;
    }

    sort(a.begin(), a.end(), compare);

    for (auto t : a) {
        cout << get<0>(t)+1 << " ";
    }

    
    

    return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <algorithm>

using namespace std;

int bd[10][10000];

int main(){
	while (1){
		int r, c;
		scanf(" %d %d", &r, &c);
		if (r == 0 && c == 0) break;
		for (int i = 0; i < r; i++){
			for (int j = 0; j < c; j++){
				scanf(" %d", &bd[i][j]);
			}
		}
		int ans = -1;
		int up = (1 << r);
		for (int sl = 0; sl < up; sl++){
			int h = sl;
			for (int i = 0; i < r; i++){
				if (h % 2 == 1){
					for (int j = 0; j < c; j++){
						bd[i][j] = (bd[i][j] == 0) ? 1 : 0;
					}
				}
				h /= 2;
			}

			int cnt = 0;
			for (int j = 0; j < c; j++){
				int sm = 0;
				for (int i = 0; i < r; i++){
					sm += bd[i][j];
				}
				cnt += max(r - sm, sm);
			}
			ans = max(cnt, ans);
			h = sl;
			for (int i = 0; i < r; i++){
				if (h % 2 == 1){
					for (int j = 0; j < c; j++){
						bd[i][j] = (bd[i][j] == 0) ? 1 : 0;
					}
				}
				h /= 2;
			}

		}

		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1416
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    r = N%10
    if (r == 2) or (r == 4) or (r == 5) or (r == 7) or (r == 9):
        print('hon')
    elif (r == 0) or (r == 1) or (r == 6) or (r == 8):
        print('pon')
    else:
        print('bon')

if __name__ == '__main__':
    main()


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

int main() {
  int n, k, s = 0;
  cin >> n >> k;
  vector<int> x(n);
  for(int i = 0; i < n; i++)
    cin >> x.at(i);
  for(int i = 0; i < n; i++)
    s += min(x.at(i), abs(x.at(i) - k));
  cout << s * 2 << endl;
}

Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : July 06, 2020 9:53 AM
 *    Problem Name  : A - Payment
 *    Problem Limit : 2000ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc173/tasks/abc173_a
**/

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

int main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    if( n < 1000){
	    cout << 1000 - n << endl;
    }

    else if( n%1000 == 0 ){
	    cout << "0" << endl;
    }
	
    else {
	    int temp = n / 1000;
	    int change = (temp+1) * 1000;
	    cout << change - n << endl;
    }

    return 0 ;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r, g, b;
    cin >> r >> g >> b;
    if ((r * 100 + g * 10 + b) % 4 == 0) {
        cout << "YES" << endl;

    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
//const int N=;
ll n,m;
bool check(ll x){
	ll a=n,b=m;
	if(x>=a){
		if(b>=(x-a)*2+x*2)return 1;
		else return 0;
	}else{
		if(b>=x*2)return 1;
		else return 0;
	}
}
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	cin>>n>>m;
	ll ans,l=0,r=1e12;
	while(l<=r){
		ll mid=(l+r)/2;
		if(check(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def printHeap(H,Q,n):
    if H+1 == n:
        return
    print("node",n,end=": ")
    print("key =",Q[n],end=", ")
    print("parent key =",Q[int(n/2)],end=", ") if 1<n else None
    print("left key =",Q[2*n],end=", ") if 2*n<=H else None
    print("right key =",Q[2*n+1],end=", ") if 2*n+1<=H else None
    print()
    printHeap(H,Q,n+1)
    



H = int(input())
Q = list(map(int, input().split()))
Q.insert(0,-1)
printHeap(H,Q,1)




Measured memory_bytes: 5792
N = int(input())
S = input()
T = input()

if S == T:
    print(N)
    exit()
for i in reversed(range(N)):
    if S[N-i-1:] == T[:i+1]:
        print(2*N - i - 1)
        exit()
    else:
        continue

print(2*N)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#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++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
/*
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
*/

int main() {
	int H; cin >> H;
	int N; cin >> N;
	vector<int> A(N); rep(i, N) cin >> A.at(i);
	bool f = accumulate(all(A), 0) >= H;
	Yn(f);
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100001;
int n;
long long ans[N];
struct Node
{
    int id;
    long long val;
}a[N];
bool cmp(Node x,Node y)
{
    if(x.val!=y.val) return x.val>y.val;
    else return x.id<y.id;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i].val),a[i].id=i;
    sort(a+1,a+n+1,cmp);
    int p=1;
    for(int i=2;i<=n;i++)
    {
        while(a[i].val==a[i-1].val) i++;
        ans[a[p].id]+=(a[p].val-a[i].val)*(i-1);
        if(a[i].id>a[p].id) a[p].val=a[i].val;
        else p=i;
    }
    ans[a[p].id]+=a[p].val*n;
    for(int i=1;i<=n;i++)
        printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int f[20];

int32_t main()
{
	IOS;
	for(int i=1;i<=3;i++)
	{
		int x;
		cin>>x;
		f[x]++;
	}
	if(f[5]==2 && f[7]==1)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	int rec = 0;
	for (int i = 0; i < S.length(); i++) {
		char s = S[0];
		for (int j = 0; j < S.length() - 1; j++) {
			S[j] = S[j + 1];
		}
		S[S.length() - 1] = s;
		if (S == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int flag=0;

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++)
	{
        if (s[i]==s[i+1])
		{
            cout<<i+1<<" "<<i+2<<endl;
            flag=1;
            return 0;
        }
        else if (i<s.size()-2&&s[i]==s[i+2])
		{
            cout<<i+1<<" "<<i+3<<endl;
            flag=1;
            return 0;
        }
    }
    if (!flag)  cout<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
# coding: utf-8
# Your code here!
N = int(input())
A = int(N / 1.08)
B = int(N / 1.08 + 1)



if int(A * 1.08) == N:
    print(int(A))
elif int(B * 1.08) == N:
    print(int(B))

else:
    print(":(")

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

int main(){
  int n; cin>>n;
  int t[n+1],x[n+1],y[n+1];
  t[0]=0; x[0]=0; y[0]=0;
  for(int i=1;i<=n;i++){
    cin>>t[i]>>x[i]>>y[i];
    int dis=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    if(dis>t[i]-t[i-1]){
      cout<<"No"<<endl;
      return 0;
    }else{
      dis=t[i]-t[i-1]-dis;
      if(dis%2!=0){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

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

using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n ;
    int num;
    int x=0;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> num;
        while(num%2==0)
        {
            num/=2;
            x++;
        }
    }
    cout << x ;
    return 0;
}


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

long long gcd(long long x, long long y) {
    if(y == 0) return x;
    else return gcd(y, x % y);
}

map<long long, int> factorize(long long n) {
    map<long long, int> ret;
    for(long long i=2; i * i <= n; ++i) {
        while(n % i == 0) {
            ++ret[i];
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {
    long long A,B;
    cin >> A >> B;
    long long X = gcd(A, B);
    auto fac = factorize(X);
    cout << 1 + fac.size() << endl;
}

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

long long N, W, w[109], v[109], dp[109][100009];

int main() {
	cin >> N >> W;
	for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= W; j++) dp[i][j] = -(1LL << 60);
	}
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if (j + w[i] <= W) dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i - 1][j] + v[i]);
		}
	}
	long long rem = 0;
	for (int i = 0; i <= W; i++) rem = max(rem, dp[N][i]);
	cout << rem << endl;
	return 0;
}

Measured memory_bytes: 80128
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))
A.append(0)
cost = [abs(A[i] - A[i+1]) for i in range(N+1)]
allcost = sum(cost)
for i in range(N):
    print(allcost - cost[i] - cost[i+1] + abs(A[i]-A[i+2]))


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

xsum, ysum = 0, 0
for i in range(1, N):
    xsum += (X[i] - X[i-1]) * i * (N - i)
    xsum %= MOD
for j in range(1, M):
    ysum += (Y[j] - Y[j-1]) * j * (M - j)
    ysum %= MOD

print((xsum * ysum) % MOD)


Measured memory_bytes: 18576
N, A, B = tuple(int(num) for num in input().split())

sum = 0

for num in range(1, N+1):
  s = list(str(num))
  s_list = [int(i) for i in s]
  count = 0
  if len(s_list) > 1:
    for i in s_list:
      count = count + i
  else:
    count = s_list[0]
  if count >= A and count <= B:
    sum = sum + num
print(sum)

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


int main(){
  int H , W;
  char A[52][52] = {};
  int i,j;
  bool ans = true;
  cin >> H >> W;
  for(i = 1 ;i <= H;i++){
    for(j = 1;j <= W;j++){
      cin >> A[i][j];
    }
  }
  for(i = 1;i <= H ;i++){
    for(j = 1;j <= W ;j++){
      if(A[i][j] == '#'){
        if(A[i][j+1] != '#' && A[i][j-1] != '#' && A[i-1][j] != '#' && A[i+1][j] != '#')
          ans = false;
      }
    }
  }
  if (ans)cout << "Yes" <<endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())

if a == 1 and b == 2:
  print(3)
elif a == 1 and b == 3:
  print(2)
elif a == 2 and b == 3:
  print(1)
elif a == 2 and b == 1:
  print(3)
elif a == 3 and b == 2:
  print(1)
elif a == 3 and b == 1:
  print(2)

  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,M,R;
	cin >> N >> M >> R;
	vector<ll> r(R),a(M),b(M),c(M);
	FOR(i,0,R)cin>>r[i];
	FOR(i,0,M)cin>>a[i]>>b[i]>>c[i];
	ll d[N+1][N+1];
	FOR(i,0,N+1)FOR(j,0,N+1)d[i][j]=INF;
	FOR(i,0,M){
		d[a[i]][b[i]] = c[i];
		d[b[i]][a[i]] = c[i];
	}

	FOR(k,1,N+1)
		FOR(i,1,N+1)
			FOR(j,1,N+1)
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);

	sort(r.begin(),r.end());
	ll ans = 0;
	FOR(i,0,R-1)ans += d[r[i]][r[i+1]];
	while(next_permutation(r.begin(),r.end())){
		ll w=0;
		FOR(i,0,R-1)w += d[r[i]][r[i+1]];
		ans = min(ans,w);
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long n,s;
long long dight(long long x,long long y){
    if(x>y)return y;
    else return dight(x,y/x)+y%x;
}
int main(void){
    cin>>n>>s;
    if(n<s){
        cout<<"-1"<<endl;
        return 0;
    }
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    else{
        for(long long i=2;i<=sqrt(n);i++){
            long long res = dight(i,n);
            if(res==s){
                cout<<i<<endl;
                return 0;
            }
        }
        long long ans = 100000000000;
        for(long long a=1;a<sqrt(n);a++){
            if((n-s)%a)continue;
            long long b = (n-s)/a+1;
            long long res = dight(b,n);
            if(res==s){
                ans=min(b,ans);
            }
        }
        if(ans != 100000000000){
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
bool f(char* s,int i,int j){
	int t=j/2;
	for(int k=i;k<=t;k++){
		if(s[k]!=s[j-k+1])return 0;
	}
	return 1;
}
int main(){
	char s[10000]={'a'};
	scanf("%s",s+1);
	int N=strlen(s)-1;
	if(f(s,1,(N-1)/2)&&f(s,(N+3)/2,N)&&f(s,1,N))printf("Yes\n");
	else printf("No\n");
}

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

int main() {

  int A, B;

  int numTap = 0;

  cin >> A >> B;
  
  A + (A - 1) * numTap >= B;
  

  if (B == 1) {
    numTap = 0;
  }
  else if( A >= B) {
    numTap = 1;
  }
  else {
    numTap = ceil((B - A) / (A - 1.0)) + 1;
  }

  // 結果の出力
  cout << numTap << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
   public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i < a.length;i++){
            a[i] = sc.nextInt();
        }
        
        for(int i = n-1;i >= 0;i--){
            System.out.print(a[i]);

            if(i != 0){
                System.out.print(" ");
            }
        }

        System.out.print("\n");
    
        sc.close();
   }
}


Measured memory_bytes: 26416