akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int n = in();
  vector<int> a(n);
  cin >> a;
  int q = in();
  while (q--) {
    int b, m, t;
    cin >> b >> m >> t;
    swap_ranges(a.begin() + b, a.begin() + m, a.begin() + t);
  }
  cout << a << endl;
}



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

using namespace std;

/*****************MACRO*****/

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

/*******CONSTANT***********/
#define INF (1<<30) //infinity value
#define EPS 1e-9
#define MOD 10000007
#define SIZ 1005
#define PI (acos(-1))
const int MAX= 3000;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);
    int R, G, B, N;
    cin>>R>>G>>B>>N;
    int cnt=0;
    ///r, g START hobe from 0 ; ///age bhule 1 theke start korsilam
    ///karon of course jekono box 0 ta choose kora jabe
    for(int i=0; i<=N; i++){
        for(int j=0; j<=N; j++){
            float b= (1.0*(N-i*R-j*G))/B;
            ///cout<<"r="<<i<<" g="<<j<<"   b="<<b<<"\n";
            if(b>=0 && ceil(b)==floor(b)){
                cnt++;
                ///cout<<"#cnt="<<cnt<<"\n";
            }

        }
    }
    cout<<cnt<<"\n";



    return 0;
}

/**********************************************************************************







*************************************************************************************/


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,R;

signed main(){
	cin>>N>>R;
	if(N>=10){
		cout<<R<<endl;
	}
	else{
		cout<<R+100*(10-N)<<endl;
	}
	return 0;
}


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

ll v[100005], pref[100005], suff[100005];

