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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, l, r;
string s;

int main() {
	cin >> n >> s;
	rep(i,s.length()) {
		if (s[i]=='(') {
			r++;
		}
		else {
			if (r>0) r--;
			else l++;
		}
	}
	
	rep(i,l) cout << '(';
	cout << s;
	rep(i,r) cout << ')';
	cout << ln;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0 
for i in range(n):
    ans += b[a[i]-1]
for i in range(n-1):
    if(a[i+1]-a[i]==1):
        ans += c[a[i]-1]

print(ans)


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int N) :parent(N, 0), rank(N, 0)
	{
		rep(i, 0, N)
		{
			parent[i] = i;
		}
	}

	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}

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

		if (x == y)
		{
			return;
		}

		if (rank[x] < rank[y])
		{
			parent[x] = y;
		}
		else
		{
			parent[y] = x;
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}

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

struct Edge
{
	int s, t, cost;
	Edge(int s, int t, int cost) :s(s), t(t), cost(cost) {}
	Edge() :Edge(-1, -1, -1) {}
	bool operator<(const Edge& e)const
	{
		return cost < e.cost;
	}
};

int N;
int OX[100010],OY[100010];
pii X[100010], Y[100010];

vector<Edge> edges;

int minimum_spaning_tree()
{
	sort(all(edges));
	UnionFind uf(N);

	int ans = 0;
	for (auto edge : edges)
	{
		if (!uf.same(edge.s, edge.t))
		{
			ans += edge.cost;
			uf.unite(edge.s, edge.t);
		}
	}

	return ans;
}

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

	cin >> N;
	rep(i, 0, N)
	{
		cin >> OX[i] >> OY[i];
		X[i].first = OX[i];
		Y[i].first = OY[i];
		X[i].second = Y[i].second = i;
	}

	sort(X, X + N);
	sort(Y, Y + N);

	rep(i, 0, N)
	{
		int idx = lower_bound(X, X + N, mp(OX[i], i)) - X;
		if (idx > 0)
		{
			edges.push_back(Edge(i, X[idx - 1].second, abs(X[idx - 1].first - OX[i])));
		}

		idx = lower_bound(Y, Y + N, mp(OY[i], i)) - Y;
		if (idx > 0)
		{
			edges.push_back(Edge(i, Y[idx - 1].second, abs(Y[idx - 1].first - OY[i])));
		}
	}

	int ans = minimum_spaning_tree();

	cout << ans << endl;

	return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N = 50000;
int sum [100001];

vector<int> sieve()
{
	deque<bool> is_prime(N + 1,true);
	vector<int> res;
	for(int i = 2;i <= N;i++) if(is_prime [i]){
		res.push_back(i);
		for(int j = i * 2;j <= N;j += i) is_prime [j] = false;
	}
	return res;
}

int main()
{
	vector<int> prime = sieve();
	FOR(i,0,prime.size()){
		FOR(j,i,prime.size()){
			sum [prime [i] + prime [j]]++;
		}
	}

	int P;
	while(scanf("%d",&P),P){
		printf("%d\n",sum [P]);
	}

	return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int x = in.nextInt();
		int y = in.nextInt();
		
		if (y > x) {
			int tmp = y;
			y = x;
			x = tmp;
		}
		
		while (y > 0) {
			int tmp = x%y;
			x = y;
			y = tmp;
		}
		
		System.out.println(x);
	}
}



Measured memory_bytes: 26328
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N];
multiset<int> S;

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	S.clear();
	for (int i=1;i<=n;i++) {
		auto it=S.lower_bound(a[i]);  //查找第一个大于等于a[i]的值 
		if (it!=S.begin()) S.erase(--it);  //(--it)就是小于a[i]且最大的值，a[i]将会替换它 
		S.insert(a[i]);
	}
	cout<<S.size()<<endl;
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
inline void input(){
    fast_io();
    cin >> N;
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b!=0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    }
    else{
        x = 1, y = 0;
    }
    return d;
}

void chmin(ll &a, ll b){if(a>b)a=b;}

