akhauriyash/Code-Regression huggingface dataset:
n = int(input())
edgeList = []
rootList = [-1 for i in range(n)]

def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]
        
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(i):
        if a[j] != -1:
            edgeList.append([a[j], getRoot(i), getRoot(j)])
sumLength = 0
edgeList.sort(key=lambda x: x[0])
for e in edgeList:
    x = getRoot(e[1])
    y = getRoot(e[2])
    if x != y:
        sumLength += e[0]
        rootList[x] = rootList[y] = min(x, y)
print(sumLength)

Measured memory_bytes: 5864
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, n) cin >> l[i];

  sort(l.begin(), l.end(), greater<int>());

  int ans = 0;
  rep(i, k) ans += l[i];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

string s;

signed main(){
    ll k,l;
    cin>>s>>k;
    l=(ll)s.size();//

    for(ll i=0 ; i<l;i++)
    {
        if(('z'-s.at(i)+1)%26<=k){
            k-=('z'-s.at(i)+1)%26;
            s.at(i) = 'a';
            if(k==0){
                break;
            }
        }
    }

    k%=26;
    while(k>0){
        if(s.at(l-1)=='z'){
            s.at(l-1)='a';
            k--;
            continue;
        }
        s.at(l-1)++;
        k--;
    }

    cout << s << endl;
}
//'z'-s.at(i)+1 はs.at(i)='a'の時０に


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
int main(){
    ll l,r;
    ll ans=2019;

    cin>>l>>r;
    if(r-l>=2019){
        cout<<0<<endl;
        return 0;
    }
    else{
        for(ll i=l;i<r;i++){
        for(ll j=i+1;j<=r;j++){
            ans = min(ans, i*j%2019);
        }
    }
    cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((2.5**i-1)/1.5)for i in range(15,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


Measured memory_bytes: 53324
import sys
import heapq
sys.setrecursionlimit(10**8)


#最大公約数
def gcd(a,b):
	while b:
		a,b = b, a%b
	return a
	
#最小公倍数
def lcm(a,b):
	return a*b // gcd(a,b)



N = int(input())

a = int(input())

for i in range(N-1):
	b = int(input())
	a = lcm(a,b)
	
print(a)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int res,res2;
	for(int i=11;i<20000000;i++){
		res=(i*8)/100;
		res2=i/10;
		if(res==a&& res2==b){cout<<i<<endl;return 0;}
	}
	cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

constexpr int mod = int(1e9) + 7;

int mult(int a, int b) {
	return int(a * LL(b) % mod);
}

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

	int n;
	cin >> n;
	vector<char> in(2 * n);
	for(char &c : in)
		cin >> c;

	vector<char> brackets;
	int open_cnt = 0;
	REP(i, 2 * n) {
		int val = in[i] == 'B';
		debug(i, val, open_cnt);
		if(val == open_cnt % 2) {
			brackets.emplace_back(')');
			--open_cnt;
			if(open_cnt < 0)
				return cout << "0\n", 0;
		}
		else {
			brackets.emplace_back('(');
			++open_cnt;
		}
	}
	debug(brackets);
	if(open_cnt > 0)
		return cout << "0\n", 0;

	int answer = 1;
	for(char c : brackets)
		if(c == '(')
			++open_cnt;
		else {
			answer = mult(answer, open_cnt);
			--open_cnt;
		}
	debug(answer);

	int perm = 1;
	FOR(i, 2, n)
		perm = mult(perm, i);
	debug(perm);

	answer = mult(answer, perm);
	debug(answer);

	cout << answer << '\n';
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;

  if(0<a){
    cout << "Positive" << "\n";
  }
  else if(a<=0&&0<=b){
    cout << "Zero" << "\n";
  }
  else{
    if((b-a)%2==0){
      cout << "Negative" << "\n";
    }
    else{
      cout << "Positive" << "\n";      
    }
  }
  
  return 0;
}


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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e6 + 5;
const int INF = 2e9;

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	int n;
	cin >> n;

	int a[n];

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

	sort(a, a + n);

	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){

			auto l = lower_bound(a, a + n, abs(a[i] - a[j]) + 1) - a;
			auto r = upper_bound(a, a + n, a[i] + a[j] - 1) - a - 1;


			ans +=  r - l + 1ll;

			if(i >= l && i <= r) ans--;
			if(j >= l && j <= r) ans--;
			//cout << a[i] + a[j] << " " << l << " " << r << endl;
		}
	}
	assert((ans % 3) == 0);
	cout << ans / 3;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

