akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

void solve() {
    int N, K; cin >> N >> K;
    int digits = 1;
    while (N >= pow(K, digits)) digits++;
    cout << digits;
    
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:250000000")

#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <functional>
#include <numeric>
#include <random>
#include <cstring>
#include <ctime>
#include <cassert>

#define y1 klfjvkldfngldf

using namespace std;

typedef long long LL;

int n;


int main()
{
	cin >> n;
	map<int, int> M;
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin >> x;
		M[x]++;
	}
	if (M.size() > 2 || M.size() == 2 && M.begin()->first != M.rbegin()->first - 1)
	{
		cout << "No\n";
		return 0;
	}

	if (M.size() == 1)
	{
		if (M.begin()->first == n - 1 || M.begin()->first * 2 <= n)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	else
	{
		int x = M.begin()->first;

		int a = M.begin()->second;
		int b = M.rbegin()->second;

		if (a < x + 1 && 2 * (x + 1 - a) + a <= n)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> g[100000];
int dist[2][100000];
int id;
void dfs(int idx,int par=-1){
	if(~par) dist[id][idx]=dist[id][par]+1;
//	for(auto &to : g[idx])if(to!=par)dfs(to,idx);//等于下面的
	for(int i=0;i<g[idx].size();i++) if(g[idx][i]!=par) dfs(g[idx][i],idx);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin>>N;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	id=0;
	dfs(0);
	id=1;
	dfs(N-1);
	int ret=0;
	for(int i=0;i<N;i++){
		if(dist[0][i]<=dist[1][i]){
			ret++;
		}
	}
	if(ret>=(N+2)/2) cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 999;
	for (int i = 0; i <= s.size() - 3; i++) {
		int num = (s.at(i) - '0') * 100 + (s.at(i + 1) - '0') * 10 + s.at(i + 2) - '0';
		ans = min(ans, abs(num - 753));
	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
	int N;
	cin >> N;
	long long total = 0;
	for (int i = 1; i < N + 1; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			total += i;
			}
		else {
			continue;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 3632
N,C = map(int,input().split())
S = []
for _ in range(N):
    x,v = map(int,input().split())
    S.append([x,v])
S.sort()
A = [[0,0]]
B = [[0,0]]
for i in range(N):
    A.append([S[i][0],A[-1][1]+S[i][1]])
    B.append([C-S[N-i-1][0],B[-1][1]+S[N-i-1][1]])
g = [[0,0]]
for i in range(1,N+1):
    if g[-1][0]<=A[i][1]-A[i][0]:
        g.append([A[i][1]-A[i][0],A[i][0]])
    else:
        g.append(g[-1])
g = g[::-1]
g2 = [[0,0]]
for i in range(1,N+1):
    if g2[-1][0]<=A[i][1]-2*A[i][0]:
        g2.append([A[i][1]-2*A[i][0],A[i][0]])
    else:
        g2.append(g2[-1])
g2 = g2[::-1]
ans = max(A[-1][1]-A[-1][0],B[-1][1]-B[-1][0])
for i in range(N):
    ans = max(ans,B[i][1]-2*B[i][0]+g[i][0],B[i][1]-B[i][0]+g2[i][0])
print(ans)



Measured memory_bytes: 130064
#include <algorithm>
#include <unordered_map>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  unordered_map<string, uint64_t> S;
  for (size_t i =0; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    if (S.count(s) == 0) {
      S.emplace(s, 1);
    } else {
      S[s] += 1;
    }
  }

  uint64_t count = 0;

  for (const auto& s : S) {
    if (s.second == 1) { continue; }
    count += (s.second - 1) * (s.second) / 2;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


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



int main(){

ios::sync_with_stdio(false);
cin.tie(0);
long long int n,d;
cin>>n>>d;

int x[n][d];

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

long long int count=0;

for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
long long int al=0;
for(int k=0;k<d;k++){
al+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
//cout<<x[i][k]<<"="<<x[j][k]<<endl;
}
long long int all=al;
all=sqrt(all);
all*=all;
//cout<<al<<" "<<all<<endl;
if(al==all)count++;
}
}


cout<<count<<endl;


}



//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int D;
vector<vector<int>> s(366,vector<int>(26));
vector<int> c(26);
vector<int> last(26,0);
vector<int> t(366,-1);

int calc_down(int d){
  int ans=0;
  for(int i=0;i<26;i++){
    ans+=c.at(i)*(d-last.at(i));
  }
  return ans;
}

int calc(int d,int now){
  int ans=s.at(d).at(now);
  int tmp=last.at(now);
  last.at(now)=d;
  ans-=calc_down(d);
  last.at(now)=tmp;
  return ans;
}

int calc_change(int d,int q){
  int old=t.at(d);
  int ans=s.at(d).at(q)-s.at(d).at(old);

  int old_l=0;
  int old_r=D+1;
  for(int i=1;i<d;i++)  if(t.at(i)==old)  old_l=i;
  for(int i=D;i>d;i--)  if(t.at(i)==old)  old_r=i;
  int now_l=0;
  int now_r=D+1;
  for(int i=1;i<d;i++)  if(t.at(i)==q)  now_l=i;
  for(int i=D;i>d;i--)  if(t.at(i)==q)  now_r=i;
  //cout << "old  " << old_l << " " << old_r << endl;
  //cout << "now  " << now_l << " " << now_r << endl;
  ans+=c.at(q)*(d-now_l)*(now_r-d);
  ans-=c.at(old)*(d-old_l)*(old_r-d);
  return ans;
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  cin >> D;
  for(int i=0;i<26;i++) cin >> c.at(i);
  for(int i=1;i<D+1;i++){
    for(int j=0;j<26;j++) cin >> s.at(i).at(j);
  }
  for(int i=1;i<D+1;i++){
    cin >> t.at(i);
    t.at(i)--;
  }

  int total_v=0;
  for(int i=1;i<D+1;i++){
    /*int tmp_ma=-1e9;
    int tmp_t=-1;
    for(int j=0;j<26;j++){
      int tmp=calc(i,j);
      if(tmp>tmp_ma){
        tmp_ma=tmp;
        tmp_t=j;
      }
    }*/
    //t.at(i)=tmp_t;
    last.at(t.at(i))=i;
    total_v+=s.at(i).at(t.at(i));
    total_v-=calc_down(i);
  }
  //for(int i=1;i<D+1;i++)  cout << t.at(i)+1 << endl;
  //cout << total_v << endl;

  int M;
  cin >> M;
  for(int _=0;_<M;_++){
    int d,q;
    cin >> d >> q;
    q--;

    int tmp=calc_change(d,q);
    t.at(d)=q;
    total_v+=tmp;
    cout << total_v << endl;
  }

  return 0;
}


Measured memory_bytes: 3684
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

main = do
  [n, m, c] <- map (read::String -> Int) . words <$> getLine
  coef <- map (read::String -> Int) . words <$> getLine
  results <- forM [1..n] (\i -> do
    arr <- map (read::String -> Int) . words <$> getLine
    return $ sum . map (\(x, y) -> x * y) $ zip (1:arr) (c:coef))
  print $ length $ filter ((<) 0) results

Measured memory_bytes: 1020
ls = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000,1020]
X = int(input())
for i in range(len(ls)):
  if X<ls[i]:
    print(ls[i-1])
    break


Measured memory_bytes: 3064
abc = list(map(int, input().split()))

cnt = 0
while True:
    if abc[0] == abc[1] == abc[2]:
        print(cnt)
        break

    if abc.count(min(abc)) == 2:
        if abc.count(abc[0]) == 2 and abc.count(abc[1]) == 2:
            abc[0] += 1
            abc[1] += 1
        if abc.count(abc[0]) == 2 and abc.count(abc[2]) == 2:
            abc[0] += 1
            abc[2] += 1
        if abc.count(abc[1]) == 2 and abc.count(abc[2]) == 2:
            abc[1] += 1
            abc[2] += 1
    else:
        abc[abc.index(min(abc))] += 2
    cnt += 1


Measured memory_bytes: 3064
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val h, w, k = sc.nextInt()
  val c = Array.fill(h)(sc.next().map(_ == '#'))

  var ans = 0

  for {
    is <- 0 until 1 << h
    js <- 0 until 1 << w
  } {
    val d = Array.tabulate(h, w){case (i, j) => c(i)(j)}
    for (i <- 0 until h if ((is >> i) & 1) == 1) {
      for (j <- 0 until w) {
        d(i)(j) = false
      }
    }
    for (j <- 0 until w if ((js >> j) & 1) == 1) {
      for (i <- 0 until h) {
        d(i)(j) = false
      }
    }
    if (d.map(_.count(_ == true)).sum == k) {
      ans += 1
    }
  }

  println(ans)
}


Measured memory_bytes: 57812
from itertools import permutations as perm
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    P = input([int, N])
    Q = input([int, N])
    p, q = tuple(P), tuple(Q)

    base = [x for x in range(1, N + 1)]
    base_list = sorted(perm(base))
    pn, qn = -1, -1
    for c, x in enumerate(base_list):
        if x == p:
            pn = c
        if x == q:
            qn = c
    print(abs(pn - qn))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 8180
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n>>k;
        int a[n+1];
        FOR(i,1,n+1)  cin>>a[i];
        if(k<=n)
        {
            i=1;
            while(k--)
                i=a[i];
            cout<<i<<endl;
            continue;
        }
        map<int,int> vis;
        i=1;j=0;
        while(vis.find(i)==vis.e())
        {
            // cout<<i<<" "<<j<<endl;
            vis[i]=j;
            i = a[i];
            j++;
        }
        ll cycsize = j-vis[i];
        // cout<<endl<<cycsize<<" ";
        k -= vis[i];
        ll go = k%cycsize;
        // cout<<go<<" ";
        FOR(j,0,go)
            i=a[i];
        cout<<i<<endl;
    }
}

Measured memory_bytes: 11872
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    string s,s1,s2,s3;
cin>>s1>>s2>>s3;
    s=s1+' '+s2+' '+s3;
    cout<<(char)(s[0]-32);
    for(int i=0;i <s.length();i++){
    if(s[i]==' ')
    cout<<(char)(s[i+1]-32);
    else
    continue;
    }
    
    
}