ll solve(ll n){
    if(n==1) return 1;
    auto pf = prime_factor(2*n);
    ll k = 2*n;
    vector<ll> Pfs;
    for(auto [p,e]:pf) Pfs.push_back((ll)pow(p,e));
    int m = Pfs.size();
    for (int bit = 1; bit < (1<<m); bit++)
    {
        ll a = 1LL;
        for (int i = 0; i < m; i++)
        {
            if((bit>>i)&1LL) a *= Pfs[i];
        }
        ll b = 2*n/a;
        if(a==1LL || b==1LL) continue;
        ll x, y;
        extgcd(a,b,x,y);
        // debug(a,b,x,y);
        // if(x==0 || y==0) continue;
        if(x<0) chmin(k,-a*x);
        else chmin(k,-b*y);
    }
    return k;
}   

int main()
{
    input();
    cout << solve(N) << "\n";
    return 0;
}


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

const int INF = 100000;
int dp[310][310][310];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int A, B, C;
	cin >> A >> B >> C;

	fill((int*)begin(dp), (int*)end(dp), INF);
	dp[A][B][C] = 0;
	for(int i = 0; i < 300; i++){
		for(int j = 0; j < 300; j++){
			for(int k = 0; k < 300; k++){
				if(dp[i][j][k] != INF){
					int d = dp[i][j][k];
					dp[i + 1][j + 1][k] = d + 1;
					dp[i + 1][j][k + 1] = d + 1;
					dp[i][j + 1][k + 1] = d + 1;
					dp[i + 2][j][k] = d + 1;
					dp[i][j + 2][k] = d + 1;
					dp[i][j][k + 2] = d + 1;
				}
			}
		}
	}

	int ans = INF;
	for(int i = 0; i <= 300; i++){
		if(dp[i][i][i] != INF) ans = min(ans, dp[i][i][i]);
	}
	cout << ans << endl;
}


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

int main(){
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    vector<int> l,r;
    int i=0;
    while(i<s.size()){
        if(s.at(i)=='o'){
            l.push_back(i);
            i+=c;
        }
        if(l.size()==k) break;
        i++;
    }
    i=s.size()-1;
    while(i>=0){
        if(s.at(i)=='o'){
            r.push_back(i);
            i-=c;
        }
        if(r.size()==k) break;
        i--;
    }
    rep(i,k){
        if(l.at(i)==r.at(k-i-1)){
            cout<<l.at(i)+1<<endl;
        }
    }
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  if(S=="SUN")
    cout << 7 << endl;
  if(S=="SAT")
    cout << 1 << endl;
  if(S=="FRI")
    cout << 2 << endl;
  if(S=="THU")
    cout << 3 << endl;
  if(S=="WED")
    cout << 4 << endl;
  if(S=="TUE")
    cout << 5 << endl;
  if(S=="MON")
    cout << 6 << endl;
}


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

