akhauriyash/Code-Regression huggingface dataset:
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut mp = std::collections::BTreeMap::new();
    let mut vs = vec![];
    let mut cs = vec![0; n];
    let mut ci = 0;
    for _ in 0 .. n {
    	let a = get!();
        if let Some(&i) = mp.get(&a) {
            cs[i] += 1;
            continue;
        }
        vs.push(a);
        mp.insert(a, ci);
        cs[ci] = 1;
        ci += 1;
    }
    if ci > 3 {
        println!("No");
        return;
    }
    if ci == 2 {
        // 1 1 0 1 1 0
        if vs[0] ^ vs[0] == vs[1] && cs[0] == cs[1] * 2 {
            println!("Yes");
        } else if vs[1] ^ vs[1] == vs[0] && cs[1] == cs[0] * 2 {
            println!("Yes");
        } else {
            println!("No");
        }
        return;
    }
    if ci == 1 {
        if vs[0] ^ vs[0] == vs[0] {
            println!("Yes");
        } else {
            println!("No");
        }
        return;
    }
    if vs[0] ^ vs[1] != vs[2] {
        println!("No");
        return;
    }
    if n % 3 != 0 {
        println!("No");
        return;
    }
    if cs[0] == cs[1] && cs[1] == cs[2] {
        println!("Yes");
        return;
    }
    if cs[0] != cs[1] || cs[0] != cs[2] {
        println!("No");
        return;
    }
    let p0 = vs[0];

    let p1 = vs[1];
    let mut rs = vec![0; n];
    if let Some(&i) = mp.get(&p0) {
        rs[i] += 1;
    }
    if let Some(&i) = mp.get(&p1) {
        rs[i] += 1;
    }
    let mut pa = p0;
    let mut pb = p1;
    let mut ok = true;
    for _ in 2 .. n {
        let p = pa ^ pb;
        if let Some(&i) = mp.get(&p) {
            if rs[i] < cs[i] {
                rs[i] += 1;
            } else {
                ok = false;
                break;
            }
        } else {
            ok = false;
            break;
        }
        pa = pb;
        pb = p;
    }
    if pa ^ pb != p0 {
        ok = false;
    }
    if pb ^ p0 != p1 {
        ok = false;
    }
    if ok {
        println!("Yes");
        return;
    }
    println!("No");
}