Measured memory_bytes: 256
N = int(input())
A = [int(n) for n in input().split()]

def main():
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    ks =  all(map(lambda k: k % 2 == 0, d.keys())) or all(map(lambda k: k % 2 != 0, d.keys()))
    if 0 in d:
        d[0] += 1
    vs = all(map(lambda v: v == 2, d.values()))

    if ks and vs:
        n = N if N % 2 == 0 else N - 1
        n //= 2
        ans = 1
        for _ in range(n):
            ans *= 2
            ans %= 1000000007
    else:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14436
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<vp> pref(n);
    rep(i, m) {
        int p, y;
        cin >> p >> y;
        pref[p-1].eb(y, i);
    }
    vp ans(m);
    rep(i, n) {
        sort(pref[i].begin(), pref[i].end());
        rep(j, sz(pref[i])) {
            int id = pref[i][j].se;
            ans[id] = P(i+1, j+1);
        }
    }
    rep(i, m) {
        printf("%06d%06d\n", ans[i].fi, ans[i].se);
    }
}

Measured memory_bytes: 7808
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

const int MOD = 1e9 + 7;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

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

} // namespace null_null

class Combination {
public:
  using i64 = std::int_fast64_t;

private:
  const i64 MOD;
  std::vector<i64> fac, finv, inv;

