akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    const long double rate = 380000.0;
    int N;
    cin >> N;
    long double jpy = 0, btc = 0;
    rep(i, N){
        long double x; string u;
        cin >> x >> u;
        if(u == "JPY") jpy += x;
        else btc += x;
    } 

    cout << setprecision(8) << jpy + btc*rate << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = 1e18;
void min_self(ll &a,ll b){
  a = min(a,b);
}
const int N = 110;
int n,W;
int main(){
  scanf("%d%d",&n,&W);
  vector<ll> weight(n);
  vector<ll> value(n);
  for(int i=0;i<n;++i){
    cin>>weight[i]>>value[i];
  }
  ll sum = 0;
  for(int x:value){
    sum += x;
  }
  vector<ll> dp(sum+1,inf);
  dp[0] = 0;
  for(int i=0;i<n;++i){
    for(int va = sum - value[i];va>=0;--va){
      min_self(dp[va+value[i]],dp[va]+weight[i]);
    }
  }
  ll ans = 0;
  for(int i=0;i<=sum;++i){
	if(dp[i]<=W){
      ans = max(ans,(ll)i);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> a,b;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(x<0){
      b.push_back(-x);
    }else a.push_back(x);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int ans=1e18;
  if(a.size()>=k)ans=min(ans,a[k-1]);
  if(b.size()>=k)ans=min(ans,b[k-1]);
  for(int i=1;i<k;i++){
    int sum=0;
    if(a.size()<i)continue;
    if(b.size()<k-i)continue;
    int x=a[i-1],y=b[k-i-1];
    sum=max(x,y)+min(x,y)*2;
    //cout<<x<<" "<<y<<endl;
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1656
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: Vec<char> = input::<String>().chars().collect();
    let b: Vec<char> = input::<String>().chars().collect();

    if a.len() > b.len() {
        println!("GREATER");
    } else if a.len() < b.len() {
        println!("LESS");
    } else {
        println!(
            "{}",
            if a > b {
                "GREATER"
            } else if a < b {
                "LESS"
            } else {
                "EQUAL"
            }
        );
    }
}


Measured memory_bytes: 4352
N = int(input())
A,B = map(int, input().split())
P = sorted(list(map(int,input().split())))

a,b,c = 0,0,0
for p in P:
    if p <= A:
        a += 1
    elif p <= B:
        b += 1
    else:
        c += 1

ans = min(a,b,c)
print(ans)


Measured memory_bytes: 3060
def method_name(n, ai)
  bi = Array.new(n, 0)
  n.downto(1) do |i|
    sum = (2*i).step(n, i).inject(0){|v, j| v += bi[j-1]}
    bi[i-1] = 1 if sum.odd? != ai[i-1].odd?
  end

  puts bi.inject(:+)
  bi.each_with_index{|v, k| puts k + 1 if v == 1}
end

n = gets.chomp.to_i
ai = gets.chomp.split.map(&:to_i)
method_name(n, ai)

Measured memory_bytes: 22788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;
void solve(ll X, ll Y){
	ll x = 0;
	for(int i = 0 ; i < 10000 ; i++){
		x += X;
		if( x % Y != 0 ){
			cout << x << endl;
			return;
		}
	}
	cout << -1 << endl;
}

int main(){	
	ll X;
	ll Y;
	scanf("%lld",&X);
	scanf("%lld",&Y);
	solve(X, Y);
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>

char TomorrowWeather(char* a_acWeather);

int main(void) {
	char acWeather[7];
	//天気を入力
	scanf("%s", acWeather);
	//明日の天気を出力
	if (TomorrowWeather(acWeather) == 1) {
		printf("Cloudy\n");
	}
	else if (TomorrowWeather(acWeather) == 2) {
		printf("Rainy\n");
	}
	else {
		printf("Sunny\n");
	}	
	return 0;
}

/*********
*	今日の天気に応じて明日の天気のフラグを返す関数
*	a_acWeather	入力された今日の天気
*/
char TomorrowWeather(char* a_acWeather) {
	char cWeatherFlag = 0;
	if (strcmp(a_acWeather, "Sunny") == 0) {
		cWeatherFlag = 1;
	}
	else if (strcmp(a_acWeather, "Cloudy") == 0) {
		cWeatherFlag = 2;
	}
	else {}

	return (cWeatherFlag);
}


Measured memory_bytes: 1600
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var a = ReadSplitInt();

            var min = double.MaxValue;
            for (int i = -100; i <= 100; i++)
            {
                var sum = 0D;
                for (int j = 0; j < N; j++)
                {
                    sum += Pow(a[j] - i, 2);
                }
                min = Min(min, sum);
            }
            Println(min);
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		cout << s << endl;
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

typedef long long i64;

const int N = 200000 + 10;

struct Edge {
  int x, y, z;
  Edge() {}
  Edge(int _x, int _y, int _z): x(_x), y(_y), z(_z) {}
  inline bool operator< (const Edge &rhs) const {
    return z < rhs.z;
  }
};

inline void check(int &lhs, int rhs) { lhs = (lhs < rhs ? lhs : rhs); }

int n, tag[N];
std::vector<Edge> edge;

void init() {
  int m;
  scanf("%d%d", &n, &m);
  memset(tag, 0x3f, sizeof tag);
  while (m--) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    edge.push_back(Edge(a, b, c));
    check(tag[a], c + 1);
    check(tag[b], c + 2);
  }
  for (int i = 0; i < 3 * n; ++i) check(tag[(i + 1) % n], tag[i % n] + 2);
}

int anc[N];
int find(int x) { return anc[x] == x ? x : (anc[x] = find(anc[x])); }

int main() {
  init();
  for (int i = 0; i < n; ++i) edge.push_back(Edge(i, (i + 1) % n, tag[i]));
  std::sort(edge.begin(), edge.end());
  for (int i = 0; i < n; ++i) anc[i] = i;
  i64 ans = 0;
  for (int i = 0; i < edge.size(); ++i) {
    int x = find(edge[i].x), y = find(edge[i].y), z = edge[i].z;
    if (x != y) anc[x] = y, ans += z;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 10604
fn check(s: &String) -> bool {
    let rev_s: String = s.chars().rev().collect();
    *s == rev_s
}

fn main() {
    let s: String = read();
    let n = s.len();

    if check(&s) && check(&s[0..((n-1)/2)].to_string()) && check(&s[((n+3)/2-1)..].to_string()) {
        println!("Yes");
    } else {
        println!("No");
    }

}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}



Measured memory_bytes: 4352
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define mp make_pair
#define ll long long
#define reg register
#define inf 0x7fffffff
#define MOD 1000000007
#define clr(a) memset(a,sizeof(a),0);
#define rep(i,l,r) for(reg int i=l;i<=r;i++)
#define dow(i,l,r) for(reg int i=l;i>=r;i--)
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
inline ll readl(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
template<class T>inline T power(T a,T b){T ans=1;while(b){if(b&1){ans=ans*a%MOD;}b>>=1;a=a*a%MOD;}return ans%MOD;}
/*================Header Template==============*/
int main(){
	char s[100005];
	scanf("%s",s+1);int len=strlen(s+1);
	int w=read();
	for(int i=1;i<=len;i+=w) cout<<s[i];
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, x;
  std::cin >> N >> x;

  if (N == 1) {
    std::cout << "Yes" << std::endl;
    std::cout << 1 << std::endl;
    goto FINISHED;
  }
  if (x == 1 || x == 2 * N - 1) {
    std::cout << "No" << std::endl;
    goto FINISHED;
  }
  if (x == N) {
    std::cout << "Yes" << std::endl;
    for (i64 i = 1; i <= 2 * N - 1; ++i) {
      std::cout << i << std::endl;
    }
    goto FINISHED;
  }
  if (x < N) {
    std::vector<i64> left;
    left.reserve(2 * N - 5);
    for (i64 i = 1; i <= 2 * N - 1; ++i) {
      if (i != 1 && i != x && i != 2 * N - 2 && i != 2 * N - 1) {
        left.push_back(i);
      }
    }
    std::cout << "Yes" << std::endl;
    for (i64 i = 0; i < (N - 2) - 1; ++i) {
      std::cout << left[i] << std::endl;
    }
    std::cout << 2 * N - 2 << std::endl;
    std::cout << 1 << std::endl;
    std::cout << x << std::endl;
    std::cout << 2 * N - 1 << std::endl;
    for (i64 i = (N - 2) - 1; i < 2 * N - 5; ++i) {
      std::cout << left[i] << std::endl;
    }
    goto FINISHED;
  }
  if (x > N) {
    std::vector<i64> left;
    left.reserve(2 * N - 5);
    for (i64 i = 1; i <= 2 * N - 1; ++i) {
      if (i != 1 && i != 2 && i != x && i != 2 * N - 1) {
        left.push_back(i);
      }
    }
    std::cout << "Yes" << std::endl;
    for (i64 i = 0; i < (N - 2) - 1; ++i) {
      std::cout << left[i] << std::endl;
    }
    std::cout << 1 << std::endl;
    std::cout << 2 * N - 1 << std::endl;
    std::cout << x << std::endl;
    std::cout << 2 << std::endl;
    for (i64 i = (N - 2) - 1; i < 2 * N - 5; ++i) {
      std::cout << left[i] << std::endl;
    }
    goto FINISHED;
  }

FINISHED:
  return 0;
}

Measured memory_bytes: 3072
/**
 * Program Name: ADSL1-1-D : Maximum Profit
 * author:Xin Peng
 * date:2020/1/5
 * Program problem source:AOJ
*/
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 200000

int main()
{
    int Rt[MAX];
    int n;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> Rt[i];
    }

    int maxProfit = Rt[1] - Rt[0];
    int minValue = Rt[0];

    for (int i = 1; i < n; i++)
    {
        maxProfit = max(maxProfit, (Rt[i] - minValue));
        minValue = min(minValue, Rt[i]);
    }

    cout << maxProfit << endl;

    return 0;
}



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

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

    int ans = 0;
    for (int i=A; i<=B; ++i) {
        int arr[5];
        int num = i;
        for (int j=0; j<5; ++j) {
            arr[j] = num % 10;
            num /= 10;
        }
        if ((arr[0] == arr[4]) && (arr[1] == arr[3])) ++ans; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
import java.util.*;

import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 1000000007;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] adL, adH;
	static int n, q;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = sc.nextInt();
		String s=sc.nextLine();
		q = sc.nextInt();
		TreeSet<Integer> []a=new TreeSet[26];
		for(int i=0;i<26;i++)
			a[i]=new TreeSet<>();
		for(int i=0;i<s.length();i++)
			a[s.charAt(i)-'a'].add(i);
		for(int i=0;i<q;i++) {
			if(sc.nextInt()==1) {
				int d=sc.nextInt()-1;
				int g=sc.nextChar()-'a';
				 for(int j=0;j<26;j++)
					 if(a[j].contains(d)) {
						 a[j].remove(d);
						 break;
					 }
				 a[g].add(d);
			}
			else {
			 int ans=0;
			 int l=sc.nextInt()-1;
			 int r=sc.nextInt();
			 for(int j=0;j<26;j++)
				 if(!a[j].subSet(l, r).isEmpty())
					 ans++;
			 out.println(ans);
			}
		}
		out.flush();
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 105624
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
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;
}
#define pb push_back
#define mp make_pair
#define mt make_tuple

const int MX = 310;
vector<double> cache(MX * MX * MX, -1.0);

int to_index(int n1, int n2, int n3) {
    return n1 * MX * MX + n2 * MX + n3;
}

double dfs(int n0, int n1, int n2, int n3) {
    if (n1 == 0 && n2 == 0 && n3 == 0) {
        return 0.0;
    }
    int idx = to_index(n1, n2, n3);
    if (cache[idx] != -1.0) {
        return cache[idx];
    }

    double n_sum = n0 + n1 + n2 + n3;
    double righthand = 0.0;

    righthand = 1.0;
    if (n1 > 0) righthand += (n1 / n_sum) * dfs(n0 + 1, n1 - 1, n2, n3);
    if (n2 > 0) righthand += (n2 / n_sum) * dfs(n0, n1 + 1, n2 - 1, n3);
    if (n3 > 0) righthand += (n3 / n_sum) * dfs(n0, n1, n2 + 1, n3 - 1);

    double lefthand = 1.0 - n0 / n_sum;
    double ans = righthand / lefthand;

    cache[idx] = ans;
    return ans;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N; cin >> N;
    vector<int> dishes(4);
    REP(n, N) {
        int a; cin >> a;
        dishes[a]++;
    }

    cout << fixed << setprecision(20)
         << dfs(dishes[0], dishes[1], dishes[2], dishes[3]) << endl;

    return 0;
}


Measured memory_bytes: 233088
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
int n,d;
cin >>n >>d;
vector<int> all;

for(int  i=0; i<2*n; i++){
    int num;
    cin >>num;
    all.push_back(num);
}
/*
//読み込み確認
for(int  i=0; i<all.size(); i++){
    cout <<all[i] <<" ";
}
*/

int c=1;
vector<int> a;
vector<int> b;
for(int i=0; i<2*n; i++){
    if(c%2==1) a.push_back(all[i]);
    else b.push_back(all[i]);
    c++;
} 

vector<double> dis;
for(int i=0; i<n; i++){
dis.push_back(sqrt(pow(a[i],2)+pow(b[i],2)));
}
  
int cnt=0;
for(int i=0; i<dis.size(); i++){
    if(dis[i]<=d) cnt++;
}
cout <<cnt;

return 0;
}

Measured memory_bytes: 10368
public class Main {

  private static void solve() {
    int x = ni();
    for (int k = 1; k <= 360; k++) {
      if (360 * k % x == 0) {
        System.out.println(360 * k / x);
        return;
      }
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36704
import math


def check(k, A, B, H):
    return sum([max([0, math.ceil((h - B * k) / (A - B))]) for h in H]) <= k


def main():
    N, A, B = list(map(int, input().split(' ')))
    H = [int(input()) for _ in range(N)]
    ng, ok = 0, 10**9
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if check(mid, A, B, H):
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == '__main__':
    main()

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

using namespace std;

using ll = long long;

const int MX = 100 * 1000 + 7;

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int c;
    cin >> c;
    int k;
    cin >> k;
    vector<int> t(n);
    for (int& x : t) {
        cin >> x;
    }
    sort(t.begin(), t.end());
    int lst = 0;
    int ans = 0;
    for (int i = 1; i < t.size(); i++) {
        if (i - lst + 1 > c || t[i] - t[lst] > k) {
            ans++;
            lst = i;
        }
    }
    ans++;
    cout << ans << endl;
}

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

using namespace std;

bool comp(pair<int, pair<string, int> > a, pair<int, pair<string, int> > b) {
    if (a.second.first != b.second.first) {
        return a.second.first < b.second.first;
    } else {
        return !(a.second.second < b.second.second);
    }
}

int main()
{
    int N;
    string s;
    int p;

    cin >> N;

    vector< pair<int, pair<string,int> > > v(N);
    for (int i=0; i<N; i++) {
        cin >> s >> p;
        v[i] = make_pair(i+1, make_pair(s, p));
    }

    sort(v.begin(), v.end(), comp);

    for (int i=0; i<N; i++) {
        cout << v[i].first << endl;
    }
    
    return 0;
}

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

const int MAX = 1000000;
const int MOD = 1e9+7;

long mpow(long x, long n){
    long ans = 1;
    while(n != 0){
        if(n%2==1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n/2;
    }
    return ans;
}

long mfact(long n){
  long ans = 1;
  for(long i=2; i<=n; i++){
    ans = ans*i % MOD;
  }
  return ans;
}

long mcomb(long n, long m){ //aCbをmod計算
    if(n == 0 && m == 0) return 1;
    if(n < m || n < 0) return 0;
    long ans = mfact(n)*mpow(mfact(m), MOD-2) %MOD;
    ans = ans*mpow(mfact(n-m), MOD-2) %MOD;
    return ans;
}

int main(){
  int X, Y;
  cin >> X >> Y;
  if((X+Y)%3!=0 || X>2*Y || Y>2*X){
    cout << "0" << endl;
    return 0;
  }
  int n=(X+Y)/3;
  int m=X-n;
  cout << mcomb(n, m) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007

#define ARRAY_MAX 200005

int main(){

    ll n;
    cin >> n;
    vector<ll> a(n);
    if(n == 25){
        cout << "Christmas" << endl;
    }else if(n == 24){
        cout << "Christmas Eve" << endl;
    }else if(n == 23){
        cout << "Christmas Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve Eve" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int m, k;
	cin >> m >> k;
	if(m == 0) {
		if(k == 0) {
			cout << "0 0";
		}
		else {
			cout << -1;
		}
	}
	else if(m == 1) {
		if(k == 0) {
			cout << "0 0 1 1";
		}
		else {
			cout << -1;
		}
	}
	else if(k >= (1LL << m)) {
		cout << -1;
	}
	else {
		cout << k << " ";
		for(int i = 0; i < (1LL << m); i++) {
			if(i != k) {
				cout << i << " ";
			}
		}
		cout << k << " ";
		for(int i = (1LL << m) - 1; i >= 0; i--) {
			if(i != k) {
				cout << i << " ";
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  long long n,i,j,s=0;
  scanf("%lld",&n);
  for(i=1;i*i<=n;i++){
    if((n-i)%i==0){
      j=(n-i)/i;
      if(j&&n/j==n%j)s+=j;
    }
    if(n/i==n%i)s+=i;    
  }
  
  printf("%lld\n",s);
  return 0;
}


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

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

	vector<int> d(N);
	for (int i = 0; i < N; ++i) {
		cin >> d[i];
	}
	
	vector<int> vec(110);
	int counter = 0;
	for (int i = 0; i < N; ++i) {
		vec[d[i]]++;
      
	}
	for (int i = 0; i < 110; ++i) {
		if (vec[i] != 0) ++counter;
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

const int mod = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<bool> a(N + 1);

    for (int i = 1; i <= N; i++) {
        int ai;
        cin >> ai;
        if (ai == 1) {
            a[i] = false;
        } else {
            a[i] = true;
        }
    }

    vector<bool> c(N + 1, false); //すくなくとも1つはiの倍数（i自身）があるのでfalse(割ったあまりが1)
    vector<vector<int>> divisor(N + 1);
    for (int i = 1; i <= N; i++) {
        for (int j = 2 * i; j <= N; j += i) {
            divisor[j].push_back(i);
        }
    }

    vector<int> b;
    for (int i = N; i >= 1; i--) {
        if (a[i] == c[i]) {
            b.push_back(i);
            for (int d : divisor[i]) {
                c[d] = !c[d];
            }
        }
    }

    reverse(b.begin(), b.end());
    int M = b.size();
    cout << M << endl;
    rep(i, M)
    {
        printf("%d%c", b[i], i == M - 1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 25244
#include <stdio.h>
int main (){
  int r,c,i,i2,i3,a,b,d,total;
  int chart[102][102]={{}};
  int  sumhor[102]={};
  int  sumvir[102]={};
  b=0;
  
  scanf("%d%d",&r,&c);
  for(i=1;i<=r;i++){
    for(i2=1;i2<=c;i2++){
      scanf("%d",&a);
      chart[i][i2]=a;
      sumhor[i]+=a;
    }
    b+=sumhor[i];
  }

  for(i2=1;i2<=c;i2++){
    for(i=1;i<=r;i++){
      sumvir[i2]+=chart[i][i2];
    }
  }

  for(i=1;i<=r;i++){
    for(i2=1;i2<=c+1;i2++){
      if(i2<=c)   {printf("%d ",chart[i][i2]);}
      if(i2==c+1) {printf("%d\n",sumhor[i]);}
    }
  

    if(i==r) {
      for(i2=1;i2<=c;i2++){
	printf("%d ",sumvir[i2]);
      }
    }
     
  }
  printf("%d\n",b);

  return 0;
}

Measured memory_bytes: 1076
from sys import stdin
def stdinput():
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    inputs = list(map(int, [stdinput() for _ in range(n)]))

    primes = 0
    for a in inputs:
        if is_prime(a, None):
            primes += 1
    print(primes)

def is_prime(a, primes):
    # Search for num below a**0.5,
    # as when A can be devided by number > a**0.5,
    # it means existing number < a**0.5 also can devide A.
    for p in range(2, int(a ** 0.5)  + 1):
        if a % p == 0:
            return False
    return True

if __name__ == '__main__':
    main()


Measured memory_bytes: 6564
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] == 0 {
			fmt.Println(0)
			return
		}
	}

	var product int64
	product = 1
	for i := range a {
		tmp := product * a[i]
		if tmp < product {
			fmt.Println(-1)
			return
		}
		if tmp > 1_000_000_000_000_000_000 {
			fmt.Println(-1)
			return
		}
		product = tmp
	}
	fmt.Println(product)
}


Measured memory_bytes: 6308
#include <stdio.h>
#include <stdlib.h>
int fibo(int);
int main(){
  int i,n;
  scanf("%d",&n);
  if(n <0 || n>44) exit(8);
  printf("%d\n",fibo(n));
  return 0;
}
int fibo(int n){
  static int F[44]={};  
  if(n == 0 || n == 1)
    {
      F[n] = 1;
      return F[n];
    }
  if(F[n]!=0) return F[n];
  F[n]=fibo(n-2) + fibo(n-1);
  return F[n];
}



Measured memory_bytes: 2112
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

using namespace std;

typedef long long li;
typedef unsigned long long lu;
const li infl = ~0LLU >> 2;

template <class T>
inline void Min(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void Max(T &x, T y) {
  if (y > x) x = y;
}

const int mod = 1e9 + 7;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}
int Inv(int x) {
  return Pow(x, mod - 2);
}

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

const int maxn = 2e5;

int n, len[maxn];
map<int, int> str;

bool AddOne(int len, int maxc) {
  int i = len - 1;
  while (i >= 0 && str[i] == maxc - 1) {
    str[i] = 0;
    --i;
  }
  if (i == -1) {
    return false;
  }
  ++str[i];
  return true;
}

bool Check(int maxc) {
  str.clear();
  int slen = 0;
  for (int i = 0; i < n; ++i) {
    if (len[i] > slen) {
      slen = len[i];
      continue;
    }
    if (len[i] < slen) {
      while (!str.empty() && prev(str.end())->first >= len[i]) {
        str.erase(prev(str.end()));
      }
      slen = len[i];
    }
    if (!AddOne(slen, maxc)) {
      return false;
    }
  }
  return true;
}

int main(void) {
  scanf("%d", &n);
  bool can = true;
  for (int i = 0; i < n; ++i) {
    scanf("%d", len + i);
    if (i > 0 && len[i - 1] >= len[i]) {
      can = false;
    }
  }
  if (can) {
    puts("1");
    return 0;
  }

  int low = 2, high = n + 1;
  while (high - low > 1) {
    int mid = low + high >> 1;
    if (Check(mid - 1)) {
      high = mid;
    } else {
      low = mid;
    }
  }
  printf("%d\n", low);
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
//なんかよくわからないやつ
class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      //入力のやつ
        int X = sc.nextInt();
        //鉄道運賃
        int Y = sc.nextInt();
        //バス運賃
        System.out.println(X + Y / 2);
        //合計運賃を計算して出力
    }
}

Measured memory_bytes: 23764
import copy
N=int(input())
p=list(map(int,input().split()))
ans=0
q=copy.deepcopy(p)
q.sort()
for i in range(N):
    if p[i]!=q[i]:
        ans+=1
if ans==0 or ans==2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int n,m,x,ans=1e9;
vector<vector<int> >a;
vector<int>b;

bool check(){
	for(int i=1;i<=m;i++){
		if(b[i]<x)return 0;
	}
	return 1;
}

void dfs(int p){
	if(p==n)return;
	for(int i=p;i<n;i++){
		for(int j=0;j<=m;j++)b[j]+=a[i][j];
		if(check())ans=min(ans,b[0]);
		dfs(i+1);
		for(int j=0;j<=m;j++)b[j]-=a[i][j];
	} 
}

int main(){
	cin>>n>>m>>x;
	a.resize(n,vector<int>(m+1));
	b.resize(m+1);
	for(int i=0;i<n;i++){
		for(int j=0;j<=m;j++)cin>>a[i][j];
	}
	dfs(0);
	if(ans==1e9)cout<<-1;
	else cout<<ans;
	return 0;
}


Measured memory_bytes: 3628
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100+10;
const int V=20200+10,E=50010+10;
const int inf=0x3f3f3f3f;

int n,m;
char s[N][N];
int S,sx,sy,T,tx,ty;

struct edge { int v,w,nxt; } e[E<<1];
int head[V];
void addEdge(int u,int v,int w) {
	static int cnt=1;
	e[++cnt]=(edge){v,w,head[u]},head[u]=cnt;
	e[++cnt]=(edge){u,0,head[v]},head[v]=cnt;
}

int lv[V];
int bfs() {
    memset(lv,0,sizeof(lv)),lv[S]=1;
    queue<int> Q; Q.push(S);
    while (!Q.empty()) {
        int u=Q.front(); Q.pop();
        for (int i=head[u];i;i=e[i].nxt) {
            int v=e[i].v;
            if (e[i].w&&!lv[v]) lv[v]=lv[u]+1,Q.push(v);
        }
    }
    return lv[T]!=0;
}
int dfs(int u,int r) {
    if (u==T||!r) return r;
    int a=0;
    for (int i=head[u];i;i=e[i].nxt) {
        int v=e[i].v;
        if (e[i].w&&lv[v]==lv[u]+1) {
            int t=dfs(v,min(r,e[i].w));
            e[i].w-=t,e[i^1].w+=t,a+=t,r-=t;
            if (!r) break;
        }
    }
    if (!a) lv[u]=0;
    return a;
}
int dinic() { int s=0; while (bfs()) s+=dfs(S,inf); return s; }

int main() {
	n=read(),m=read();
	for (int i=1;i<=n;++i) scanf("%s",s[i]+1);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) {
			if (s[i][j]=='S') S=(i-1)*m+j,sx=i,sy=j;
			if (s[i][j]=='T') T=(i-1)*m+j,tx=i,ty=j;
			if (s[i][j]=='o') {
				int u=(i-1)*m+j,v=(i-1)*m+j+n*m,r=i+2*n*m,c=j+2*n*m+n;
				addEdge(r,u,inf),addEdge(c,u,inf);
				addEdge(u,v,1);
				addEdge(v,r,inf),addEdge(v,c,inf);
			}
		}
	if (sx==tx||sy==ty) { puts("-1"); return 0; }
	addEdge(S,sx+2*n*m,inf),addEdge(S,sy+2*n*m+n,inf);
	addEdge(tx+2*n*m,T,inf),addEdge(ty+2*n*m+n,T,inf);
	printf("%d\n",dinic());
	return 0;
}

Measured memory_bytes: 5008
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  
  vector<int> cont(N);
  
  for(int i = 0 ; i < N ; i++){
    cin >> cont.at(i);
  }
  
  sort(cont.begin() , cont.end());
  double sum = cont.at(0);
  
  for(int i = 1 ; i < N ; i++){
    int a = cont.at(i);
    sum = (sum + a)/2;
  }
  
  cout << fixed << setprecision(10);
  cout << sum << endl;
}

Measured memory_bytes: 256
N,C=map(int,input().split())

L=[]
for i in range(N):
    x,y=map(int,input().split())
    L.append([x,y])
    
l=L[::-1]
L=[[0,0]]+L
R=[]

for i in range(N):
    R.append([C-l[i][0],l[i][1]])
R=[[0,0]]+R


#print(L)
#print(R)
TS=[0]
TW=[0]
RS=[0]
RW=[0]

for i in range(N):
    TS.append(TS[i]-L[i+1][0]+L[i][0]+L[i+1][1])
    TW.append(TW[i]-2*(L[i+1][0]-L[i][0])+L[i+1][1])
    RS.append(RS[i]-R[i+1][0]+R[i][0]+R[i+1][1])
    RW.append(RW[i]-2*(R[i+1][0]-R[i][0])+R[i+1][1])
    
MTS=[0]
MRS=[0]
for i in range(1,N+1):
    MTS.append(max(MTS[i-1],TS[i]))
    MRS.append(max(MRS[i-1],RS[i]))

ans=0
for i in range(N+1):
    if i>0 and L[i-1][0]*2>C:
        break
    else:
        if ans<TW[i] + MRS[N-i]:
            ans=TW[i] + MRS[N-i]
            
for i in range(N+1):
    if i>0 and R[i-1][0]*2>C:
        break
    else:
        if ans<RW[i]+MTS[N-i]:
            ans=RW[i]+MTS[N-i]
print(ans)

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A * B >= C * D){
    cout << A * B << endl;
  }
  else
  {
    cout << C * D << endl;
  }
  
}

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

int main(){
	int w;
	while(cin >> w, w != -1){
		int fee = 1150;
		for(int i=11; i <= 20 && i <= w; i++) fee += 125;
		for(int i=21; i <= 30 && i <= w; i++) fee += 140;
		for(int i=31; i <= w; i++) fee += 160;

		cout << 4280 - fee << endl;
	}
}

Measured memory_bytes: 1156
from sys import stdin

def main():
    N = int(stdin.readline())
    H = list(map(int,stdin.readline().split()))
    answer = 1
    for i in range(1,len(H)):
        if H[i] >= max(H[:i]):
            answer += 1

    print(answer)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
use std::io::*;
use std::str::FromStr;


fn abc(n: i32) -> i32 {
    if n < 105 {
        return 0
    } else if n < 135 {
        return 1
    } else if n < 165 {
        return 2
    } else if n < 189 {
        return 3
    } else if n < 195{
        return 4
    } else {
        return 5
    }
}



fn main() {
    /*
    assert_eq!(abc(), "Yes");
    assert_eq!(abc(101), "No");
    assert_eq!(abc(999999999), "Yes");
    */
    let n: i32 = read();

    let result = abc(n);
    
    println!("{}", result);
    
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (
        T&& t
      ) noexcept
      : T(forward<T>(t))
      {
      }
    template<typename... Args>
    constexpr decltype(auto)
    operator()(
        Args&&... args
      ) const
      {
        return T::operator()(*this, forward<Args>(args)...);
      }
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{forward<T>(t)};
}
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<vector<int>> grh(n);
  for (int i = 0; i < n - 1; i++) {
    int s, t;
    cin >> s >> t;
    grh[--s].push_back(--t);
    grh[t].push_back(s);
  }
  constexpr long long inf = 1LL << 60;
  long long ans = inf;
  for (int st = 0; st < n; st++) {
    vector<long long> sz(n), mn(n), mx(n);
    fix ([&](auto dfs, int crr, int prt) -> void {
      sz[crr] = s[crr] == '1';
      long long mn_singular = -1, mx_singular = -1;
      for (auto const& nxt : grh[crr]) if (nxt != prt) {
        dfs(nxt, crr);
        sz[crr] += sz[nxt];
        mx[crr] += mx[nxt] + sz[nxt];
        if (mn[nxt] + sz[nxt] > mn_singular) {
          mn_singular = mn[nxt] + sz[nxt];
          mx_singular = mx[nxt] + sz[nxt];
        }
      }
      if (mn_singular > mx[crr] - mx_singular) {
        mn[crr] = mn_singular - (mx[crr] - mx_singular);
      } else {
        mn[crr] = mx[crr] % 2;
      }
    })(st, st);
    if (mn[st] == 0) {
      cmn(ans, mx[st] / 2);
    }
  }
  cout << (ans == inf ? -1 : ans) << endl;
  return 0;
}

Measured memory_bytes: 640
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  cout << N * N - A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
inline int read() 
{
    register int x = 0 , ch = getchar(); 
    while( !isdigit( ch ) ) ch = getchar(); 
    while( isdigit( ch ) ) x = x * 10 + ch - '0' , ch = getchar();     
    return x; 
}
ll quick_power(ll a,ll b,ll modn)
{
    ll ans=1;
    while(b)
    {
        if(b%2)
            ans=ans*a%modn;
        a=a*a%modn;
        b=(b>>1);
    }
}
ll turtle_muti(ll ain,ll bin,ll modn)
{
    ll res=0;
    for(;bin;bin>>=1) 
    {
        if(bin&1)
            res=(res+ain)%modn;
        ain=(ain<<1)%modn;
    }
    return res;
}
/*------------------Coding Area------------------*/
const int maxn=1000010;
const int inf=0x3f3f3f3f;
int n,k;
struct info
{
    int x,v;
}a[maxn];
bool cmp(info one,info two)
{
    return one.v>two.v;
}
int vis[maxn];
stack<int> s;
int main()
{
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;++i)
        scanf("%d %d",&a[i].x,&a[i].v);
    sort(a+1,a+1+n,cmp);
    ll cnt=0;
    ll tp=0;
    ll res=0;
    ll ans=0ll;
    for(int i=1;i<=n;++i)
    {
        if(cnt<k)
        {
                if(vis[a[i].x]==0)
                {
                    vis[a[i].x]=1;
                    tp++;
                }
                else
                    s.push(a[i].v);
                res+=a[i].v;
                cnt++;
                ans=max(ans,res+1ll*tp*tp);
        }
        else
        {
            if(s.empty())
                break;
            if(vis[a[i].x])
                continue;
            vis[a[i].x]=1;
            tp++;
            res-=s.top();
            res+=a[i].v;
            s.pop();
            ans=max(ans,res+tp*tp);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>

int n,in,r;


int main(){������
	scanf("%d %d",&n,&r);
	
	if (n < 10){
		in=r+100*(10-n);
		printf("%d",in);
		return 0;
	}
	printf("%d",r);
	
	
	return 0;
}

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

long long a[101010],f[101010];
int n,k;

main()
{
    cin >> n >> k;
    for(int i=2; i<=n; i++) f[i]=1e11;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=2; i<=n; i++)
    {
        for(int j=i-1; j>=i-k &&j>=1; j--)
            f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
    }
    cout << f[n];
}


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

int main()
{
  ll n; cin >> n;
  ll r; cin >> r;
  if (n >= 10) cout << r << endl;
  else cout << r+(100*(10-n)) << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	if (s <= "2019/04/30") cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	ll n,m;
	cin >> n >> m;
	vector<ll> a(n);
	vector<pair<ll, ll>> cb;
	FOR(i, 0, n-1) {
		cin >> a[i];
	}
	sort(ALL(a));

	FOR(i, 1, m) {
		ll b, c;
		cin >> b >> c;
		cb.push_back(MP(c, b));
	}
	sort(ALL(cb));
	
	vector<ll> change(m);
	RFOR(i,m-1,0){
		auto itr = lower_bound(ALL(a), cb[i].F);
		//change[i] = min((itr - a.begin()), int(cb[i].S));
		change[i] = itr - a.begin();
	}

	ll nowidx = 0;
	RFOR(i, m - 1, 0) {
		if (change[i] > nowidx) {
			int cnt = 0;
			FOR(j, nowidx, change[i] - 1) {
				a[j] = cb[i].F;
				cnt++;
				nowidx++;
				if (cnt == cb[i].S)break;
			}
			//nowidx = change[i];
		}
	}
	ll res = accumulate(ALL(a), 0LL);
	pv(res);
	return(0);
}

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

#define ll long long
using namespace std;



const int m = 1e9+7;



ll  mod(ll  n){
	return (n%m + m)%m;
}



ll mul(ll i,ll n){
	return mod(mod(i)*mod(n));
}

ll add(ll i,ll n){
	return mod(mod(i)+mod(n));
}

 


ll min(ll i,ll n){
	return mod(mod(i)-mod(n));
}

ll pow(ll a,ll b,ll m){
	ll res = 1;
	while(b>0){
		if(b&1){
			res = (res*a)%m;
		}
		a = (a*a)%m;
		b = b>>1;
	}
	
	return res;

}


int main(){

ll n;
cin >> n;
if(n == 1){
	cout << 0;
}
else if(n == 2){
	cout << 2;
		
}else{
ll  ans = min(add(pow(10ll,n,m), pow(8ll,n,m)),mul(2ll,pow(9ll,n,m)) );

cout << ans << endl;

}


return 0;

}

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 998244353;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

int main()
{
    IOS
    for(int i=1;i<=5;i++) {
        int x;
        cin >> x;
        if(x == 0) {
            cout << i << endl;
            break;
        }
    }
    return 0; 
}



Measured memory_bytes: 3560