akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int n, x[MAXN], L, T;
long long cur;
pair<int, int> a[MAXN];
int main(){
    int _;// scanf("%d", &_);
    _ = 1;
    for(int CA = 1; CA <= _; ++CA){
        scanf( "%d%d%d", &n, &L, &T );
        for(int i = 0; i < n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
        pair<int, int> tmp;
        sort(a, a + n);
        cur = lower_bound(a, a + n, tmp) - a;
        for( int i = 0 ; i < n ; i++ )
            if(a[i].second == 1 ){
                x[ i ] = ( a[i].first + T ) % L;
                cur += ( a[i].first + T ) / L;
            }
            else{
                x[ i ] = ( a[i].first - T ) % L;
                cur += ( a[i].first - T ) / L;
                if( x[ i ] < 0 ) x[ i ] += L, cur--;
            }
        cur = ( cur % n + n ) % n;
        sort( x, x + n );
        for(int i = cur; i < n; ++i)printf("%d\n", x[i]);
        for(int i = 0; i < cur; ++i)printf("%d\n", x[i]);
    }
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int parent(int i){
	return i/2;
}

int left(int i){
	return 2*i;
}

int right(int i){
	return 2*i +1;
}

int heapsize(vector <int> x){
	return x.size()-1;
}

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

	vector <int> x(n+1);

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

	int xsize = x.size()-1, tmp;
	stringstream buf;
	for (int i=1; i<n+1; i++){
		buf<<"node "<<i<<": ";
		buf<<"key = "<<x[i]<<", ";
		tmp = parent(i);		
		if (tmp>0 && tmp<=xsize) buf<<"parent key = "<<x[tmp]<<", ";
		tmp = left(i);		
		if (tmp>0 && tmp<=xsize) buf<<"left key = "<<x[tmp]<<", ";
		tmp = right(i);		
		if (tmp>0 && tmp<=xsize) buf<<"right key = "<<x[tmp]<<", ";
		cout<<buf.str()<<endl;
		buf.str("");
	}
	return 0;
} 

Measured memory_bytes: 1232
from heapq import heapify, heappush, heappop

n, m = map(int, input().split())
A = list(map(int, input().split()))

A = list(map(lambda x: x * (-1), A))

heapify(A)
for i in range(m):
    x = heappop(A)
    x = (x + 1) // 2
    heappush(A, x)

print(-1 * sum(A))


Measured memory_bytes: 20140
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
set<int> S[101010];
int T[101010];
vector<int> C;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		S[x-1].insert(y-1);
		S[y-1].insert(x-1);
	}
	FOR(i,N) {
		cin>>x;
		C.push_back(x);
	}
	sort(ALL(C));
	set<pair<int,int>> cand;
	FOR(i,N) cand.insert({(int)S[i].size(),i});
	ll ret=0;
	FORR(c,C) {
		x=cand.begin()->second;
		cand.erase(cand.begin());
		T[x]=c;
		ret+=1LL*c*S[x].size();
		FORR(s,S[x]) {
			cand.erase({(int)S[s].size(),s});
			S[s].erase(x);
			cand.insert({(int)S[s].size(),s});
		}
	}
	
	cout<<ret<<endl;
	FOR(i,N) cout<<T[i]<<" ";
	cout<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