  i64 combination(i64 n, i64 k) {
    if (n < k)
      return 0;
    if (n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }

  i64 permutation(i64 n, i64 k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
  }

  i64 homogeneousProduct(i64 n, i64 k) { return combination(n + k - 1, k); }

public:
  Combination(size_t MAX_N, i64 MOD) : MOD(MOD) {
    fac.resize(MAX_N, 1);
    finv.resize(MAX_N, 1);
    inv.resize(MAX_N, 1);
    for (size_t i = 2; i < MAX_N; i++) {
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
  }

  i64 nCk(int n, int k) { return combination(n, k); }
  i64 nPk(int n, int k) { return permutation(n, k); }
  i64 nHk(int n, int k) { return homogeneousProduct(n, k); }
};

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  i64 N, K;
  std::cin >> N >> K;

  Combination c(10101, MOD);

  for (usize i = 1; i <= K; i++) {
    i64 res = c.nCk(N - K + 1, i);
    res = (res * c.nHk(K - i + 1, i - 1)) % MOD;
    std::cout << res << std::endl;
  }
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 512
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S],H=0,[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:print(g(n,E,*p))
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    vector<int> a(n-1);
    rep(i,n-1) cin >> a.at(i);
    vector<int> ans(n);
    rep(i,n-1){
        ans.at(a.at(i)-1) += 1;
    }
    for (size_t i = 0; i < n; i++)
    {
        cout << ans.at(i) << endl;
    }
}   

Measured memory_bytes: 4908
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<map>

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

bool second_change(const pair<ll,ll>& first, const pair<ll,ll>& second){
    return first.second < second.second;
}

int main(){
    ll n,first,second,ans;
	cin >> n;
    vector<pair<ll,ll>> task;
    REP(i,0,n){
        cin >> first;
        cin >> second;
        task.push_back(make_pair(first,second));
    }
    sort(ALL(task),second_change);

    ll task_weight=0;
    bool flag = true;
    REP(i,0,task.size()){
        task_weight+=task[i].first;
        if(task_weight>task[i].second){
            flag=false;
            break;
        }
    }

	cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 6384
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	string s;
	cin>>s;
	if(s=="ARC") cout<<"ABC\n";
	else cout<<"ARC\n";
	return 0;
}


Measured memory_bytes: 3648
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    trains = []
    for i in range(n-1):
        trains.append(f())