int main(){
    int n,a,b;
    cin>>n>>a>>b;

    int sum=0;
    for(int i=1;i<=n;i++){
        int dig=i/1000+(i/100)%10+(i%100)/10+i%10;
        if(i==10000){
            sum+=10000;

        }else if(dig<=b && dig>=a){
            sum+=i;

        }
    }
    cout<<sum<<endl;
}

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

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	rep(i, s.size()) {
        if(s[i]=='a') continue;
		if ('z' - s[i] + 1 <= k) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	if (k > 0)  s.back() = 'a'+(s.back()-'a' + k) % 26;
	cout << s << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int fibonacci(int n);

int F[45];

int main(){
	int n;

	scanf("%d", &n);

	printf("%d\n", fibonacci(n));

	return 0;
}

fibonacci(n){
	if(n == 1 || n == 0) return F[n] = 1;

	else if(F[n]) return F[n];

	return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

Measured memory_bytes: 596
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
long long p[1000000],q[1000000],r[1000000];
long long s[1000000];
bool cmp(long long a,long long b)
{
	return a>b;
}
int main()
{
	long long x,y,a,b,c,i,j;
	scanf("%lld %lld %lld %lld %lld",&x,&y,&a,&b,&c);
	for(i=0;i<a;i++) scanf("%lld",&p[i]);
	for(i=0;i<b;i++) scanf("%lld",&q[i]);
	for(i=0;i<c;i++) scanf("%lld",&r[i]);
	sort(q,q+b,cmp);sort(p,p+a,cmp);
	for(i=0;i<x;i++) s[i]=p[i];
	for(i=0;i<y;i++) s[i+x]=q[i];
	for(i=0;i<c;i++) s[i+x+y]=r[i]; 
	sort(s,s+x+y+c,cmp);
	long long sum=0;
	for(i=0;i<x+y;i++)
	{
		sum=sum+s[i];
	}
	printf("%lld",sum);
}

Measured memory_bytes: 13312
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
X = LI()
if 0 in X:
    X.remove(0)
    K -= 1

if K == 0:
    print(0)
    exit()
# 累積和を使う
distances = []
mid = bisect.bisect_left(X, 0)
#  print(mid)
#  if mid == 0:
#      # 正の数しかない
#      distances = [0]
#      for x in X:
#          distances.append(distances[-1] + x)
#      distances = distances[1:]
#  else:
#      # 負の数あり
#      negs = [0]
#      for x in X[:mid]:
#          # 負の数を足して逆にする
#          negs.append(negs[-1] + x)
#      negs = negs[::-1][:-1]
#      posi = [0]
#      for x in X[mid:]:
#          posi.append(posi[-1] + x)
#      posi = posi[1:]
#      distances = negs + posi

#  from itertools import accumulate
#  distances = list(accumulate(X))
for x in X:
    if x < 0:
        distances.append(-x)
    else:
        distances.append(x)
#  print('dist', distances)

#左端から右にずれていく。
results = []
for start in range(N):
    end = start + K
    if end > N: break
    #  print('start, end', start, end)
    #  if end >= len(X): break
    if start < mid < end:
        # 飛び越える場合
        results.append(min(distances[start], distances[end-1]) * 2 + max(distances[start], distances[end-1]))
    elif start >= mid:
        # 全部右側
        results.append(distances[end-1])
    else:
        results.append(distances[start])

#  print(results)
print(min(results))

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


int main()
{
    ll x;
    while(~scanf("%lld",&x))
    {
        ll i=1;
        while(1)
        {
            if((i+1)*i/2>=x) break;
            i++;
        }
        printf("%lld\n",i);
    }
}


Measured memory_bytes: 256
import sys
def main():
    readline = sys.stdin.readline
    write = sys.stdout.write

    def gcd(m, n):
        while n:
            m, n = n, m % n
        return m

    def init(p, q=1):
        g = gcd(p, q)
        return p//g, q//g
    def add(A, B):
        pa, qa = A
        pb, qb = B
        if pa == 0:
            return B
        if pb == 0:
            return A
        g = gcd(qa, qb)
        ra = pa*qb//g + pb*qa//g; rb = qa*qb//g
        g = gcd(ra, rb)
        return ra // g, rb // g

    INF = 10**18
    def cp(X):
        vw, pf, vf, th = X
        if vw == 0:
            return INF
        return th/vw
    while 1:
        N = int(readline())
        if N == 0:
            break
        pw = int(readline())
        P = [list(map(int, readline().split())) for i in range(N)]
        P.append((1, 0, 1, 0))
        P.sort(key=cp)
        A = [init(0)]*(N+1)
        B = [init(0)]*(N+1)
        a = b = init(0)
        a = init(pw)
        for i, (vw, pf, vf, th) in enumerate(P):
            if vw == 0:
                if th > 0:
                    b = add(b, (th*pf, vf))
                continue
            if vw > 0:
                if th^vw >= 0:
                    a = add(a, (-vw*pf, vf))
                    b = add(b, (th*pf, vf))
                    A[i] = init(vw*pf, vf)
                    B[i] = init(-th*pf, vf)
            else:
                if th^vw >= 0:
                    A[i] = init(-vw*pf, vf)
                    B[i] = init(th*pf, vf)
                else:
                    a = add(a, (-vw*pf, vf))
                    b = add(b, (th*pf, vf))
        ans = INF
        for i, (vw, pf, vf, th) in enumerate(P):
            if vw == 0:
                continue
            if th^vw < 0:
                continue
            a = add(a, A[i]); b = add(b, B[i])
            pa, qa = a; pb, qb = b
            v = (pa*th*qb + pb*vw*qa) / (vw * qa * qb)
            if ans + 0.01 < v:
                break
            ans = min(ans, v)
        write("%.016f\n" % ans)
main()


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int count = 1;
  if(a != b)
  {
    count++;
  }
  if(c != a && c != b)
  {
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	while (cin >> s) {
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '@') {
				for (int j = 0; j < s[i + 1] - '0'; j++) {
					cout << s[i + 2];
				}
				i += 2;
			}
			else cout << s[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
int a,b;cin>>a>>b;
string s1,t1;
rep(i,b)s1+=a+'0';
rep(i,a)t1+=b+'0';
if(s1<=t1)cout<<s1<<endl;
else cout<<t1<<endl;
}

Measured memory_bytes: 256
// abc128_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int A, P;
    cin >> A >> P;

    int x = A * 3 + P;
    int y = x / 2;

    print(y);
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int main(){
    int a,b;
    in(a);in(b);
    if(a%2!=b%2)printf("IMPOSSIBLE\n");
    else printf("%d\n",(a+b)/2);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *x, int *y)
{
    int t;
    
    t = *x;
    *x = *y;
    *y = t;
}

void sort(int *n)
{
    int i, j;
    
    for (i = 0; i < 5; i++) {
        for (j = 4; j > i; j--) {
            if (n[j] > n[j - 1])
                swap(&n[j], &n[j - 1]);
        }
    }
}

int main(void)
{
    int n[5], i;
    
    for (i = 0; i < 5; i++) {
        scanf("%d", &n[i]);
    }
    sort(n);
    for (i = 0; i < 5; i++) {
        printf("%d", n[i]);
        if (i != 4)
            printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define PI 3.141592653589793238
using namespace std;

int main(){
    int a,b;cin>>a>>b;
    int h,m;cin>>h>>m;
    long double angle_minute_hand=6*m;
    long double angle_hour_hand=30*h + 0.5*m;
    long double angle=max(angle_minute_hand,angle_hour_hand)-min(angle_minute_hand,angle_hour_hand);
    if(angle>180){
        angle=360-angle;
    }
    if(angle==180){
        printf("%.10f", (double)a+b);
        return 0;
    }
    if(angle==0){
        printf("%.10f", (double)abs(a-b));
        return 0;
    }
    long double dist=sqrt((a*a)+(b*b)-2*a*b*cos(angle*PI/180));
    printf("%20.20Lf",dist);
}


Measured memory_bytes: 4104
using System;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0, b = 0,c=0,count=0;
                           string[] str = Console.ReadLine().Split(' ');
                a = int.Parse(str[0]);
                b = int.Parse(str[1]);
                c = int.Parse(str[2]);

                for(;a<b+1;a++)
                {
                    if (c % a == 0)
                        count++;

                }
                Console.WriteLine("{0}",count);
            
        }
    }
    
}



Measured memory_bytes: 9252
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    string s, ans = "No";
    cin >> s;
    rep(i, s.size() - 1)if(s[i] == 'A' && s[i + 1] == 'C')ans = "Yes";

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n,c,k;
  cin >> n >> c >> k;
  int t[n];
  for(int i=0;i<n;i++){
    cin >> t[i];
  }

  sort(t,t+n);
  int temp,count=0,ans=0;
  bool ck=false;
  for(int i=0;i<n;){
    if(!ck){
      temp = t[i]+k;
      ck = true;
      ans++;
    }
    if((count < c) && (temp >= t[i])){
      count++;
      i++;
    }else{
      ck = false;
      count = 0;
    }
  }
  cout << ans;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0
o = a[0]
for i in a:
	s += b[i-1]
	if i-o == 1:
		s += c[o-1]
	o = i
print (s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vvi e(n);
    REP(_,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        e[a].pb(b);
        e[b].pb(a);
    }
    vi a(n,-1);
    a[0]=0;
    queue<int> que;
    que.push(0);
    while(que.size()){
        int t=que.front();que.pop();
        REP(i,e[t].size()){
            if(a[e[t][i]]==-1){
                a[e[t][i]]=a[t]+1;
                que.push(e[t][i]);
            }
        }
    }
    vi b(n,-1);
    b[n-1]=0;
    que.push(n-1);
    while(que.size()){
        int t=que.front();que.pop();
        REP(i,e[t].size()){
            if(b[e[t][i]]==-1){
                b[e[t][i]]=b[t]+1;
                que.push(e[t][i]);
            }
        }
    }
    int x=0,y=0;
    REP(i,n){
        if(a[i]<=b[i]){
            x++;
        }else{
            y++;
        }
    }
    if(x>y){
        cout<<"Fennec"<<endl;
    }else{
        cout<<"Snuke"<<endl;
    }
    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll X; cin >> X;
  for (ll a = 0; a <= 100; a++) {
    for (ll b = 0; b <= 100; b++) {
      ll t = a*a*a*a*a + b*b*b*b*b;
      if (t == X) {
	cout << a << " " << -b << endl;
	return 0;
      }
    }
  }
  for (ll a = 0; a <= 1000; a++) {
    for (ll b = 0; b <= 1000; b++) {
      ll t = a*a*a*a*a - b*b*b*b*b;
      if (t == X) {
	cout << a << " " << b << endl;
	return 0;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[205],n;
	cin>>n;
	for(int i=0;i<2*n;i++)
		cin>>a[i]; 
	sort(a,a+2*n);
	int count=0;
	for(int i=0;i<2*n;i+=2)
		count+=a[i];
	cout<<count;
	return 0;
} 


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, y;
    cin >> n >> y;
    y /= 1000;
    
    for (int a = 0; a <= n; a++) {
        for (int b = 0; b <= n; b++) {
            int now = a*10 + b*5;
            int res = y - now;
            if (res < 0 || res != (n - a - b)) continue;
            else {
                cout << a << " " << b << " " << res << endl;
                return 0;
            }
        }
    }
    
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int parent[N];
pair < int , int > X[N];
pair < int , int > Y[N];
pair < int , int > points[N];

int getP(int u){
    if(u == parent[u])
        return parent[u];
    return parent[u] = getP(parent[u]);
}

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        int x, y;
        scanf("%d%d" , &x , &y);
        points[i] = {x , y};
        X[i] = {x , i};
        Y[i] = {y , i};
        parent[i] = i;
    }
    sort(X + 1 , X + n + 1);
    sort(Y + 1 , Y + n + 1);
    long long ans = 0;
    vector < pair < int , pair < int , int > > > MST;
    for(int i = 1; i < n; i++){
        int dX = X[i + 1].first - X[i].first;
        int dY = Y[i + 1].first - Y[i].first;
        MST.push_back({dX , {X[i + 1].second , X[i].second}});
        MST.push_back({dY , {Y[i + 1].second , Y[i].second}});
    }
    sort(MST.begin() , MST.end());
    for(int i = 0; i < MST.size(); i++){
        int u = MST[i].second.first;
        int v = MST[i].second.second;
        int dist = MST[i].first;
        u = getP(u);
        v = getP(v);
        if(u == v)
            continue;
        ans += dist;
        parent[v] = u;
    }
    printf("%lld\n" , ans);
}


Measured memory_bytes: 7540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;
	ul temp;
	cin >> n;
	ul mi = 1000000001, ma = 0;
	rep(i, n){
		cin >> temp;
		chmax(ma, temp);
		chmin(mi, temp);
	}
	cout << ma - mi << endl;
}


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


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  vll x;
  cin >> n >> m;
  FOR(i, 0, m) {
	cin >> tmp;
	x.pb(tmp);
  }

  FOR(i, n, inf) {
	s = to_string(i);
	ok = true;
	FOR(j, 0, s.length()) {
	  FOR(k, 0, x.size()) {
		if (s[j] - '0' == x[k]) {
		  ok = false;
		}
	  }
	}

	if (ok) {
	  ans = i;
	  break;
	}
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
	string s;
	while ( cin >> s ) {
		int change = 0;
		int ss = s.size();
		
		for (int i = 0; i < ss; ++i) {
			if ( s[i] == i%2 + 48 ) change++ ;
		}
		
		change = min( change, ss-change );
		
		cout << change << '\n';
	}
	return 0;
}

Measured memory_bytes: 512
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n>>k;
     p=n*2;
     l=n*4;
     if(k>=p && k<=l && k%2==0){
        cout<<"Yes"<<endl;
     }
     else{
        cout<<"No"<<endl;
     }


     return EXIT_SUCCESS;
}


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

typedef array<int,10000> Int;
typedef long long ll;

#define CR const &

Int gen(int x){
    Int res;
    res.fill(0);
    for (int i = 2; i <= x; i++){
        if (x%i == 0){
            int c = 0;
            while (x%i == 0)x /= i, c++;
            res[i] = c;
        }
    }
    return res;
}

ll rev(Int CR x){
    ll res = 1;
    for (int i = 0; i < 10000; ++i) {
        for (int j = 0; j < x[i]; ++j) {
            res *= i;
        }
    }
    return res;
}

Int mul(Int a, Int CR b){
    for (int i = 0; i < 10000; ++i) {
        a[i] += b[i];
    }
    return a;
}

Int div(Int a, Int CR b){
    for (int i = 0; i < 10000; ++i) {
        a[i] -= b[i];
    }
    return a;
}

Int gcd(Int a, Int CR b){
    for (int i = 0; i < 10000; ++i) {
        a[i] = min(a[i], b[i]);
    }
    return a;
}

Int lcm(Int a, Int CR b){
    for (int i = 0; i < 10000; ++i) {
        a[i] = max(a[i], b[i]);
    }
    return a;
}

Int d[20], v[20];

int main(int argc, char ** argv) {
    int n;
    while (cin >> n && n){
        Int l1;
        l1.fill(0);
        for (int i = 0; i < n; ++i) {
            ll dd, vv;
            cin >> dd >> vv;
            d[i] = gen(dd);
            v[i] = gen(vv);
            l1 = lcm(l1, v[i]);
        }
        Int l2;
        l2.fill(0);
        for (int i = 0; i < n; ++i) {
            l2 = lcm(l2, div(mul(d[i],l1) , v[i]));
        }
        for (int i = 0; i < n; ++i) {
            Int ans = div(mul(v[i], l2), mul(d[i], l1));
            cout << rev(ans) << endl;
        }
    }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
template <class T> void chmax(T &x, T y) { if (x < y) x = y; }
int main() {
    int N; cin >> N;
    vector<int> V(1 << 18), W(1 << 18);
    for (int i = 1; i <= N; i++) cin >> V[i] >> W[i];
    int Q; cin >> Q;
    vector<int> v(Q), L(Q);
    for (int i = 0; i < Q; i++) cin >> v[i] >> L[i];
    array<vector<int>, 512> A;
    for (int i = 1; i < A.size(); i++) {
        auto &vec = A[i];
        vec.resize(1e5 + 1);
        int t = i;
        array<int, 9> items = {};
        int cnt = 0;
        while (t > 0) {
            items[cnt++] = t;
            t /= 2;
        }
        for (int bits = 0; bits < (1 << cnt); bits++) {
            int weight = 0, value = 0;
            for (int j = 0; j < cnt; j++) if (bits & (1 << j)) {
                weight += W[items[j]];
                value += V[items[j]];
            }
            if (weight < vec.size()) chmax(vec[weight], value);
        }
        for (int i = 1; i < vec.size(); i++) {
            chmax(vec[i], vec[i - 1]);
        }
    }
    for (int i = 0; i < Q; i++) {
        if (v[i] < (1 << 9)) {
            cout << A[v[i]][L[i]] << '\n';
        } else {
            array<int, 9> items = {};
            int t = v[i];
            int j = 0;
            while (t >= (1 << 9)) {
                items[j++] = t;
                t /= 2;
            }
            int ans = 0;
            for (int bits = 0; bits < (1 << 9); bits++) {
                int weight = 0, value = 0;
                for (int j = 0; j < 9; j++) if (bits & (1 << j)) {
                    weight += W[items[j]];
                    value += V[items[j]];
                }
                if (weight <= L[i]) {
                    chmax(ans, value + A[t][L[i] - weight]);
                }
            }
            cout << ans << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 206476
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ld n;
    cin >> n;
    ld s1 = n / 3;
    ld sum = s1 * s1 * s1;
    cout << fixed << setprecision(12) << sum << endl;

    return 0;
}


Measured memory_bytes: 3780
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	//cout << A;
	int k = 1;
	int ans = 0;
	rep(i, N) {
		int a = A[i];
		if (a == k)
			++k;
		else {
			ans += (a - 1) / k;
			A[i] -= (a - 1) / k * k;
			if (A[i] == 1 && k == 1)
				++k;
		}
	}
	//cout << A;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<vector<int>> v(n);
	int t = 0;
	rep(i, n - 1)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		v[a].push_back(b);
		v[b].push_back(a);
		if (v[a].size() > 1)t = a;
	}
	vector<int> c(n); rep(i, n)cin >> c[i];
	sort(all(c), greater<int>());
	vector<bool> used(n);
	queue<int> q;
	q.push(t);
	used[t] = true;
	vector<int> res(n);
	res[t] = c[0];
	int i = 1;
	int s = 0;
	while (!q.empty())
	{
		int now = q.front();
		q.pop();
		for (int next : v[now])
		{
			if (used[next])continue;
			used[next] = true;
			res[next] = c[i];
			s += c[i];
			++i;
			q.push(next);
		}
	}
	cout << s << endl;
	rep(i, n)cout << res[i] << " ";

}

Measured memory_bytes: 3952
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		long n 	= Long.parseLong(scanner.nextLine());
		long ans = 0;

		for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		}

		System.out.println(ans);



	}
}