int cnt = 0;
int A[500001];
int L[250002], R[250002];

void Merge(int A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	rep(i, n1) L[i] = A[left + i];
	rep(i, n2) R[i] = A[mid + i];
	L[n1] = R[n2] = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
		}
	}
}

void Mergesort(int A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		Mergesort(A, left, mid);
		Mergesort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

int main() {
	int n;
	cin >> n;
	rep(i, n) cin >> A[i];
	int left = 0;
	int right = n;
	Mergesort(A, left, right);
	rep(i, n) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 6988
fn main() {
  let s = get::val::<String>();

  let ans = match &s[..] {
    "KIHBR" |
    "KIHBRA" |
    "KIHBAR" |
    "KIHBARA" |
    "KIHABR" |
    "KIHABRA" |
    "KIHABAR" |
    "KIHABARA" |
    "AKIHBR" |
    "AKIHBRA" |
    "AKIHBAR" |
    "AKIHBARA" |
    "AKIHABR" |
    "AKIHABRA" |
    "AKIHABAR" |
    "AKIHABARA" => "YES",
    _ => "NO"
  };

  println!("{}", ans)
}

#[allow(dead_code)]
mod put {
  use std::string::*;

  pub fn vec<T: ToString>(vec: &Vec<T>, sep: &str) {
    let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join(sep);
    println!("{}", out);
  }

  pub fn mat<T: ToString>(mat: &Vec<Vec<T>>, sep: &str) {
    for v in mat {
      vec(v, sep);
    }
  }
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
//#define MOD (1000000007)
#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int k,n;cin>>k>>n;
    vi v(n);cin>>v;
    int d=k-v[n-1]+v[0];
    for(int i=0;i<n-1;i++){
        d=max(abs(v[i]-v[i+1]),d);
    }
    cout<<k-d;
}

Measured memory_bytes: 1792
import sys
from heapq import heappush, heappop
 
n, m = list(map(int, input().split()))
#print (n)
#print (m)
works = []
for line in sys.stdin:
    a, b = map(int, line.split())
    if a > m:
        continue
    works.append((a, b))
 
works.sort(reverse=True)
 
q = []
ans = 0
for i in range(1, m + 1):
    while works and works[-1][0] <= i:
        a, b = works.pop()
        heappush(q, -b)
    #print(q)
    if q:
        b = -heappop(q)
        ans += b
print(ans)

Measured memory_bytes: 17212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int f[n][10];
    int c[n];
    rep(i, 0, n) {
        int cnt = 0;
        rep(j, 0, 10) {
            cin >> f[i][j];
            if (f[i][j]) cnt++;
        }
        c[i] = cnt;
    }
    int p[n][11];
    rep(i, 0, n) {
        rep(j, 0, 11) {
            cin >> p[i][j];
        }
    }

    ll ans = -1e18;
    rep(i, 1, 1 << 10) {
        ll gain = 0;
        rep(j, 0, n) {
            int both = 0;
            rep(k, 0, 10) {
                if (i & (1 << k)) {
                    if (f[j][k]) both++;
                }
            }
            gain += p[j][both];
        }
        ans = max(ans, gain);
    }

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


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C
// Getting Started - Prime Numbers

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <set>
#include <cmath>

using namespace std;
using i64 = long long;

const int MAX_N = 20;
bool is_prime_number[MAX_N + 1];
bool checked[MAX_N + 1];

// this problem constraint shows the judged value x is 2 <= x <= 10^8.
// so eratos is not worked.
void eratos() {
    is_prime_number[0] = false, checked[0] = true;
    is_prime_number[1] = false, checked[1] = true;
    for (int i = 2; i <= MAX_N; ++i) {
        if (!checked[i]) {
            is_prime_number[i] = true;
            for (int k = 2 * i; k <= MAX_N; k += i) {
                is_prime_number[k] = false;
                checked[k] = true;
            }
        }
    }
}

bool is_prime(int x) {
    if (x <= 1) return false;
    if (x <= 3) return true;
    if (x % 2 == 0 || x % 3 == 0) return false;

    for (int i = 5; i * i <= x; i+= 6) {
        if (x % i == 0 || x % (i + 2) == 0) return false;
    }

    return true;
}

int n;

int main() {
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (is_prime(x)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
 
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2112
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;

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

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

    unordered_map<ll, int> count;
    for (int i = 0; i < n; i++)
    {
        count[i - A[i]]++;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += count[A[i] + i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 20028
L,R = map(int,input().split())
MOD = 2019

ans = 10**10
for i in range(L,min(R,L+MOD)+1):
    for j in range(i+1,min(R,L+MOD)+1):
        if ans > (i*j)%MOD:
            ans = (i*j)%MOD

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>


using namespace std;
typedef long long ll;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}







int main() {
  int N,M;
  cin>>N>>M;
  int sum=0;
  sum+=1900*M+100*(N-M);
  for(int i=1;i<=M;i++){
    sum*=2;
  }
  cout<<sum<<endl;
  
  
  
}



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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    int n,m;
    cin >> n >> m;
    if(n==m) cout << "Yes\n";
    else cout << "No\n";
    
    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const ll INF=1000000000000001;
const double PI=3.141592653589;

int main(){
  int a,b; cin>>a>>b;
  int c=b-a;
  int sum=(c)*(c+1)/2;
  sum-=b;
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    cout << 0 << ln;
    string base; cin >> base;
    if(base != "Vacant"){
        int left = 0, right = n;
        while(right - left > 1){
            int mid = (right + left) / 2;
            cout << mid << ln;
            string res; cin >> res;
            if(res == "Vacant") break;
            if((mid%2==0 && res != base) || (mid%2==1 && res == base)){
                right = mid;
            }else{
                left = mid;
            }
        }
    }
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int aa,ab,ba,bb;
    cin>>aa>>ab>>ba>>bb;

    cout<<max(0,min(ab,bb)-max(aa,ba))<<endl;

    return 0;
}




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

int main()
{
        while(true)
        {
                int n,A[100]={0};
                cin>>n;
                if(n==0) break;
                rep(i,n) cin>>A[i];
                sort(A,A+n);

                int sum=0;
                rep(i,n-2) sum+=A[i+1];
                cout<<sum/(n-2)<<endl;
        }
        return 0;
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    for (int i = 1; i <= B; i++)
    {
        int temp = i * A;
        if (temp % B == C)
        {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,t,m,n,a)vector<vector<t> > name(m,vector<t> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int n,x;
	int ans=0;
	for(;;){
		int ans=0;
		std::cin >> n>>x;
	if(n==0&&x==0)exit(0);
	for (int i = 1; i <= n-2; i++) {
		/* code */
		for (int j = i+1; j <=n-1; j++) {
			for (int k = j+1; k <=n; k++) {
				if(i+j+k==x){
					ans++;
				//	std::cout << i<<j<<k << std::endl;
				}
			}
		}
	}
		std::cout << ans << std::endl;
	}
	
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;


int mainsolve(){

    ll n,k,c;
    cin >> n >> k >> c;

    string s;
    cin >> s;

    vector<ll> tmp1, tmp2, res;

    rep(i,n){
        if(!tmp1.empty() && i - tmp1.back() <= c) continue;
        if(s[i] == 'o') tmp1.push_back(i);
        if(tmp1.size() == k) break;
    }

    for(ll i = n-1; i >= 0; i--){
        if(!tmp2.empty() && tmp2.back() - i <= c) continue;
        if(s[i] == 'o') tmp2.push_back(i);
        if(tmp2.size() == k) break;        
    }

    rep(i,k){
        if(tmp1[i] == tmp2[k-1-i]){
            cout << tmp1[i]+1 << endl;
        }
    }

	return 0;
}

int main(){
	
	return mainsolve();

}

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

const int MX = 100005 ; 

int main(){
  int n ; 
  cin >> n ;
  vector<ll> cnt(MX) ; 
  rep(i , n){
    int a ; 
    cin >> a ; //最初の数列の値
    cnt[a]++ ; //インデックスと同じ値の要素がいくつあるか
  }
    ll tot = 0 ; //数列の和
    rep(i,MX) tot += i*cnt[i] ; 
  
  int q ; 
  cin >> q ; 
  
  rep(i,q){
    int b , c ; 
    cin >> b >> c ; 
    tot += (c-b)*cnt[b] ;  
    cnt[c] += cnt[b] ;  
    cnt[b] = 0 ;
    cout << tot << endl ; 
  }
  
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i=0; i<N; i++){
    cin >> l.at(i);
  }
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  for(int i=0; i<K; i++){
    ans += l.at(i);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
	int n, m; cin >> n >> m;
	vector<vector<ll>> cakes(n);
	rep(i, n) {
		ll x, y, z; cin >> x >> y >> z;
		cakes[i] = {x, y, z};
	}

	ll ans = 0;
	rep(bit, 1<<3) {
		vector<vector<ll>> tmp = cakes;
		rep(i, 3) {
			if (bit & 1<<i) {
				rep(j, n) {
					tmp[j][i] *= -1;
				}
			}
		}
		vector<ll> tmp2(n);
		rep(i, n) tmp2[i] = tmp[i][0]+tmp[i][1]+tmp[i][2];
		sort(tmp2.rbegin(), tmp2.rend());
		ll tot = 0;
		rep(i, m) tot += tmp2[i];
		chmax(ans, tot);
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <time.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	char s[4];
	int ans = 0, i;

	scanf("%s", s);

	for (i = 0; i < 4; i++) {
		if (s[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 1724
import sys
from collections import *

n = int(input())
v = [int(x) for x in input().split()]

if not n:
    print(0)
    sys.exit()

n1 = Counter(v[::2])
n2 = Counter(v[1::2])

max1 = 0

n1 = sorted([(count, k) for k, count in n1.items()], reverse=True)
n2 = sorted([(count, k) for k, count in n2.items()], reverse=True)

if n1[0][1] == n2[0][1]:
    if len(n1) == 1 and len(n2) == 1:
        print(n//2)
        sys.exit()
    if len(n1) == 1 or n1[0][0] > n2[0][0]:
        print(n - n1[0][0] - n2[1][0])
        sys.exit()
    if len(n2) == 1 or n1[0][0] < n2[0][0]:
        print(n - n1[1][0] - n2[0][0])
        sys.exit()
    if n1[0][0] == n2[0][0]:
        if n1[1][0] >= n2[1][0]:
            print(n - n1[1][0] - n2[0][0])
        elif n1[1][0] < n2[1][0]:
            print(n - n1[0][0] - n2[1][0])
        sys.exit()

count = n - n1[0][0] - n2[0][0]
print(count)


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

int main()
{
	int a, b;
	cin >> a >> b;
	int score = 0;

	if (a <= b)
	{
		score += b;
		b--;
		if (a <= b)
		{
			score += b;
		}
		else
		{
			score += a;
		}
	}
	else
	{
		score = a;
		a--;
		if (a <= b)
		{
			score += b;
		}
		else
		{
			score += a;
		}
	}

	cout << score << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans;


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

	int K,S;
	cin >> K >> S;

	rep(x,K+1){
		rep(y,K+1){
			if(S - x - y >=0 && S - x - y <= K){
				ans++;
			}
		}
	}

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


Measured memory_bytes: 256
N=int(input())
S=[]
T=[]
for i in range(N):
  s,t=input().split()
  S.append(s)
  T.append(int(t))
X=input()
flag=0
ans=0
for i in range(N):
  if S[i]==X:
    flag=1
    continue
  if flag==1:
    ans+=T[i]
print(ans)

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

int main(){
  int A,B,C,D,E;
  int a[5];
  cin >> A >> B >> C >> D >> E;
  a[0] = A%10;
  a[1] = B%10;
  a[2] = C%10;
  a[3] = D%10;
  a[4] = E%10;
  
  A /= 10;
  A *= 10;
  B /= 10;
  B *= 10;   
  C /= 10;
  C *= 10;
  D /= 10;
  D *= 10;
  E /= 10;  
  E *= 10;
  
  int sum=0;
  int max = a[0];//typo of min
  int index = 0;
  for(int i=1; i<5; i++){
    if(a[i] < max && a[i] != 0) {
      max = a[i];
      if(a[index]==0) a[index]=0;
      else a[index] = 10;
      sum += a[index];
      index = i;
    }else{
      if(a[i]==0) a[i]=0;
      else a[i] = 10;
      sum += a[i];
    }
  }
  cout << A+B+C+D+E+sum+max<<endl;
  return 0;
}


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

int main()
{
  uint64_t a, b;
  cin >> a >> b;
  uint64_t x[] {a, 1, a + 1, 0};
  uint64_t y[] {b, 1, b + 1, 0};
  cout << (a xor x[a % 4] xor y[b % 4]) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+10;
const int mod=1e9+7;
main(){
    int n;
    cin>>n;
    string s="";
    while(n){
        n--;
        s+=n%26+'a';
        n/=26;
    }
    for(int i=s.length()-1;i>=0;--i)cout<<s[i];
    cout<<endl;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,m,a[1010],b[1010];
map<int,int>mpa,mpb,cc,rr;
int cok,rok,dok,ddok;
int dd[1010][1010];
int cnt[1000100];
ll ans=1;

void input(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		mpa[a[i]]++;
		cc[a[i]]=i;
		cnt[a[i]]++;
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		mpb[b[i]]++;
		rr[b[i]]=i;
		cnt[b[i]]++;
	}
	return;
}

void solve(){
	for(P u:mpa){
		if(u.sc>1){
			cout<<0<<endl;
			return;
		}
	}
	for(P u:mpb){
		if(u.sc>1){
			cout<<0<<endl;
			return;
		}
	}
	cok=0,rok=0;//行の許容、列の許容
	for(int i=n*m;i>0;i--){
		if(cnt[i]==2){
			int c=cc[i],r=rr[i];
			dd[c][r]=3;
			for(int j=1;j<=m;j++){
				if(dd[c][j]==1){
					dd[c][j]=2;
					dok++;
				}
				else if(dd[c][j]==0){
					dd[c][j]++;
				}
			}
			for(int j=1;j<=n;j++){
				if(dd[j][r]==1){
					dd[j][r]=2;
					dok++;
				}
				else if(dd[j][r]==0){
					dd[j][r]++;
				}
			}
		}
		else if(cnt[i]==1){
			int c=cc[i],r=rr[i],ccc=0;
			bool fl=false;
			if(c){
				for(int j=1;j<=m;j++){
					if(dd[c][j]==1){
						if(!fl)dd[c][j]=3,fl=true,ccc++;
						else dd[c][j]=2,dok++,ccc++;
					}
					else if(dd[c][j]==0){
						dd[c][j]++;
					}
				}
			}
			else {
				for(int j=1;j<=n;j++){
					if(dd[j][r]==1){
						if(!fl)dd[j][r]=3,fl=true,ccc++;
						else dd[j][r]=2,dok++,ccc++;
					}
					else if(dd[j][r]==0){
						dd[j][r]++;
					}
				}
			}
			ans*=ccc;
			ans%=MOD;
			if(!fl){
				cout<<0<<endl;
				return;
			}
		}
		else{
			if(!dok){
				cout<<0<<endl;
				return;
			}
			ans*=dok;
			ans%=MOD;
			dok--;
		}
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 6272
#include<iostream>

using namespace std;

int main(){
  char c[4][4];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c[i][j];
      if(i==j){
        cout << c[i][j];
      }
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    for (int i = 0; i < Q; i++) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--, B[i]--;
    }
    vector<int> ary(N);
    int ans = 0;
    auto recur = [&](auto& recur, int idx, int num) -> void {
        ary[idx] = num;
        if (idx == N - 1) {
            int a = 0;
            for (int i = 0; i < Q; i++) {
                if (ary[B[i]] - ary[A[i]] == C[i]) {
                    a += D[i];
                }
            }
            ans = max(ans, a);
        } else {
            for (int t = num; t <= M; t++) {
                recur(recur, idx + 1, t);
            }
        }
    };
    recur(recur, 0, 1);
    cout << ans << endl;
    return 0;
}


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

int N;
struct Node {
    int l, r, p;
};

Node *nd;

int depth (int k ) {
    int d = 0;
    while (nd[k].p != -1) {
        d++;
        k = nd[k].p;
    }
    return d;
}

int *H;
int height (int k) {
    int h1 = 0,h2 = 0;
    if (nd[k].l != -1) {
        h1  = 1+ height(nd[k].l);
    }
    if (nd[k].r != -1) {
        h2 = 1 + height(nd[k].r);
    }
   H[k] = max(h1,h2);
    return H[k];
}

string type(int k) {
   if (nd[k].p == -1) {
       return "root";
   } else if (nd[k].l == -1 && nd[k].r == -1) {
        return  "leaf";
    } else {
        return "internal node";
    }
}
//　　　node id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type
void print(int k) {
    cout << "node " <<  k << ": parent = " << nd[k].p << ", sibling = ";
    int sb = -1;
    if (nd[k].p != -1) {
      if( nd[nd[k].p].l == k)  sb = nd[nd[k].p].r;
        else  sb = nd[nd[k].p].l;
    }

    cout << sb << ", degree = ";
    int dg = 0;
    if (nd[k].l != -1) dg++ ;
    if (nd[k].r != -1) dg++;
    cout << dg << ", depth = " << depth(k) << ", height = " << H[k] << ", " << type(k) << endl;
}

int main() {
    cin >> N;
    int id, l, r;
    nd = new Node[N];
    H = new int [N];
    for (int j = 0; j < N; ++j) {
        nd[j].l = nd[j].r = nd[j].p = -1;
        H[j] = -1;
    }

    for (int i = 0; i < N; ++i) {
        cin >> id >> l >> r;
        nd[id].l = l; nd[id].r = r; nd[l].p = id; nd[r].p = id;
    }

    int root ;
    while (nd[root].p != -1) { root = nd[root].p; }
    height(root);

    for (int k = 0; k < N; ++k) {
        print(k);
    }

    return 0;
}



Measured memory_bytes: 3208
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;


ull E = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> T;
    for (int i = 0; i < N; ++i) {
        int t;
        cin >> t;
        T.push_back(t);
    }
    int M;
    cin >> M;
    vector<P> PX;
    for (int i = 0; i < M; ++i) {
        int p, x;
        cin >> p >> x;
        PX.push_back({p, x});
    }
    for (const auto& px : PX) {
        int time = 0;
        for (int i = 0; i < N; ++i) {
            if (i + 1 == px.first) {
                time += px.second;
            } else {
                time += T[i];
            };
        }
        cout << time << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (ll)(998244353)
#define MAX (ll)(1e5 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;

int main () {
	int r;
	cin >> r;
	cout << r * r << "\n";
}


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

N_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 
          1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(N_list[K - 1])

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; 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;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

vector <ll> par; // 各元の親を表す配列
vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

void init_u(ll sz_) {
	par.resize(sz_);
	siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
	for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
}

string S;
ll q;
bool rev;
vector<char> a, b;

void solve() {
	cin >> S >> q;
	rep(i, q) {
		ll t;
		cin >> t;
		if (t == 1) rev = !rev;
		else {
			ll f;
			char c;
			cin >> f >> c;
			if ((f == 1 && !rev) || (f == 2 && rev)) a.pb(c);
			else b.pb(c);
		}
	}
	if (rev) {
		reverse(b.begin(), b.end());
		for (char c: b) cout << c;
		for (ll i = S.length() - 1; i >= 0; i--) cout << S[i];
		for (char c: a) cout << c;
		cout << endl;
	}
	else {
		reverse(a.begin(), a.end());
		for (char c: a) cout << c;
		cout << S;
		for (char c: b) cout << c;
		cout << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 976
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NK = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = NK[0];
            int K = NK[1];
            if(K == 0)
            {
                Console.WriteLine("0 0");
                return;
            }
            int[] A = new int[N];
            Boolean[] B = new Boolean[N];
           
            for(int i = 0; i < K; i++)
            {
                string[] vs = Console.ReadLine().Split(' ');
                int P = int.Parse(vs[0]) - 1;
                string S = vs[1];
                if (!B[P])
                {
                    if("AC" == S)
                    {
                        B[P] = true;
                    }
                    else
                    {
                        A[P] += 1;
                    }
                }
            }
            int okcnt = 0;
            int ngcnt = 0;

            for(int i = 0;i < N; i++)
            {
                if (B[i])
                {
                    okcnt++;
                    ngcnt += A[i];
                }
            }

            Console.WriteLine(okcnt + " " + ngcnt);
        }
    }
}


//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


Measured memory_bytes: 17632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
#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...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
 // 	freopen("input.txt","r",stdin);
 // 	freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		int i =0,ans=0;
		for(int i =0 ;;i++){
			int x =pow(2,i);
			if(x <n){
				ans+=x;
			}
			else if(x==n){
				ans+=x;break;
			}
			else{
				break;
			}
		}	
		cout <<ans<<endl;
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] r = new int[n];
        for(int i = 0; i < n; i++){
            r[i]  = Integer.parseInt(sc.next());
        }
        
        int min = r[0];
        int max = -1000000000;
        for(int i = 1; i < n; i++){
            if(r[i] - min > max){
                max = r[i] - min;
            }
            if(r[i] < min){
                min = r[i];
            }
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 73268
import sys


def rectangle_or_rhombus(a, b, c):
    if a**2 + b**2 == c**2:
        return 'rectangle'
    elif a == b:
        return 'rhombus'
    else:
        return 'other'


h = {'rectangle':0, 'rhombus':0, 'other':0}

for line in sys.stdin:
    (a, b, c) = tuple(map(int, line.split(',')))
    h[rectangle_or_rhombus(a,b,c)] += 1

print h['rectangle']
print h['rhombus']

Measured memory_bytes: 4224
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B = input().split()
A = int(A)
B = int(B.replace(".", "")) # 100倍

ans = A * B // 100
print(ans)

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

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	map<ll,int> mp;
	rep(i,n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	ll ans = 0;
	rep(i,n){
		if(mp[a[i]] > a[i]){
			ans += mp[a[i]] - a[i];
			mp[a[i]] = a[i];
		}
		if(mp[a[i]] < a[i]){
			ans += mp[a[i]];
			mp[a[i]] = 0;
		}
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7040
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N = int(stdin.readline().rstrip())

ans = 0
for k in range(1, int(math.sqrt(N+1))):
    if N % k == 0:
        # N = k(m+1) で表すことができる ...よってkはNの約数
        # m = N/k-1
        ans += ((N//k)-1)

print(ans)


Measured memory_bytes: 65768
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#ifdef ONLINE_JUDGE
#define filename(_ST_) \
		freopen(_ST_".in", "r", stdin); \
		freopen(_ST_".out", "w", stdout);
#else
#define filename(_ST_)
#endif
template<typename T>
inline void read(T &x) {
	char ch=0; x=0;
	bool sign=false;
	while(ch < '0' || '9' < ch) sign |= ch == '-', ch = getchar();
	while('0' <= ch && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	x = sign ? -x : x;
}
template<typename T>
inline void print(T x) {
	static char outp[64];
	if(!x) { putchar('0'); return; }
	if(x < 0) putchar('-'), x = -x;
	int tot = 0;
	while(x) outp[tot++] = x % 10 + '0', x /= 10;
	while(tot) putchar(outp[--tot]);
}
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rt register int
#define all(it) it.begin(), it.end()
#define rep(it, f, e) for (rt it = f; it <= e; ++it)
#define per(it, f, e) for (rt it = f; it >= e; --it)
const int MAXN = 1e5 + 10;
int dp[MAXN];
vector<int> edge[MAXN];
inline void dfs(int u) {
	if (dp[u]) return;
	for (auto v : edge[u]) {
		dfs(v);
		dp[u] = max(dp[u], dp[v] + 1);
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, ans = 0;
	cin >> n >> m; 
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		edge[u].push_back(v);
	}
	for (int i = 1; i <= n; ++i) {
		dfs(i);
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7296
# D
import numpy as np
N, X, Y = map(int, input().split())

D = [0]*N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        d = min(j-i, abs(j-Y) + abs(i-X) + 1) 
        D[d] += 1
for i in range(1, N):
    print(D[i])

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    REP(i, n) cin >> v[i];

    ll ans = 0;
    for(int i = 1; i < n; ++i) {
        ll cost = (v[i] - v[i -1]) * a;
        if(cost > b) ans += b;
        else ans += cost;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s, c;
  cin >> s >> c;

  vector<string> v;
  int len_s = s.length(), len_c = c.length();
  bool make = false;

  REP(i,len_s){
    int k = 0;
    REP(j,len_c){
      if(i + k < len_s && (s[i + k] == '?' || s[i + k] == c[j])){
        k++;
        if(k == len_c){
          string tmp = s;
          make = true;
          REP(l,len_c){
            tmp[i + l] = c[l];
          }
          v.pb(tmp);
          break;
        }
      }
    }
  }

  if(make == false){
    printf("UNRESTORABLE\n");
    return 0;
  }

  bool p = false;
  string res;
  REPI(itr,v){
    if(p == false){
      res = *itr;
      p = true;
    }else{
      if(res > *itr){
        res = *itr;
      }
    }

  }

  REP(i,len_s){
    if(res[i] == '?'){
      cout << "a";
    }else{
      cout << res[i];
    }
  }

  cout << "\n";
  return 0;
}



Measured memory_bytes: 256