Measured memory_bytes: 8444
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < h; i++) {
		string b = a[i];
		bool ok = false;
		int counter = 0;
		for (int j = 0; j < w; j++) {
			if (b.at(j) == 'c') {
				ok = true;
				counter = 0;
				cout << 0;
			}
			else {
				counter++;
				if (ok) {
					cout << counter;
				}
				else {
					cout << -1;
				}
			}
			if (j != w - 1) cout << " ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3248
N = int(input())
arms = []

for _ in range(N):
    X, L = map(int, input().split())
    tmp = (X-L, X+L)
    arms.append(tmp)

arms.sort()

trash_count = 0
focus_point = 0

focus_point = arms[0][1]
for arm in arms[1:]:
    if focus_point <= arm[0]:
        focus_point = arm[1]
    elif focus_point <= arm[1]:
        trash_count += 1
    else:
        trash_count += 1
        focus_point = arm[1]

print(N-trash_count)


Measured memory_bytes: 17360
def find_factor(N):
    factors=[]
    factors2=[]
    S=int(N**0.5)
    for i in xrange(2,S+1):
        if N%i==0:
            factors+=[i]
            factors2+=[N//i]
    if S**2!=N:
        all_factor= factors+factors2[::-1]   
    else:
        all_factor= factors[:-1]+factors2[::-1] 

    return [1]+all_factor+[N]

def find_ans(N):
    ans=0
    factors=find_factor(N)
    for i in xrange(len(factors)):
        x=factors[i]
    
        m=x-1
        k=N//x
        if m==0:
            continue
        if k==N%m:
            ans+=m
    return ans

N=input()
print(find_ans(N))

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int n; cin >> n;
	int ans = 0, mp = n+1;
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		if (mp > p) {
			++ans;
			mp = p;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import scala.io.Source.stdin

object Main {
  val w = List(1,2,4,8,16,32,64,128,256,512)
  def main(args:Array[String]) =
    stdin.getLines.map(_.toInt).foreach { i => println(w.filter(y=>(y & i)>0).mkString(" ")) }
}

Measured memory_bytes: 43816
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N, D;
  cin >> N >> D;
  int cur = 0;
  int res = 0;
  while (true) {
    cur += D * 2 + 1;
    ++res;
    if (cur >= N) {
      break;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
X=int(input())
def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum
B=seachPrimeNum(100100)
for i in range(len(B)):
    if B[i]>=X:
        answer=i
        break
print(B[answer])

Measured memory_bytes: 16708
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

uint64_t nCr(uint64_t n, uint64_t r) {
	if (n == 0) return 0;
	if (r > n) return 0;

	uint64_t ret = 1;
	for (uint64_t i = 0; i < r; i++) {
		ret = ret * (n - i) / (i + 1);
	}
	return ret;
}

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

	int n; cin >> n;
	
	vector<string> ss(n);
	for (auto& s : ss) {
		cin >> s;
		sort(s.begin(), s.end());
	}

	sort(ss.begin(), ss.end());
	
	string prev = "";
	int c = 0;
	int64_t sum = 0;
	for (auto& s : ss) {
		if (s != prev) {
			prev = s;
			if (c >= 2) {
				sum += nCr(c, 2);
			}
			c = 0;
		}
		c++;
	}

	if (c >= 2) {
		sum += nCr(c, 2);
	}
	
	cout << sum << endl;


	return 0;
}

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

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<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()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut dp: Vec<Vec<usize>> = vec![];
    for i in 0..n {
        if i == 0 {
            dp.push(vec![read(), read(), read()]);
            continue;
        }
        let a: usize = read();
        let b: usize = read();
        let c: usize = read();
        let vec = vec![
            std::cmp::max(dp[i - 1][1] + a, dp[i - 1][2] + a),
            std::cmp::max(dp[i - 1][0] + b, dp[i - 1][2] + b),
            std::cmp::max(dp[i - 1][0] + c, dp[i - 1][1] + c),
        ];
        dp.push(vec);
    }
    println!("{}", dp[n - 1].iter().max().unwrap());
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if(i%2==0&&a%2==1) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
// AOJ 2868 Hierarchical Calculator
// 2018.3.29 bal4u

#include <stdio.h>

int a[63];
int c[5];		// a = -2, -1, 0, 1, 2;

int main()
{
	int N, i;

	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", a+i);
		c[2+a[i]]++;
	}
	c[2] = c[3] = 0;
	if (!(c[0] & 1)) c[1] = 0;
	else if (c[1]) c[1] = 1;
	else c[0]--;
	printf("%d\n", c[0]+c[1]+c[4]);
	for (i = 1; i <= N; i++) {
		if (c[2+a[i]]) printf("%d\n", i), c[2+a[i]]--;
	}
	return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < (int) b.size(); i++) {
    cout << a[i] << b[i];
  }
  if (a.size() > b.size()) cout << a.back();
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, x, y;
pii ed;
vector<int> v[200005];
void dfs(int N, int P, int D){
  ed = max(mp(D, N), ed);
  fox(l, v[N].size()){
    if (v[N][l]==P) continue;
    dfs(v[N][l], N, D+1);
  }
}
int32_t main(){
  scanf("%i", &n);
  fox(l, n-1){
    scanf("%i%i", &x, &y);
    v[x].pb(y);
    v[y].pb(x);
  }
  ed = mp(-1, -1);
  dfs(1, -1, 1);
  ed.x = -1;
  dfs(ed.y, -1, 1);
  if (ed.x%3 == 2) printf("Second");
  else printf("First");
  return 0;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n,k;
    cin >> n >> k;
    int ans=0;
    REP(i,n){
        int h;
        cin >> h;
        if(h>=k)ans++;
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int n;
  int k;
  scanf("%d", &n);
  scanf("%d", &k);

  vector<int> h(n);
  REP(i, n) {
    scanf("%d", &h[i]);
  }
  sort(ALL(h));
  reverse(ALL(h));

  long long sum = 0;
  REP(i, n) {
    if (i < k) continue;
    sum += h[i];
  }

  printf("%lld\n", sum);

  return 0;
}


Measured memory_bytes: 1024
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#pragma GCC      optimize ("Ofast")
#include         <bits/stdc++.h>
#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
using namespace std;

const int N = (int)1e5 + 4;
int n;
int memo[N], h[N];
int dp (int i) {
	if (i >= n) return 0;
	else if (memo[i] != -1) return memo[i];
	else {
		int j1  = dp (i + 1) + abs(h[i] - h[i + 1]),
			j2 = (i + 2 <= n ? dp (i + 2) +  abs (h[i] - h[i + 2]) : INT_MAX);
		return memo[i] = min(j1, j2);
	}
}

int main() {
	IOS; PREC;

	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> h[i], memo[i] = -1;
	cout << dp (1) << endl;

	return EXIT_SUCCESS;
}




Measured memory_bytes: 4224
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const double pi = 3.1415926535897932;
const double eps = 0.000000000001;
const int inf = 1145141919;
struct edge { int to, cost; };
typedef pair<int, int>P;
typedef pair<int, P> PP;
typedef pair<string, string>PS;
map<PS,int>M1,M2;

signed main() {
	int n; cin >> n;
	string s; cin >> s;
	rep(i, 1<<n) {
		string t,u;
		rep(j, n) {
			if (i&(1 << j))t.push_back(s[j]);
			else u.push_back(s[j]);
		}
		M1[PS(t, u)]++;
	}
	string V;
	for (int i = n; i < 2 * n; i++)V.push_back(s[i]);
	reverse(V.begin(), V.end());
	rep(i, 1 << n) {
		string t, u;
		rep(j, n) {
			if (i&(1 << j))t.push_back(V[j]);
			else u.push_back(V[j]);
		}
		M2[PS(t, u)]++;
	}
	int sum = 0;

	for (auto itr = M1.begin(); itr != M1.end(); itr++) {
		PS A = itr->first;
		sum += itr->second*M2[A];
	}
	cout << sum << endl;
}

Measured memory_bytes: 108288
// 2017/11/20 Tazoe

#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

class SP{
public:
	string p;
	int n;		// ?????°

	int find0()		// 0?????¢???
	{
		for(int i=0; i<8; i++){
			if(p[i]=='0')
				return i;
		}

		return -1;
	}

	void swp1()		// ???????????????
	{
		int i0 = find0();

		if(4<=i0 && i0<=7){
			swap(p[i0], p[i0-4]);
		}
	}

	void swp2()		// ???????????????
	{
		int i0 = find0();

		if(0<=i0 && i0<=3){
			swap(p[i0], p[i0+4]);
		}
	}

	void swp3()		// ???????????????
	{
		int i0 = find0();

		if(i0!=0 && i0!=4){
			swap(p[i0], p[i0-1]);
		}
	}

	void swp4()		// ???????????????
	{
		int i0 = find0();

		if(i0!=3 && i0!=7){
			swap(p[i0], p[i0+1]);
		}
	}
};


int main()
{
	queue<SP> que;			// ?????\???
	map<string, int> memo;		// ?????¢

	SP now;
	now.p = "01234567";
	now.n = 0;
	que.push(now);
	memo[now.p] = now.n;

	while(!que.empty()){		// ?????\???????????????????????§
		now = que.front();
		que.pop();

		SP nex1 = now;  nex1.swp1();  nex1.n++;
		if(memo.find(nex1.p)==memo.end()){
			que.push(nex1);
			memo[nex1.p] = nex1.n;
		}

		SP nex2 = now;  nex2.swp2();  nex2.n++;
		if(memo.find(nex2.p)==memo.end()){
			que.push(nex2);
			memo[nex2.p] = nex2.n;
		}

		SP nex3 = now;  nex3.swp3();  nex3.n++;
		if(memo.find(nex3.p)==memo.end()){
			que.push(nex3);
			memo[nex3.p] = nex3.n;
		}

		SP nex4 = now;  nex4.swp4();  nex4.n++;
		if(memo.find(nex4.p)==memo.end()){
			que.push(nex4);
			memo[nex4.p] = nex4.n;
		}
	}


	while(true){
		string q;
		cin >> q;

		if(cin.eof())
			break;

		for(int i=1; i<8; i++){
			string c;
			cin >> c;

			q += c;
		}

		cout << memo[q] << endl;
	}

	return 0;
}

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

int main(){
    int n;
    long long ans = 0;
    cin >> n;
    for (int i=1; i<=n; i++){
        if (i % 3 == 0 || i % 5 == 0) continue;
        else ans += i;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3620
fn main() {
    let v = read_vec::<i64>();
    let n = v[0];
    let m = v[1];
    if (n - m).abs() >= 2 {
        println!("0");
        return;
    }

    let mut ans = 1;
    let div = 1000000007;
    let x = std::cmp::min(n, m) + 1;
    for i in 1..x {
        ans *= i;
        ans %= div;
        ans *= i;
        ans %= div;
    }
    if n != m {
        ans *= x;
        ans %= div;
    } else {
        ans *= 2;
        ans %= div;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
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()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
    a[i] = input()
# print(a)

# 行、列に黒が存在するならTrue
row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True
# print(row)
# print(col)

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                # 一つずつprintすると改行されてしまう
                # end="" で改行しないようにする
                print(a[i][j], end='')
        print()  # print() で改行、次のrowへ

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

int n;
vector<int> a;

bool isAnswer(int i, int m) {
    if (m == 0) return true;
    if (i >= n) return false;
    return isAnswer(i+1, m) || isAnswer(i+1, m-a[i]);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        a.push_back(ai);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int m;
        cin >> m;
        bool isAns = isAnswer(0, m);
        if (isAns) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}



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

int main() {
    ll n, k, s;
    cin >> n >> k >> s;

    ll tmp = 1000000000;
    if(s!=tmp){
        rep(i, k){
            cout << s;
            cout << " ";
        }
        rep(i, n-k){
            cout << tmp;
            if(i!=n-k-1) cout << " ";
        }
        cout << endl;
    }
    else{
        rep(i, k){
            cout << tmp;
            cout << " ";
        }
        rep(i, n-k){
            cout << 1;
            if(i!=n-k-1) cout << " ";
        }
        cout << endl;
    }

}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

map<ll, ll> factors;

int main() {
    ll N; cin >> N;
    bool check = true;
    if(N == 1) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 2; i <= sqrt(N); i++) {
        while (N % i == 0) {
            check = false;
            factors[i]++;
            N /= i;
        }
        if (N == 1) break;
    }
    if(check) {
        cout << 1 << endl;
        return 0;
    }

    if (N != 1) factors[N]++;
   
    
    ll ans = 0;
    for (const auto& [key, value] : factors) {
        ll k = (-1 + sqrt(1 + 8 * value)) / 2;
        ans += k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int main() {
  ll H, W, K;
  cin >> H >> W >> K;
  vvi c(H, vi(W));
  for (ll i = 0; i < H; i++) {
    string s;
    cin >> s;
    for (ll j = 0; j < W; j++) {
      c[i][j] = s[j] == '.' ? 0 : 1;
    }
  }

  ll ans = 0;

  // (2^6)^2=4096
  for (ll maskH = 0; maskH < (1 << H); maskH++) {
    for (ll maskW = 0; maskW < (1 << W); maskW++) {
      ll cnt = 0;
      for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
          if (c[i][j] == 1 && ((maskH >> i) & 1) && ((maskW >> j) & 1)) {
            cnt++;
          }
        }
      }
      if (cnt == K) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3628
fun main(args: Array<String>) {
  val K = readInt()
  val (A, B) = readInts()
  for (i in A..B) {
    if (i % K == 0) {
      println("OK")
      return
    }
  }
  println("NG")
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 36328
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define Mod 1000000007
using namespace std;
int N;
int c[100010];
int lowbit(int x)
{
	return x&(-x);
}
void add(int x,int y)
{
	for(;x<=N+1;x+=lowbit(x))
		c[x]=(c[x]+y)%Mod;
	return ;
}
int query(int x)
{
	int ans=0;
	for(;x;x-=lowbit(x))
		ans=(ans+c[x])%Mod;
	return ans;
}
struct Point{
	int x,y;
}p[100010];
int tmp[100010];
bool cmp(Point a,Point b)
{
	return a.x<b.x||(a.x==b.x&&a.y>b.y);
}
int a[100010],b[100010];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)scanf("%d",&b[i]);
	int now=1;
	for(int i=1;i<=n;i++)
	{
		while(now<=m&&b[now]<=a[i])now++;
		if(now==1||now>m)continue;
		N++;
		p[N].x=a[i]-b[now-1];
		p[N].y=b[now]-a[i];
		tmp[N]=p[N].y;
	}
	sort(tmp+1,tmp+N+1);
	sort(p+1,p+N+1,cmp);
	add(1,1);
	for(int i=1;i<=N;i++)
	{
		if(p[i].x==p[i-1].x&&p[i].y==p[i-1].y)continue;
		int pos=lower_bound(tmp+1,tmp+N+1,p[i].y)-tmp;
		int val=query(pos);
		add(pos+1,val);
	}
	printf("%d\n",query(N+1));
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll n;
  ll m;
  cin >> n >> m;
  ll x[n],y[n],z[n];
  rep(i,n)cin >> x[i] >> y[i] >> z[i];
  ll ans=0;
  rep(i,8){
    ll aans=0;
    ll k[n];
    rep(j,n){
      ll p=0;
      if(i&(1<<0)){
        p+=x[j];
      }
      else p-=x[j];
      if(i&(1<<1)){
        p+=y[j];
      }
      else p-=y[j];
      if(i&(1<<2)){
        p+=z[j];
      }
      else p-=z[j];
      k[j]=p;
    }
    sort(k,k+n);
    rep(v,m)aans+=k[n-1-v];
    ans=max(ans,aans);
  }
  cout << ans << endl;
}  


Measured memory_bytes: 256
s,t;main(a,b,c,d,e,f,g,h){scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h);s=a+b+c+d;t=e+f+g+h;s=!printf("%d\n",s>t?s:t);}

Measured memory_bytes: 592
;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int[] arr = inputval();
        int l = arr[0]+arr[1];
        int r = arr[2]+arr[3];
        if(l>r) System.out.println("Left");
        else if(l==r) System.out.println("Balanced");
        else System.out.println("Right");
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

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

ll N,x;

int main(){
  cin >> N >> x;
  vector<ll> S(N);
  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }
  ll ans[N][N];
  for(int i=0;i<N;i++){
    if(i==0){
      for(int j=0;j<N;j++){
        ans[i][j]=S.at(j);
      }
    }else{
      for(int j=0;j<N;j++){
        if(j==0)
          ans[i][j]=min(ans[i-1][N-1],ans[i-1][0]);
        else
          ans[i][j]=min(ans[i-1][j-1],ans[i-1][j]);
      }
    }
  }
  for(int i=0;i<N;i++){
    S.at(i)=x*i;
    for(int j=0;j<N;j++){
      S.at(i)+=ans[i][j];
    }
  }/*
  for(int i=0;i<N;i++){
    cout << S.at(i) << endl;
  }*/
  sort(S.begin(),S.end());
  cout << S.at(0) << endl;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,m;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m+2;i++)
	{
		cout<<"#";
	}
	cout<<endl;
	for(int i=1;i<=n;i++)
	{
		cout<<"#";
		for(int j=1;j<=m;j++)
		{
			char tmp;
			cin>>tmp;
			cout<<tmp;
		}
		cout<<"#";
		cout<<endl;
	}
	for(int i=1;i<=m+2;i++)
	{
		cout<<"#";
	}
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

n = input()
n = bin(n)[2:]

def func(dig, val1, val2):
    for i in range(dig):
        v1 = val1 * 2 + val2
        v2 = val2 * 2 + val1
        val1, val2 = v1, v2
    return val2

ans = 0
val1 = 0
val2 = 1
for i in range(len(n)):
    if n[i] == '1':
        ans += func(len(n) - i - 1, val1, val1 + val2)
        val1 = val1 + val2
    else:
        val2 = val1 + val2
print (ans + val2) % (10 ** 9 + 7)

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



int main()
{

    long long  n,a,b;
    cin >> n >> a >> b;

    if (abs(a-b)%2==0) cout << abs(a-b)/2;
        else
    cout <<            min( min(a,b)-1, n - max(a,b))   +  (abs(a-b)+1)/2;                      ;             

    
    
    
    
    
    
    
    
    
    

}























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

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

typedef long long ll;

using namespace std;

const int MOD = 1000000007;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 3;
	if (a == b) {
		if (b == c) {
			ans = 1;
		}
		else {
			ans = 2;
		}
	}
	else if (a == c || b == c) {
		ans = 2;
	}

	cout << ans << endl;

	return 0;
}

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

int INF = 1'000'000'000;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<int> ans(n, INF);
    ans[0] = 0;
    ans[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++){
        ans[i] = min(ans[i-1] + abs(h[i] - h[i-1]) , ans[i-2] + abs(h[i] - h[i-2]));
    }
    cout << ans.back() << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  } else if(s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  } else if(s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

int main(){
	long long h, ans, tmp;
	cin >> h;
	ans = 0;
	tmp = 1;
	while(h>0){
		h /= 2;
		ans += tmp;
		tmp *= 2;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;++i){
		int a[3];
		for(int j = 0;j < 3;++j){
			cin >> a[j];
		}
		sort(a, a + 3);
		if(a[0] * a[0] + a[1] * a[1] == a[2] * a[2]){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1168
import bisect
from collections import Counter
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n, a = II(), LI()
ans = 0
right = 0
sum = 0

for left in range(n):
    
    while right < n and sum ^ a[right] == sum + a[right]:
        sum += a[right]
        right += 1

    ans += (right - left)

    if left == right:
        right += 1
    else:
        sum -= a[left]

print(ans)


Measured memory_bytes: 25088
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  string ans = (N <= 999) ? "ABC" : "ABD";
  cout << ans << endl;
  return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M, long long C, std::vector<long long> B, std::vector<std::vector<long long>> A){
    int ans = 0;
    REP(i, N) {
        int now = 0;
        REP(j, M) {
            now += A[i][j] * B[j];
        }
        now += C;
        ans += 0 < now;
    }
    cout << ans << endl;
}

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


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

int main(void)
{
  int a;
  int b;
  int *pa;
  int *pb;
  int i;
  int c;
  int ia;
  int ib;
  int result;
  int ca;
  int cb;

  pa = (int *)malloc(sizeof(int) * 10000);
  pb = (int *)malloc(sizeof(int) * 10000);
  result = scanf("%d", &a);
  result = scanf("%d", &b);

  i = 0;
  ia = 0;
  ib = 0;
  while (i < 10000)
  {
    c = i * 0.08;
    if (c == a)
    {
      pa[ia] = i;
      ia++;
    }
    c = i * 0.10;
    if (c == b)
    {
      pb[ib] = i;
      ib++;
    }
  i++;
  }

  ca = 0;
  while (ca <= ia)
  {
    cb = 0;
    while (cb <= ib)
    {
      if (pa[ca] == pb[cb] && pa[ca] != 0 && pb[cb] != 0)
      {
        printf("%d", pb[cb]);
        return (0);
      }
      cb++;
    }
  ca++;
  }
  printf("-1");
  return (0);
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
char ch[maxn];
int a[maxn*2];
int main()
{
     int i,j,k=0,n,d,p=0,r=0;  int u=0;
     scanf("%d",&n);
     for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>k){
            k=a[i];r=i;
        }
     }

     for(i=0;i<n;i++){
        if(a[i]!=k&&a[i]>p){
            p=a[i];
        }
        if(a[i]==k) u++;
     }
     if(u>1){
        for(i=0;i<n;i++)
            printf("%d\n",k);
     }
     else {
         for(i=0;i<n;i++){
        if(a[i]!=k)
            printf("%d\n",k);
        else printf("%d\n",p);
     }
     }

    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>

int main(){
    int A[100];
    int n, m, i, j;
    int count = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }

    for(i = 0; i < n-1; i++){
        for(j = n-1; j > i; j--){
            if(A[j] < A[j-1]){
                m = A[j];
                A[j] = A[j-1];
                A[j-1] = m;
                count++;
            }
        }
    }
    
    
    for(i = 0; i < n; i++){
        if(i > 0){
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n%d\n", count);

  return 0;
}

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

#define SZ(a) (int)a.size()
#define PB push_back
//#define cerr if(false)cerr
#define print(x) cerr<<"\n" << (#x) << " is " << (x) << endl;

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

typedef vector<int> vi;
typedef vector<ll> vll;

const int MAXN = 1000007;
const int INF = 1000303;
const int MOD = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	while(n > 0){
		n /= k;
		cnt ++;
	}
	cout << cnt << endl;
}


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

using namespace std;

const double pi = acos(-1);
const int N = 2 * (1e5) + 10, inf = 2147483647;

struct F
{
    int x, y;
    void read() { scanf("%d%d", &x, &y); }
    friend bool operator<(F x, F y) { return x.x < y.x; }
} a[N];
int lis[N], rec[N];
int n, m;
int stx, sty, edx, edy;
double ans;
int Abs(int x) { return x < 0 ? -x : x; }
void solve()
{
    int tmp, len = 0;
    memset(rec, -1, sizeof(rec));
    for (int i = 1; i <= lis[0]; ++i)
    {
        if (rec[len] < lis[i])
        {
            rec[++len] = lis[i];
            continue;
        }
        tmp = lower_bound(rec + 1, rec + 1 + len, lis[i]) - rec;
        rec[tmp] = lis[i];
    }
    if (len == (edx - stx + 1) || len == Abs(sty - edy) + 1)
        ans = pi * 5.0;
    else
        ans = 0;
    ans += 1LL * ((edx - stx) + Abs(sty - edy)) * 100;
    ans += (pi * 5.0 - 20) * len;
    printf("%.15lf\n", ans);
}

int main()
{
    scanf("%d%d%d%d", &stx, &sty, &edx, &edy);
    if (stx > edx)
        swap(stx, edx), swap(sty, edy);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        a[i].read();
    sort(a + 1, a + 1 + n);
    if (sty > edy)
    {
        for (int i = 1; i <= n; ++i)
            a[i].y = 1e8 - a[i].y + 1;
        sty = 1e8 - sty + 1;
        edy = 1e8 - edy + 1;
    }
    lis[0] = 0;
    for (int i = 1; i <= n && a[i].x <= edx; ++i)
        if (stx <= a[i].x)
        {
            if ((sty >= edy && edy <= a[i].y && a[i].y <= sty) || (sty <= edy && sty <= a[i].y && a[i].y <= edy))
                lis[++lis[0]] = a[i].y;
        }
    solve();
}

Measured memory_bytes: 3328
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    s = input()
    if len(s) < 26:
        al = [chr(ord('a') + i) for i in range(26)]
        for i in al:
            if not (i in s):
                print(s + i)
                exit()
    if s == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
        exit()
    for i in range(25):
        if s[i] < s[i + 1]:
            k = i
    a = "z"
    for i in range(k + 1, 26):
        if s[k] < s[i]:
            a = min(a, s[i])
    print(s[:k] + a)

if __name__ == '__main__':
    main()

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll a, b, c;

int main(){
    scanf("%lld%lld%lld", &a,&b,&c);
    if(a==b&&b==c){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
//#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
using std::swap;
vector <vector<int>> d;

int main() {
	int N, D,t=0;
	cin >> N >> D ;
	d.resize(N);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < D; ++j) {
			int x;
			cin >> x;
			d[i].push_back(x);
		}
	}
	for (int i = 0; i < N-1; ++i) {
		for (int j = i+1; j < N; ++j) {
			double x = 0;
			for (int k = 0; k < D; ++k) {
				x += pow(d[i][k] - d[j][k], 2);
			}
			if (ceil(sqrt(x)) == floor(sqrt(x)))++t;
		}
	}
	cout << t << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

// struct path
// {
//     pair<ll, ll> f;
//     pair<ll, ll> t;
// };

// struct cmp
// {
//     bool operator() ( path a, path b ) const
//     { return std::make_pair(a.f,a.t) > std::make_pair(b.f,b.t) ; }
// };


bool cmp1(pair<ll,ll>&a, pair<ll,ll>&b)
{
    if(a.second==b.second)
    {
        return a.first>b.first;
    }
    return a.second<b.second;
}

bool cmp2(pair<ll,ll>&a, pair<ll,ll>&b)
{
    if(a.first==b.first)
    {
        return a.second<b.second;
    }
    return a.first>b.first;
}

void solve()
{
    ll n;
    cin >> n;
    vector<pair<ll,ll>>l;
    vector<pair<ll,ll>>r;

    ll rem=0;
    for (int i = 0; i < n; i++)
    {
        string x;
        cin >> x;
        stack<char> s;
        for (int j = 0; j < x.size(); j++)
        {
            if(s.empty())
            {
                s.push(x[j]);
            }
            else if((x[j]==')' && s.top()=='('))
            {
                s.pop();
            }
            else
            {
                s.push(x[j]);
            }
        }

        ll needr=0, needl=0;
        if(s.empty())
        {
            continue;
        }
        while (!s.empty())
        {
            if (s.top() == '(')
            {
                needl++;
            }
            else
            {
                needr++;
            }
            s.pop();
        }


        if(!needr)
        {
            rem+=needl;
        }
        else if(needl>=needr)
        {
            l.push_back({needl, needr});
        }
        else
        {
            r.push_back({needl, needr});
        }
    }

    sort(l.begin(), l.end(), cmp1);
    sort(r.begin(), r.end(), cmp2);

    for(auto it:l)
    {
        rem-=it.second;
        if(rem<0)
        {
            cout<<"No"<<endl;
            return;
        }
        rem+=it.first;
    }

    for(auto it:r)
    {
        rem-=it.second;
        if(rem<0)
        {
            cout<<"No"<<endl;
            return;
        }
        rem+=it.first;
    }

    if(rem!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 12092
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n>>x;
    if(n>=10)c=x;
    else c=x+100*(10-n);
    
    
    
    cout<<c<<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i += 2) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

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

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

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


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int x[n],y[n],a[n];
  int left = 0,right = w, down = 0, up = h;
  for(int i = 0; i < n; i++){
    cin>>x[i]>>y[i]>>a[i];
    if(a[i]==1){
      if(left<x[i]) left = x[i];
    }
    else if(a[i]==2){
      if(right>x[i]) right = x[i];
    }
    else if(a[i]==3){
      if(down<y[i]) down = y[i];
    }
    else if(a[i]==4){
      if(up>y[i]) up = y[i];
    }
  }
  cout<<max(right-left,0)*max(up-down,0)<<endl;
  return 0;
}



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

int P,Q,R,a;
char *p;

int formula(){
  int l,r;
  char c = *p++;
  if(isdigit(c)) return c-'0';
  if(isupper(c)) return (c == 'P' ? P : c == 'Q' ? Q : R);
  if(c == '-') return 2-formula();
  if(c == '('){
    l = formula(); c = *p++; r = formula(); *p++;
    if(c == '*') return (l < r ? l : r);
    return (l > r ? l : r);
  }
  return 0;
}

int main(){
  char s[100];
  while(scanf("%s",s), s[0] != '.'){
    a = 0; 
    for(P = 0 ; P < 3 ; P++){
      for(Q = 0 ; Q < 3 ; Q++){
        for(R = 0 ; R < 3 ; R++){
          p = s;
          if(formula() == 2) a++;
        }
      }
    }
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 536
#include <iostream>
using namespace std;
int main() {
	char a[2];
	int hex[2];
	cin >> a[0] >> a[1];
	for (int i = 0; i < 2; i++) {
		switch (a[i]) {
		case 'A':
			hex[i] = 0;
			break;
		case 'B':
			hex[i] = 1;
			break;
		case 'C':
			hex[i] = 2;
			break;
		case 'D':
			hex[i] = 3;
			break;
		case 'E':
			hex[i] = 4;
			break;
		case 'F':
			hex[i] = 5;
			break;
		}	
	}
	if (hex[0] < hex[1]) {
		cout << "<\n";
	}
	else if (hex[0] > hex[1]) {
		cout << ">\n";
	}
	else {
		cout << "=\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a[] = new int[100000+1];
		for(int i=0; i<n; i++) {
			int v=sc.nextInt();
			a[v]++;
		}
		int ans = -1;
		for(int i=0; i<100000+1; i++) {
			int tmp=a[i];
			if(i>1) tmp +=a[i-1];
			if(i<n-1) tmp +=a[i+1];
			ans = Math.max(ans,tmp);
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 48220