akhauriyash/Code-Regression huggingface dataset:
import java.util.*;


class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		System.out.println( (A + B >= C) ? "Yes" : "No" );
	}
}


Measured memory_bytes: 21844
class BIT():
    """区間加算、一点取得クエリをそれぞれO(logN)で答える
    add: 区間[l, r)にvalを加える
    get_val: i番目の値を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


from operator import itemgetter
n, d, a = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

info = sorted(info, key = itemgetter(0))
bit = BIT(n)

for i in range(n):
    bit.add(i, i+1, info[i][1])

info.append([10**18, 0])
ans = 0 
r = 0
for i in range(n):
    num = bit.get_val(i)
    if num <= 0:
        continue
    while True:
        if info[r][0] - info[i][0] > 2*d:
            break
        else:
            r += 1
    ans += -((-num) // a)
    bit.add(i, r, -(-((-num) // a)) * a)
print(ans)

Measured memory_bytes: 96856
from collections import defaultdict
from bisect import bisect_left
N, M = map(int, input().split())
A = []
B = defaultdict(list)
 
for i in range(M):
    p, y = map(int, input().split())
    A.append([p, y])
    B[p].append(y)
 
for key in B.keys():
    B[key].sort()

# print(A,B)
# for a in A:
#     print(a[0],a[1],B[a[0]],bisect_left(B[a[0]],a[1]))
for a in A:
    print("%06d%06d" % (a[0], bisect_left(B[a[0]], a[1])+1))

Measured memory_bytes: 38444
N = int(input())
C = 0
D = 0
E = 0
F = 0
S = ''

for i in range(N):
    S = input()
    if S == 'AC':
        C += 1
    elif S == 'WA':
        D += 1
    elif S == 'TLE':
        E += 1
    elif S == 'RE':
        F += 1
print('AC x '+ str(C), 'WA x ' + str(D),  'TLE x ' + str(E),  'RE x ' + str(F), sep='\n')


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
typedef long double ld;
//////////////////////////////////////////////////////////////////////



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

  int h,w;cin>>h>>w;
  int a[10][10];
  
  for(int i=0;i<10;i++)for(int j=0;j<10;j++)
      cin>>a[i][j];

  for(int k=0;k<10;k++)
    for(int i=0;i<10;i++)
      for(int j=0;j<10;j++)
	a[i][j] = min(a[i][j],a[i][k]+a[k][j]);
  
  int v;
  int ans = 0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      cin>>v;
      if(v!=-1)ans += a[v][1];
    }
  cout << ans << nl;
  
  return 0;
};


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		String N = sc.get();
		switch (N.charAt(N.length() - 1)) {
			case '2':
			case '4':
			case '5':
			case '7':
			case '9':
				System.out.println("hon");
				break;
			case '0':
			case '1':
			case '6':
			case '8':
				System.out.println("pon");
				break;
			default:
				System.out.println("bon");
		}
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32512
import sys
n,k = map(int,input().split())
h = input().split()
for i in range(n):
    h[i] = int(h[i])

h.sort(reverse=True)

min = 0

if(k >= n):
    print(0)

else:
    for i in range(k):
        h[i] = 0
    print(sum(h))

Measured memory_bytes: 20240
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
class ParseError {};

/*
   <??????????????????> ::= <??????????????????> (+ or -) <??????????????????> (+ or -) ...
   <??????????????????> ::= <??°> (* or /) <??°> (* or /) ...
   <??°>           ::= ...
   */


int expression(State &begin);
int term(State &begin);
int number(State &begin);
int factor(State &begin);

int factor(State &begin)
{ 
  if (*begin == '(')
  {
    begin++;
    int ret = expression(begin);
    begin++;
    return ret;
  }
  else
  {
    return number(begin);
  }
}


int main(void) {
  int N;
  cin >> N;
  cin.ignore();
  for(int i = 0; i < N; i++)
  {
    string s;
    getline(cin, s);
    
    State begin = s.begin();
    int ans = expression(begin);
    cout << ans << endl;
  }

  return 0;
}
int expression(State &begin)
{
  int ret = term(begin);
  for(;;) {
    if(*begin == '+') {
        begin++;
        ret += term(begin);
    } else if (*begin == '-')
       {
          begin++;
          ret -= term(begin);
       }
    else{
        break;
    }
    
  }
  return ret;
}
int term(State &begin)
{
  int ret = factor(begin);
  for(;;)
  {
    if(*begin == '*')
    {
      begin++;
      ret *= factor(begin);
    } else if(*begin == '/') {
      begin++;
      ret /= factor(begin);
    } else {
      break;
    }
  }
  return ret;
}
int number(State &begin) {
  int ret = 0;
  while(isdigit(*begin)) {
    ret *=10;
    ret += *begin - '0';
    begin++;
  }

  return ret;

}

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

long long n, m;
long long a[100005];
long long memo[100005];
map<long long, vector<long long> >gcount;

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

	for(long long i = 0; i < n - 1; i++){
		long long start = a[i];
		long long goal = a[i+1];
		gcount[goal].push_back((goal - start + m)%m);
		if(start > goal){
			memo[0]++;
		}
		memo[start + 1]++;
		memo[goal]--;
	}

	for(long long i = 1; i < m; i++){
		memo[i] += memo[i-1];
	}

	long long ans = 0;
	long long cur = 0;
	for(long long i = 0; i < n - 1; i++){
		long long start = a[i];
		long long goal = a[i+1];
		//cout << start << " -> " << goal << endl;
		cur += min( 1 + (goal + m)%m, (goal + m - start)%m);
	}
	//cout << "first " << cur << endl;

	ans = cur;
	for(long long i = 1; i < m; i++){
		//ai+x == iのとき 1 -> (ai+1 + m - ai)%m
		//cout << "gcount size = " << gcount[i-1].size() << endl;
	 	for(long long j = 0; j < gcount[i-1].size(); j++){
			cur--;
			cur += gcount[i-1][j];
		}
		//cout << "memo[" << i << "] = " << memo[i] << endl;
		cur -= memo[i-1];
		//cout << "i = " << i << " " << cur << endl;
		ans = min(ans, cur);
	}
	cout << ans << endl;
}


Measured memory_bytes: 12032
#include <iostream>
#include <string>
#include <iostream>
using namespace std;
int main()
{
	char str1[3];
	char str2[3];
	int a;

	cin >> str1;
	cin >> str2;
	a = 0;

	for (int i = 0; i < 3; i++) {
		if (str1[i] == str2[i]) {
			a = a + 1;
		}
	}

	cout << a;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll x[100100];
priority_queue<ll> pq;

int main(void){
	int n,m,i;
	ll ans;
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> x[i];
	}
	sort(x,x+m);
	ans = x[m-1] - x[0];
	for(i=1; i<m; ++i){
		pq.push(x[i]-x[i-1]);
	}
	for(i=1; i<n; ++i){
		if(pq.empty()){
			break;
		}
		ans -= pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2168
def main():
    s = [input() for l in range(2)]
    N, A_dct, A = int(s[0]), {int(x): int(x) for x in s[1].split()}, [int(x) for x in s[1].split()]
    if 0 in A_dct:
        print(0)
    else:
        tmp = 1
        for k in A:
            tmp *= k
            if tmp > 10**18:
                tmp = -1
                break
        print(tmp)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 36436
// atcoder/abc129/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n, m;
  while (cin >> n >> m) {
    vector<int> a(m);
    cin >> a;
    sort(a.begin(), a.end());

    const lli mod = 1e9 + 7;
    const int N = 1e5 + 5;
    static lli dp[N];
    fill(dp, dp + N, 0);
    dp[0] = 1;

    for (int i = 0; i < n; ++i) {
      unless (binary_search(a.begin(), a.end(), i + 1)) {
        (dp[i + 1] += dp[i]) %= mod;
      }
      unless (binary_search(a.begin(), a.end(), i + 2)) {
        (dp[i + 2] += dp[i]) %= mod;
      }
    }
    cout << dp[n] << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
s = io.read()
n = #s
c = 0
r = s:sub(1, 1) == "A"
for i = 3, n - 1 do
  if s:sub(i, i) == "C" then
    c = c + 1
  end
end
if c ~= 1 then r = false end
for i = 2, n do
  ss = s:sub(i, i)
  if ss:byte() < 96 and ss ~= "C" then
    r = false
  end
end
print(r and "AC" or "WA")


Measured memory_bytes: 888
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<time.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first    
#define se second
void solve()
{
    ll a,b,k;
    cin>>a>>b;
    k=(a+b)/2;
    if(abs(a-k)==abs(b-k))
        cout<<k;
    else
        cout<<"IMPOSSIBLE";
}
int main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif  
    clock_t tStart = clock();
    ll t,k;
    // cin>>t;
    // while(t--)
        solve();
    // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	string s;
	cin >> s;
	int n = sz(s);
	ll ans = 0;
	rep(i,0,n) if(s[i] == 'W') ans += i;
	int m = count(all(s), 'W');
	rep(i,0,m) ans -= i;
	cout << ans << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int r; cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, int> PLDI;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
const int INF = (1e9);
const LL MOD = 1e9+7;
const double EPS = 1e-5;
const double PI=atan2(0,-1);

int main()
{
    LL n,x;
    cin>>n>>x;
    vector<LL> a(n);
    LL sum=0, s;
    REP(i,n)
    {
        cin>>a[i];
        if(i==0) continue;
        s=a[i-1]+a[i];
        if(s>x)
        {
            LL p=min(a[i],s-x);
            a[i]-=p;
            a[i-1]-=s-p;
            sum+=s-x;
        }
        
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define n_l '\n'
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: "; cerr << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cerr << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cerr << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cerr << endl
#define run(a, b) cerr << fixed << setprecision(6) << (double) (b - a) / (double) (CLOCKS_PER_SEC) << " s" << endl;
#define ll long long
#define ld long double
#define INF (1e18L + 5)
#define MOD (ll)(1e9 + 7)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            ans += (arr[i] * arr[j]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template<typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}

struct UnionFind {
  int n;
  vi par;

  UnionFind(int n): n(n) {
    par.resize(n, -1);
  }

  int root(int x) {
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);

    if(par[x] > par[y]) swap(x, y);
    par[y] = x;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, m;
  cin >> n >> m;
  vll a(n);
  REP(i, n) cin >> a[i];
  UnionFind uf(n);
  REP(i, m) {
    int x, y;
    cin >> x >> y;
    uf.unite(x, y);
  }

  if(n - m == 1) {
    cout << 0 << endl;
    return 0;
  }

  map<int, multiset<ll>> mp;
  REP(i, n) {
    mp[uf.root(i)].insert(a[i]);
  }

  ll su = 0;
  ll cnt = 0;
  multiset<ll> st;
  for(auto e: mp) {
    su += *(e.second.begin());
    cnt++;
    e.second.erase(e.second.begin());
    for(auto &e2: e.second) {
      st.insert(e2);
    }
  }

  while(!st.empty() && cnt < 2 * (n - m - 1)) {
    cnt++;
    su += *(st.begin());
    st.erase(st.begin());
  }

  if(cnt < 2 * (n - m - 1)) cout << "Impossible" << endl;
  else cout << su << endl;

}
























Measured memory_bytes: 18516
#!/usr/bin/env python
# -*- coding: utf-8 -*-

acgt_array = ["A","C","G","T"]

count = 0
max_val = 0

input_str = input()

for i in input_str:
    if(i in acgt_array):
        count += 1
    else:
        count = 0
    if(count > max_val):
        max_val = count
print(max_val)


Measured memory_bytes: 2940
from sys import stdin
N,M,X=list(map(int,(stdin.readline().strip().split())))
cost=[]
money=0
und=[0]*M
sankousho=[]
for i in range(N):
    book = list(map(int, (stdin.readline().strip().split())))
    sankousho.append(book)
def hantei(und):
    for i in und:
        if i<X:return False
    return True
def kiroku(b,und):
    for i in range(M):
        und[i]+=b[i+1]
    return und
def use(book,i,money,und):
    money_A=money
    money_B=money
    und_A=und.copy()
    und_B=und.copy()
    if i==N:
        if hantei(und):
            cost.append(money)
    else:
        und_A=kiroku(book[i],und_A)
        money_A+=book[i][0]
        use(book,i+1,money_A,und_A)
        use(book,i+1,money_B,und_B)

use(sankousho,0,0,und)
if len(cost)==0:print(-1)
else:print(min(cost))



Measured memory_bytes: 9252
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll N,X,T;
    cin>>N>>X>>T;
    cout<<(((N-1)/X)+1) * T;
    return 0;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>; 



int main(){
    int n; cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    cout<<""<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin >> x >> y;
        if (x==0 && y==0) break;
        if (x > y) {
            cout << y << " " << x;
        } else {
            cout << x << " " << y;
        }
        cout << endl;
    }
}


Measured memory_bytes: 2996
n,K=map(int,input().split());c={}
for i in range(n):
  a,b=map(int,input().split())
  if a in c:c[a]+=b
  else:c[a]=b
for k,v in sorted(c.items()):
  K-=v
  if K<=0:print(k);exit()

Measured memory_bytes: 14688
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        double[] d = new double[N];
        for (int i = 0; i < N; i++) {
            d[i] = scan.nextDouble();
        }
        double avg = Arrays.stream(d).sum() / N;
        int ans = -1;
        double min = Double.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            double distance = Math.abs(avg-d[i]);
            if (distance < min) {
                min = distance;
                ans = i;
            }
        }
        System.out.println(ans);
    }
}


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

int main() {
  string s;
  cin >> s;
  int ans, cur = 0;
  bool streak = true;
  for(auto a : s) {
    if(a == 'R' && streak) ++cur;
    else if(a == 'R' && !streak){ ++cur; streak = true; }
    else streak = false, ans = max(ans,cur), cur = 0;
  }
  ans = max(ans,cur);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>

using namespace std;

#define ll long long

int main()
{
	long k, x;
	cin >> k >> x;

	if (500 * k < x)
		printf("No");
	else
		printf("Yes");

	return 0;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

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

    int n,m;
    cin>>n>>m;
    cout<<((((n-1)*n)/2)+(((m-1)*m)/2));
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {

    private static final int INF = (int) 1e9;

    static class Pair {
        int val, idx;
    }

    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        Pair[] a = new Pair[n + 1];
        a[0] = new Pair();
        a[0].val = 0;
        a[0].idx = INF;
        for (int i = 1; i <= n; i++) {
            a[i] = new Pair();
            a[i].val = in.nextInt();
            a[i].idx = i;
        }
        Arrays.sort(a, 1, n + 1, new Comparator<Pair>() {
            @Override
            public int compare(Pair o1, Pair o2) {
                if (o1.val != o2.val) return Integer.compare(o1.val, o2.val);
                return Integer.compare(o1.idx, o2.idx);
            }
        });
//        for (int i = 1; i <= n; i++) out.print(a[i].val + " ");
//        out.println();
//        for (int i = 1; i <= n; i++) out.print(a[i].idx + " ");
//        out.println();
        TreeMap<Integer, Long> map = new TreeMap<>();
        int it = n, size = 1, minIndex = Integer.MAX_VALUE;
        while (it >= 1) {
            if (a[it].val > a[it - 1].val) {
                minIndex = Math.min(minIndex, a[it].idx);
                map.put(minIndex, map.get(minIndex) == null ?  size * (long) (a[it].val - a[it - 1].val) : map.get(minIndex) + size * (long) (a[it].val - a[it - 1].val));
            }
//            out.println("Min Index " + minIndex);
            it--;
            size++;
        }
        for (int i = 1; i <= n; i++) {
            if (map.containsKey(i)) {
                out.println(map.get(i));
            } else {
                out.println(0);
            }
        }
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

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

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

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

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

Measured memory_bytes: 57436
#include <iostream>
#include<map>
using namespace std;
int main(void){
    // Your code here!
    map<string, int> m;
    
    int t;
    string input;
    cin>>t;
    while(t--){
        cin>>input;
        m[input]++;
    }
    
    cout<<"AC"<<" "<<"x "<<m["AC"]<<endl;
    cout<<"WA"<<" "<<"x "<<m["WA"]<<endl;
    cout<<"TLE"<<" "<<"x "<<m["TLE"]<<endl;
    cout<<"RE"<<" "<<"x "<<m["RE"]<<endl;
    
}


Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
int main(void){
    int n,k;
    string s;
    cin >> n>>k>>s;

    for(int i=0 ;i<n;i++){
        if(i+1==k){
            if(s[i]=='A') cout<<'a';
            else if(s[i]=='B') cout<<'b';
            else cout<<'c';
        }else{
            cout<<s[i];
        }
    }
    cout<<endl;

    return 0;
}
//////////////////
//  B
/*int main(void){

    return 0;
}*/
//////////////////
//  C
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL MOD = 1000000007LL;
int main() {
	int N;
	string s, t;
	cin >> N;
	cin >> s >> t;
	for (int len = N; len >= 0; len--) {
		if (s.substr(N - len) == t.substr(0, len)) {
			cout << 2 * N - len << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;

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

	int A, B, C, l = 0, k = 0, o = 0; cin >> A >> B >> C;
	if (A <= B && A <= C) {
		cout << A + min(C, B) << endl;
	}
	else if (B <= A && B <= C) {
		cout << B + min(C, A) << endl;
	}
	else if (C <= A && C <= A) {
		cout << C + min(A, B) << endl;
	}
	else if(A==B&&C==B) cout << A + B << endl;
	return 0;
}



Measured memory_bytes: 3604
<?php
// Your code here!
    while($line=trim(fgets(STDIN))){
        if($line == "-")break;
        $num = intval(trim(fgets(STDIN)));
        for($i=0;$i<$num;$i++){
            $s_num = intval(trim(fgets(STDIN)));
            $len = strlen($line);
            $string = substr($line,0,$s_num);
            $line = $line.$string;
            // echo $line."\n";
            $line = substr($line,$s_num,$len);
            // echo $string."\n\n";
            
        }
            echo $line."\n";
    }

?>


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

main() {
	int k, s;
	int x, y, z;
	int cnt = 0;

	cin >> k >> s;

	for(int x = 0; x <= k; x++) {
		for (int y = x; y <= k; y++) {
			for (int z = y; z <= k; z++) {
				if ((x + y + z) == s) {
					if (x == y && y == z) {
						cnt++;
					} else if (x == y || x == z || y == z) {
						cnt += 3;
					} else {
						cnt += 6;
					}
				}
			}
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 384
import java.util.*;

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

	static String find(String s) {
		boolean[] ft = { false, true };

		for (boolean b1: ft)
			for (boolean b2: ft)
				for (boolean b3: ft)
					for (boolean b4: ft)
						if (String.format("%sKIH%sB%sR%s", a(b1), a(b2), a(b3), a(b4)).equals(s))
							return "YES";
		return "NO";
	}

	static String a(boolean b) {
		return b ? "A" : "";
	}
}


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

//atcoder129
int main() {
  int P, Q, R;
  cin >> P >> Q >> R;

  int ans = 1000;

  if(P + R < ans) ans = P + R;
  if(P + Q < ans) ans = P + Q;
  if(R + Q < ans) ans = R + Q;

  cout << ans;

  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve()
{
    stack<char> ss;
    string s; cin >> s;
    for(auto x: s)
    {
        if(x == 'B' && !ss.empty()) ss.pop();
        else if(x != 'B')ss.push(x);
    }
    s.clear();
    while(!ss.empty())
    {
        s += ss.top(); ss.pop();
    }
    reverse(all(s));
    cout << s;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int ans = 0;
    for(auto& e : a) {
        cin >> e;
        ans += min(e-0, k-e) * 2;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N,D,count=0;
  cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> X.at(i).at(j);
    }
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      int dis=0;
      for(int k=0;k<D;k++){
        int A=X.at(i).at(k)-X.at(j).at(k);
        dis+=A*A;
      }
      for(int k=1;k<128;k++){
        if(dis==k*k){
          count++;
          break;
        }
      }
    }
  }
  cout << count << endl;
}

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

using namespace std;

const int N = 301;
bool vis[N][N][N];
double dp[N][N][N];
int c1, c2, c3, n;

double solve(int a, int b, int c) {
  if (a == 0 && b == 0 && c == 0)
    return 0;
  if (vis[a][b][c])
    return dp[a][b][c];
  vis[a][b][c] = true;
  if (a != 0)
    dp[a][b][c] += a * solve(a - 1, b, c);
  if (b != 0)
    dp[a][b][c] += b * solve(a + 1, b - 1, c);
  if (c != 0)
    dp[a][b][c] += c * solve(a, b + 1, c - 1);
  dp[a][b][c] += 1;
  dp[a][b][c] /= (a + b + c);
  return dp[a][b][c];
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    switch (x) {
    case 1: ++c1; break;
    case 2: ++c2; break;
    case 3: ++c3; break;
    }
  }
  cout << n * solve(c1, c2, c3) << '\n';
  return 0;
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC136.Transfer();
        }
    }

    class ABC136
    {
        public static void Transfer()
        {
            int[] n = Input.getIntArray();
            int a = n[0];
            int b = n[1];
            int c = n[2];

            int water = c - (a-b);
            if(water<0) water=0;
            Console.WriteLine(water);
        }

    }
  
    class Input
    {
        public static int getInt()
        {
            int i = int.Parse(Console.ReadLine());
            return i;
        }

        public static string getString()
        {
            string s = Console.ReadLine();
            return s;
        }
        public static int[] getIntArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            int[] num = s.Select(x=>int.Parse(x)).ToArray();
            return num;
        }
        public static long[] getLongArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            long[] num = s.Select(x=>long.Parse(x)).ToArray();
            return num;
        }
    }

}


Measured memory_bytes: 11348
import itertools
H, W, K = map(int, input().split())
S = ["" for i in range(H)]
for i in range(H):
    S[i] = input()

ans = 0
# print(S)
for h in itertools.product([0, 1], repeat=H):
    for w in itertools.product([0, 1], repeat=W):
        # print(h, w)
        count = 0
        for i in range(H):
            for j in range(W):
                if h[i] == 0 and w[j] == 0:
                    if S[i][j] == "#":
                        count += 1
        # print(count)
        if count == K:
            ans += 1

print(ans)


Measured memory_bytes: 9204
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a[9]={};
		int b[9]={};
		int dat[9],o=0,s=0,f;
		for(int k=0;k<10;k++){
			cin>>f;
			dat[k]=f;
		}
		for(int j=0;j<=10;j++){
			if(j==10){
				cout<<"YES"<<endl;
				break;
						}					if(s==0 || dat[j]>a[s-1]){
				a[s]=dat[j];
				s++;
			}
			else if(o==0 || dat[j]>b[o-1]){
				b[o]=dat[j];
				o++;}
			else{
				cout<<"NO"<<endl;
			break;
			}
					}
	}
	return 0;
}

Measured memory_bytes: 1156
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())
N = int(input())
B = {int(input()) for _ in range(N)}

h1 = {A11, A12, A13}
h2 = {A21, A22, A23}
h3 = {A31, A32, A33}
v1 = {A11, A21, A31}
v2 = {A12, A22, A32}
v3 = {A13, A23, A33}
c1 = {A11, A22, A33}
c2 = {A13, A22, A31}

if len(h1 & B)==3 or len(h2 & B)==3 or len(h3 & B)==3 or len(v1 & B)==3 or len(v2 & B)==3 or len(v3 & B)==3 or len(c1 & B)==3 or len(c2 & B)==3:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--) 
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    ll L,R;
    cin >> L >> R;
    ll mod =2019;
    ll rest=INFINITY;

    if((R-L)>mod){
        R=L+mod;
    }

    for(ll i=L;i<=R-1;i++){
        for(ll j=i+1;j<=R;j++){
            rest=min(rest,(i*j)%mod);
        }
    }

    cout << rest << endl;
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isNumber = (x: unknown): x is number => typeof x === "number";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isBigint = (x: unknown): x is bigint => typeof x === "bigint";
type NumberOrBigintOrElse<T> = number | bigint extends T
  ? undefined
  : T extends number
  ? number
  : T extends bigint
  ? bigint
  : undefined;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const max = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.max(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc >= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const min = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.min(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc <= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const abs = <T extends number | bigint>(t: T) =>
  (isNumber(t)
    ? Math.abs(t)
    : isBigint(t)
    ? t >= 0n
      ? t
      : -t
    : undefined) as NumberOrBigintOrElse<T>;

/**
 * Program
 */
type Color = "R" | "W";

const getAns = (N: number, cs: Color[]): number => {
  const rNum = cs.filter((c) => c === "R").length;
  return min(rNum, N - rNum, cs.slice(0, rNum).filter((c) => c === "W").length);
};

{
  const N = nCin();
  const cs = cin()
    .split("")
    .map((c) => c as Color);
  const ans = getAns(N, cs);
  console.log(ans);
}


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

l = list(map(int, input().split()))
count = 0

for i in range(n):
    for j in range(n-1, i, -1):
        if l[j] < l[j-1]:
            l[j], l[j-1] = l[j-1], l[j]
            count += 1
print(" ".join(map(str, l)))
print(count)


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

//2017に似た数の累積和
vector<int> a(100002, 0);

bool is_prime(int x) {
    bool ok = true;
    for (int i = 2; i*i <= x; i++) {
        if (x % i == 0) ok = false;
    }
    if (x == 1) ok = false;
    return ok;
}

void init() {
    for (int i = 0; i <= 100000; i++) {
        a[i+1] = a[i];
        if (i % 2 != 0 && is_prime(i) && is_prime((i+1)/2)) a[i+1]++;
    }
}

int main() {
    init();
    int Q; cin >> Q;
    vector<int> ans(Q);
    for (int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r;
        ans[i] = a[r+1]-a[l];
    }
    for (int i = 0; i < Q; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mod 1000000007
ll h,w;
char ar[1001][1001];
ll dp[1001][1001];

ll path(ll i,ll j){
    if(i==h-1&&j==w-1) return 1;
    if(dp[i][j]!=-1) return dp[i][j];
    ll x=0,y=0;
    if(i+1<h&&ar[i+1][j]!='#') x=path(i+1,j);
    if(j+1<w&&ar[i][j+1]!='#') y=path(i,j+1);
    return dp[i][j]=(x+y)%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>h>>w;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin>>ar[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<path(0,0)<<endl;
    return 0;
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    int h[10], w;
    vector<int> ans;
    rep(i, 10) {
        h[i] = pow(2.0, (double)i);
    }
    
    while (cin >> w) {
        ans.clear();
        for (int i = 9; i >= 0; i--) {
            if (w == 1) {
                ans.push_back(h[0]);
                break;
            }
            else if (h[i] <= w){
                ans.push_back(h[i]);
                w -= h[i];
            }
        }
        
        for (int i = (int)ans.size() - 1; i >= 0; i--) {
            cout << ans[i];
            i == 0 ? cout << endl : cout << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 1256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){return b==0?a:gcd(b,a%b);}

int main()
{
  int n;
  ll k, maxn, t, g;
  scanf("%d%lld", &n, &k);
  scanf("%lld", &g);
  maxn = g;
  for(int i = 1; i < n; i++){
    scanf("%lld", &t);
    g = gcd(g, t);
    maxn = max(maxn, t);
  }
  if(maxn >= k && (maxn-k)%g==0)  printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 128
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
ll ds(ll Q){
        ll sum=0;
        ll dig;
        while(Q){
        dig = Q % 10;
        sum = sum + dig;
        Q = Q / 10;
        }
        return sum;
    }

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    long double x;
    vector<ll> aa;

    ll Q,N,K;
    long double a, b;
    string S;
    cin  >>S;
    ll flag=0;
    ll t1=0;
    ll t2=0;
  	
    ll Q1=Q;

    ll temp=1;
    ll pl=1;

    
    if(S[0]=='7' || S[1]=='7' ||S[2]=='7' ){
    cout << "Yes" << endl;
    }else{
        cout<< "No" << endl;
    }
    


    return 0;
}

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

int main(){
	int N;
	cin>>N;
	vector<long>A(N),B(N),C(N);
	for(int i=0;i<N;++i)cin>>A[i];
	for(int i=0;i<N;++i)cin>>B[i];
	for(int i=0;i<N;++i)cin>>C[i];
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());
	/*
	for(int i=0;i<N;++i){
		cout<<A[i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<N;++i){
		cout<<B[i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<N;++i){
		cout<<C[i]<<" ";
	}
	cout<<endl;
	*/
	vector<long>num;
	int left,right,mid;
	for(int i=0;i<N;++i){
		if(C[N-1]<=B[i]){
			num.push_back(0);
			continue;
		}
		left=0;
		right=N-1;
		while(left<right){
			mid=(left+right)/2;
			if(C[mid]>B[i]){
				right=mid;
			}
			else{
				left=mid+1;
			}
		}
		num.push_back(N-left);
	}
	for(int i=N-2;i>=0;--i){
		num[i]+=num[i+1];
	}
	/*
	for(int i=0;i<N;++i){
		cout<<num[i]<<" ";
	}
	cout<<endl;
	*/
	long ans=0;
	for(int i=0;i<N;++i){
		if(B[N-1]<=A[i])break;
		left=0;
		right=N-1;
		while(left<right){
			mid=(left+right)/2;
			if(B[mid]>A[i]){
				right=mid;
			}
			else{
				left=mid+1;
			}
		}
		//cout<<left<<endl;
		ans+=num[left];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3704
N=int(input())
a=list(map(int,input().split()))
mi=0
ma=0
l=[]
count=0
for i in range(N):
 if a[i]<3200:
  l.append(a[i]//400)
 else:
  count=count+1

print(max(1,len(set(l))),max(1,len(set(l))+count))


Measured memory_bytes: 38256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int sumOfDigits(int x) {
    int sum = 0;
    while (x > 0) {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

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

    bool canDevide = (N % sumOfDigits(N) == 0);
    string ans = canDevide ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608