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

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

double x[100],y[100];
int N;
double mag = 10;
double memo[205][205];
double x_max = 1000;
double y_max = 1000;
double x_min = 0;
double y_min = 0;

double search(double cx, double cy){
    double ret = 0;
    for (int i = 0;i < N;i++){
        double dist = (cx-x[i])*(cx-x[i])+(cy-y[i])*(cy-y[i]);
        ret = max(ret,dist);
    }
    return ret;
}

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

    cin >> N;
    for (int i = 0;i < N;i++){
        cin >> x[i] >> y[i];
    }

    for (int pre= 0;pre < 1500;pre++){
        double m = 1e10;
        int ni,nj;
        for (int i = 0;i <= 100;i++){
            for (int j = 0;j <= 100;j++){
                memo[i][j] = search(x_min+i*mag, y_min+j*mag);
                if(memo[i][j] < m){
                    m = memo[i][j];
                    ni = i; nj = j;
                }
            }
        }
        x_min = x_min+(ni)*mag - mag*0.5*50;
        y_min = y_min+(nj)*mag - mag*0.5*50;
        mag *= 0.5;
    }

    printf("%.30f\n",sqrt(search(x_min+mag*50,y_min+mag*50)));

    return 0;

}

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

int main() {
    std::string S;
    std::cin >> S;
    int res;
    if (S == "RRR") res = 3;
    else if (S == "SRR" || S == "RRS") res = 2;
    else if (S == "SSS") res = 0;
    else res = 1;
    std::cout << res << '\n';
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a,b,c,d,e;
  cin>>a>>b;
  c=a+b;
  d=a-b;
  e=a*b;
  ll ans=c;
  if(ans<d)ans=d;
  if(ans<e)ans=e;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        void Omame()
        {
            cin = new Scanner();
            int n = cin.nextInt();
            List<int> a = new List<int>();
            List<int> b = new List<int>();
            List<int> c = new List<int>();
            for (int i = 0; i < n; i++)
            {
                a.Add(cin.nextInt());
                b.Add(cin.nextInt());
                c.Add(cin.nextInt());
            }

            List<int[]> ans = new List<int[]>();
            ans.Add(new int[3] { a[0], b[0], c[0] });

            for (int i = 1; i < n; i++)
            {
                ans.Add(new int[3]);
                ans[i][0] = Math.Max(ans[i - 1][1] + a[i], ans[i - 1][2] + a[i]);
                ans[i][1] = Math.Max(ans[i - 1][0] + b[i], ans[i - 1][2] + b[i]);
                ans[i][2] = Math.Max(ans[i - 1][0] + c[i], ans[i - 1][1] + c[i]);
            }

            Console.WriteLine(Math.Max(Math.Max(ans[n - 1][0], ans[n - 1][1]), ans[n - 1][2]));
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 27968
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int a;
  int b;
  int c;
  int d;
  cin>>a>>b>>c>>d;
  if((a+b)>(c+d)){
    cout<<"Left"<<endl;
  }else if((a+b)==(c+d)){
    cout<<"Balanced"<<endl;
  }else{
    cout<<"Right"<<endl;
  }

  
    
}


Measured memory_bytes: 3604
#include<iostream>

using namespace std;

int main()
{ int N; cin >> N;
 int min_sum = N;
 for(int i = 0; i <= N; i++)
 {int m = N - i;
  int t = i;
  int a = 0;
  while(t > 0){ a += t % 6; t /= 6;}
  while(m > 0){ a += m % 9; m /= 9;}//進数表示の桁和計算
  
 if(a < min_sum)
 {min_sum = a ;}}
 
 cout << min_sum << endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 ten[25];



i64 dfs(i64 r,i64 l,i64 d){
  if(l >= r){
    return (d == 0) * (l == r ? 10 : 1);
  }
  i64 to = (ten[r] - ten[l]) / ten[l] / 9;
  int now = (d % 10 + 10) % 10;
  return dfs(r - 1,l + 1,(d - now * to) / 10) * (10 - now - (l == 1)) + 
    (now == 0 ? 0 : (dfs(r - 1,l + 1,(d + (10 - now) * to) / 10) * (now - (l == 1))));
}

int main(){
  ten[1] = 1;
  for(int i = 2;i < 25;i++) ten[i] = ten[i - 1] * 10;
  i64 D;
  cin >> D;
  if(D % 9 != 0){
    cout << 0 << endl;
    return 0;
  }
  i64 ans = 0;
  for(int i = 2;i <= 18;i++){
    ans += dfs(i,1,D / 9);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 座標数
		int N = sc.nextInt();

		//x
		int[] x = new int[N];
		//y
		int[] y = new int[N];
		//z(高さ)
		int[] h = new int[N];
		//各座標を配列に順に詰める
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}
		//x,yは1以上100以下の整数より100*100のループ
		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100; j++) {
				int H = 0;
				Boolean B = true;
				for (int k = 0; k < N; k++) {
					//配列のk番目の高さが0でない場合、z(高さ)を計算
					if (h[k] != 0) {
						H = h[k] + Math.abs(x[k] - i) + Math.abs(y[k] - j);
					}
				}
				for (int k = 0; k < N; k++) {
					//高さが0ならfalseしてループ継続
					if (h[k] != Math.max(H - Math.abs(x[k] - i) - Math.abs(y[k] - j), 0)) {
						B = false;
					}
				}
				if (B) {
					System.out.println(i + " " + j + " " + H);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 24332
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on
int A, B, K;

void solve()
{
  int ans = 0;
  int cnt = 0;
  for (int i = min(A, B); i >= 1; i--) {
    if (A % i == 0 && B % i == 0) cnt++;
    if (cnt == K) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

int main(void)
{
  cin >> A >> B >> K;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int cnt = 0;
    bool st = false;
    bool ron=false,lon=false;
    while(n--){
      string s;
      cin>>s;
      if(s=="lu") lon=true;
      if(s=="ru") ron=true;
      if(s=="ld") lon=false;
      if(s=="rd") ron=false;
      if(!st & ron&lon){
	++cnt;
	st=true;
      }
      else if(st & !ron & !lon){
	++cnt;
	st=false;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
from bisect import bisect_left
def sieve_of_eratosthenes(N):
    numbers = [n & 1 for n in range(N + 1)]
    numbers[1] = 0
    primes = [2]
    p = 1
    while True:
        while not numbers[p]:
            p += 2
        if p * p > N:
            for i in range(p, N + 1, 2):
                if numbers[i]:
                    primes.append(i)
            return primes
        primes.append(p)
        for i in range(p, N + 1, p):
            numbers[i] = 0
primes = sieve_of_eratosthenes(10 ** 5 + 3)
print(primes[bisect_left(primes, int(input()))])

Measured memory_bytes: 4240
//////////////////////////////
//////////////////////////////
////                      ////
////  Please give me AC!  ////
////  Please give me AC!  ////
////                      ////
//////////////////////////////
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
using  UM=unordered_map<char,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  vector<string> s(N);
  vector<UM> vec(N);
  vector<ll> so(10);
  for(ll i=0;i<N;i++){
    string str;
    cin>>str;
    for(ll i=0;i<10;i++){
      so.at(i)=str.at(i);
    }
    sort(so.begin(),so.end());
    for(ll i=0;i<10;i++){
      str.at(i)=so.at(i);
    }
    s.at(i)=str;
  }
  ll ans=0;
  sort(s.begin(),s.end());
  for(ll i=1;i<N;i++){
    ll count=1;
    while(s.at(i)==s.at(i-1)){
      count++;
      i++;
      if(i>=N){break;}
    }
    ans+=count*(count-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdint>
#include<algorithm>

struct block {
  int w, s;
  int64_t v;
};

bool operator< (block const& l, block const& r) {
  return l.w+l.s < r.w+r.s;
}

int const MAXN = 1000;
int const MAXW = 10000;
int const MAXS = 10000;

int64_t dp[MAXN][MAXW+MAXS+1];
int64_t const INF = (int64_t)1<<59;

block blks[MAXN];
int N;

int main() {
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> blks[i].w >> blks[i].s >> blks[i].v;
  }
  std::sort(blks, blks+N);
  int maxws = blks[N-1].w + blks[N-1].s;

  for(int s = 0; s <= MAXW; ++s) dp[0][s] = -INF;
  dp[0][0] = 0;
  dp[0][blks[0].w] = blks[0].v;
  for(int n = 1; n < N; ++n) {
    for(int s = 0; s < blks[n].w; ++s) dp[n][s] = dp[n-1][s];
    int ub = blks[n].w+blks[n].s;
    for(int s = blks[n].w; s <= ub; ++s) {
      dp[n][s] = std::max(dp[n-1][s], dp[n-1][s-blks[n].w] + blks[n].v);
    }
    for(int s = ub+1; s <= maxws; ++s) dp[n][s] = dp[n-1][s];
  }
  int64_t m = 0;
  for(int s = 0; s <= maxws; ++s) m = std::max(m, dp[N-1][s]);
  std::cout << m << std::endl;
  return 0;
}


Measured memory_bytes: 156416
N = int(input())
A = list(map(int, input().split()))
A.sort()
def divisors(n):
    div = set()
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div.add(A)
            else:
                B = n//A
                div.add(A)
                div.add(B)
        A += 1
    return div
div = list(divisors(A[0]) | divisors(A[1]))
m = 0
for x in div:
    count = 0
    for a in A:
        if a%x != 0:
            count += 1
        if count > 1:
            break
    if count <= 1:
        m = max(m, x)
print(m)

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    VI t(5);
    REP(i, 5) cin >> t[i];
    int t_last = 0;
    int t_min = 10;
    REP(i, 5) {
        if(t[i] % 10 <= t_min and t[i] % 10 > 0) {
            t_min = t[i] % 10;
            t_last = i;
        }
    }

    int ans = 0;
    REP(i, 5) {
        if(i == t_last) ans += t[i];
        else ans += (t[i] + 10 - 1) / 10 * 10;
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve()
{
    string a,b;
    cin>>a>>b;
    int s,t;
    cin>>s>>t;
    string u;
    cin>>u;
    if(u==a){
        s--;
    }else{t--;}
    cout<<s<<" "<<t<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Nikkei2019
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            Node[] nodes = new Node[n];
            for(int i = 0; i < n; i++)
            {
                nodes[i] = new Node();
            }
            for(int i = 0; i < n - 1 + m; i++)
            {
                int[] ab = ReadInts();
                int a = ab[0] - 1;
                int b = ab[1] - 1;
                nodes[a].outEdges.Add(b, true);
                nodes[b].inEdges.Add(a, true);
            }
            int[] parents = new int[n];
            int rootIndex = 0;
            for(int i = 0; i < n; i++)
            {
                if (nodes[i].inEdges.Count == 0)
                {
                    rootIndex = i;
                    break;
                }
            }
            Queue<int> queue = new Queue<int>();
            queue.Enqueue(rootIndex);
            parents[rootIndex] = 0;
            var visitedDict = new Dictionary<int,bool>();
            while (queue.Count > 0)
            {
                int index = queue.Dequeue();
                visitedDict.Add(index, true);
                foreach(int key in nodes[index].outEdges.Keys)
                {
                    nodes[key].inEdges.Remove(index);
                    if (nodes[key].inEdges.Count == 0)
                    {
                        parents[key] = index + 1;
                        queue.Enqueue(key);
                    }
                }
            }
            for(int i = 0; i < n; i++)
            {
                Console.WriteLine(parents[i]);
            }
        }

        class Node
        {
            public Dictionary<int, bool> inEdges;
            public Dictionary<int, bool> outEdges;
            public Node()
            {
                inEdges = new Dictionary<int, bool>();
                outEdges = new Dictionary<int, bool>();
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

const int MOD = 998244353 , _ = 2e5 + 7;
char str[_] , tmp[_]; int num[_] , N;

signed main(){
	scanf("%d %s" , &N , str); int ans = 0; reverse(str , str + N);
	for(int i = 1 ; i <= N ; ++i)
		if(N % i == 0 && (N / i % 2)){
			int cnt = 0;
			for(int j = N - 1 ; j >= N - i ; --j) cnt = (cnt * 2 + str[j] - '0') % MOD;
			for(int j = N - 1 ; j >= 0 ; --j) tmp[j] = j >= N - i ? str[j] : (tmp[j + i] ^ 1);
			bool flg = 1;
			for(int j = N - 1 ; flg && j >= 0 ; --j){
				flg &= !(tmp[j] == '1' && str[j] == '0');
				if(str[j] == '1' && tmp[j] == '0') break;
			}
			num[i] = cnt + flg;
		}
	for(int i = 1 ; i <= N ; ++i)
		if(N % i == 0 && (N / i % 2)){
			ans = (ans + 1ll * num[i] * 2 * i) % MOD;
			for(int j = 2 ; j * i <= N ; ++j)
				num[j * i] = (num[j * i] - num[i] + MOD) % MOD;
		}
	cout << ans; return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

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

	long long int a,ct=0;
	cin>>a;
	while(a>0)
	{
		a/=2; ct++;
	}
	cout<<(1ll<<ct)-1;
	
	return 0;	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			System.out.println(((a % 3 == 0) || (b % 3 == 0) || ((a + b) % 3 == 0)) ? "Possible" : "Impossible");
		}
	}
}


Measured memory_bytes: 23380
#include<stdio.h>
int main()
{
    unsigned long long int a,b,x,sum;
    while(scanf("%lld %lld %lld",&a,&b,&x)!=EOF)
    {
        sum=(b/x)-(a/x);
        if(a%x==0)
            printf("%lld\n",sum+1);
        else
            printf("%lld\n",sum);
        sum=0;
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

int f(const int& x){
	return x * x;
}

int main(){
	int d;
	while (std::cin >> d){
		int sum = 0;
		for (int i = 0; i < 600 / d; i++){
			sum += d * f(d*i);
		}
		std::cout << sum << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    int x,y;
    cin>>x>>y;
    int a[4]={};
    a[0]=y-x;
    a[1]=-y-x+1;
    a[2]=y+x+1;
    a[3]=-y+x+2;
    sort(a,a+4);
    for(int i=0;i<4;i++){
        if(a[i]>0){
            cout<<a[i]<<endl;
            return 0;
        }
    }
}   




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

int main(void){
    int n; cin >> n;
    bool graph[n][n];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) graph[i][j]=false;
    }
    for(int i=0; i<n; i++){
        int v,k; cin >> v >> k;
        for(int j=0; j<k; j++){
            int w; cin >> w;
            graph[v-1][w-1]=true;
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j) cout << " ";
            cout << graph[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3064
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define flash_all ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;



int main()
{
	flash_all;
	int i,j,cnt=0;
	string s,t;
	cin>>s>>t;
	for(i=0;i<s.size();i++){
			if(s[i]!=t[i]){
				cnt++;
			}
	}
	cout<<cnt<<nl;
	return 0;
}
//Happy Coding......

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

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

  int N; cin >> N;
  vector<int> T(N, 0);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    sum += T[i];
  }

  int M; cin >> M;
  for (int i = 0; i < M; i++) {
    int P; cin >> P;
    int X; cin >> X;
    P--;
    cout << (sum - T[P] + X) << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
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

n = int(input())

count = 0
a = factorization(n)
if n == 1:
  print(0)
  exit()
  
for i in range(len(a)):
  a[i][1] -= 1
  count += 1
  count_n = 2
  while a[i][1] > 0:
    a[i][1] -= count_n
    if a[i][1] >= 0:
      count += 1
    count_n += 1

print(count)


Measured memory_bytes: 9500
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
p = nin(n)
print(sum(p) - max(p) + max(p) // 2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h, w, dp[55][55];
    string s[55];
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> s[i];
    }

    dp[0][0] = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0 && j==0) continue;
            if(i==0){
                dp[i][j] = dp[i][j-1] + s[i][j]-'0';
            }else if(j==0){
                dp[i][j] = dp[i-1][j] + s[i][j]-'0';
            }else{
                dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + s[i][j]-'0';
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void chmax(T &a, T b) { a = max(a, b); }
template<typename T> void chmin(T &a, T b) { a = min(a, b); }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> s(n);
    rep(i,n) cin >> a.at(i);
    s.at(0) = a.at(0);
    for (int i = 1; i < n; ++i) s.at(i) = a.at(i) + s.at(i-1);
    ll ans = 1e15;
    rep(i, n-1) ans = min(ans, abs(s.at(n-1) - s.at(i) - s.at(i)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t K;
  cin >> K;
  vector<int64_t> result = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  while (true) {
    if (K <= static_cast<int64_t>(result.size())) {
      cout << result[K - 1] << endl;
      break;
    } else {
      K-= static_cast<int64_t>(result.size());
    }
    vector<int64_t> old;
    swap(result, old);
    for (int64_t &v : old) {
      for (int64_t d = -1; d <= 1; ++d) {
        if (v % 10 + d >= 0 && v % 10 + d < 10) {
          result.emplace_back(v * 10 + (v % 10 + d));
        }
      }
    }
  }
  // const int64_t L = static_cast<int64_t>(T.length());
  return 0;
}


Measured memory_bytes: 4616
import java.util.*;

public class Main {
	public static void main(String[] args){
 
        Scanner sc = null;
        sc = new Scanner(System.in);
        long ans = 0;
        long max = 0;
        long work = 0;
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            work = sc.nextLong();
            if (i != 0 && work < max) {
                ans += (max - work);
            }else if(work > max){
                max = work;
            }
        }
        sc.close();
        System.out.println(ans);   
      }
}

Measured memory_bytes: 58432
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let SA: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };
    let SB: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };
    let SC: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let mut S = vec![SA.clone(), SB.clone(), SC.clone()];
    for i in 0..2 {
        S[i].reverse();
    }
    let mut i = 0;
    while let Some(c) = S[i].pop() {
        i = match c {
            'a' => 0,
            'b' => 1,
            _ => 2
        };
    }

    let ans = if i == 0 { "A" } else if i == 1 { "B" } else { "C" };

    println!("{}", ans);
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if ((a - c) * (b - c) < 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3580
while True:
    data = map(int, raw_input().split())
    if data[0] == 0 and data[1] == 0:
        break
    else:
        for i in range(data[0]):
            if i % 2 == 0:
                if data[1] % 2 == 0:
                    print "#." * (data[1] / 2)
                else :
                    print "#." * (data[1] / 2) + "#"
            elif i % 2 == 1:
                if data[1] % 2 == 0:
                    print ".#" * (data[1] / 2)
                else :
                    print ".#" * (data[1] / 2) + "."
        print 

Measured memory_bytes: 6444
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val s = in.readLine()
    val k = in.readLine().toLong

    val words = split(s)
    val replaceCounts = words.map { word =>
      word.length / 2
    }

    val doubleWords = split(s + s)
    val doubleReplaceCounts = doubleWords.map { word =>
      word.length / 2
    }

    System.out.println(
      if (words.size * 2 == doubleWords.size) {
        k * replaceCounts.sum
      } else if (words.size == 1 && doubleWords.size == 1) {
        k * s.length / 2
      } else {
        replaceCounts.dropRight(1).sum +
          (k - 1) * doubleReplaceCounts.drop(replaceCounts.size - 1).dropRight(1).sum +
          replaceCounts.drop(1).takeRight(1).sum
      }
    )
  }

  def split(str: String): List[String] = {
    if (str.isEmpty) {
      Nil
    } else {
      val ch = str.charAt(0)
      str.takeWhile(ch == _) :: split(str.dropWhile(ch == _))
    }
  }
}


Measured memory_bytes: 27340
def main():
    s = int(input())
    numbers = [s]
    while True:
        next_number = 0
        if numbers[-1] % 2 == 0:
            next_number = numbers[-1] // 2
        else:
            next_number = numbers[-1] * 3 + 1
        if next_number in numbers:
            print(len(numbers) + 1)
            break
        else:
            numbers.append(next_number)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n; string s; cin>>n>>s;
	int ans=0;
	rep(i,n){
		int a[26]={},b[26]={},cnt=0;;
		rep(j,i+1) a[s[j]-'a']++;
		for(int j=i+1;j<n;j++) b[s[j]-'a']++;
		rep(i,26){
			if(a[i]>0 and b[i]>0) cnt++;
		}
		if(ans<cnt) ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}


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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	cout << (a + b - 3) / (a - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 2e5, MOD = 998244353, SIZE = 2e7, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n;
char c[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
deque<char> s;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(n)
    while(n) --n,
        s.push_front(c[n % 26]), n /= 26;
	FORALL(c, s) cout << c;
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで、intは2*10^9まで

int main() {
  int n, h=0;
  int64_t res=0;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(h>a[i]) res+=(h-a[i]);
    else h=a[i];
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 4400
import java.io.*;
import java.util.*;
class   Main       {
	public static void main(String[] args) 
	{
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int n = in.nextInt();
		int k=in.nextInt();
		int arr[]= new int[10001];
		arr= in.nextIntArray(n);
		Arrays.sort(arr);
		long ans=0;
		for(int i=n-k;i<n;i++)
			ans+=arr[i];
		
		w.println(ans);
		w.close();
	}
	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		public InputReader(InputStream st) {
			this.stream = st;
		}
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		
		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		
		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		
		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		
		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
		
	}
	
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int A[1000000], n;

int binarySearch(int key){
    int left = 0;
    int right = n;
    int mid;
    while(left < right){
        mid = (left + right) / 2;
        if(A[mid] == key) return 1;
        else if(key < A[mid]) right = mid;
        else if(key > A[mid]) left = mid + 1;
    }
    return 0;
}

int main(){
    int i, q, k, sum = 0;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &k);
        if(binarySearch(k)) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3544
#include <stdio.h>
int main(){
  int a,b,c,d,e;
  scanf("%d",&a);
  b=a/3600;
  c=a%3600;
  d=c/60;
  e=c%60;
  printf("%d:%d:%d\n",b,d,e);
  return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main()
{

    //freopen("input.txt", "r", stdin);


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

    int mx = 0, start;
    map< int,pair<int,int> > dp;
    for (int i = 0, x; i < n; ++i)
    {
        scanf("%d", &x);
        if (!dp.count(x - 1))
            dp[x] = {1, i};
        else
        {
            if (dp.count(x))
            {
                if (dp[x].first < dp[x - 1].first + 1)
                    dp[x] = {dp[x - 1].first + 1, i};
            }
            else
                dp[x] = {dp[x - 1].first + 1, i};
        }
        mx = max(mx, dp[x].first);
    }

    printf("%d", n - mx);

}


Measured memory_bytes: 12800
void main()
{
    long x = rdElem;

    Pair[] list;
    foreach (i; 0L .. 3000L)
    {
        list ~= Pair(i, i ^^ 5);
        if (i) list ~= Pair(-i, -i ^^ 5);
    }

    foreach (a; list)
    {
        foreach (b; list)
        {
            if (a.b - b.b == x)
            {
                writeln(a.a, " ", b.a);
                return;
            }
        }
    }
}

struct Pair
{
    long a, b;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 2820
using System;


class Program
{
    static void Main(string[] args)
    {
        var x = double.Parse(Console.ReadLine());
        double bank = 100;
        var cnt = 0;
       
        while (true)
        {
            cnt++;
            bank = Math.Floor(bank* 1.01);
            if (bank >= x)
            {
                Console.WriteLine(cnt);
                break;
            }

        }
    }
}


Measured memory_bytes: 27508
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll mod_div(ll a,ll b){
  ll tmp=MOD-2,c=b,ret=1;
  while(tmp>0){
    if(tmp&1){
      ret*=c;ret%=MOD;
    }
    c*=c;c%=MOD;tmp>>=1;
  }
  return a*ret%MOD;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  ll num = 1;
  for(ll i=1;i<n;i++){
    num *= i;
    num%=MOD;
  }

  vi rui(n+1);
  for(int i = 1;i < n;i++){
    rui[i] = (rui[i-1]+mod_div(num,i))%MOD;
  }
  ll ans = 0;
  for(int i=0;i<n-1;i++){
    ans += (A[i+1]-A[i])*rui[i+1];
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for (int i=(a); i<(b); i++)

int main(){
	int n, cnt=0;
	cin>>n;
	char s[n+1];
	cin>>s;
	For(i,0,n){
		if (strstr(s+i,"ABC")){
			cnt++;
			i=(int)(strstr(s+i,"ABC")-s);
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
x = [0] * 5
for i in range(5):
  x[i] = int(input())

k = int(input())

ans = 0
for i in range(5):
  for j in range(5):
    if (x[i] - x[j]) > k:
      print(':(')
      exit(0)

print('Yay!')

Measured memory_bytes: 61272
from fractions import gcd
def solve(L, R, A, B):
  return query(R, A, B) - query(L-1, A, B)
def query(N, A, B):  # num 1..N not div by A nor B
  return N - N/A - N/B + N/(A*B /gcd(A,B))
print solve(*map(int, raw_input().split()))


Measured memory_bytes: 34792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n, m;
    cin >> n >> m;
    priority_queue <int> products; 
    int x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        products.push(x);
    }
    for (int i = 0; i < m; i++) {
        int cur = products.top();
        products.pop();
        cur /= 2;
        products.push(cur);
    }
    ll ans = 0;
    while(!products.empty()) {
        ans += products.top();
        products.pop();
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 892
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int l = sc.nextInt();
    
    int x = Math.abs(l);
    int k = 1;
    
    for(int i=2; i<=n; i++){
      if(x>Math.abs(l+i-1)){
        x = Math.abs(l+i-1);
        k = i;
      }
    }
    
    int ans = 0;
    
    for(int i=1; i<=n; i++){
      if(i!=k){
        ans += (l+i-1);
      }
    }
    
    System.out.println(ans);
  }
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;

int main(void)
{
    IOS
    vector<int> a(5);
    REP(5) cin >> a[i];
    int k; cin >>k;
    reverse(ALL(a));

    REP(5) {
        FOR(j,i,5) {
            if (a[i] - a[j] > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;


    return 0;
}


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

using ll=long long;
using ld=long double;

void solve(){
	string s,t;
	cin>>s;
	cin>>t;
	int n=(int) s.length();
	int m=(int) t.length();
	int ans=0;
	for(int i=0;i<=n-m;i++){
		int cnt=0;
		for(int j=0;j<m;j++){
			if(i+j<n && s[i+j]==t[j]){
				cnt++;
			}
		}
		ans=max(cnt,ans);
	}
	cout<<(int) t.length()-ans;
	
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3656
<?php
$N=(int)fgets(STDIN);
$Ab=$As=explode(' ',trim(fgets(STDIN)));
 
for($i=0;$i<$N;$i++)
  for($j=$N-1;$i<$j;$j--)
    if($Ab[$j][1]<$Ab[$j-1][1]) list($Ab[$j],$Ab[$j-1])=[$Ab[$j-1],$Ab[$j]];
 
for($i=0;$i<$N;$i++){
  for($mini=$j=$i;$j<$N;$j++)
    if($As[$j][1]<$As[$mini][1]) $mini=$j;
  if($i!=$mini) list($As[$i],$As[$mini])=[$As[$mini],$As[$i]];
}
 
$diff=0;
for($i=0;$i<$N;$i++)
  if($Ab[$i]!=$As[$i]){$diff=1;break;}
 
$sAb=implode(' ',$Ab);
echo $sAb,PHP_EOL,'Stable',PHP_EOL;
if($diff) echo implode(' ',$As),PHP_EOL,'Not stable';
else echo $sAb,PHP_EOL,'Stable';
?>

Measured memory_bytes: 15464
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
	int d;

	while(cin >> d){
		int sum=0;
		for(int i=d; i<600; i+=d){
			sum += (i*i*d);
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0, x = 0;
    int tmp;
    ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];
	for (int i = 40; i >= 0; i--)
	{
		ll now = (ll)1 << i;
		if(x + now > k) continue;
		tmp = 0;
		REP(j , n){
			if(now & a[j]) tmp ++;
		}
		//cout << now << " " << tmp << " " << i << endl;
		if(tmp > n / 2) continue;
		else x += now; 
	}
	//cout << x << endl;
	REP(i, n){
		ans += x ^ a[i];
	}
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    int n;
    while(cin>>n){
        int num[300][3]={};
        rep(i,n){
            rep(j,3){
                cin>>num[i][j];
            }
        }
        
        int point[300]={};
        rep(i,3){
            rep(j,n){
                int flag=true;
                rep(k,n){
                    if(j!=k && num[j][i]==num[k][i]){
                        flag=false;
                    }
                }
                if(flag)point[j]+=num[j][i];
            }
        }
        
        rep(i,n){
            cout<<point[i]<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1164
from math import sqrt

def make_prime_list(n):
    if n < 2:
        return []
    numbers = [i for i in range(n)]
    numbers[1] = 0
    for number in numbers:
        if number > sqrt(n):
            break
        if number == 0:
            continue
        for non in range(2*number, n, number):
            numbers[non] = 0
    return [number for number in numbers if number != 0]

N = int(input())
MOD = 10**9 + 7

dictionary = {}
primes = make_prime_list(N+1)

for prime in primes:
    dictionary[prime] = 0
    x = prime
    while x <= N:
        dictionary[prime] += N // x
        x *= prime

answer = 1
for value in dictionary.values():
    answer *= value + 1
    answer %= MOD
print(answer)
    

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  vector <int> vec;
  for (int i = 0; i < 3; i++) {
    int x;
    cin >> x;
    vec.push_back(x);
  }
  sort(vec.begin(), vec.end());
  if (vec[0] == vec[1] && vec[1] != vec[2]) {
    cout << "Yes" << endl;
  } else if (vec[1] == vec[2] && vec[1] != vec[0]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256