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

#define ll                 long long
#define ull                unsigned long long
#define ld                 long double
#define fastio             ios_base::sync_with_stdio(false);cin.tie(NULL);
#define NO                 cout << "NO" << endl
#define YES                cout << "YES" << endl
#define vec                vector<ll>
#define pi                 pair<ll, ll>
#define intarr(arr, n)     ll arr[n]; for (ll i = 0; i < n; i++) cin >> arr[i]
#define intvec(v, n)       for (ll i = 0; i < n; i++) { ll x;cin >> x; v.pb(x);}
#define loop(i, a, b, c)   for (ll i = a; i < b; i += c)
#define pb                 push_back
#define mkp                make_pair
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define endl               "\n"
#define mod2               998244353
#define mod                1000000007
#define mem(dp, a)         memset(dp, a, sizeof(dp));
#define all(v)             v.begin(), v.end()
#define ump                unordered_map<ll, ll>
#define ff                 first
#define ss                 second
#define PI                 3.14159265358979
#define minh               priority_queue<ll>
#define maxh               priority_queue<ll,vector<ll>,greater<ll>>
#define flush              cout<<flush


ll Ceil(ll a, ll b)
{
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}

ll gcd(ll a, ll b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll inv(ll a)
{
  ll p = mod;
  ll b = p - 2, ans = 1;
  for (; b > 0; a = a * a % p, b >>= 1)
    if (b & 1)
      ans = ans * a % p;
  return ans;
}

ll ncrmod(ll n, ll m)
{
  ll p = mod;
  if (m > n)
    return 0;
  ll up = 1, down = 1;
  for (ll i = n - m + 1; i < n + 1; i++)
    up *= i, up %= p;
  for (ll i = 1; i < m + 1; i++)
    down *= i, down %= p;
  return up * inv(down) % p;
}

ll powmod(ll a, ll n)
{
  if (!n)
    return 1;
  ll pt = powmod(a, n / 2);
  pt *= pt, pt %= mod;
  if (n & 1)
    pt *= a, pt %= mod;
  return pt;
}

// void factorize(long long int n)
// {
//   ll count = 0;

//   while (!(n % 2)) {
//     n >>= 1;
//     count++;
//   }

//   if (count)
//   {
//     sum2 += count;
//   }

//   for (long long i = 3; i <= sqrt(n); i += 2) {
//     count = 0;
//     while (n % i == 0) {
//       count++;
//       n = n / i;
//     }
//     if (count)
//     {
//       if (i & 1)sum += count;
//     }
//   }
//   if (n > 2)
//   {
//     sum++;
//   }
// }

void solve()
{
  ll n, k;
  cin >> n >> k;
  intarr(a, n);
  sort(a, a + n);
  ll ans = 0;
  for (ll i = 0; i < k; i++) ans += a[i];
  cout << ans;
}
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  fastio;
  ll t;
  t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }

  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

  return 0;
}

Measured memory_bytes: 3640
# GRL_1_A - Single Source Shortest Path
from heapq import heappop, heappush
from typing import List

inf = 1 << 30


def dijkstra(source: int, edges: List[List[List[int]]]) -> List[int]:
    """
    Compute the distance of the shortest path from V_source to each vertex.

    Args:
        source: V_source
        edges: Edges info
    Returns:
        dist: A list of distance from V_source
    """
    edges_count = len(edges)
    dist = [inf] * edges_count
    dist[source] = 0
    undetermined = edges_count - 1  # V_0 is determined in 1-idx graph
    queue = [(0, source)]
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        for next_cost, u in edges[v]:
            if cost + next_cost < dist[u]:
                dist[u] = cost + next_cost
                heappush(queue, (dist[u], u))
        undetermined -= 1
        if not undetermined:
            break
    return dist  # There may be no path from V_source to some vertices.


def main():
    N, M, R, *E = map(int, open(0).read().split())
    edges: List[List[List[int]]] = [[] for _ in range(N)]
    for v, u, cost in zip(*[iter(E)] * 3):
        edges[v].append([cost, u])
    dist = dijkstra(R, edges)
    ans = [i if i < inf else "INF" for i in dist]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()