Measured memory_bytes: 35552
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 100 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

ll x,k,d;

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> x >> k >> d;

    x = abs(x);
    ll m = x % d;

    if(x/d + 1 <= k) {
        cout << (((x/d)&1) != (k&1) ? d - m : m);
    } else {
        cout << x - k * d;
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 3644
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

A.sort!.reverse!

bottom = 0
ticket = 0
lte = (0...N).find{|i|
	msb = A[i].bit_length
	next true if msb <= bottom
 	ticket += msb - bottom
	if M < ticket
		up = (ticket-M+i)/(i+1)
		bottom += up
		ticket -= up*(i+1)
	end
	false
}||N
lte.times.each{|i|
	A[i] >>= A[i].bit_length - bottom
}
lt = (lte...N).find{|i|
	A[i].bit_length < bottom
}||N
lt.times.sort_by{|i| -A[i] }.take(M-ticket).each{|i|
	A[i] >>= 1
} if ticket < M

p A.inject(&:+)


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

const int maxn=2e5+10;
int prime[maxn],tot;
int vis[maxn];
void init(){
    tot=0;
    for(int i=2;i<maxn;i++){
        if(!vis[i]){
            prime[++tot]=i;
        }
        for(int j=1;j<=tot;j++){
            if(1ll*i*prime[j]>=maxn)break;
            vis[i*prime[j]]=1;
            if(i%prime[j]==0)break;
        }
    }
    //for(int i=1;i<=tot;i++)printf("%d\n",prime[i]);
}
signed main(){
    int x;
    init();
    scanf("%d",&x);
    for(int i=1;i<=tot;i++){
        if(prime[i]>=x){
            printf("%d\n",prime[i]);
            return 0;
        }
    }
    return 0;
}


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

#define int long long int
#define MOD 1000000007

char get(char ch)
{
    if(ch == 'r')
        return 'p' ;
    else if(ch == 'p')
        return 's' ;
    else
        return 'r' ;
}

int getp(char ch, int r, int s, int p)
{
    if(ch == 'r')
        return r ;
    else if(ch == 's')
        return s ;
    else
        return p ;
}

void solve()
{
    int n, k ;
    cin >> n >> k ;
    int r, s, p ;
    cin >> r >> s >> p ;
    string t ;
    cin >> t ;
    int ans = 0 ;
    string a;
    for(int i = 0 ; i < (int)t.length() ; i++)
    {
        if(i < k)
        {
            char ch = get(t[i]) ;
            a += ch ;
            ans += getp(ch, r, s, p) ;
            continue ;
        }
        char prev = a[i-k] ;
        char cur = get(t[i]) ;
        if(prev != cur)
        {
            ans += getp(cur, r, s, p) ;
            a += cur ;
            continue ;
        }
        else
        {
            a += (char)('a' + rand() % 14) ;
        }
    }
    //cout << a << endl ;
    cout << ans << endl ;
}

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

    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 640
fun main(args:Array<String>) {
    val (s,e,n) = readLine()!!.split(" ").map{ it.toLong() }
    (s..e).take(n.toInt())
        .plus( (s..e).reversed().take(n.toInt()) )
        .distinct()
        .sorted()
        .forEach { println(it) }
}

Measured memory_bytes: 37740
#include <iostream>

using namespace std;

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

    if(a+b>a-b){
        if(a+b>a*b){
            cout << a+b;
        } else {
            cout << a*b;
        }
    } else {
        if(a-b>a*b){
            cout << a-b;
        } else {
            cout << a*b;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef unsigned long long ll;
using namespace std;
ll dp[100009][15];
const ll mod=1e9+7;
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    ll n,k,ans=0,i,j;
    string s;
    cin>>s;
    n=s.size();
    if(s[0]=='?')
    {
        for(i=0;i<=9;i++)
        {
            dp[0][i]=1;
        }
    }
    else
    {
        dp[0][s[0]-'0']=1;
    }
    for(i=1;i<n;i++)
    {
        if(s[i]=='?')
        {
            for(j=0;j<=12;j++)
            {
                for(k=0;k<=9;k++)
                {
                    dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]%mod + dp[i-1][j]%mod)%mod;
                }
            }
        }
        else
        {
            for(j=0;j<=12;j++)
            {
                ll x=s[i]-'0';
                dp[i][(j*10+x)%13]=(dp[i][(j*10+x)%13]%mod+ dp[i-1][j]%mod)%mod;
            }
        }
    }
//    for(i=0;i<n;i++)
//    {
//        for(j=0;j<=12;j++)
//        {
//            cout<<dp[i][j]<<' ';
//        }
//        cout<<endl;
//    }
    cout<< dp[n-1][5] <<endl;
    return 0;
}