    for i in range(n):
        time = 0
        for train in trains[i:]:
            start_time = (time//train[2] +  (0 if time%train[2]==0 else 1))* train[2] if time > train[1] else train[1]
            time = start_time + train[0]

        print(time)

        

solve()


Measured memory_bytes: 3316
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

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

    std::string s;
    std::cin >> s;

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        std::unordered_map<char, int> before, after;
        for (int j = 0; j < i; j++) {
            before[s[j]]++;
        }

        for (int j = i; j < n; j++) {
            after[s[j]]++;
        }

        int sum = 0;
        for (auto i = before.begin(); i != before.end(); i++) {
            if (after[i->first]) {
                sum++;
            }
        }
        ans = std::max(sum, ans);
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long friendli[200005];
long long ans=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>friendli[i];
	}
	sort(friendli+1,friendli+n+1);
	ans+=friendli[n];
	int flag=n-1;
	for(int i=n-2;i>n%2;i-=2)
	{
		ans+=2*friendli[flag];
		//cout<<"+"<<friendli[flag]<<"*2"<<endl; 
		flag--;
	}
	if(n%2==1) ans+=friendli[flag]; //cout<<"+"<<friendli[flag]<<"*1"<<endl;
	//else ans+=friendli[flag]*2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5192
import java.io.BufferedReader;
import java.io.InputStreamReader;
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 A = scan.nextInt();
        int B = scan.nextInt();
        if (B % A ==0) {
            System.out.println(A+B);
        } else {
            System.out.println(B-A);
        }
    }
}


Measured memory_bytes: 21844
use std::collections::BinaryHeap;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut queue: Vec<i32> = vec![];
    for _ in 0..n {
        queue.push(read());
    }
    let mut ans = 0;
    for l in 0..(std::cmp::min(n, k) + 1) {
        for r in 0..(std::cmp::min(n, k) - l + 1) {
            let mut now = 0;
            let mut hands: BinaryHeap<i32> = BinaryHeap::new();
            for i in 0..l {
                now += queue[i];
                hands.push(-queue[i]);
            }
            for j in 0..r {
                now += queue[n - j - 1];
                hands.push(-queue[n - j - 1]);
            }
            for _ in 0..k - (r + l) {
                let minus_value = match hands.pop() {
                    Some(i) => i,
                    None => break,
                };
                if minus_value < 0 {
                    break;
                }
                // negate value
                now += minus_value;
            }
            ans = std::cmp::max(ans, now);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
class BinarySearchTree:
    def __init__(self):
        self.root = None
    def in_order_traversal(self):
        in_order_from(self.root)
        print('')
    def pre_order_traversal(self):
        pre_order_from(self.root)
        print('')
    def insert(self, key):
        node = Node(key)
        insert(self, node)
    def find(self, key):
        if find(self.root, key):
            print('yes')
        else:
            print('no')

class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

def insert(T, z):
    y = None
    x = T.root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y == None:
        T.root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def in_order_from(node):
    if node:
        in_order_from(node.left)
        print(' {0}'.format(node.key), end = '')
        in_order_from(node.right)

def pre_order_from(node):
    if node:
        print(' {0}'.format(node.key), end = '')
        pre_order_from(node.left)
        pre_order_from(node.right)

def find(node, k):
    while node:
        if node.key == k:
            return True
        if k < node.key:
            node = node.left
        else:
            node = node.right
    return False


import sys

t = BinarySearchTree()

m = sys.stdin.readline()

for i in sys.stdin.readlines():
    if i[0] == 'i':
        t.insert(int(i[7:]))
    elif i[0] == 'f':
        t.find(int(i[5:]))
    else:
        t.in_order_traversal()
        t.pre_order_traversal()

Measured memory_bytes: 162280
using System;
using System.Collections.Generic;
namespace ITP1_2_C
{
    class MainClass
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }



        public static void Main (string[] args)
        {
            List<string[]> arr_result = new List<string[]>();
            arr_result = getinputdata ();

            int a = int.Parse(arr_result[0][0]);
            int b = int.Parse(arr_result[0][1]);
            int c = int.Parse(arr_result[0][2]);

//            int mindata = Math.Min(a,b);
//            mindata = Math.Min(mindata, c);

            if (a >= b && b>=c)
            {
                Console.WriteLine(c + " " + b + " " + a);
            }
            else if(a>=c && c>=b)
            {
                Console.WriteLine(b + " " + c + " " + a);
            }
          
            else if(c>=b && b>=a)
            {
                Console.WriteLine(a + " " + b + " " + c);
            }
            else if(c>=a && a>=b)
            {
                Console.WriteLine(b + " " + a + " " + c);
            }
            else if(b>=c && c>=a)
            {
                Console.WriteLine(a + " " + c + " " + b);
            }
            else if(b>=a && a>=c)
            {
                Console.WriteLine(c + " " + a + " " + b);
            }





            //Console.WriteLine(mindata);



        }
    }
}