Measured memory_bytes: 169644
/******************************************
* AUTHOR : SHASHANK *
* NICK : lance_lot *
* INSTITUTION : BIT MESRA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
ll arr[N][3];
ll dp[N][3];
ll rec(ll i,ll j,ll n) {
    if(i >= n)
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(j == 0) {
        dp[i][j] = arr[i][j] + max(rec(i+1,j+1,n),rec(i+1,j+2,n));
    }
    if(j == 1) {
        dp[i][j] = arr[i][j] + max(rec(i+1,j-1,n),rec(i+1,j+1,n));
    }
    if(j == 2) {
        dp[i][j] = arr[i][j] + max(rec(i+1,j-1,n),rec(i+1,j-2,n));
    }
    return dp[i][j];
}

int main() {
fast;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n;
    cin>>n;
    for(ll i = 0;i < n;i++) {
        for(ll j = 0;j < 3;j++) {
            cin>>arr[i][j];
            dp[i][j] = -1;
        }
    }
    ll ans = max(rec(0,0,n),max(rec(0,1,n),rec(0,2,n)));
    cout<<ans;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define int long long
int MOD=1000000007LL;
string s;
int expr(int &p);
int term(int &p);
void sp(int &p);
int number(int &p); 
int expr(int &p){
  int res=term(p);
  sp(p);
  int q=p;
  while(q+1<(int)s.size()&&s[q]=='>'&&s[q+1]=='>'){
    q+=2;
    sp(q);
    if(q>=(int)s.size()||s[q]=='>') break;
    p+=2;
    sp(p);
    int y=term(p);
    if(y>31) res=0;
    else res>>=y;
    sp(p);
    q=p;
  }
  return res;
}
int term(int &p){
  int res;
  if(s[p]=='S'){
    p++;
    sp(p);
    assert(s[p]=='<');
    p++;
    sp(p);
    int x=expr(p);
    sp(p);
    assert(s[p]=='>');
    p++;
    res=(x*x)%MOD;
  }else{
    res=number(p);
  }
  return res;
}
void sp(int &p){
  while(p<(int)s.size()&&s[p]==' ') p++;
}
int number(int &p){
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p]))
    res=(res*10+s[p++]-'0')%MOD;
  return res;
}
signed main(){
  while(getline(cin,s),s!="#"){
    int p=0;
    cout<<expr(p)<<endl;
  }
  return 0;
}

Measured memory_bytes: 5836
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+2*c-2>=b){
    for(int i = a;i<b+1;i++){
      cout << i << endl;
    }
  }
  else {for(int i = a;i<a+c;i++){
    cout << i << endl;
  }
  for(int i = b - c + 1;i<=b;i++){
    cout << i << endl;
  }
       }
}

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

int main(){
    int n, m, sum;
    cin >> n >> m;
    int A[n][m], b[m];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++) cin >> A[i][j];
    }
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i < n; i++){
        sum = 0;
        for (int j = 0; j < m; j++) sum += A[i][j] * b[j];
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <ctime>
#include <vector>
#include <memory>
#include <cstring>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#define LL long long
#define N 100005
#define maxn 100
#define INFINITY 0x3f3f3f3f
#define mase(a,b) memset(a,b,sizeof(a))
#define MIN(a,b) (a<b?a:b)
#define MAX(a,b) (a>b?a:b)
#define lson l,m,num<<1
#define rson m+1,r,num<<1|1
using namespace std;
char a[N];
int main()
{
    int re;
    int len;
    scanf("%s",a);
    len=strlen(a);
    re=len;
    for(int i=1;i<len;i++)
    {
        if(a[i]!=a[i-1])
        {
            re=MIN(re,MAX(i,len-i));
        }
    }
    printf("%d\n",re);
    return 0;
}


Measured memory_bytes: 3924
if __name__ == "__main__":
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()
    point = {'r': p, 's': r, 'p': s}

    ans = 0

    for i in range(k):
        next_skip = False
        for j in range(i, n, k):
            if next_skip:
                next_skip = False
                continue
            if j + k < n and t[j] == t[j + k]:
                next_skip = True
            ans += point[t[j]]
    print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;


int main()
{
    ll N, M;
    cin >> N >> M;

    vector< vector<int> > G(N, vector<int>());

    rep (i, M)
    {
        ll a, b;
        cin >> a >> b;
        --a;
        --b;

        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    vector<int> from(N, -1);
    from[0] = 0;

    queue<int> Q;
    Q.push(0);

    while(!Q.empty())
    {
        const auto prev = Q.front();
        Q.pop();

        for (const auto next : G[prev]) if (from[next] == -1)
        {
            from[next] = prev;
            Q.push(next);
        }
    }

    const auto isOK = [&]()
    {
        rep (i, N - 1) { if (from[i + 1] == -1) { return false; } }
        return true;
    };

    if (isOK())
    {
        cout << "Yes" << endl;
        rep (i, N - 1) { cout << from[i + 1] + 1 << endl; }
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

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

	int n,t;
	vector <long long int> v;
	long long int Max = 0;
	long long int res = 0;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}
	Max = v[0];
	for(int i=1;i<n;i++)
	{
		if(v[i] < Max)
		{
			res += (Max - v[i]);
		}
		else
		{
			Max = max(Max,v[i]);
		}
	}

	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 5328
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif
    int x;
    int per;
    cin >> x >> per;

    double p = per/100.0;

    if (x % 2 == 0) {
        cout << (1/p) * (x/2) << endl;
    }   
    else {

        double l = (1/p) * ((x - 1)/2) + 1;
        double r = (1/p) * ((x + 1)/2) + 1;
        cout << (per * l + (100 - per) * r) / 100.0 << endl;
    }   
    
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,x1;
  double x2,y;
  cin >> a >> b;
  x2 =(a+b)/2.0;
  x1 =(a+b)/2;
  y = x2-x1;
  cout << x2 + y << endl;
}

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

struct data{
  int l,r,id;
};

vector< data > t;
int n;

void funcW(int,int);
void funcD(int);
int funcR(int);

int main(){
  char ch;
  int a,b;
  while(cin>>n&&n){
    t.clear();
    t.push_back( (data){-1,-1,-1} );
    t.push_back( (data){1e9+1,1e9+1,-1});
    for(int i=0;i<n;i++){

      cin>>ch;
      if(ch=='W'){
	cin>>a>>b;
	funcW(a,b);
      }else if(ch=='D'){
	cin>>a;
	funcD(a);
      }else{
	cin>>a;
	cout<<funcR(a)<<endl;
      }
    }

    cout<<endl;
  }
  return 0;
}

void funcW(int id,int size){
  for(int i=1;i<(int)t.size();i++){
    int d=min(t[i].l-t[i-1].r-1 ,size);
    if(d==0)continue;
    size-=d;
    t.insert(t.begin()+i ,(data){t[i-1].r+1,t[i-1].r+d,id});
    if(size==0)break;
  }
}

void funcD(int id){

  for(int i=t.size()-1;i>=0;i--){
    if(t[i].id!=id)continue;
    t.erase(t.begin()+i);
  }
}

int funcR(int pos){
  for(int i=0;i<(int)t.size();i++){
    if(t[i].l<=pos&&pos<=t[i].r)return t[i].id;
  }
  return -1;
}

Measured memory_bytes: 1312
fn select_type(c: &Vec<usize>, s: &Vec<Vec<isize>>, lastvals: &Vec<usize>, d: usize) -> usize {
    let current_downval_data: Vec<usize> = lastvals.iter()
        .enumerate()
        .map(|pair| c[pair.0] * (d + 1 - pair.1))
        .collect()
    ;
    s[d].iter().zip(current_downval_data.iter())
        .map(|s_d| *s_d.0 as isize - *s_d.1 as isize)
        .enumerate()
        .max_by_key(|x| x.1)
        .map_or(0, |pair| pair.0)
    + 1
}

fn downval(c: &Vec<usize>, lastvals: &Vec<usize>, d: usize) -> usize {
    lastvals.iter()
        .enumerate()
        .map(|pair| c[pair.0] * (d + 1 - pair.1))
        .sum()
}

fn main() {
    let mut d = String::new();
    std::io::stdin().read_line(&mut d).ok();
    let d: usize = d.trim().parse().unwrap();
    let mut c = String::new();
    std::io::stdin().read_line(&mut c).ok();
    let c: Vec<usize> = c.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut satisfied: Vec<Vec<isize>> = vec![vec![]; d];
    let mut lastvals: Vec<usize> = vec![0; 26];
    for i in 0..d {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let s: Vec<isize> = s.trim().split_whitespace().map(|t| t.parse().unwrap()).collect();
        satisfied[i] = s;
    }
    let mut result: isize = 0;
    for i in 0..d {
        let t = select_type(&c, &satisfied, &lastvals, i);
        lastvals[t-1] = i+1;
        //result += satisfied[i][t] as isize;
        //result -= downval(&c, &lastvals, i) as isize;
        println!("{}", t);
        //println!("{} {}", t, result);
    }
}


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

int main()
{
    int n = 0 ,d = 0;
    double dis = 0;
    int ans = 0;
    cin >> n >> d;
    double x[n],y[n];

    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        dis = sqrt(x[i] * x[i] + y[i] * y[i]);
        if(dis <= d)
        {
            ans++;
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 6908
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli gcd(lli a, lli b){
	lli c;
	if(a < b){
		c = a;
		a = b;
		b = c;
	}
	while(b != 0){
		c = a%b;
		a = b;
		b = c;
	}
	return a;
}

lli N;
lli A[100010];
lli L[100010] , R[100010];
lli ans=1;

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

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	L[0] = A[0];
	dbug(L[0])
	for(int i = 1; i < N-1; i++){
		L[i] = gcd(A[i], L[i-1]);
		dbug(L[i])
	}
	dbugln
	R[N-1] = A[N-1];
	dbug(R[N-1])
	for(int i = N-2; i > 0; i--){
		R[i] = gcd(A[i], R[i+1]);
		dbug(R[i])
	}
	dbugln;
	ans = max(ans, R[1]);
	for(int i = 1; i <N-1; i++){
		ans = max(ans, gcd(L[i-1], R[i+1]));
	}
	ans = max(ans, L[N-2]);

	cout << ans;

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll h,w,s;
ll sum;
ll num[40][40];
pair<ll,ll> memo[40][40][40][40];
const int MAX_N = 50;
int row,col;
ll rui[MAX_N][MAX_N];
void make_sum(){
  row = h;
  col = w;
  for(int i=1;i<=row+1;i++)
    for(int j=1;j<=col+1;j++)
      rui[i][j] = num[i][j] + rui[i-1][j] + rui[i][j-1] - rui[i-1][j-1];
}

ll get_sum(int lx,int ly,int rx,int ry){//閉区間
  if(lx>rx||ly>ry)return 0;
  else return rui[rx][ry] - rui[lx-1][ry] - rui[rx][ly-1] + rui[lx-1][ly-1]; 
}

//kosuu,
pair<ll,ll> dfs(int lx,int ly,int rx,int ry){

  if(memo[lx][ly][rx][ry].F>=0)return memo[lx][ly][rx][ry];
  if(s-(sum-get_sum(lx+1,ly+1,rx+1,ry+1)) < 0)return mp(0,0);

  memo[lx][ly][rx][ry] = mp(1,s-(sum-get_sum(lx+1,ly+1,rx+1,ry+1)));

  for(int i=ly;i<ry;i++){
    pair<ll,ll>p1 = dfs(lx,i+1,rx,ry);
    pair<ll,ll>p2 = dfs(lx,ly,rx,i);

    if(p1.F+p2.F > memo[lx][ly][rx][ry].F){
      memo[lx][ly][rx][ry] = mp(p1.F+p2.F,min(p1.S,p2.S));
    }else if(p1.F+p2.F == memo[lx][ly][rx][ry].F){
      memo[lx][ly][rx][ry] = mp(p1.F+p2.F,max(memo[lx][ly][rx][ry].S, min(p1.S,p2.S)));
    }
  }

  for(int i=lx;i<rx;i++){
    pair<ll,ll>p1 = dfs(lx,ly,i,ry);
    pair<ll,ll>p2 = dfs(i+1,ly,rx,ry);

    if(p1.F+p2.F > memo[lx][ly][rx][ry].F){
      memo[lx][ly][rx][ry] = mp(p1.F+p2.F,min(p1.S,p2.S));
    }else if(p1.F+p2.F == memo[lx][ly][rx][ry].F){
      memo[lx][ly][rx][ry] = mp(p1.F+p2.F,max(memo[lx][ly][rx][ry].S,min(p1.S,p2.S)));
    }
  }

  return memo[lx][ly][rx][ry];
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin>>h>>w>>s,h+w+s){
    sum = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>num[i+1][j+1];
	sum+=num[i+1][j+1];
	//	cout<<i<<" "<<j<<endl;
      }
    }
    for(int i=0;i<40;i++){
      for(int j=0;j<40;j++){
	rui[i][j]=0;
	for(int k=0;k<40;k++){
	  for(int l=0;l<40;l++){
	    memo[i][j][k][l] = mp(-1,llINF);
	  }
	}
      }
    }
	
    make_sum();

    pair<ll,ll>ans = dfs(0,0,h-1,w-1);
    cout<<ans.F<<" "<<ans.S<<endl;
  }
  return 0;
}



Measured memory_bytes: 43200
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	a,b,c := scanInt(),scanInt(),scanInt()

	if c < a-b {
		fmt.Println(0)
	} else {
		fmt.Println(c-(a-b))
	}
}


Measured memory_bytes: 640
use proconio::input;
fn digits(num: usize) -> Vec<usize>{
    fn x_inner(n: usize, xs: &mut Vec<usize>) {
        if n >= 10{
            x_inner(n/10, xs);
        }
        xs.push(n % 10);
    }
    let mut xs = Vec::new();
    x_inner(num, &mut xs);
    xs
}
fn main() {
    input!{N:usize};

    let N = digits(N);

    let ans = match N.last().unwrap() {
        0|1|6|8   => "pon",
        2|4|5|7|9 => "hon",
        3         => "bon",          
        _ => unreachable!()
    };

    println!("{}",ans);


}


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

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

Measured memory_bytes: 3628
import java.util.*;
 
public class Main{

	public static void main(String []args){
	    Scanner sc= new Scanner(System.in);
	    
		int n=sc.nextInt();
		long total=0;
		long temp;
		long[] neg= new long[n];
		long smallest=0;
		int count=0;
		
		for(int i=0; i<n; i++){
		    temp=sc.nextLong();
		    
		    if(temp<0){
		        neg[count]=temp;
		        count++;
		        
		        
		    }
		    if(0>temp) temp=-1*temp;
		    if(i==0||smallest>temp) smallest=temp;
		    total=temp+total;
		}
		
		if(count%2==1){
		    total=total-smallest*2;
		
		}
		
		System.out.println(total);
	}
}

Measured memory_bytes: 62664
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> S(n);
    for (int i = 0; i < n; ++i) cin >> S[i];
    sort(S.begin(), S.end());
    for (int i = 0; i < n; i++) {
        cout << S[i];
    }
    cout << endl;
    return 0;
}

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

int main() {
	int N, W;
	cin >> N >> W;
	vector<long long> w(N);
	vector<long long> v(N);
	for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

	long long max_v = *max_element(v.begin(), v.end());
	vector<vector <long long>> dp(N + 1, vector<long long>(N * max_v + 1));
	long long INF = 1LL << 60;
	for (int i = 0; i < N + 1; i++) {
		for (int j = 0; j < N * max_v + 1; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i < N + 1; i++) {
		for (int j = 0; j < N * max_v + 1; j++) {
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			if (j >= v[i - 1])
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
		}
	}

	int ans = 0;
	for (int i = 1; i < N * max_v + 1; i++) {
		if (dp[N][i] <= W) {
			ans = max(ans, i);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 80256
#include<iostream>
#include<cstdio>

using namespace std;

int m[1500][1500];
int main(){
  int n;
  cin>>n;
  char A[1500];
  char B[1500];
  for(int i=0;i<n;i++){
    cin>>A;
    cin>>B;
    int x;
    int y;
    for(x=0;A[x]!='\0';x++){
      for(y=0;B[y]!='\0';y++){
	if(A[x]==B[y]){
	  m[x+1][y+1]=m[x][y]+1;
	}
	else {
	  if(m[x][y+1]>m[x+1][y]){
	    m[x+1][y+1]=m[x][y+1];
	  }
	  else m[x+1][y+1]=m[x+1][y];
	}
      }
    }
    cout<<m[x][y]<<endl;

  }

  
  return 0;
}

Measured memory_bytes: 0
N,K=map(int,input().split())
S=input()
S="*"+S+"*"

A=0
for i in range(1,N+1):
    if S[i]=="L":
        A+=(S[i-1]=="L")
    elif S[i]=="R":
        A+=(S[i+1]=="R")

for i in range(K):
    A=min(N-1,A+2)

print(A)


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

// greatest common divisor
LL GCD(LL a,LL b){
    LL t; LL r;
    if(a<b){t=a;a=b;b=t;}
    if(b==0){return a;}
    while(a%b!=0){r=a%b;a=b;b=r;}
    return b;
}

// least common multiple
LL LCM(LL a,LL b){LL ab=(a*b);return ab/GCD(a%b,b);}

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

    LL lcm = LCM(c,d);
    LL A = b-a+1;
    LL B = b/c-(a-1)/c;
    LL C = b/d-(a-1)/d;
    LL D = (b/lcm-(a-1)/lcm);

    cout<<A-B-C+D<<endl;

    return 0;
}

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


#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    string s;
    cin >> s;
    set<char> all;
    for (int c = 'a'; c <= 'z'; c++) {
        all.insert(c);
    }

    for(char c : s) {
        all.erase(c);
    }

    if(all.empty()) {
        cout << "None" << endl;
        return 0;
    }

    cout << *all.begin() << endl;

}

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

#define INF 1e+18
vector<vector<ll> > d(201,vector<ll>(201,INF));
int V;

void wf(){
    for(int k=1;k<=V;k++){
        for(int i=1;i<=V;i++){
            for(int j=1;j<=V;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){

    int m,r;

    cin >> V >> m >> r;

    vector<int> mati(r);

    rep(i,r){
        cin >> mati[i];
    }

    rep(i,201){
        d[i][i]=0;
    }

    rep(i,m){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        d[a][b]=c;
        d[b][a]=c;
    }


    wf();
    ll ans =0;
    ll mi=INF;

    sort(mati.begin(),mati.end());
    for(int j=0;;){
        ans=0;
        for(int i=0;i<r-1;i++){
            ans+=d[mati[i]][mati[i+1]];
        }
        mi=min(mi,ans);
        if(!next_permutation(mati.begin(),mati.end())) break;
    }
    cout << mi << endl;

    return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define Loop(i, a, b) for(int i = a ; i < b ; ++i)
#define loop(i, n) Loop(i, 0, n)
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vvll vector<vll>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18+5
#define inf 1e9+5
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

template <typename T> T max(T a, T b, T c){ return max(a, max(b, c));}
template <typename T> T min(T a, T b, T c){ return min(a, min(b, c));}

int M = 1e9+7; //check


int main() {
	_69e27;
	ll r;
	cin >> r;
	cout << r*r;
	return 0;
}

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

int main(){
  int N , R;
  cin >> N >> R;
  int ans;
  if(N >= 10){
    ans = R;
  }
  else {
    ans = R + 1000 - 100*N; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int dp[100005][31];

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

    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    vector<int> B(N);
    int ans = 0;
    REP(i, N) {
        cin >> A[i] >> B[i];
        if ((K | A[i]) == K) ans += B[i];
    }

    REP(j, 30) {
        if ((K & (1 << j)) == 0) continue;
        int t = K;
        t ^= 1 << j;
        t |= (1 << j) - 1;

        int cur = 0;
        REP(i, N) {
            if ((t | A[i]) == t) {
                cur += B[i];
            }
        }
        ans = max(ans, cur);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
n, m = [int(i) for i in input().split()]

a = sorted([int(i) for i in input().split()])

import bisect

l = []
for i in range(m):
    b, c = [int(i) for i in input().split()]
    l.append((b, c))

l.sort(key=lambda x:x[1], reverse=True)

left = 0

for i in range(len(l)):
    for j in range(l[i][0]):
        if a[left] < l[i][1]:
            a[left] = l[i][1]
        else:
            break
        left += 1
        if left == len(a):
            break
    else:
        continue
    break

print(sum(a))

Measured memory_bytes: 22520
#include <bits/stdc++.h>
using namespace std;
vector<int>adj[100];
int visited[100];
void bfs(int s,int n)
{
    for(int i=0; i<n; i++)
    {
        visited[i]=0;
        queue<int>Q;
        Q.push(s);
        visited[s]=1;
        while(!Q.empty())
        {
            int u=Q.front();
            Q.pop();
            for(int i=0; i<adj[u].size(); i++)
            {
                if(visited[adj[u][i]]==0)
                {
                    int v=adj[u][i];
                    visited[v]=1;
                    Q.push(v);
                }
            }
        }
    }
}
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}

int main()
{

    double n;
    cin>>n;
  double k=ceil(n/1.08);
   if(floor(k*1.08)==n)
   {
       cout<<k<<endl;
   }
   else cout<<":("<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	stdin := bufio.NewReader(os.Stdin)
	var n, q int
	fmt.Fscan(stdin, &n, &q)
	var s string
	fmt.Fscan(stdin, &s)

	ssr := make([]int, len(s))
	for is := 0; is < len(s)-1; is++ {
		ssr[is+1] = ssr[is]
		if s[is] == 'A' && s[is+1] == 'C' {
			ssr[is+1]++
		}
	}

	for i := 0; i < q; i++ {
		var l, r int
		fmt.Fscan(stdin, &l, &r)

		fmt.Println(ssr[r-1] - ssr[l-1])
	}
}


Measured memory_bytes: 6016
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
using namespace std;

string s;

set<int> solve(int l, int r)
{
	int par = 0;
	bool found = false;
	set<int> result;

	for (int i = l; i < r; ++i) {
		if (s[i] == '(')
			++par;
		if (s[i] == ')')
			--par;

		if (par == 0 && (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/')) {
			found = true;

			set<int> lhs = solve(l, i-1), rhs = solve(i+1, r);
			for (set<int>::iterator it = lhs.begin(); it != lhs.end(); ++it) {
				for (set<int>::iterator jt = rhs.begin(); jt != rhs.end(); ++jt) {
					if (s[i] == '+')
						result.insert((*it) + (*jt));
					else if (s[i] == '-')
						result.insert((*it) - (*jt));
					else if (s[i] == '*')
						result.insert((*it) * (*jt));
					else if ((*jt) != 0)
						result.insert((*it) / (*jt));
				}
			}
		}
	}

	if (!found) {
		if (s[l] == '(')
			return solve(l+1, r-1);
		result.insert(atoi(s.substr(l, r-l+1).c_str()));
	}
	return result;
}

int main()
{
	while (cin >> s) {
		if (s == "#")
			break;
		cout << solve(0, s.size()-1).size() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a.at(0)==b.at(2) && a.at(1)==b.at(1) && a.at(2)==b.at(0)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
char a[1001],b[1001];
int s,j,z;
int main()
{  
    cin>>a>>b;
    s=strlen(a)+strlen(b);
    for(int i=0;i<=s;i++)
    {
    	if(i%2==0){
    		if(a[z]!='\0')
    			cout<<a[z];	
    		z++;
		}
    	else if(i%2!=0)
		{
			if(b[j]!='\0')
				cout<<b[j];
			j++;
		}
	}
    return 0;
}


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

template<typename T>
struct Dijkstra {
	struct Edge {
		const int from;
		const int to;
		const T cost;
		Edge(const int from, const int to, const T cost) :
			from(from),
			to(to),
			cost(cost)
			{}
	};
	const int V;
	vector<vector<Edge>> G;
	int start;
	const int INF = numeric_limits<T>::max();
	vector<T> dist;
	vector<int> rec;
	Dijkstra(const int V) :
		V(V),
		G(vector<vector<Edge>>(V, vector<Edge>()))
		{}
	void addEdge(const int from, const int to, const T cost) {
		assert(cost >= 0);
		G[from].emplace_back(from, to, cost);
	}
	void build(const int start) {
		(*this).start = start;
		dist = vector<T>(V, INF);
		rec = vector<int>(V, -1);
		priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
		dist[start] = 0;
		que.push({0, start});
		while(que.size()) {
			T cost;
			int from;
			tie(cost, from) = que.top();
			que.pop();
			for(Edge e : G[from]) {
				if(dist[e.from] + e.cost < dist[e.to]) {
					dist[e.to] = dist[e.from] + e.cost;
					rec[e.to] = e.from;
					que.push({dist[e.to], e.to});
				}
			}
		}
	}
	T distance(const int to) {
		if(dist[to] == INF) throw "INVALID";
		return dist[to];
	}
	vector<int> route(int to) {
		distance(to);
		vector<int> ret;
		while(to != start) {
			ret.push_back(to);
			to = rec[to];
		}
		ret.push_back(start);
		reverse(ret.begin(), ret.end());
		return ret;
	}
};

int main() {
	int V, E, r; cin >> V >> E >> r;
	Dijkstra<int> ds(V);
	while(E--) {
		int s, t, d; cin >> s >> t >> d;
		ds.addEdge(s, t, d);
	}
	ds.build(r);
	for(int to = 0; to < V; ++to) {
		try {
			cout << ds.distance(to) << "\n";
		}
		catch(...) {
			cout << "INF" << "\n";
			continue;
		}
	}
	return 0;
}


Measured memory_bytes: 15748
def solve(yen,cnt):
  if yen<0:
    print("-1 -1 -1")
    return False
  elif yen==0:
    print(cnt,0,0)
    return True
  else:
    res=0
    while res<=cnt:
      for i in range(0,cnt-res+1):
        if res*5000+i*9000 == yen:
          print(cnt-i-res,res,i)
          return True
      res+=1
    print("-1 -1 -1")
    return False

N,Y=map(int,input().split())
ans=N*10000-Y

solve(ans,N)


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
static const int MAXN = 303;
static const int MAXM = 302;
static const int MODULUS = 1e9 + 7;
#define _  %  MODULUS
#define __ %= MODULUS

int n, m;
std::pair<std::pair<int, int>, short> q[MAXM];

// f[length][occurrence of a second colour, or 0][occurrence of a third colour, or 0]
// - number of ways of colouring, while satisfying all constraints with right endpoint <= length
int f[MAXN][MAXN][MAXN] = {{{ 0 }}};
std::vector<int> qwr[MAXN];

inline bool check_feasibility(int x, int i, int j, int k)
{
    static int occ[5] = { MAXN, 0, 0, 0, -1 };
    occ[1] = i, occ[2] = j, occ[3] = k;
    return (q[x].first.first > occ[q[x].second + 1] && q[x].first.first <= occ[q[x].second]);
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i) {
        scanf("%d%d%hd", &q[i].first.first, &q[i].first.second, &q[i].second);
        qwr[q[i].first.second].push_back(i);
    }

    f[0][0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j)
            for (int k = 0; k <= j; ++k) if (f[i][j][k]) {
                // Check all constraints
                bool f1 = true, f2 = true, f3 = true;
                for (auto x : qwr[i + 1]) {
                    if (!check_feasibility(x, i + 1, j, k)) f1 = false;
                    if (!check_feasibility(x, i + 1, i, k)) f2 = false;
                    if (!check_feasibility(x, i + 1, i, j)) f3 = false;
                }
                // Accumulate to answer
                if (f1) (f[i + 1][j][k] += f[i][j][k])__;
                if (f2) (f[i + 1][i][k] += f[i][j][k])__;
                if (f3) (f[i + 1][i][j] += f[i][j][k])__;
            }
    }

    int ans = 0;
    for (int j = 0; j < n; ++j)
        for (int k = 0; k < n; ++k) (ans += f[n][j][k])__;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 106752
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  int AC, WA, TLE, RE;
  AC=WA=TLE=RE=0;
  
  for(int i=0; i<N;i++){
    cin>>S;
    if(S=="AC"){
      AC++;
    }
    if(S=="WA"){
      WA++;
    }
    if(S=="TLE"){
      TLE++;
    }
    if(S=="RE"){
      RE++;
    }
  }

  cout<<"AC x "<<AC<<endl;
  cout<<"WA x "<<WA<<endl;
  cout<<"TLE x "<<TLE<<endl;
  cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<62)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
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;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vl a(3),b={5,5,7};
    cin>>a[0]>>a[1]>>a[2];
    sort(all(a));
    YN(a==b);
    
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, D;
    cin >> N >> D;
    cout << (N+2*D) / (2*D + 1) << endl;

    return 0;
}


Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }
    var currentGcd = l[0]
    for(i in 0 until n){
        currentGcd = gcd(currentGcd, l[i])
    }
    println(currentGcd)
}

fun gcd(a: Int, b: Int) :Int{
    if (b == 0) return Math.abs(a)
    return gcd(b, a % b)
}

Measured memory_bytes: 53652
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    int ans=0;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){ans++;}
    }
    cout<<ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#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;

int main() {
   int a,b;
   cin >> a >> b;
   cout << (a<10 && b<10 ? a*b : -1) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define MOD (1e10+7)
typedef pair<int, ll> PIL;

bool done[123456];
vector<PIL> g[123456];
ll x[123456];
queue<int> q;

int main(void){
	int n,m,l,r,i,j,t;
	ll d;
	bool flag = true;
	fill(done,done+123456,false);
	x[0] = 0;
	cin >> n >> m;
	for(i=0; i<m; i++){
		cin >> l >> r >> d;
		l--;
		r--;
		g[l].push_back(PIL(r,d));
		g[r].push_back(PIL(l,-d));
	}
	for(i=0; i<n; i++){
		if(done[i]){
			continue;
		}
		x[i] = 0;
		q.push(i);
		while(!q.empty()){
			t = q.front();
			q.pop();
			for(j=(g[t].size()-1); j>=0; j--){
				if(done[g[t][j].first]){
					if(x[g[t][j].first] - x[t] != g[t][j].second){
						flag = false;
						break;
					}
				}else{
					done[g[t][j].first] = true;
					x[g[t][j].first] = x[t] + g[t][j].second;
					q.push(g[t][j].first);
				}
			}
			if(!flag){
				break;
			}
		}
	}
	cout << ((flag)?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 14592
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A&lang=ja

制約
	n≤20
	q≤200
	1≤Aの要素≤2,000
	1≤mi≤2,000

*/