Measured memory_bytes: 15448
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
    n: usize, k: usize,
    h: [i32; n]
  };

  let mut dp = vec![std::i32::MAX; n];
  dp[0] = 0;
  for i in 0..n {
    for j in i+1..min(i+k+1,n) {
      dp[j] = min(dp[j], dp[i]+(h[i]-h[j]).abs());
    }
  }

  println!("{}", dp[n-1]);
}

Measured memory_bytes: 6396
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int[] num;
    int n;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n!=0){
		num = new int[n];
		for(int i=0; i<n; i++)
		    num[i] = sc.nextInt();
		sort();
	    }
	}
    }

    void sort(){
	for(int i=0; i<n; i++){
	    int j=i;
	    while(j>=1 && num[j-1]>num[j]){
		int tmp = num[j];
		num[j] = num[j-1];
		num[j-1] = tmp;
		j--;
	    }
	    show();
	}
    }

    void show(){
	StringBuffer sb = new StringBuffer();
	sb.append(num[0]);
	for(int i=1; i<num.length; i++)
	    sb.append(" "+num[i]);
	System.out.println(sb.toString());
    }
}

Measured memory_bytes: 24336
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();

        int[][] xy = new int[n][2];
        int[] a    = new int[n];

        for(int i=0; i<n; i++) {
            xy[i][0] = sc.nextInt(); // w
            xy[i][1] = sc.nextInt(); // h
            a[i]     = sc.nextInt();
        }
        sc.close();

        int cw = 0;
        int ch = 0;

        for(int i=0; i<n; i++) {
            switch(a[i]) {
                case 1:
                    cw = Math.max(cw, xy[i][0]);
                    break;
                case 2:
                    w = Math.min(w, xy[i][0]);
                    break;
                case 3:
                    ch = Math.max(ch, xy[i][1]);
                    break;
                case 4:
                    h = Math.min(h, xy[i][1]);
                    break;
            }
        }

        int sq = Math.max((w-cw), 0) * Math.max((h-ch), 0);
        System.out.println(sq);
    }
}


Measured memory_bytes: 23892