Measured memory_bytes: 9316
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

//// D
//int main(){
//    int n, m; cin >> n >> m;
//
//}

//// C
int main(){
    int n; cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for(auto& p : mp){
        int s = p.second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans;
}

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

int main() {
    int N, x;
    int even_number = 0;
    int ans;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x;
        if (x % 2 == 0) {
            even_number++;
        }
    }

    ans = pow(3, N);
    ans -= pow(2, even_number);

    cout << ans << endl;
}


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

int main() {
		/*
	 cout<<a;   printf("%d",a);
	 cin>>a;    scanf("%d",&a);
 
	*/
	int N;
 
	cin>>N;
	while (N > 0) {
		N = N - 1000;
	}
 
	N = -1*N;
	cout<<N; 
	
	return 0;
}

Measured memory_bytes: 3632
def main():
    N = int(input())
    X = list(map(int, input().split()))
    P = [sum(X) // N]
    P.append(P[0] + 1)
    answer = [0, 0]
    for x in X:
        for i in range(2):
            answer[i] += (x - P[i]) ** 2
    print(min(answer))


if __name__ == '__main__':
    main()

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

int main()
{
	int a, b, n = 0, wa;
	int countdata[1000];
	while (cin >> a >> b) {
		int count = 0;
		wa = a + b;
		while (wa > 0) {
			wa = wa / 10;
			count++;
		}
		countdata[n] = count;
		n++;
	}
	for (int a = 0; a < n; a++) {
		cout << countdata[a] << endl;
	}
}

Measured memory_bytes: 2952
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b;
    cin >> a >> b;
    if(a <= 9 && b <= 9) {
        cout << a * b << endl;
    }
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
max = 0
x = 0
def check(x, max):
    if max < x:
        return x
    else:
        return max

for i in s:
    if i == "I":
        x += 1
        max = check(x, max)
    elif i == "D":
        x -= 1
        max = check(x, max)
print(max)


Measured memory_bytes: 2940
while gets
    n, m = $_.split.map &:to_i
    break if n == 0
    a = (1..n).to_a
    until a.size == 1
        i = (m-1) % a.size
        a = a[i+1..-1] + (i == 0 ? [] : a[0..i-1])
    end
    p a[0]
end

Measured memory_bytes: 18348
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  if (k > 50){
    for (int i = 0; i < n; i++){
      cout << n << (i == n - 1 ? "" : " ");
    }
    cout << endl;
  }
  else {
    for (int j = 0; j < k; j++){
      vector<ll> imos(n + 1, 0);
      for (int i = 0; i < n; i++){
        imos[max(0LL, i - a[i])]++;
        imos[min(n, i + a[i] + 1)]--;
      }
      for (int i = 1; i < n+1; i++){
        imos[i] += imos[i-1];
      }
      for (int i = 0; i < n; i++){
        a[i] = imos[i];
      }
    }
    for (int i = 0; i < n; i++){
      cout << a[i] << (i == n - 1 ? "" : " ");
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

std::vector<int> tree;
std::vector<int> a,b,c,d;
int n,m,q;
ll ans = 0;

void dfs(int now) {
    if (now == n-1) {
        FOR(j,1,m) {
            if (tree[now-1] > j) continue;
            ll temp = 0;
            tree[now] = j;
            // std::cout << 'A' << "\n";
            // REP(i,n) std::cout << tree[i] << " ";
            // std::cout  << "\n";
            REP(i,q) {
                if ( tree[b[i]-1] - tree[a[i]-1] == c[i]) {
                    temp += d[i];
                    // std::cout << "here" << temp << d[i] << "\n";
                }
            }
            if (temp > ans) ans = temp;
        }
    } else{
        FOR(i,1,m) {
            if (tree[now-1] > i) continue;
            tree[now] = i;
            dfs(now+1);
        }
    }
}

int main(int argc, char const *argv[]) {
    std::cin >> n >> m >> q;
    tree.resize(n);
    a.resize(q); b.resize(q); c.resize(q); d.resize(q);
    REP(i,q) std::cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(0);
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3584
#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 all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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;}

int N,S,E,T;
map<pint,int>W;
vint G[111111];

int num[111111];
bool uku[111111];
bool predfs(int v,int p){
	bool ret=false;
	for(auto u:G[v]){
		if(u==p)continue;
		ret|=predfs(u,v);
	}
	if(v==E)ret=true;
	uku[v]=ret;
	return ret;
}

bool dfs(int v,int p){
	int nex=-1;
	vint lis;
	for(auto u:G[v]){
		if(u==p)continue;
		if(uku[u]){
			nex=u;
		}
		else{
			num[u]++;
			if(!dfs(u,v))return false;
			lis.pb(W[pint(u,v)]-num[u]*T);
		}
	}
	sort(all(lis));
	rep(i,lis.size()){
		if(lis[i]-num[v]*T<=0)return false;
		num[v]++;
	}

	if(nex==-1)return true;
	if((num[v]+num[nex])*T>=W[pint(v,nex)])return false;
	num[nex]++;
	return dfs(nex,v);
}

signed main(){
	cin>>N>>T>>S>>E;
	S--;E--;
	rep(i,N-1){
		int a,b,w;
		cin>>a>>b>>w;
		a--;b--;
		G[a].pb(b);G[b].pb(a);W[pint(a,b)]=W[pint(b,a)]=w;
	}

	predfs(S,-1);
	if(dfs(S,-1))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 29708
#import<cstdio>
#define k 1024
#define r(a) for(int i=0;i<a;i++)
#define s(a) scanf("%d",&a);
#define c(a,b) a=a<b?a:b
int w,n,m,d[k],p[k];main(){s(n)s(m)r(n)s(d[i])r(n)p[i]=1e9;r(m){s(w)r(n)c(p[i],p[i+1]+w*d[n-i-1]);}printf("%d\n",p[0]);}

Measured memory_bytes: 1032
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N = ii()
    S = input()
    d = {str(i): [] for i in range(10)}
    for i, s in enumerate(S):
        d[s].append(i)

    ans = 0
    for a in map(str, range(10)):
        if not d[a]:
            continue
        l = d[a][0]
        for c in map(str, range(10)):
            if not d[c]:
                continue
            r = d[c][-1]
            if not l < r:
                continue
            for b in map(str, range(10)):
                if not d[b]:
                    continue
                if not d[b][0] < r:
                    continue
                if l < d[b][meg(lambda x: d[b][x] < r, 0, len(d[b]))] < r:
                    ans += 1
    print(ans)






main()


Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ll x,k,d;
  cin>>x>>k>>d;
  ll x1=abs(x);
 ll m=x1/d;
  if(k<=m){
    cout<<x1-k*d;
    return 0;
  }
else if((k-m)%2==0) cout<<x1-m*d;
else if((k-m)%2==1) cout<<abs(x1-m*d-d);
return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;
 
#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)
 
#define MAXVALUE 1000000007
 
int main(){
    int N, M;
    cin >> N >> M;
    int a[M];
    unsigned long ans = 0;
    Fp(i, 0, M) cin >> a[i];
    Fp(i, 0, M - 1){
        if(a[i + 1] == a[i] + 1){
            cout << 0 << endl;
            return 0;
        }
    }
 
    unsigned long b[2] = {};
    int num = 0;
    if(a[0] != 1) b[0] = 1;
    else num++;
    if(a[num] != 2) b[1] = b[0] + 1;
    else num++;
    if(N >= 3){
        Fp(i, 2, N){
            if(a[num] != i + 1){
                ans = b[1] + b[0];
                b[0] = b[1];
                b[1] = ans; 
                //cout << "段数: " << i + 1 << ",ans: " << ans << endl;
            }else{
                b[0] = b[1];
                b[1] = 0;
                num++;
            }
            if(b[1] > MAXVALUE && b[0] > MAXVALUE){
                b[1] -= MAXVALUE;
                b[0] -= MAXVALUE;
            }else if(b[1] == 0 && b[0] > MAXVALUE){
                b[0] -= MAXVALUE;
            }else if(b[0] == 0 && b[1] > MAXVALUE){
                b[1] -= MAXVALUE;
            }
        }
    }else if(N == 2){
        cout << b[1] << endl;
        return 0;
    }
    else{
        cout << b[0] << endl;
        return 0;
    }
 
    cout << ans % MAXVALUE << endl;
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
# 整数の入力
N, T = map(int, input().split())
cost = 10000
for i in range(N):
  ci, ti = map(int, input().split())
  if ti <= T:
    if ci <= cost:
      cost = ci

if(cost == 10000):
  print('TLE')
else:
  print(cost)

Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

int endA = 0;
int startB = 0;
int both = 0;

void solve() {
  int n;
  cin >> n;
  int ret = 0;
  while(n--) {
    string s;
    cin >> s;
    if(s[s.size()-1] == 'A' && s[0] == 'B') both++;
    else if(s[s.size()-1] == 'A') endA++;
    else if(s[0] == 'B') startB++;
    for(int i = 1; i < s.size(); i++) {
      if(s[i-1] == 'A' && s[i] == 'B') ret++;
    }
  }
  bool started = false;
  while(startB && endA) {
    started = true;
    startB--;
    endA--;
    ret++;
  }
  if(startB || endA) {
    started = true;
  }
  if(!started && both > 0) {
    started = true;
    both--;
  }
  while(both) {
    assert(started);
    both--;
    ret++;
  }
  cout << ret << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    long long int n, sum, mul;
    long long int i, j;
    sum = 0;
    scanf("%lld",&n);
    for(i=1;i<n;i++){
        sum += (n-1) / i;
    }
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 1716
#include<iostream>
using namespace std;
 
int main(){
   int a,b;
   cin >> a >> b;
   if(a==0){
       if(b!=100) cout << b << endl;
       else cout << b+1 <<endl;
   } else if(a==1){
       if(b!=100) cout << b*100 << endl;
       else cout << (b+1)*100 << endl;
   } else if(a==2){
       if(b!=100) cout << b*10000 << endl;
       else cout << (b+1)*10000 <<endl;
   }
   return 0;
}

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

# その段で使用する枝の数
branches = dict()
for idx,a in enumerate(A):
  if idx == 0:
    branch = 1-a
  else:
    branch = branch * 2 - a
  if branch <0:
    print(-1)
    quit()
  branches[idx] = branch

# 後ろから葉と枝の数(nodes)を計算していく
ans =0 
for idx,leaf in enumerate(reversed(A)):
  if idx == 0:
    nodes = leaf
  else:
    if branches[len(A)-idx-1] <nodes//2:
      print(-1)
      break
    nodes = min(
      leaf + nodes,
      leaf + branches[len(A)-idx-1]
    )
  ans += nodes
else:
  print(ans)


Measured memory_bytes: 703916
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;


void solve(int X, int Y, int Z, int K, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    auto a = A;
    V<ll> b(Y * Z);
    loop (Y * Z, i) {
        b[i] = B[i % Y] + C[i / Y];
    }
    sort(a.begin(), a.end(), greater<>());
    sort(b.begin(), b.end(), greater<>());

    V<ll> ans;
    loop (X, i) loop (min(K, Y * Z), j) {
        ans.push_back(a[i] + b[j]);
    }
    sort(ans.begin(), ans.end(), greater<>());
    loop (K, i) cout << ans[i] << endl;
}

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



Measured memory_bytes: 42984
def print_flame(h,w):
    print("#"*w)
    for _ in range(h-2):
        s = "#"+"."*(w-2)+"#"
        print(s)
    print("#"*w)
    print()

while True:
    h,w = map(int,input().split())
    if h+w == 0:
        break;
    print_flame(h,w)


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

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

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed;
  int n, val, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> val;
    if (is_prime(val)) {
      ++ans;
    }
  }
  cout << ans << '\n';  return 0;
}


Measured memory_bytes: 3180
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define pu putchar
#define pun putchar('\n')
int n,nn,u,v,w,e,ki,i,sx,qd,zh,q1,q2,q3,q4,x[30009],p[2000000],q[2009],z[2009],t[30009],li[30009],r[30009];
ll cx,g[50],hf[30009],d[2009];
bool b[2009],bb[2009];
int sri(){char c=getchar();int x=0;while(c<'0')c=getchar();while(c>='0')x=(x<<3)+(x<<1)+c-'0',c=getchar();return x;}
ll srl(){char c=getchar();ll x=0;while(c<'0')c=getchar();while(c>='0')x=(x<<3)+(x<<1)+c-'0',c=getchar();return x;}
void sc(ll x){int l=0;if(x==0)g[l=1]=0;while(x)g[++l]=x%10,x/=10;for(;l;l--)pu(g[l]+'0');}
void jia(int u,int v,int rr,ll h){
	x[++ki]=z[u];z[u]=ki,t[ki]=v;r[ki]=rr,li[ki]=0;hf[ki]=h;
	x[++ki]=z[v];z[v]=ki,t[ki]=u;r[ki]=0,li[ki]=0;hf[ki]=-h;
}
bool spfa(){
	for(int i=1;i<=zh;i++)bb[i]=0;
	u=0;w=1;p[w]=qd;b[qd]=1;d[qd]=0;bb[qd]=1;
	while(u!=w){
		u++;if(u&sx)u=1;v=p[u];b[v]=0;
		for(int i=z[v];i;i=x[i]){
			e=t[i];
			if(li[i]<r[i]&&(bb[e]==0||d[v]+hf[i]<d[e])){
				d[e]=d[v]+hf[i];q[e]=i;bb[e]=1;
				if(!b[e]){
					w++;if(w&sx)w=1;p[w]=e;b[e]=1;
				}
			}
		}
	}return bb[zh];
}
void ekspfa(){
	while(spfa()){int zz=n;
		for(int u=zh;u!=qd;u=t[q[u]^1])zz=min(zz,r[q[u]]-li[q[u]]);
		for(int u=zh;u!=qd;u=t[q[u]^1])li[q[u]]+=zz,li[q[u]^1]-=zz,cx+=zz*hf[q[u]];
	}
}
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	n=sri();nn=n<<1;q1=nn+1,q2=nn+2,q3=nn+3,q4=nn+4,qd=nn+5;zh=nn+6;ki=1;sx=1<<20;
	for(i=1;i<=n;i++){
		u=sri();v=sri();w=sri();jia(qd,i,w,0);
		jia(i,q1,w,-u-v);
		jia(i,q2,w,-u+v);
		jia(i,q3,w,u-v);
		jia(i,q4,w,u+v);
	}
	for(i=1;i<=n;i++){
		u=sri();v=sri();w=sri();jia(i+n,zh,w,0);
		jia(q1,i+n,w,u+v);
		jia(q2,i+n,w,u-v);
		jia(q3,i+n,w,-u+v);
		jia(q4,i+n,w,-u-v);
	}
    ekspfa();
    sc(-cx);
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    ll d;
    cin >> n >> d;
    int ans = 0;
    d *= d;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        if (d >= x * x + y * y)
        {
            ans++;
        }
    }

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

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

int main(){
    int N;
    cin>>N;
    if(N>=11){
       N = N-(N/10)*10;
        
    }if(N==2||N==4||N==5||N==7||N==9){
        cout<<"hon"<<endl;
    }else if(N==0||N==1||N==6||N==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"bon"<<endl;
    
    }
}

Measured memory_bytes: 3616
N,K,Q=map(int,input().split())
ans=[]
L=[]
for _ in range(N):
    L.append(0)
for _ in range(Q):
  ans.append(int(input()))
for k in range(Q):
  L[ans.pop()-1]+=1
for j in range(N):
  if K-(Q-L[j])>0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 56864
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] n = line.split(" ");
        int a = Integer.parseInt(n[0]);
        int b = Integer.parseInt(n[1]);
        String str = "";
        if(a%3 == 0){
            str = "Possible";
        } else if(b%3 == 0) {
            str = "Possible";
        } else if((a+b)%3 ==0) {
            str = "Possible";
        } else {
            str = "Impossible";
        }
        System.out.println(str);
    }
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int x;
    scanf("%d",&x);
    printf("%d\n",x*x*x);
    return 0;
}

Measured memory_bytes: 1172