int main(){

    ll n, k; cin >> n >> k;
    for(ll i = 1; i <= n; i++)
        cin >> v[i];
    for(ll i = 1; i <= n; i++)
        pref[i] = pref[i-1] + v[i];
    for(ll i = n; i >= 1; i--)
        suff[i] = suff[i+1] + v[i];
    
    ll res = 1e18;

    for(int i = k; i <= n; i++){ // window i-k+1...i with size k
        if(v[i-k+1]*v[i] > 0){
            ll mini = min(abs(v[i-k+1]), abs(v[i]));
            ll maxi = max(abs(v[i-k+1]), abs(v[i]));
            res = min(res, maxi);
        }
        else{
            ll mini = min(abs(v[i-k+1]), abs(v[i]));
            ll maxi = max(abs(v[i-k+1]), abs(v[i]));
            ll r1 = min(2*mini+maxi, 2*maxi+mini);
            res = min(res, r1);
        }
    }

    cout << res << endl;

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int n,b[65][300009];
ll a[300009],ans=0,f[65];
int main()
{
    f[0]=1;
    for(int i=1; i<=61; i++)
        (f[i]=f[i-1]*2%mod)%=mod;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        for(int j=1; j<=60; j++)
            b[j][i]=(a[i]>>(j-1))&1;
    }
    for(int i=1; i<=61; i++)
        for(int j=1; j<=n; j++)
            b[i][j]+=b[i][j-1];
    for(int i=1; i<=n; i++)
    {
        ll tmp=a[i];
        for(int j=1; j<=61; j++)
        {
            if(((a[i]>>(j-1))&1)==0)
                (ans+=(b[j][n]-b[j][i])*f[j-1]%mod)%=mod;
            else
                (ans+=(n-i-b[j][n]+b[j][i])*f[j-1]%mod)%=mod;
            //printf("%lld\n",ans);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 76032
import numpy as np

N=int(input())
A=[]
PRECISION_DIGITS=9
NO_ENTRY = 0
ARR_SIZE=PRECISION_DIGITS*2+1
cnt=np.full((ARR_SIZE,ARR_SIZE),NO_ENTRY,int)
# cnt=np.zeros((PRECISION_DIGITS*2,PRECISION_DIGITS*2),int)

# print(cnt)

for n in range(N):
	tmpA = float(input())
	tmpA = round(tmpA*10**PRECISION_DIGITS)
	#print(tmpA)

	five = 0
	two = 0
	# (10**9) -> (two,five)=(9,9)
	# min = 10**-9, ignore < 10**9 ???
	while (tmpA % 2) == 0 and two < PRECISION_DIGITS*2:
		two += 1
		tmpA //= 2
	while (tmpA % 5) == 0 and five < PRECISION_DIGITS*2:
		five += 1
		tmpA //= 5

	if cnt[two][five] == NO_ENTRY:
		cnt[two][five]=1
	else:
		cnt[two][five]+=1

# print(cnt)
ans = 0

for x1 in range(ARR_SIZE):
	for y1 in range(ARR_SIZE):
		if cnt[x1][y1] == NO_ENTRY:
			continue

		for x2 in range(x1,ARR_SIZE):
			for y2 in range(ARR_SIZE):
				if cnt[x2][y2] == NO_ENTRY:
					continue
				# 2**a(a>=0) and 5**b(b>=0) => integer
				if 0 <= x1+x2 - PRECISION_DIGITS*2 and 0 <= y1+y2 -PRECISION_DIGITS*2:
					if x1 == x2 and y1 == y2:
						# same entry
						# Total number of combinations choose 2 items
						# nC2 = n*(n-1)/2
						ans += int((cnt[x1][y1]*(cnt[x2][y2]-1))//2)
					else:
						ans += int(cnt[x1][y1]*cnt[x2][y2])

		# completed counted up entry
		cnt[x1][y1] = NO_ENTRY

print(ans)



Measured memory_bytes: 26976
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) long long(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	long long ans=n/(a+b)*a;
	if (n%(a+b) && n%(a+b)<=a)  ans+=n%(a+b);
	else if (n%(a+b))  ans+=a;
	cout<<ans;
	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* ?????° {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  int n;
  while (cin >> n, n){
    int sum1, sum2;
    sum1 = sum2 = 0;
    REP(i, n){
      int a = in(), b = in();
      if (a > b){
        sum1 += a + b;
      } else if (a < b){
        sum2 += a + b;
      } else {
        sum1 += a;
        sum2 += b;
      }
    }

    cout << sum1 << " " << sum2 << endl;
  }

}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9

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

const double pi = 3.1415926535;

int main(){
    int n;
    cin >> n;
    cout <<fixed<<setprecision(10)<< 2 * n * pi << endl;
}


Measured memory_bytes: 3760
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>

int compare(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int sum(int *data, int n) {
    int i;
    int result = 0;
    for (i = 0; i < n; i++) {
        result += data[i];
    }
    return result;
}

int main(void) {
    int n,i;
    int result;
    scanf("%d", &n);
    int a[n];
    for (i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    qsort(a, n, sizeof(int), compare);
    result = sum(a,n);
    if (result % 10 == 0) {
        for (i=0; i<n; i++) {
            if (a[i] % 10 != 0) {
                result -= a[i];
                break;
            }
        }
        if (result == sum(a,n)) {
            result = 0;
        }
    }
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int n;
    scanf("%d", &n);
    char s[n];
    scanf("%s", s);
    int r = 0, b = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            r++;
        }
        else
        {
            b++;
        }
    }
    if (r > b)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <tuple>
#include <queue>
#include <vector>

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))

using lli = long long int;

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

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


constexpr lli inf = 8e18;

std::vector<int> R;
std::vector<std::vector<std::pair<int, int>>> Road;

// Cost[a][b] := R[a] -> R[b]への移動にかかる最小コスト
std::vector<std::vector<int>> Cost; 

// ダイクストラの計算に必要
std::vector<lli> Dist;
std::vector<bool> hasVisited;


int main(void){
    // 入力 1
    int n, m, r; scanf("%d%d%d", &n, &m, &r);
    R.resize(r); REP(i, r) {scanf("%d", &R[i]); R[i]--;}

    // グラフの入力
    Road.resize(n);
    REP(i, m){
        int a, b, c; scanf("%d%d%d", &a, &b, &c); a--; b--;
        Road[a].push_back(std::pair<int, int>(b, c));
        Road[b].push_back(std::pair<int, int>(a, c));
    }

    Cost.resize(r, std::vector<int>(r));

    // 距離の計算
    Dist.resize(n); hasVisited.resize(n);
    REP(x, r){
        // 初期化
        std::fill(hasVisited.begin(), hasVisited.end(), false);
        std::fill(Dist.begin(), Dist.end(), inf);
        
        // 優先度付きキュー
        using Pli = std::pair<lli, int>; // (コスト, 頂点)
        std::priority_queue<Pli, std::vector<Pli>, std::greater<Pli>> PQ;
        PQ.push(Pli(0, R[x]));

        // ダイクストラの実行
        while(not PQ.empty()){
            lli cost; int vertex;
            std::tie(cost, vertex) = PQ.top(); PQ.pop();
            if(hasVisited[vertex]) continue; // 既に訪れている場合

            Dist[vertex] = cost;
            hasVisited[vertex] = true;
            
            // 次の頂点
            for(std::pair<int, int>& nxt : Road[vertex]){
                int nv, c; std::tie(nv, c) = nxt;
                if(Dist[vertex] + c < Dist[nv]){
                    PQ.push(Pli(Dist[vertex] + c, nv));
                }
            }
        }

        // 距離の記録
        REP(y, r) Cost[x][y] = Dist[R[y]];
    }

    lli ans = inf;
    // 順番の全探索
    std::vector<int> Perm(r); REP(i, r) Perm[i] = i;
    do{
        lli partDist = 0;
        for(int x = 0; x + 1 < r; ++x) partDist += Cost[Perm[x]][Perm[x+1]];
        chmin(ans, partDist);
    } while(std::next_permutation(Perm.begin(), Perm.end()));

    // 出力
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 2148
A,B,C,D=map(int,input().split())

def gcd(a, b):
   while b%a:
      b,a=a,b%a
   return a

lcm=C*D//gcd(C,D)
print(B-A+1-B//C+(A-1)//C-B//D+(A-1)//D+B//lcm-(A-1)//lcm)


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

//y
using namespace std;
vector<vector<char>> vec;
int n,m;
int meme[1007][1007];
const int M=1000000007;


int solve(int x , int y){
    if(x>=n || x<0 || y>=m || y<0 || vec[x][y]=='#'){
        return 0;
    }
    if(x==n-1 && y==m-1){
        return (1%M);
    }
    int &ret = meme[x][y];
    if(~ret){
        return ret%M;
    }
    ret = ((solve(x+1,y)%M) + (solve(x,y+1)%M))%M;
    
    return ret%M;
}

int main(){
        cin>>n>>m;
        memset(meme,-1,sizeof(meme));
        vec = vector<vector<char>>(n+2,vector<char>(m+2));
        string line;
        for(int i = 0 ; i<n ; i++){
            cin>>line;
            for(int j = 0 ; j<line.size() ; j++){
                vec[i][j] = line[j];
            }
        }
        cout<<solve(0,0)<<endl;

    return 0;
}

Measured memory_bytes: 8592
#include<stdio.h>
int main()
{
    int a,b,sum,sub,mul,div;
    char op;
    while(1)
    {
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')
        {
           return 0;
        }
        else{
        if(op=='+')
        {
            sum = a+b;
            printf("%d\n",sum);
        }
        else if(op=='-')
        {
            sub = a-b;
            printf("%d\n",sub);
        }
        else if(op=='*')
        {
            mul = a*b;
            printf("%d\n",mul);
        }
        else if(b>0 && op=='/')
        {
            div = a/b;
            printf("%d\n",div);
        }
    }
    }
    return 0;
}



Measured memory_bytes: 2056
#include<stdio.h>

int main(){

int N;
scanf("%d",&N);

int T[N];
int T_sum=0;
for (int i = 0; i < N; i++){
    scanf("%d",&T[i]);
    T_sum += T[i]; 
}

int M,P,X;
scanf("%d",&M);
for (int i = 0; i < M; i++){
  scanf("%d%d",&P,&X);
  printf("%d\n",T_sum-T[P-1]+X);
}


return 0;

}

Measured memory_bytes: 1700
#include <iostream>
using namespace std;
using ll = long long;
int main() {
	ll N, sum = 0;
	cin >> N;

	for (ll i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    vvi dp(h, vi(w, INF));
    dp[0][0] = s[0][0] == '#' ? 1 : 0;

    REP1(i, h + w - 1) {
        REP(j, i + 1) {
            if (i - j - 1 >= 0 && i - j < w && j >= 0 && j < h) {
                if (s[j][i - j] == '#' && s[j][i - j - 1] == '.') {
                    chmin(dp[j][i - j], dp[j][i - j - 1] + 1);
                } else {
                    chmin(dp[j][i - j], dp[j][i - j - 1]);
                }
            }
            if (i - j - 1 >= 0 && i - j < h && j >= 0 && j < w) {
                if (s[i - j][j] == '#' && s[i - j - 1][j] == '.') {
                    chmin(dp[i - j][j], dp[i - j - 1][j] + 1);
                } else {
                    chmin(dp[i - j][j], dp[i - j - 1][j]);
                }
            }
        }
    }
    // REP(i, h) printv(dp[i]);
    cout << dp[h - 1][w - 1] << endl;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == 'A') {
		int idx;
		bool flag = false;
		for (int i = 2; i < s.size() - 1; i++) {
			if (s[i] == 'C') {
				if (flag) {
					flag = false;
					break;
				} else {
					idx = i;
					flag = true;
				}
			}
		}
		if (!flag) {
			cout << "WA" << endl;
			return 0;
		}
		for (int i = 1; i < s.size(); i++) {
			if (i != idx && s[i] < 'a') {
				cout << "WA" << endl;
				return 0;
			}
		}
		cout << "AC" << endl;
		return 0;
	} else {
		cout << "WA" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int k;
	priority_queue<int> pq;
	for(int i=0;i<n;i++){
		cin>>k;
		pq.push(k);
	}
	for(int i=0;i<m;i++){
		if(pq.empty()) break;
		k = pq.top();
		pq.pop();
		k/=2;
		if(k!=0) pq.push(k);
	}
	long long int ans=0;
	while(!pq.empty()){
		ans+=pq.top();
		pq.pop();
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3860
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  class Node {
    var id: Int = 0
    var key: Int = 0
    var parent: Node = null
    var left: Node = null
    var right: Node = null
    override def toString: String = {
      val sb = new StringBuilder(s"node ${id}: key = ${key}, ")
      if (parent != null) sb.append(s"parent key = ${parent.key}, ")
      if (left != null) sb.append(s"left key = ${left.key}, ")
      if (right != null) sb.append(s"right key = ${right.key}, ")
      sb.toString
    }
  }

  val n = readInt
  val arr = readLine.split(" ").map(_.toInt)

  val nodes = Array.fill[Node](n)(new Node)
  for (i <- 0 until n) {
    val id = i + 1
    nodes(i).id = id
    nodes(i).key = arr(i)
    var parentId = -1
    if (id % 2 == 0)  parentId = id / 2
    else parentId = (id - 1) / 2
    if (parentId >= 1 && parentId <= n) nodes(i).parent = nodes(parentId - 1)
    val leftId = id * 2
    val rightId = leftId + 1
    if (leftId <= n) nodes(i).left = nodes(leftId - 1)
    if (rightId <= n) nodes(i).right = nodes(rightId - 1)
  }

  for (i <- 0 until n) {
    println(nodes(i))
  }
}



Measured memory_bytes: 44268
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

const ll mod = 1e9 + 7;
ll mypow(ll x, ll y, ll m = mod)
{
    ll ans = 1;
    ll q = x;
    while (y > 0)
    {
        if (y % 2 == 1)
        {
            ans *= q;
            ans %= m;
        }
        q = q * q;
        q %= m;
        y = y / 2;
    }
    return ans % m;
}

ll permulation(ll x, ll y, ll m = mod)
{
    ll ans = 0;
    if (x >= y)
    {

        ans = 1;
        for (ll i = x - y + 1; i <= x; i++)
        {
            ans = (ans * i) % m;
        }
    }
    return ans;
}

ll combination(ll x, ll y, ll m = mod)
{
    ll ans = 0;
    if (y == 0 || y == x)
        ans = 1;
    else
    {
        ans = 1;
        for (ll i = x - y + 1; i <= x; i++)
        {
            ans = (ans * i) % m;
        }
        for (ll i = 1; i <= y; i++)
        {
            ans = (ans * mypow(i, m - 2, m)) % m;
        }
    }
    return ans;
}

ll fractual(ll x, ll m = mod)
{
    if (x == 0)
        return 0;
    else
        return permulation(x, x, m);
}

ll multi_choose(ll x, ll y, ll m = mod)
{
    return combination(x + y - 1, y - 1, m);
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    ll n, k;
    cin >> n >> k;
    cout << ( (n <= k) ? 1 : 0 ) << endl;
    return 0;
}



Measured memory_bytes: 3104
num, t = map(int, input().split())
taste = []
findmin = []

sum= 0
for i in range(1,num + 1):
  taste.append(t+i-1)
  sum += t+i-1
for j in range(len(taste)):
  findmin.append(taste[j]*taste[j])
m = findmin.index(min(findmin))
print(sum - taste[m])


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

using namespace std;

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

  int n;
  cin >> n;
  int mn = 1e9, ans = 0;
  while (n--) {
    int x;
    cin >> x;
    if (x <= mn) {
      ++ans;
    }
    mn = min(mn, x);
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
class Main
{
     static InputStreamReader isr;
     static BufferedReader br;
     static String output;
     static String[] data = new String[3];
     static int[] idata = new int[3];
      
     static void initialize ()
     {
          isr = new InputStreamReader(System.in);
          br = new BufferedReader(isr);
          output = null;
          for (String d : data)
          {
               d = null;
          }
          for (int i : idata)
          {
               i = 0;
          }
     }
 
     static void output ()
     {
           for (int i=0; i<data.length;++i) {
               idata[i] = Integer.parseInt(data[i]);
           }
           
           Arrays.sort(idata);
           
           for (int j=0; j<data.length;++j) {
                if (j<data.length-1) {
                     System.out.print(idata[j] + " ");
                } else {
                     System.out.println(idata[j]);
                }
           }
     }
      
     public static void main (String[] args)
     {
           initialize();
           try {
                data = (br.readLine()).split(" ");
                output();
           } catch (IOException e) {
           } finally {
                try {
                      br.close();
                } catch (IOException e) {
                }
           }
     }
}

Measured memory_bytes: 24340
#include <stdio.h>
 
int main(void) {
     
    int n;
     
    scanf("%d", &n);
     
    if(n == 0) printf("1\n");
   else if(n == 1) printf("2\n");
else if(n == 2) printf("1\n");
else printf("0\n");

    return 0;
}

Measured memory_bytes: 580
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
k= []
l = []
f = 0
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")

a,b,c = ma()
if c<b:print(0)
elif a==1 and b!=c:print(0)
else:
    print((a-2)*c-(a-2)*b+1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		
		
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        	
				
		if(a<3200) {
			System.out.println("red");
		}else{
			System.out.println(s);
		}
		
	}

}


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

int main(void){
  int A, B;
  cin >> A >> B;
  if(A>B) swap(A, B);
  int ans;
  if(B - A >= 1) ans = B + (B-1);
  else ans = A + B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int m[101][101];
  int i,j,k,n,u,v;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      m[i][j]=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<=k-1;j++){;
      scanf("%d",&v);
      m[u][v]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j-1)printf(" ");
      printf("%d",m[i][j]);
    }
    printf("\n");
  }
  return 0;
}

    
  
  



Measured memory_bytes: 2772
#include <stdio.h>
#include <ctype.h>

#define MOD_BY 1000000007
#define SIZE_MAX 2000000

#define ESU (-1)
#define SIFUTO (-2)
#define KAKKO (-3)

int expr[SIZE_MAX];
int expr_num;
int stack[SIZE_MAX];
int stack_num;

void compile(const char* expr_str) {
	int i;
	int digit_flag=0;
	int current_number=0;
	expr_num=stack_num=0;
	for(i=0;expr_str[i]!='\0';i++) {
		if(isdigit(expr_str[i])) {
			current_number=current_number*10+expr_str[i]-'0';
			digit_flag=1;
		} else {
			if(digit_flag) {
				expr[expr_num++]=current_number;
				current_number=0;
				digit_flag=0;
			}
			switch(expr_str[i]) {
				case 'S':
					stack[stack_num++]=ESU;
					break;
				case '<':
					stack[stack_num++]=KAKKO;
					break;
				case '>':
					while(stack_num>0 && stack[stack_num-1]!=KAKKO) {
						expr[expr_num++]=stack[--stack_num];
					}
					stack[stack_num++]=SIFUTO;
					i++;
					break;
				case ')':
					while(stack_num>0 && stack[--stack_num]!=KAKKO) {
						expr[expr_num++]=stack[stack_num];
					}
					break;
			}
		}
	}
	if(digit_flag) {
		expr[expr_num++]=current_number;
		digit_flag=0;
	}
	while(stack_num>0) {
		expr[expr_num++]=stack[--stack_num];
	}
}

int run(void) {
	int i;
	stack_num=0;
	for(i=0;i<expr_num;i++) {
		if(expr[i]==ESU) {
			int ret=0,now=stack[stack_num-1],left=stack[stack_num-1];
			while(left>0) {
				if(left&1) {
					ret+=now;
					if(ret>=MOD_BY)ret-=MOD_BY;
				}
				now+=now;
				if(now>=MOD_BY)now-=MOD_BY;
				left>>=1;
			}
			stack[stack_num-1]=ret;
		} else if(expr[i]==SIFUTO) {
			if(stack[stack_num-1]<32) {
				stack[stack_num-2]>>=stack[stack_num-1];
			} else {
				stack[stack_num-2]=0;
			}
			stack_num--;
		} else if(expr[i]>=0) {
			stack[stack_num++]=expr[i];
		}
	}
	return stack[0];
}

int main(void) {
	static char input[SIZE_MAX];
	while(fgets(input,sizeof(input),stdin)!=NULL && input[0]!='#') {
		int i;
		int expect_number=1;
		for(i=0;input[i];i++);
		for(i--;i>=0;i--) {
			if(input[i]=='>') {
				if(expect_number) {
					input[i]=')';
				} else {
					i--;
					expect_number=1;
				}
			} else if(isdigit(input[i])) {
				expect_number=0;
			} else if(input[i]=='S') {
				expect_number=0;
			}
		}
		compile(input);
		printf("%d\n",run());
	}
	return 0;
}

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

ll MOD = 998244353LL;


ll pow_mod(ll a, ll n) {
    if (n == 1LL) {
        return a;
    } else if (n == 0LL) {
        return 1LL;
    }else {
        ll half = pow_mod(a, n / 2);
        if (n % 2 == 0) {
            return half * half % MOD;
        } else {
            half = half * half % MOD;
            return half * a % MOD;
        }
    }
}

int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    ll ans = 0LL;
    ll comb;
    for (ll i = 0LL; i <= k; i++) {
        // comb(n - 1, i)
        if (i == 0LL) {
            comb = 1LL;
        } else {
            comb = comb * (n - 1 - i + 1) % MOD;
            comb = comb * pow_mod(i, MOD - 2) % MOD;
        }
        // cout << "comb(" << n - 1 << ", " << i << "): ";
        // cout << comb << endl;

        // comb (n, i) * (m - 1) ** (n - i - 1)
        ll temp = comb * pow_mod(m - 1, n - i - 1);
        // cout << (temp % MOD) << endl;
        ans += (temp % MOD);
        ans %= MOD;
    }
    ans = ans * m % MOD;
    cout << ans << endl;
    return 0;
}

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

int N;
pair<int,int> r[101], b[101];
bool used[101] = {};

int main(){
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> r[i].second >> r[i].first;
    }
    for(int i = 0; i < N; ++i){
        cin >> b[i].first >> b[i].second;
    }
    sort(b, b + N);
    sort(r, r + N);
    reverse(r, r + N);
    int ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(r[j].first < b[i].second && r[j].second < b[i].first && !used[j]){
                used[j] = true;
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
m,d = map(int,input().split())
cnt=0
for i in range(m):
    i+=1
    for j in range(d):
        j+=1
        d1=j//10
        d2=j-d1*10
        if(d1>=2 and d2>=2 and d1*d2==i):
            cnt+=1

print(cnt)

Measured memory_bytes: 3060
$m=1e9+7;
sub p{my($a,$b)=@_;$b?p($a*$a%$m,$b>>1)*($b%2?$a:1)%$m:1}
($H,$W,$A,$B)=glob<>;
@f=$t=1;
push@f,$t=$t*$_%$m for 1..2e5;
$\=($\+$f[$H-$A-1+$_]*$f[$A+$W-$_-2]%$m*p($f[$H-$A-1]*$f[$_]%$m*$f[$A-1]%$m*$f[$W-1-$_]%$m,$m-2)%$m)%$m for$B..$W-1;
print

Measured memory_bytes: 9344
#include <stdio.h>
#include <stdlib.h>
int main(){
  char S[4];
  int ans;
  scanf("%s",S);
  if(strcmp("RRR",S)==0) ans=3;
  else if(strcmp("SRR",S)==0 || strcmp("RRS",S)==0) ans=2;
  else if(strcmp("SSS",S)==0) ans=0;
  else ans=1;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <map>
#include <utility>

using namespace std;

int main() {
    long long h, w;
    int n;

    cin >> h >> w >> n;

    long long a, b;
    map<pair<long long, long long>, long long> mp;

    for (int i = 0; i < n; i++) {
        cin >> a >> b;

        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a - j >= 1 && b - k >= 1 &&
                    a - j + 2 <= h && b - k + 2 <= w) {
                    mp[make_pair(a - j, b - k)]++;
                }
            }
        }
    }

    long long ans[10];

    for (int i = 0; i < 10; i++) {
        ans[i] = 0;
    }

    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans[itr->second]++;
    }

    ans[0] = (h-2) * (w-2);
    for (int i = 1; i < 10; i++) {
        ans[0] -= ans[i];
    }

    for (int i = 0; i < 10; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    bool A[105];
    REP(i,105) A[i]=true;
    int n,k,d,ans,a;
    cin>>n>>k;
    ans=n;
    REP(i,k){
        cin>>d;
        REP(j,d){
            cin>>a;
            if(A[a]==true){
                ans--;
                A[a]=false;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll r,d,x;cin>>r>>d>>x;
	FOR(i,1,10){
		x=r*x-d;
		cout<<x<<"\n";
	}
}
/*
1 3
#.#


2 3
#.#
..#

3 3
##.
#.#
..#

3
2 5
6 1
3 7
Ans:6

4
3 7
2 9
8 16
10 8
Ans:9
*/


Measured memory_bytes: 256
import sys
K = int(input())
A = list(map(int, input().split()))
minA = 2
maxA = 2
for ai in A[::-1]:
    if minA <= ai <= maxA:
        minA = ai
        maxA = maxA - maxA%ai + ai - 1
    elif ai < minA:
        minA = minA + ai * int(minA%ai>0) - minA%ai
        maxA = maxA - maxA%ai + ai - 1
    elif ai > maxA:
        print(-1)
        sys.exit()
if minA > maxA:
    print(-1)
else:
    print(minA, maxA)

Measured memory_bytes: 85644
n = int(input())
d = {}
for i in input().split():
  if i not in d:
    d[i] = 1
  else:
    d[i] += 1
m = int(input())
if m > n:
  print('NO')
  exit()
for j in input().split():
  if j not in d or d[j] == 0:
    print('NO')
    exit()
  else:
    d[j] -= 1
print('YES')

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, a, b;
    cin >> n >> m;
    vector<int> cost(n);
    vector<bool> good(n, true);
    for (int i = 0; i < n; i++) {
        cin >> cost[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--, b--;
        if (cost[a] <= cost[b]) {
            good[a] = false;
        }
        if (cost[b] <= cost[a]) {
            good[b] = false;
        }
    }
    cout << acusum(good) << endl;

    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  cout << s[0] << sz(s) - 2 << s[sz(s) - 1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main() {
  char a[200010];
  scanf("%s", a);
  int ptr;
  int i;
  long long length = strlen(a);
  long long dame = 0;
  long long num_words[26] = {};
  for (i = 0; i < length; i++) {
    if (a[i] == 'a') {
      num_words[0] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'b') {
      num_words[1] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'c') {
      num_words[2] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'd') {
      num_words[3] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'e') {
      num_words[4] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'f') {
      num_words[5] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'g') {
      num_words[6] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'h') {
      num_words[7] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'i') {
      num_words[8] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'j') {
      num_words[9] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'k') {
      num_words[10] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'l') {
      num_words[11] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'm') {
      num_words[12] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'n') {
      num_words[13] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'o') {
      num_words[14] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'p') {
      num_words[15] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'q') {
      num_words[16] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'r') {
      num_words[17] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 's') {
      num_words[18] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 't') {
      num_words[19] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'u') {
      num_words[20] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'v') {
      num_words[21] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'w') {
      num_words[22] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'x') {
      num_words[23] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'y') {
      num_words[24] += 1;
    }
  }
  for (i = 0; i < length; i++) {
    if (a[i] == 'z') {
      num_words[25] += 1;
    }
  }
  for (i = 0; i < 26; i++) {
    dame += (num_words[i]*(num_words[i]-1))/2;
  }
  long long ans = length*(length-1)/2 + 1 - dame;
  printf("%lld\n", ans);
  return 0;
}


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

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

    vector<int> A(N);
    int64_t sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        sum += A.at(i);
    }
    sort(A.rbegin(), A.rend());

    int res = 1;
    int Ap = A.at(0);
    for (int i = 1; i < N; i++)
    {
        sum -= Ap;
        if (Ap > sum * 2)
        {
            break;
        }
        res++;
        Ap = A.at(i);
    }
    cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

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

    //write here
    ll X,Y;
    cin >> X >> Y;
    cout << X + Y / 2;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
  static void Main()
  {
	string[] line = Console.ReadLine().Trim().Split();
    int first = int.Parse(line[0]);
    int second = int.Parse(line[1]);
    int third = int.Parse(line[2]);

    int result = first + second + third;
    string output = result < 22 ? "win" : "bust";
    Console.WriteLine(output);
  }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>

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

using namespace std;

int n;
int p[100];

int main(){
	cin >> n;
	rep(i, n * (n - 1) / 2){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		--a;
		--b;
		if(c == d){
			--p[a];
			--p[b];
		}
		else{
			if(c < d){
				swap(a, b);
			}
			p[a] -= 3;
		}
	}

	vector<int> v(p, p + n);
	sort(v.begin(), v.end());
	rep(i, n){
		cout << lower_bound(v.begin(), v.end(), p[i]) - v.begin() + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <limits>
 
using namespace std;
 
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
 
    int n;
    cin >> n;

    vector<long long> a(3*n, 0);
    multiset<long long> left, right, deleted;
    for(int i = 0; i < 3*n; ++i){
        cin >> a[i];
    }
 
    for(int i = 0; i < n; ++i){
        left.insert(a[i]);
    }

    vector<long long> b(n*2, 0);
    for(int i = n; i < 3*n; ++i){
        b[i-n] = a[i];
    }
    sort(b.begin(), b.end());

    for(int i = 0; i < n; ++i){
        right.insert(b[i]);
    }
    for(int i = 0; i < n; ++i){
        deleted.insert(b[i+n]);
    }

    long long left_sum = 0;
    long long right_sum = 0;

    for(auto x : left) {
        left_sum += x;
    }
    for(auto x : right) {
        right_sum += x;
    }

    long long max_score = left_sum - right_sum;

    for(int i = n; i < 2*n; ++i){
        // left
        left_sum+=a[i];
        left.insert(a[i]);
        long long left_min = *left.begin();
        left.erase(left.find(left_min));
        left_sum -= left_min;

        // right;
        if (right.find(a[i]) != right.end()) {
            right.erase(right.find(a[i]));
            right_sum -= a[i];
            long long deleted_min = *deleted.begin();
            right.insert(deleted_min);
            right_sum += deleted_min;
            deleted.erase(deleted.find(deleted_min));
        } else {
            deleted.erase(deleted.find(a[i]));
        }

        max_score = max(max_score, left_sum - right_sum);
    }

    cout << max_score;
    return 0;
}


Measured memory_bytes: 18176
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = inputI()
A = inputIL()

dic = [[INF,0]]

for i in range(N):
  dic.append([A[i],i+1])

dic.sort(reverse=True)

table = [[0 for i in range(N+1)] for j in range(N+1)]


for n in range(1,N+1):
  for i in range(n+1):
    if i == 0:
      table[n][0] = table[n-1][0] + dic[n][0] * (dic[n][1] -n)
    elif i == n:
      table[0][n] = table[0][n-1] + dic[n][0] * (N -(n-1) - dic[n][1])
    else:
      table[n-i][i] = max(table[n-i-1][i] + dic[n][0] * (dic[n][1] -(n-i)), table[n-i][i-1] + dic[n][0] * (N -(i-1) - dic[n][1]))
  
m = 0
for i in range(0,N+1):
  m = max(m,table[N-i][i])
  
print(m)

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

int main() {
    int n;
    cin>>n;
    int a[n],dp[n+1];
    for(int i=0;i<n;i++)
        cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 4340
mod = 10**9+7
n = int(input())
*A, = map(int, input().split())
X = [0, 0, 0]
cnt = 1
for a in A:
    cnt = cnt*X.count(a) % mod
    for i in range(3):
        if X[i] == a:
            X[i] += 1
            break
print(cnt % mod)


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

using namespace std;

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

int N, M, L, R, D, check = 0;
int loc[100005];
vector<pi> AdjList[100005];

void dfs(int x, int p){
	if (check) return;
	if (p == -1) loc[x] = 0;
	for (auto it : AdjList[x]){
		if (loc[it.first] == -1e9-1){
			loc[it.first] = loc[x] + it.second;
			dfs(it.first,x);
		}
		else if (loc[it.first] != loc[x] + it.second){
			check = 1;
			return;
		}
		if (check == 1) return;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= N; ++i){
		loc[i] = -1e9-1;
	}
	for (int i = 1; i <= M; ++i){
		cin >> L >> R >> D;
		AdjList[L].push_back(pi(R,D));
		AdjList[R].push_back(pi(L,-D));
	}
	for (int i = 1; i <= N; ++i){
		if (loc[i] == -1e9-1){
			dfs(i,-1);
		}
	}
	if (check == 1) cout << "No\n";
	else cout << "Yes\n";
	cout << flush;
}

Measured memory_bytes: 12928
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    if(a==b){
        printf("%d",c);
        return 0;
    }
    else if(a==c){
        printf("%d",b);
        return 0;
    }
    else if(b==c){
        printf("%d",a);
        return 0;
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

ll ans=0;
int n,k;

int main(){
  cin>>n>>k;
  int dp[100050][20];
  rep(i,n+1){
    rep(j,k+1){
      dp[i][j]=0;
    }
  }
  rep(i,n+1){
    dp[i][1]=1;
  }
  repi(i,2,k+1){
    repi(j,i-1,n+1){
      for(int k=2;k<=n;k++){
	if(j*k>n) break;

	else dp[j*k][i]+=dp[j][i-1];
      }
    }
  }
 
  ll ans=0;
  repi(i,1,n+1){
    ans+=dp[i][k];
  }
  cout<<ans<<endl;
  return 0;
}










Measured memory_bytes: 10864