#include <bits/stdc++.h>

using namespace std;

void disp(int *n, int N);

int main(void){

	int N;
	scanf("%d", &N);
	int n[N];

	for(int i=0; i<N; i++) scanf("%d", &n[i]);

	disp(n, N);

	for(int i=1; i<N; i++){
		int v = n[i];
		int j = i-1;
		while(j >=0 && n[j] > v){
			n[j+1] = n[j];
			j--;
		}
		//printf("i = %d, ", i);
		n[j+1] = v;
		disp(n, N);
	}
	//printf("\n");

	return 0;
	
  
}

void disp(int *n, int N){
	//printf("disp: ");
	for(int i=0; i<N; i++) {
		printf("%d", n[i]);
		if( i != N-1) printf(" ");
	}
	printf("\n");
}


Measured memory_bytes: 3180
#include <stdio.h>
#include <string.h>
int main(void)
{
	int i;
	char type[3]={0};
	int  num[4]={0}; // A,B,AB,O
	while(scanf("%*d,%s",type)!=EOF)
	{
		     if(strcmp(type,"A" )==0) num[0]++;
		else if(strcmp(type,"B" )==0) num[1]++;
		else if(strcmp(type,"AB")==0) num[2]++;
		else if(strcmp(type,"O" )==0) num[3]++;
	}
	for(i=0; i<4; i++)
		printf("%d\n", num[i]);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  vector<bool>A(N,false);
  A[0]=true;
  vector<int>B(N,1);
  for(int i=0;i<M;i++){
    int a,b; cin>>a>>b;
    a--;b--;
    if(A[a]==true){
      if(B[a]==1)A[a]=false;
      A[b]=true;
    }
    if(B[a]!=0){B[a]--;B[b]++;}
  }
  int ans=0;
  for(int i=0;i<N;i++)if(A[i]==true)ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3652
import scala.util.control.Breaks

object Main extends App {
  val nm =  scala.io.StdIn.readLine()
  val nmArray = nm.split(" ").map(_.toInt).toSeq
  val n = nmArray(0)
  val m = nmArray(1)

  val aInput =  scala.io.StdIn.readLine()
  val aArray = aInput.split(" ").map(_.toInt).toVector.sorted.reverse
  val aSum = aArray.sum.toDouble
  var result = true

  val b = new Breaks
  b.breakable {
    (1 to m).foreach { i =>
      val target = aArray(i  - 1).toDouble
      val judge = aSum / (4 * m).toDouble
      if(target < judge) {
        result = false
        b.break()
      }
    }
  }
  println(if (result) "Yes" else "No")
}

Measured memory_bytes: 25520
n = int(input())
a = [[int(i) for i in input().split()] for j in range(n)]
good = False
for i in range(n-2):
  ok = True
  for j in range(i, i+3):
    ok &= a[j][0] == a[j][1]
  good |= ok
print("Yes" if good else "No")

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

int main() {
    string s, ans;
    cin >> s; 
    int size = s.size();
    for (int i = 0, j = 0; i < size; ++i) {
        if (s[i] != 'B') ans += s[i];
        else if (ans.size() > 0) ans.erase(--ans.end());

;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int k, s, cnt;

int main()
{
    cin>>k>>s;
    for(int i = 0 ; i <= k ; i++ )
        for(int j = 0 ; j <= k ; j++ )
            if( i+j <= s and s-i-j <= k ) cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

// k = a + b + c
// E(a,b,c) := Expected no. of trials required to reach (0,0,0) from (a,b,c)
// E(a,b,c) = (n-k)/n * E(a,b,c) + a/n * E(a-1,b,c) + b/n * E(a+1,b-1,c) + c/n * E(a,b-1,c+1)
// E(a,b,c) = n/k + a/k * E(a-1,b,c) + b/k * E(a+1,b-1,c) + c/k * E(a,b+1,c-1)

const int N = 304;

ff E[N][N][N];
int n, cnt[3];

void solve() {
   E[0][0][0] = 0;

   for (int c = 0; c < N; ++c) {
      for (int b = 0; b+c < N; ++b) {
         for (int a = 0; a+b+c < N; ++a) {
            if (a + b + c > N) continue;
            if (!a && !b && !c) continue;

            int k = a + b + c;
            ff repeat = 1.0*n/k;
            ff p_a = 1.0*a/k, p_b = 1.0*b/k, p_c = 1.0*c/k;

            E[a][b][c] = repeat;

            if (a) E[a][b][c] += E[a-1][b][c] * p_a;
            if (b) E[a][b][c] += E[a+1][b-1][c] * p_b;
            if (c) E[a][b][c] += E[a][b+1][c-1] * p_c;
         }
      }
   }
   cout << E[cnt[0]][cnt[1]][cnt[2]] << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;

   cnt[0] = cnt[1] = cnt[2] = 0;

   for (int i = 0, foo; i < n; ++i)
      cin >> foo, cnt[foo-1]++;

   cerr << cnt[0] << ' ' << cnt[1] << ' ' << cnt[2] << '\n';

   solve();

   return EXIT_SUCCESS;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  map<int, bool> isCorrect;
  map<int, int> WAcount;
  int ACcount = 0;
  int total_WA = 0;
  int num;
  string result;
  for (int i = 0; i < M; i++) {
    cin >> num >> result;
    if(result == "WA" && (isCorrect[num] == false || isCorrect.find(num) == end(isCorrect) ) ){
        WAcount[num] += 1;   
    }
    if(result == "AC"){
        if(isCorrect[num] == false || isCorrect.find(num) == end(isCorrect)){
            ACcount++;
            total_WA += WAcount[num];
            isCorrect[num] = true;
        }else continue;
    }
  }
  cout << ACcount << " " << total_WA << endl;
  return 0;
}

Measured memory_bytes: 9600