int main(){
    string S;
    cin >> S;
    ll out = 0;
    ll N = S.size();

    for (int bit = 0; bit < (1 << (N-1)); bit++){
      ll tmp = 0;
      for (int i = 0; i < N - 1; i++){
        tmp *= 10;
        tmp += S[i] - '0';
        if(bit & (1<<i)){
          out += tmp;
          tmp = 0;
        }
      }
      tmp *= 10;
      tmp += S.back() - '0';
      out += tmp;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3500
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;

int main(){

	int n,l,sortFlag=1;
	char s[100][1000],tmp[1000];
	
	cin>>n>>l;

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

	while(sortFlag){
		sortFlag=0;
		for(int i=0;i<n-1;i++){
			if(strcmp(s[i],s[i+1])>0){
				strcpy(tmp,s[i]);
				strcpy(s[i],s[i+1]);
				strcpy(s[i+1],tmp);
				sortFlag=1;
			}
		}
	}
	
	for(int i=0;i<n;i++)
		cout<<s[i];

	cout<<endl;

	return 0;
}

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

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

    map<string, int> mp;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s] += 1;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    return 0;
}


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

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

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

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

    long long ans = a * b / gcd(a, b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.round
import kotlin.math.sin

fun main() {
    val n = readInt()

    var cnt = 0L
    for (a in 1..n) {
        for (b in 1..n) {
            val c = n - a.toLong() * b.toLong()
            if (c <= 0) break

            cnt++
        }
    }
    println(cnt)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


Measured memory_bytes: 34676
#include <bits/stdc++.h>
using namespace std;
#define int long long
//nt a[100000];
int dp[100][100001];

int solve(vector<pair<int,int>> &ar,int n,int w){
    dp[0][ar[0].first]=ar[0].second;
    for(int i=1;i<n;++i){
        for(int weight=0;weight<=w;++weight){
           dp[i][weight]=  dp[i-1][weight];

            if(ar[i].first>weight){
                continue;
            }

            dp[i][weight]=max(dp[i-1][weight], ar[i].second+ dp[i-1][weight-ar[i].first]);
        }
    }

  int mx=-1;
  for(int i=0;i<=w;++i){
      mx=max(mx,dp[n-1][i] );
  }

  return mx;
}
int32_t main() {
      memset(dp, 0, sizeof dp);
    vector< pair<int,int> > ar;
    int n,w; cin>>n>>w;
    for(int i=0;i<n;++i){
       int wt,val;
       cin>>wt>>val;
       ar.push_back(make_pair(wt,val));
    }
    cout<<solve(ar, n, w);

    return 0;
}

Measured memory_bytes: 81708
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

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

af = set(factorize(a))
bf = set(factorize(b))

count = 0
print(len(af&bf)+1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    int n, m; cin >> n >> m;
    map<int, pair<int, bool>> mp;
    int a = 0, w = 0;
    for(int i = 0; i < m; i++)
    {
        int p; cin >> p;
        string s; cin >> s;
        if(s == "AC")
        {
            if(mp[p].second == false)
            {
                w += mp[p].first;
                a++;
            }
            mp[p].second = true;
        }
        else
        {
            mp[p].first++;
        }
    }
    cout << a << " " << w << endl;
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;
    static int r, b;
    rep(i, n) {
        if (s[i] == 'R') ++r;
        else ++b;
    }
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl; 

    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
A = list(map(int,input().split()))

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0:
            continue
        elif A[i] % 5 == 0:
            continue
        else:
            print('DENIED')
            sys.exit()
print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,T;
    cin>>N>>T;
    int ans=1e8;
    int count=0;
    for(int i=0;i<N;i++){
        int c,t;
        cin>>c>>t;
        if(t<=T){
            ans=min(ans,c);
        }
        else count++;
    }
    if(count==N) cout<<"TLE"<<endl;
    else cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	int x;
	int ans = 0;
	cin >> x;
	for (int i = 111; i < 1000; i += 111) {
		if (x == i) {
			ans = i;
			break;
		}
		else {
			if (x <= i) {
				ans = i;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	ll n;
	cin >> n;	
	ll N = n;
	int sum = 0;
	while( n > 0 ){
		sum += n % 10;
		n /= 10;
	}
	if( N % sum ) No;
	else Yes;
	ret 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty = list(map(int, input().split()))
ans = []
#一回目
for i in range(ty - sy):
    ans.append("U")
for i in range(tx - sx):
    ans.append("R")
for i in range(ty - sy):
    ans.append("D")
for i in range(tx - sx):
    ans.append("L")
#二回目
ans.append("L")
for i in range(ty + 1 - sy):
    ans.append("U")
for i in range(tx + 1 - sx):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(ty + 1 - sy):
    ans.append("D")
for i in range(tx + 1 - sx):
    ans.append("L")
ans.append("U")
print("".join(ans))


Measured memory_bytes: 3188
# coding:utf-8

n = map(int, raw_input().split())
t, a = map(int, raw_input().split())

h = raw_input().split()

# print n
# print t
# print h[0]

hdiff = [0] * n[0]
for i in range(n[0]):
    hdiff[i] = abs(t - a - int(h[i]) * 0.006)

# print hdiff

ans = hdiff.index(min(hdiff))
print ans + 1



Measured memory_bytes: 2692
#include <stdio.h>

#define MAX_ARRAY 100

int main() {
	int num, cnt, i, ans[MAX_ARRAY];
	
	while(1){
		scanf("%d", &num);
		if(num == -1) break;
		
		cnt = 0;
		do{
			ans[cnt++] = num%4;
			num /= 4;
		}while(num>0);
		
		for(i=cnt-1;i>=0;i--){
			printf("%d", ans[i]);
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define NFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); --i)
#define endl "\n"
#define mp make_pair
#define X first
#define Y second
#define inf 1e18
#define mod 1000000007
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
// #define lli int
typedef long long int lli;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<lli,lli> pll;
typedef vector<lli> vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

vi Adj[100010];
int grundy[100010];

void DFS(int u, int p) {
	int currNum = 0;
	for (auto v : Adj[u]) {
		if (v != p) {
			DFS(v, u);
			currNum ^= (grundy[v] + 1);
		}
	}
	grundy[u] = currNum;
}

int main() {
	int n;
	cin >> n;
	FOR(i, 1, n-1) {
		int a1, b1; cin >> a1 >> b1; Adj[a1].pb(b1), Adj[b1].pb(a1);
	}
	DFS(1, 0);
	if (grundy[1] == 0) {
		cout << "Bob\n";
	} else {
		cout << "Alice\n";
	}
return 0;}


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

int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int total = 0;
  for(int five_hundred = 0; five_hundred <= a; ++five_hundred) {
    for(int one_hundred = 0; one_hundred <= b; ++one_hundred) {
      for(int fifty = 0; fifty <= c; ++fifty) {
        if(x == 500*five_hundred + 100*one_hundred + 50*fifty) {
          total++;
        }
      }
    }
  }

  cout << total << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,ret;
  while(cin >> n ,n){
    ret = 0;
    int i,j,cn;
    for(i=1;i<=(n+1)/2;i++){
      cn=0;
      for(j=i;j<=(n+1)/2;j++){
        cn+=j;
        if(cn==n && cn!=1){
          ret++;
          break;
        }
      }
    }
    cout << ret << endl;
  }
  return 0;
}



Measured memory_bytes: 3000
# A[i]が採用されるとき、A[i-1]も採用されるという単調性があるので二分探索で解く
N, M, V, P = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

capacity = M * (N-V)


def isOK(i):
    ai = A[i]  # 基準となる値
    s = 0
    # 0~P-2番目のP-1問とi番目とi番目以降には全員が投票しても構わない
    # P-1番目からi-1番目までについて考える必要がある
    for j in range(P-1, i):
        d = A[j] - ai
        # A[j]とaiの差がM以上あるということは、A[0]からA[j-1]までも差がM以上あり追いつけない
        if d > M:  # この時点で先頭のA[j]問を含む先頭の問題たちはaiが追いつけないスコアをもっている
            return False
        s += d
    if s > capacity:
        return False
    else:
        return True


left = -1
right = N
while right - left > 1:
    mid = right + (left-right)//2
    if isOK(mid):  # 中央値が満たすなら下界をあげる
        left = mid
    else:  # 中央値が満たさないなら上界を下げる
        right = mid
print(left + 1)


Measured memory_bytes: 14964
// 2015/05/19 Tazoe

#include <iostream>
using namespace std;

int gcd(int a, int b)
{
	if(b==0)
		return a;

	return gcd(b, a%b);
}

int main()
{
	while(true){
		int a, b;
		cin >> a >> b;

		if(cin.eof())
			break;

		int g = gcd(a, b);

		cout << g << ' ' << a/g*b << endl;
	}

	return 0;
}

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

using namespace std;

int main(void){
    
    string temp_s, temp_t;
    cin >> temp_s >> temp_t;

    vector<char> s(temp_s.size());
    vector<char> t(temp_t.size());

    for(int i=0; i<temp_s.size(); i++) {
        s[i] = temp_s[i];
    }
    
    for(int i=0; i<temp_t.size(); i++) {
        t[i] = temp_t[i];
    }
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    
    temp_s = "";
    temp_t = "";
    
    for(int i=0; i<s.size(); i++) {
        temp_s += s[i];
    }
    
    for(int i=0; i<t.size(); i++) {
        temp_t += t[i];
    }
    
    if(temp_s<temp_t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
    
}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline

x, n = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
d = 10 ** 9

for i in range(-200, 201):
    if i not in p:
        if abs(x - i) < d:
            d = abs(x - i)
            ans = i

print(ans)


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

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int ans = A * 100 / 8 - 3;
    while (1) {
        if (int(ans * 0.08) < A) {
            ans++;
            continue;
        }
        if (int(ans / 10) == B && int(ans * 0.08) == A) {
            cout << ans << endl;
            return 0;
        } else if (int(ans / 10) > B || int(ans * 0.08) != A) {
            cout << -1 << endl;
            return 0;
        }
        ans++;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int H, W;
	while (true)
	{
		cin >> H >> W;
		if (!H && !W)
			break;
		for (int i = 0; i < H; i++)
		{
			if (i == 0 || i == H - 1)
				for (int j = 0; j < W; j++)
					cout << '#';
			else
				for (int j = 0; j < W; j++)
					if (j == 0 || j == W - 1)
						cout << '#';
					else
						cout << '.';
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    int a[n],i,j;
    map<int,int> mp;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(mp.find(a[i])!=mp.end())
        {
            mp[a[i]]=-1;
        }
        else
        mp[a[i]]=i;
    }
    int count=0,flag;
    for(i=0;i<n;i++)
    {
        flag=1;
        for(j=1;j*j<=a[i];j++)
        {
            if(a[i]%j==0)
            {
                auto it=mp.find(a[i]/j);
                if((it!=mp.end() && it->second!=i) || it->second==-1)
                {
                 flag=0;
                 break;
                }
                it=mp.find(j);
                if((it!=mp.end() && it->second!=i) || it->second==-1)
                {
                 flag=0;
                 break;
                }
            }
        }
        if(flag)
        count++;
    }
    cout<<count;
}

Measured memory_bytes: 13752
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!
function main(input) {
    var x = input.split('/');
    x[0] = '2018';
    console.log(x[0] + '/' + x[1] + '/' + x[2]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ss substr
typedef long long ll ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;
typedef map<ll,ll> mapi ;
typedef map<string,string> maps ;


int main()
{
  //freopen("lifeguards.out", "w", stdout) ;
  //freopen("lifeguards.in", "r", stdin) ;
  ios_base::sync_with_stdio(0) ;
  cin.tie(NULL) ;
  cout.tie(NULL) ;
 
 //int t ; cin >> t ; while(t--){} 
 
 int a , b ; cin >> a >> b ;
 if ( a <= 9 && b <= 9 ) cout << a*b ;
 else cout << -1 ; 
   
 }


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

#define ul unsigned long long
#define ll long long


int main()
{
  ll n,a[100];
  cin>>n;
  for (ll i = 0; i < n; i++)
  {
    cin>>a[i];
  }
  ll minj,ct=0;
  for (ll i = 0; i < n; i++)
  {
    minj=i;
    for (ll j = i; j < n; j++)
    {
      if (a[j]<a[minj]) minj=j;
    }
    swap(a[i],a[minj]);
    ct+= i!=minj;
  }
  for (ll i = 0; i < n; i++)
  {
    if (i<n-1) cout<<a[i]<<" ";
    else cout<<a[i]<<endl;
  }
  cout<<ct<<endl;

  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

using ll = long long;

void Main()
{
	int A, B;
	cin >> A >> B;

	cout << A * B << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	int X;
	int sum = 0, count = 0;
	cin >> X;

	while (1) {

		count++;
		sum += count;
		if (X <= sum) {

			cout << count << endl;
			break;

		}

	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		s = s.replace("x", "");
		System.out.println(700 + 100 * s.length());
	}

}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  ll n; cin >> n;
  
  ll ans = 0;

  vector<pair<ll,int>> fs;
  for(ll i = 2;i*i<=n;i++){
    int x=0;
    while(n%i==0){
      n /= i;
      ++x;
    }
    fs.emplace_back(i,x);
  }
  if(n != 1) fs.emplace_back(n,1);

  for(auto p : fs){
    ll key = p.first;
    ll x = p.second;
    int b = 1;
    while(x>=b){
      x -= b;
      ++b;
      ++ans;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 19708
use strict;
use warnings;
use utf8;
use Data::Dumper;

use feature qw(say);

my $limit = <STDIN>;
chomp $limit;

my $sum_hash = +{};
# もうちょいシンプルに考えられないか。全探索で解けないかを考える
for (my $x = 1; $x < 100; $x++) {
    for (my $y = 1; $y < 100; $y++) {
        for (my $z = 1; $z < 100; $z++) {
            my $sum = $x * $x + $y * $y + $z * $z + $x * $y + $y * $z + $z * $x;
            $sum_hash->{$sum} = ($sum_hash->{$sum} // 0) + 1
        }
    }
}
for (my $i = 1; $i <= $limit; $i++) {
    my $sum = $sum_hash->{$i} // 0;
    say $sum;
}

Measured memory_bytes: 10636
#include <iostream>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;

static const double INF = 1e9;
static const double EPS = 1e-9;

template<class T>
T sqr(T obj) {
	return obj * obj;
}

struct building {
	int b;
	int x;
	int y;

	building(int b_, int x_, int y_) {
		b = b_;
		x = x_;
		y = y_;
	}
};

struct edge {
	int to;
	double cost;
	edge() {}
	edge(int t, double c) {
		to = t;
		cost = c;
	}
};

struct edge1 {
	int from;
	int cur;
	double cost;

	edge1() {}
	edge1(int from_, int cur_, double cost_) {
		from = from_;
		cur = cur_;
		cost = cost_;
	}

	bool operator<(const edge1 & e) const {
		return cost > e.cost;
	}
};

int main() {
	int n;

	while(cin >> n, n) {
		vector<building> v;
		vector<vector<edge> > dist(1024, vector<edge>());
		for(int i = 0; i < n; i++) {
			int b, x, y;
			cin >> b >> x >> y;
			v.push_back(building(b, x, y));
		}

		for(int i = 0; i < v.size(); i++) {
			for(int j = 0; j < v.size(); j++) {
				double d;
				d = sqrt(sqr(v[i].x - v[j].x) + sqr(v[i].y - v[j].y));
				if(d <= 50.0) {
					dist[v[i].b].push_back(edge(v[j].b, d));
				}
			}
		}

		int m;
		cin >> m;
		for(int t = 0; t < m; t++) {
			int s, g;
			cin >> s >> g;
			pair<double,int> cost[1024];
			bool updateflg[1024];
			for(int i = 0; i < 1024; i++) {
				cost[i].first = INF;
				cost[i].second = -1;
				updateflg[i] = true;
			}
			cost[s].first = 0;

			priority_queue<edge1> q;
			q.push(edge1(-1, s, 0));

		//	cout << "dijkstra start" << endl;
			while(!q.empty()) {
				edge1 current;
				current = q.top(); q.pop();
				if(updateflg[current.cur]) {
					cost[current.cur].first = current.cost;
					cost[current.cur].second = current.from;
					updateflg[current.cur] = false;

					for(int i = 0; i < dist[current.cur].size(); i++) {
						if(updateflg[dist[current.cur][i].to]) {
							q.push(edge1(current.cur, dist[current.cur][i].to, current.cost + dist[current.cur][i].cost));
						}
					}
				}
			}
		//	cout << "dijkstra end" << endl;
		//	cout << "cost:" << cost[g].first << " from:" << cost[g].second << endl;

			stack<int> path;
			int indx = g;
			while(cost[indx].second != -1) {
				path.push(indx);
				indx = cost[indx].second;
			}

			if(path.size() == 0)
				cout << "NA" << endl;
			else {
				cout << s;
				while(!path.empty()) {
					cout << " " << path.top();
					path.pop();
				}
				cout << endl;
			}
		}
	}
}

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

typedef long long ll;

int main(){
    char alp[26] = {
        'z',
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 
        'h', 'i', 'j', 'k', 'l', 'm', 'n',
        'o', 'p', 'q', 'r', 's', 't',
        'u', 'v', 'w', 'x', 'y'
    };
    vector<int> ans;
    ll n;
    cin >> n;
    ll tmp = 1;
    int i = 0;
    while(n != 0){
        tmp = n % 26;
        ans.push_back(tmp);
        ++i;
        n /= 26;
        if(tmp == 0){
            --n;
        }
    }
    --i;
    string a = "";
    for(i; i >= 0; --i){
        a += alp[ans[i]];
    }
    cout << a << endl;
    return 0;
}

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

int main(){
	ll h,n; cin >> h >> n;
	vl a(n); rep(i,n)cin >> a[i];
	ll sum = 0;
	rep(i,n)sum += a[i];
	if(sum >= h)cout << "Yes" << endl;
	else cout << " No" << endl;
}

Measured memory_bytes: 1024
n=int(input())-1
A=list(map(int,input().split()))
i=0
for j in range(n):
 if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1
A[i],A[n]='['+str(A[n])+']',A[i]
print(*A)


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	string s;
	cin >> s;

	int ans = 0;
	for (auto c : s) {
		ans += (c == '+' ? 1 : -1);
	}

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


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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

typedef long long int ll;

ll INF = 1000000000000000000;
ll MOD = 1e9+7;

int main(){
    ll N,A,B;cin >> N >> A >> B;
    vector<ll> X(N);
    for(int i = 0;i < N;i++){
        cin >> X[i];
    }
    ll ans = 0;
    for(int i = 0;i < N-1;i++){
        ll d = X[i+1] - X[i];
        ans += min(A * d,B);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int N,C,K; cin>>N>>C>>K;
  vi T(N);
  rep(i,N) cin >> T[i];
  sort(T.begin(), T.end());
  int firstPassenger = T[0];
  int cnt = 0;
  int bus=0;
  rep(i,N) {
    int t = T[i];
    if (cnt < C && t-firstPassenger <= K) {
      cnt++;
    } else {
      bus++; cnt = 1;
      firstPassenger = t;
    }
  }
  if (cnt) bus++;
  cout << bus << endl;
  return 0;
}

Measured memory_bytes: 640
import sys

s = input()
odd = ["R", "U", "D"]
even = ["L", "U", "D"]

for i in range(len(s)):
    if (i % 2 == 0 and s[i] not in odd) or (i % 2 == 1 and s[i] not in even):
        print("No")
        sys.exit()
print("Yes")


Measured memory_bytes: 2940
N = int(input())
l = []

for i in range(N):
    a, b = map(int, input().split())
    l.append((a-b,a+b))

l = sorted(l,key=lambda x:x[1])

start = l[0][1]
ans = 1
for i in range(1,N):
    if start <= l[i][0]:
        start = l[i][1]
        ans += 1

print(ans)

Measured memory_bytes: 19028
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n-2):
    if p[i+1] > p[i] and p[i+1] < p[i+2]:
        count += 1
    elif p[i+1] < p[i] and p[i+1] > p[i+2]:
        count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int q;
	scanf("%d",&q);
	while(q--)
	{
		long long a,b;
		scanf("%lld %lld",&a,&b);
		long long lo =0, hi = 2e9;
		long long c = 0;
		while(lo <= hi)
		{
			long long mid = (lo + hi) >> 1;
			if(mid * mid < a*b)
			{
				c = mid;
				lo = mid+1;
			}
			else
			{
				hi = mid-1;
			}
		}
		long long ans = 2*c;
		if(a <= c)
			ans--;
		if(b <= c)
			ans--;
		if(c*(c+1) >= a*b)
			ans--;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((abs(a - c) <= d)
		|| ((abs(a - b) <= d) && (abs(b - c) <= d))) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int X, Y;  cin >> X >> Y;
    bool ans = false;
    
    for(int i = 0 ; i <= X ; i++)
      if(2*i + 4*(X-i) == Y)  ans = true;

    cout << ((ans) ? "Yes" : "No") << endl;
    
	return 0;
}

Measured memory_bytes: 3636
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N,M = util.Scan2 int
let As = 
  util.ScanMatrix N int
  |> List.map (Array.skip 1)

[ for i in 1..M do
    if List.forall (fun a -> Array.contains i a) As
      then yield 1
]
|> List.length
|> printfn "%d" 


Measured memory_bytes: 14300
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  ll K;
  cin >> S >> K;
  char ans = '1';
  for (ll i=0LL; i<min((ll)S.size(), K); i++) {
    if (S[i]!='1') {
      ans = S[i];
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s=[ [] for i in range(3) ]
s[0]=input()
s[1]=input()
s[2]=input()
p=0
while True:
  if len(s[p])==0:
    if p==0:
      print('A')
    elif p==1:
      print('B')
    else:
      print('C')
    exit()
  tmp=s[p][0]
  s[p]=s[p][1:]
  if tmp=='a':
    p=0
  elif tmp=='b':
    p=1
  else:
    p=2

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

using namespace std;

#define LL long long

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

    LL ans = 1;
    for (int i = 0; i < n; ++i) {
        LL t;
        cin >> t;
        ans = ans / __gcd(ans, t) * t;
    }

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

Measured memory_bytes: 256
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  newl           cout<<"\n";
#define  f              first
#define  s              second
#define  pb             push_back
#define  mp             make_pair
#define  sym(s)         s="#"+s+"#";   
#define  all(x)         (x).begin(),(x).end()
#define  alll(x, n)     x+1, x+n+1
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  mset1d(a,n,v)  foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v)foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  INP(a,n)       foo(i,1,n) cin>>a[i];
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  debm(a)        for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  debp(a,n)      foo(i,1,n)cout<<"{"<<a[i].f<<","<<a[i].s<<"}, ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/



/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    ll a, b, x, y;
    cin>>x>>y;
    b= (y-2*x)/2;
    a= (x-b);
    if(a+b==x && 2*a+4*b==y && a>=0 && b>=0)cout<<"Yes";
    else cout<<"No";
    newl;


}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 8332
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> l(N);
  int li;
  int a,b,c,ab,a_b,ans = 0;
  for (int i = 0; i < N; ++i)
  {
    cin >> li; 
    l.at(i) = li;
  }
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  
  for (int i = 0; i < N - 2; ++i)
  {
    a = l.at(i);
    for (int j = i + 1; j < N - 1; ++j)
    {
      b = l.at(j);
      ab = a + b;
      a_b = a - b;
      for (int k = j + 1; k < N; ++k)
      {
        c = l.at(k);
        if (a_b < c & 0 < c + a_b & c < ab)
        {
          ans++;
        }
        else if (a_b >= c)
        {
          break;
        }
      }
    }
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
template <typename T>
class SegmentTree{
private:
    using Fn = function<T(T, T)>;
    int N;
    vector<T> dat;
    T unit;
    Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }
  SegmentTree(const vector<T> &v, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    int sz = v.size();
    while (N < sz)
      N *= 2;
    dat.resize(2 * N - 1);
    for (int i = 0; i < N; ++i)
      dat[i + N - 1] = (i < sz ? v[i] : unit);
    for (int i = N - 2; i >= 0; --i)
      dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  // k 番目の要素を a に変更
  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  // k 番目の要素を取得
  T get(int k) { return dat[k + N - 1]; }

  // 区間 [l, r) の和を取得
  T query(int l, int r)
  {
    T vl = unit, vr = unit;
    for (l += (N - 1), r += (N - 1); l < r; l >>= 1, r >>= 1)
    {
      if ((l & 1) == 0)
        vl = func(vl, dat[l]);
      if ((r & 1) == 0)
        vr = func(vr, dat[--r]);
    }
    return func(vl, vr);
  }
  //添え字でアクセス
  T operator[](int i){
      return dat[i + N - 1];
  }
};
int main(){
    auto mini = [](ll a, ll b) { return min(a, b); };
    ll n;
    cin >> n;
    SegmentTree<ll> sgt(n, mini, INF);
    for (ll i = 0; i < n; i++) {
        ll t;
        cin>>t;
        sgt.update(i, t);
    }

    ll ans = -INF;
    for (ll i = 0; i < n; i++) {
        ans=max(ans, sgt[i] - sgt.query(0, i));
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;

int main() {
    char a;
    cin >> a;
    if (isupper(a)) cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

// c＜a＋b
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;

  CIN(N);

  int L[N];
  for (int i = 0; i < N; i++) {
    CIN(L[i]);
  }
  int count = 0;

  sort(L, L + N);

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L[i] < L[j] + L[k] &&
            L[j] < L[i] + L[k] &&
            L[k] < L[i] + L[j]) {
          // COUT("---i " << i << " " << j << " " << k);
          // COUT("" << L[i] << " " << L[j] << " " << L[k]);
          count++;
        }
      }
    }
  }
  COUT(count);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  ll n, ans = 0; cin >> n;
  queue<ll> q;
  q.push(3); q.push(5); q.push(7);
  while(q.front() <= 999999999){
    ll t = q.front();q.pop();
    q.push(t*10+3); q.push(t*10+5); q.push(t*10+7);
    bool f[3] = {false};
    if(t > n)continue;
    while(t > 0){
      int a = t % 10; t /= 10;
      if(a == 3 || a == 5 || a == 7)f[a%3] = true;
    }
    if(f[0]&&f[1]&&f[2])ans++;
  }
  cout << ans << endl;
  system("pause");
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

signed main(){
	int N,M;
	cin>>N>>M;
	rep(i,M){
		int a;cin>>a;N-=a;
	}
	chmax(N,-1);
	cout<<N<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<cstdio>
#define INF 1<<29
#define all(c) (c).begin(),(c).end()

using namespace std;

int main(void){

  int n;
  while(cin >> n,n){
    vector<int>a(n+1);
    a[0]=0;
    for(int i=1;i<=n;i++)cin >> a[i];
    double b,r,v,e,f;
    cin >> b >> r >> v >> e >> f;

    double time[10001];
    time[0]=0;
    for(int i=0;i<10001;i++){
      if(i>=r)time[i+1]=1/(v-e*(i-r))+time[i];
      else time[i+1]=1/(v-f*(r-i))+time[i];
    }
    double dp[101];
    fill(dp,dp+101,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<=n;j++)
	dp[j]=min(dp[j],dp[i]+time[a[j]-a[i]]+(i>0)*b);

    printf("%.4f",dp[n]);
    cout << endl;
  }
  return 0;
}

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

class AorC
{
    static void Main(string[] args)
    {

        var input = Console.ReadLine();

        if(input == "ABC")
        {
            Console.WriteLine("ARC");
        }
        else if(input == "ARC") {
            Console.WriteLine("ABC");
        }
        
    }
}


Measured memory_bytes: 25892
//
//  main.cpp
//  c++_atcoder
//
//  Created by 脇田康平 on 2019/07/19.
//  Copyright © 2019 脇田康平. All rights reserved.
//

#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int N = 0;
    
    scanf("%d",&N);
    
    vector<string> S(N);
    for (int i = 0;i<N;i++){
        cin >>S[i];
    }
    sort(S.begin(),S.end());
    int num = 0;
    int temp = 1;
    vector<int> lis_num(N);
    vector<string> lis_name(N);
    
    for (int i = 0;i<N;i++){
        if(i!=N-1){
            if(S[i] == S[i+1]){
                temp+=1;
            }
            else{
                lis_num[num] = temp;
                temp=1;
                lis_name[num] = S[i];
                num+=1;
            }
        }
        else{
            lis_num[num] = temp;
            temp=1;
            lis_name[num] = S[i];
            num+=1;
        }
    }
    /*for (int i = 0;i<N;i++){
        cout<<lis_num[i]<<' ';
    }
    cout<<endl;
    for (int i = 0;i<N;i++){
        cout<<lis_name[i]<<' ';
    }
    */
    int max = 0;
    for (int i =0;i<num;i++){
        if(max < lis_num[i]){
            max = lis_num[i];
        }
    }
    cout<<endl;
    for(int i =0;i<num;i++){
        if (lis_num[i]==max){
            cout<<lis_name[i]<<endl;
        }
    }
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  //int p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    //cout << p[i] << endl;
  }
  
  sort(p.begin(),p.end());
  
  int sum=0;
  for(int i=0;i<k;i++){
    sum += p[i];
  }
  
  cout << sum << endl;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int N, M, k[111];

int main() {
	cin >> N >> M;
	memset(k, -1, sizeof(k));
	
	for_(v,0,N) {
		cout << "lst " << v << endl;
		cin >> k[v];
		for_(i,0,k[v]) { int dumy; cin >> dumy; }
	}
	
	int ans = 0;
	for_(v,0,N) ans += (k[v] - 1) * k[v];
	cout << "ans " << ans << endl;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main( int argc, char *argv[] )
{
    char s[100];

    scanf( "%s", s );

//    printf( "[%s] %d\n", s, strlen( s ) );

    if( ! strcmp( s, "ABC" ) ) {
        puts( "ARC" );
        exit( 0 );
    } else if( ! strcmp( s, "ARC" ) ) {
        puts( "ABC" );
        exit( 0 );
    }

    puts( "???" );
}


Measured memory_bytes: 1608