akhauriyash/Code-Regression huggingface dataset:
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


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


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(b+1==d) cout<<0<<endl;
  else cout<<1<<endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if((B < C) || (D < A)){
    cout << 0 << endl;
  }else{
    cout << min(B,D) - max(A,C) << endl;
  }


}



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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int ans=0;
    int n;
    cin>>n;
    vector<string> s(n);
    vector<bool> bgnb(n),enda(n);
    int acnt=0,bcnt=0;
    for(int i = 0; i < n; i++)
    {
        cin>>s[i];
        if(s[i][0]=='B'){ 
            bgnb[i]=true;
            bcnt++;
        }
        if(s[i][s[i].size()-1]=='A'){
            enda[i]=true;
            acnt++;
        }
        for(int j = 0; j < s[i].size()-1; j++)
        {
            if(s[i][j]=='A' &&s[i][j+1]=='B') ans++;
        }
    }
    if(acnt==bcnt && acnt>0)
    {
        bool ok=false;
        for(int i = 0; i < n; i++)
        {
            if(bgnb[i]!=enda[i]) 
            {
                ok=true;
                break;
            }
        }
        ans+=min(acnt,bcnt);
        if(ok==false)
        {
            ans--;
        }
        
    }
    else
    {
        ans+=min(acnt,bcnt);
    }
    

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

Measured memory_bytes: 768
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, A, B = MI()
    X = LI()
    ans = 0

    for i in range(1, N):
        ans += min((X[i] - X[i-1]) * A, B)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63084
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
	int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
  long[] times = new long[n];//ここに受け取る
  for(int i = 0; i < n; i++) times[i] = long.Parse(Console.ReadLine());

  long answer = times[0];
    for(int i = 1; i < n; i++)
    {
      answer = answer / Gcd(answer,times[i]) * times[i];
    }
  
	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}

  static long Gcd(long a, long b) 
    {//引数a,bの最大公約数を返す
         if (a < b)
             return Gcd(b, a);//入れ替え
         while (b != 0) 
         {
             long changeTo = a % b;
             a = b;
             b = changeTo;
         }
         return a;
     }
}

Measured memory_bytes: 13140
# 初期入力
N = int(input())
H = list(map(int, input().split()))

#
dp_h =[0]*(N)

for i in range(1,N):
    h1 = abs( H[i] - H[i-1] )
    dp_h[i] = h1
    if 1<i:
        h2 = abs( H[i] - H[i-2] )
        dp_h[i] = min(dp_h[i-1] + h1 , dp_h[i-2] + h2)
        #print(dp_h)

print(dp_h[N-1])

Measured memory_bytes: 13928
def getMaxValue(s)
  v = s.split(//).sort.reverse
  max = ""
  v.each{|n|  max += n.to_s }
  return max.to_i
end

def getMinValue(s)
  v = s.split(//).sort
  min = ""
  v.each{|n|  min += n.to_s  }
  return min.to_i
end

$stdin.gets.to_i.times{
  input = $stdin.gets.chomp
  p getMaxValue(input) - getMinValue(input)
}

Measured memory_bytes: 6096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(Math.min(s.nextInt(),s.nextInt())+Math.min(s.nextInt(),s.nextInt()));
    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int		main(void)
{
	string S;

	cin >> S;
	int ans = 0;

	for (int i = 0; S[i]; i++)
	{
		int r = 0;
      
		while (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C')
		{
			r++;
			i++;
		}
		ans = max(ans, r);
	}
	cout << ans << endl;
}


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

int main(){
	volatile clock_t c = clock();
	string s;
	cin >> s;
	c += (s[1] - 'a' + 1) * 0.01 * CLOCKS_PER_SEC;
	while(clock() < c);
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}


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

int main() {
    int x, y;
    cin >> x >> y;
    bool flag = false;
    for (int i = 0; i <= x; i++) {
        if ((2 * i + 4 * (x - i)) == y) {
            flag = true;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> x;
  vector<ll> y;
  vector<ll> h;
  for(int i = 0;i < n;i++){
    ll nx,ny,nh;
    cin >> nx >> ny >> nh;
    if(nh > 0){
      x.push_back(nx);
      y.push_back(ny);
      h.push_back(nh);
    }
  }
  ll rx = 0;
  ll ry = 0;
  ll rh = 0;
  for(int i = 0;i <= 100;i++){
    for(int j = 0;j <= 100;j++){
      ll nowh = 0;
      nowh = h[0] + abs(i - x[0]) + abs(j - y[0]);
      bool ok = true;
      for(int k = 0;k < x.size();k++){
        if(h[k] != nowh - abs(i - x[k]) - abs(j - y[k]))ok = false;
      }     
      if(ok){
        rx = i;
        ry = j;
        rh = nowh;
      }
    }
  }
  //cout << h[0] << endl;
  if(x.size() == 1)rx = x[0],ry = y[0],rh = h[0];
  cout << rx << " " << ry << " " << rh << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
ll x, y, t, a;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    x = 1, y = 1;
    rep(i, 0, n) {
        cin >> t >> a;
        ll p = max(x%t ? x/t+1 : x/t, y%a ? y/a+1 : y/a);
        x = p * t, y = p * a;
    }
    cout << x + y << endl;
    return 0;
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
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 (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);
    ll r; cin>>r;

    cout<<2*PI*r<<endl;

    return 0;

}

Measured memory_bytes: 3792
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int left;
        static int right;

        static void Main(string[] args)
        {
            //[summary]C - Many Medians
            int N = int.Parse(Console.ReadLine());
            var X = ReadLine();

            GetMedians(X, N);

            for(int i = 0; i < N; i++)
            {
                int x = X[i];

                if (x <= left)
                {
                    Console.WriteLine(right);
                }
                else
                {
                    Console.WriteLine(left);
                }
            }            
        }

        static void GetMedians(List<int> X, int N)
        {
            var medians = new int[2];
            var sorted = X.OrderBy(x => x).ToList();

            left = sorted[N / 2 - 1];
            right = sorted[N / 2];
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 41336
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int main() {
	int T;
	cin >> T;
	rep(t, T) {
		vi input;
		int N = 0;
		while (true) {
			int a;
			cin >> a;
			if (a == 0)break;
			if (a > 0)N++;
			input.push_back(a);
		}
		vvi G(N);
		vi num(N, 0);
		num[0] = input[0];

		int pos = 0;
		int next = 1;

		stack<int> st;
		st.push(0);

		vector<set<int>> d(N);
		d[0].insert(0);

		int dist = 0;

		repl(i, 1, input.size()) {
			int x = input[i];

			/*
			cout << "num: ";
			rep(j, N) {
				cout << num[j] << " ";
			}cout << endl;
			cout << "pos: " << pos << endl;
			cout << "input: " << x << endl;
			*/

			while (num[pos] == 0) {
				st.pop();
				pos = st.top();
				dist--;
			}

			if (x > 0) {
				num[pos]--;
				G[pos].push_back(next);
				G[next].push_back(pos);

				pos = next;
				next++;
				dist++;
				d[dist].insert(pos);
				num[pos] = x - 1;
				st.push(pos);
			}
			else {
				int to = *d[dist + x].begin();
				while (num[to] == 0) {
					d[dist + x].erase(to);
					to = *d[dist + x].begin();
				}

				num[pos]--;
				num[to]--;
				G[pos].push_back(to);
				G[to].push_back(pos);
			}
		}

		rep(i, N) {
			cout << i + 1 << " ";
			sort(all(G[i]));
			rep(j, G[i].size()) {
				cout << G[i][j] + 1;
				if (j != G[i].size() - 1) {
					cout << " ";
				}
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

signed main(){
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()) cout << "GREATER" << endl;
    else if(a.size() < b.size()) cout << "LESS" << endl;
    else if(a == b) cout << "EQUAL" << endl;
    else if(a < b) cout << "LESS" << endl;
    else if(b < a) cout << "GREATER" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	string s; int n;
	set<string>st;
	map<string, vector<int>>m;
	while (cin >> s >> n) {
		st.insert(s);
		m[s].push_back(n);
	}
	for (auto i = st.begin(); i != st.end(); i++) {
		string str = *i;
		cout << str << endl;
		sort(m[str].begin(), m[str].end());
		for (int j = 0; j < m[str].size(); j++) {
			if (j)cout << ' '; cout << m[str][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

const int MOD = 1e9 + 7;

signed main(){

  int n; cin >> n;
  string s; cin >> s;

  vector<int> v(26, 1);
  for(int i = 0; i < n; i++){
    v[s[i] - 'a']++;
  }

  int ans = 1;
  for(int i = 0; i < 26; i++){
    ans = (ans * v[i]) % MOD;
  }
  cout << ans - 1 << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int p[800020];
int *a=p+400010;
int lcnt,rcnt;
int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		int t;
		scanf("%d",&t);
		if(t==0){
			int d,x;
			scanf("%d%d",&d,&x);
			if(d==0)a[--lcnt]=x;
			else a[rcnt++]=x;
		}else if(t==1){
			int x;
			scanf("%d",&x);
			printf("%d\n",a[lcnt+x]);
		}else{
			int d;
			scanf("%d",&d);
			if(d==0)lcnt++;
			else rcnt--;
		}
	}
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef priority_queue<int> Pr; typedef vector<int> V; typedef vector<P> Vp; typedef map<int,int> MP;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    Int n,m; string s,t; cin>>n>>m>>s>>t;
    Int l=n*m/__gcd(n,m);
    map<Int,int> p={};
    for (int i = 0; i < n; i++)p[i*(l/n)]=s[i]-'a'+1;
    for (int j = 0; j < m; j++){
        if(p[j*(l/m)]&&p[j*(l/m)]!=t[j]-'a'+1){cout<<-1<<'\n'; return 0;}
    }
    cout<<l<<'\n';
}

Measured memory_bytes: 10880
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        while(true){
            int k = f(n);
            boolean b = true;
            for (int i = 1; i <= k; i++){
                long a = (n / h(i)) % 10;
                if (a < 9 && (n - h(i)*(a+1) >= 0)){
                    n -= h(i)*(a+1);
                    b = false;
                }
            }
            if(b) {
                break;
            }
        }
        System.out.println(g(n));
    }
    private static int f(long k){
        int count = 1;
        while(k/10 != 0){
            k /= 10;
            count++;
        }
        return count;
    }

    private static int g(long n) {
        int ret = 0;
        for (int i = 1; i <= f(n); i++){
            ret += (n / h(i)) % 10;
        }
        return ret;
    }

    private static long h(int a){
        long ret = 1;
        for (int i = 1; i < a; i++){
            ret *= 10;
        }
        return ret;
    }
}

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

using namespace std;
bool comp(int a, int b){
	return a > b;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	vector<int> nums;
	int n;
	for(int i = 0; i < 3; i++){
		cin >> n;
		nums.push_back(n);
	}
	sort(nums.begin(), nums.end(), comp);
	cout << nums[1] + nums[2];
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	k := intScanner()
	sum := 0
	as := make([]int, n)
	fs := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = intScanner()
		sum += as[i]
	}
	for i := 0; i < n; i++ {
		fs[i] = intScanner()
	}
	sort.Ints(as)
	sort.Sort(sort.Reverse(sort.IntSlice(fs)))
	ng, ok := 0, 1000000000000
	for ok-ng > 1 {
		m := (ok + ng) / 2
		s := 0
		for i, v := range fs {
			s += smaller(m/v, as[i])
		}
		if s >= sum-k {
			ok = m
		} else {
			ng = m
		}
		if ok-ng == 1 {
			s := 0
			for i, v := range fs {
				s += smaller(ng/v, as[i])
			}
			if s >= sum-k {
				ok = ng
			}
		}
	}
	fmt.Println(ok)
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 6400
from functools import lru_cache
import sys

H,N = [int(i) for i in input().rstrip().split(' ')]
M = [[int(i) for i in input().rstrip().split(' ')] for _ in range(N)]

sys.setrecursionlimit(10**9)
DP = [0]*(H+1)

for x in range(1,H+1):
    DP[x] = min(DP[max(x-a,0)] + b for a,b in M)

print(DP[H])

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


int powmod(int n,int p){
  if(p==0)return 1;
  else if(p%2==0){
    return powmod(n*n%MOD,p/2)%MOD;
  }else{
    return n*powmod(n*n%MOD,(p-1)/2)%MOD;
  }
}
signed main(){
  int n,m;
  cin>>m>>n;
  cout<<powmod(m,n)<<endl;
  return 0;
}



Measured memory_bytes: 3068
N,D=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N)
0.upto(N-1){|d|
	A[d]=gets.chomp.split(' ').map{|n| n.to_i}
}
P = Array.new(1000) { |i|  }
i=1
P[0] = 1
while(i*i <= 1000*1000)
	P[i] = i*i
	i += 1
end
# p P
cnt = 0
for i in 0..(N-1)
	for j in (i+1)..(N-1)
		sum = 0
		for k in 0..(D-1)
			sum += (A[i][k]-A[j][k])*(A[i][k]-A[j][k])
		end
		# p sum
		P.index(sum).nil? ? 0 : cnt += 1
	end
end

puts cnt


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

// Light version
using Data = int;
const int len = 1 << 18;

struct BIT {
  vector<Data> data;
  BIT() : data(len, 0) {}
  void update(int i, Data value) {
    for (; i < len; i |= i+1) data[i] += value;
  }
  Data query(int i) {
    Data s = 0;
    for (; i >= 0; i = (i&i+1)-1) s += data[i];
    return s;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin>>n>>m;
  vector<tuple<int,int>> vp;
  REP(i,n) {
    int l,r;
    cin>>l>>r;
    vp.emplace_back(l, r);
  }
  sort(ALL(vp));
  reverse(ALL(vp));
  vecint res(m+1, n);
  BIT bit;
  auto itr = begin(vp);
  for(int i=m; i>0; --i) {
    for(int d=1;d*d <= i;++d) {
      if (i%d != 0) continue;
      res[d] -= bit.query(i+d-1);
      if (d*d == i) continue;
      res[i/d] -= bit.query(i+i/d-1);
    }
    for(; itr != end(vp); ++itr) {
      int l,r;
      tie(l,r) = *itr;
      if (l < i) break;
      bit.update(r, 1);
    }
  }
  FOR(d,1,m+1) {
    res[d] -= bit.query(d-1);
  }
  FOR(i,1,m+1) {
    cout<<res[i]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 2e5 + 5;

ll n;
ll a[nax], pref[nax];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
		pref[i] %= mod;
	}
	ll ans = 0;
	for(ll i = n; i >= 2; i--){
		ans += a[i] * pref[i-1] % mod;
		ans %= mod;
	}
	cout << ans << '\n';
	
	
}



Measured memory_bytes: 6768
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut count = 0;
    let mut is_yes = false;
    for _ in 0..n {
        let d1: usize = iterator.next().unwrap().parse().unwrap();
        let d2: usize = iterator.next().unwrap().parse().unwrap();
        if d1 == d2 {
            count += 1;
            if count >= 3 {
                is_yes = true;
                break;
            }
        } else {
            count = 0;
        }
    }

    if is_yes {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 2108
//package Beginner120;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        System.out.println(Math.min(c, b/a));
    }
}


Measured memory_bytes: 22736
#include <stdio.h>

int main(){
  int y,m,d;
  scanf("%d/%d/%d",&y,&m,&d);
  if(y<2019){ printf("Heisei\n");return 0; 
  }else if(y==2019){
    if(m<=4){ printf("Heisei\n");return 0;}
  }
  printf("TBD\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll sum = 0;
    FOR(i, 1, N+1) {
        ll d = digsum(i);
        if (A<=d && d<=B) sum += i;
    }
    cout << sum << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 100000
#define eps 1e-10
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) print("%.8lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
#define fst first
#define snd second
#define all(c) ((c).begin()), ((c).end())
#define TEST(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
using namespace std;
const long long INF = 99999999;
ll dp[100005][4];
int main(){
 
    string s;
    cin>>s;
    ll temp=1;
    int n=s.size();
    for(int i=1;i<=n;i++)
        if(s[i-1]=='A'){
            dp[i][0]=(dp[i-1][0]+temp)%mod;
            dp[i][1]=dp[i-1][1];
            dp[i][2]=dp[i-1][2];
        }else if(s[i-1]=='B'){
            dp[i][1]=(dp[i-1][0]+dp[i-1][1])%mod;
            dp[i][0]=dp[i-1][0];
            dp[i][2]=dp[i-1][2];
 
        }else if(s[i-1]=='C'){
            dp[i][2]=(dp[i-1][1]+dp[i-1][2])%mod;
            dp[i][1]=dp[i-1][1];
            dp[i][0]=dp[i-1][0];
 
        }else{
            dp[i][0]=(3LL*dp[i-1][0]+temp)%mod;
            dp[i][1]=(dp[i-1][0]+3LL*dp[i-1][1])%mod;
            dp[i][2]=(dp[i-1][1]+3LL*dp[i-1][2])%mod;
            temp=temp*3LL;
            temp%=mod;
 
        }
        cout<<dp[n][2]<<endl;
    }

Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <stdlib.h>
#include <time.h>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long
#define INF 2000000000

using namespace std;

int main() {
	char a, b;
	cin >> a >> b;
	if (a < b)cout << "<" << endl;
	else if (a == b)cout << "=" << endl;
	else cout << ">" << endl;
	return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    ll N;
    read(N);
    ll ans = LONG_LONG_MAX;
    for(ll i = 1; i * i <= N; i++){
        if(N % i != 0) continue;
        ans = min(ans, (ll)(i - 1 + N / i - 1));
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

struct Edge {int to; long long cost;};
struct Bedge { int from, to; long long cost; };

template<class T>
vector<T> Bell(const vector<vector<Edge>> &G, int s, T def) {
    int N = (int)G.size();
    vector<T> dist(N, def);
    vector<bool> negative(N);
    vector<Bedge> edges;
    for(int from = 0; from < N; ++from) {
        for(auto &e : G[from]) edges.push_back({from, e.to, e.cost});
    }
    dist[s] = 0;
    for(int loop = 0; loop < 2 * N - 1; ++loop) {
        for(auto &e : edges) {
            if(dist[e.from] == INF) continue;
            if(dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                if(loop > N - 1) negative[e.to] = true;
            }
            if(loop > N - 1 && negative[e.from]) negative[e.to] = true;
        }
    }
    for(int i = 0; i < N; ++i) {
        if(negative[i]) dist[i] = -INF;
    }
    return dist;
}

void solve() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<vector<Edge>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, P - c});
    }
    auto dist = Bell(G, 0, INF);
    long long ans = -dist[N - 1];
    if(ans == INF) cout << -1 << '\n';
    else if(ans < 0) cout << 0 << '\n';
    else cout << ans << '\n';
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()

int inf = 1e18;
const int N = 4e5+5;

/*void dfs(int u,int par,int maxx)
{


    for(int v:adj[u])
    {
        if(v==par)
            continue;
        dfs(v,u,maxx);
    }
}*/
vi freq(N);
vi arr(N);
vi dp(N);
bool help(int mid)
{


}


int32_t main()
{
    io
    int tt=1;
    //cin>>t;
    while(tt--)
    {
        int n;
        cin>>n;
      for(int i=1;i<=5000000;++i)
      {
          if(floor(1.08*i)==n)
          {
              cout<<i<<el;
              return 0;
          }
      }
      cout<<":(";
    }



        return 0;
}


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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

string s;
int n[26];
void solve();

int main() {

   solve();
   return 0;

}

void solve() {
	cin >>s;
	for(string::iterator it=s.begin();it<s.end();it++){
		n[*it-'a']++;
	}
	REP(i,26){
		if(n[i]>1){
			cout << "no" << endl;
			exit(0);
		}
	}
	cout << "yes" << endl;
	

}

Measured memory_bytes: 256
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;


const int MAXN = 1e5 + 20;

int n, m;
priority_queue<int> pq;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    cin >> n >> m;
    int a;
    for(int i = 1; i <= n; i++) {
		cin >> a;
		pq.push(a);
    }
    for(int i = 0; i < m; i++) {
    	a = pq.top();
    	pq.pop();
    	a /= 2;
    	pq.push(a);
    }
    long long res = 0;
    while(pq.size()) {
    	a = pq.top();
    	pq.pop();
    	res += a;
    }
    cout << res << endl;



    return 0;
}






















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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

vi to[200005];
vi ans;

void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}

int main() {
	int n, q; cin >> n >> q;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(n);
	int p, x;
	rep(i, q) {
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	dfs(0);
	rep(i, n) {
		cout << ans[i] << endl;
	}

}

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

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

   int a, b, c, x, y;
   scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);

   auto m = a * int64_t(x) + b * int64_t(y);
   for (auto i = 2; i <= 2*x + 2*y; i += 2)
   {
      auto p = c * int64_t(i);
      const auto left = max(0, x - i / 2), right = max(0, y - i / 2);
      p += a * int64_t(left);
      p += b * int64_t(right);
      m = min(m, p);
   }

   cout << m << '\n';

   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long K = sc.nextInt();

		long cnt = 0;
		for(long i = 1; i <= K; i++) {
			if((i + i) % K != 0) {
				continue;
			}
			if(i < K) {
				long c = (N+i)/K;
				cnt += c*c*c;
			}else {
				long c = N/K;
				cnt += c*c*c;
			}
		}

		System.out.println(cnt);
		sc.close();
	}

}

Measured memory_bytes: 23124
import math

inputted = list(map(int, input().split()))

N = inputted[0]
A = inputted[1]
B = inputted[2]

AB = A + B
remainder = N % AB

num_of_repeat = math.floor(N / AB) * A
num_of_remainder = min(A, remainder)
total = num_of_repeat + num_of_remainder

print(total)


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

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pr(a, b) pair<a, b>
#define si set<int>
#define sl set<long long>
#define pq prioirty_queue
#define all(v) v.begin(),v.end()
#define left (2*idx)+1
#define right (2*idx)+2
#define frt(i,a,b) for(ll i=a; i<b; i++)
#define rew(i,a,b) for(ll i=a; i>=b; i--)
#define fre(i,a,b) for(ll i=a; i<=b; i++)
#define pb push_back

#define test if(!true)
#define N 100007
#define MOD (ll)(1e9 + 7)

vi adj[N];
ll n, k;


ll dfs(ll i, ll P, ll cur)
{
    test cout << " In fun : " << i << " " << cur << "\n";
    ll cnt = adj[i].size() - 1 + (i == 1);
    ll tmp = cur;
    ll ans = 1;

    while(cnt--)
    {
        ans = (ans * tmp) % MOD;
        tmp-=1;
    }

    test cout << " Mid fun : " << i << ' ' << ans << "\n";
    for(auto j : adj[i])
    {
        if(j == P)
        {
            continue;
        }

        ll tmp1 = dfs(j, i, max(cur-1, k-2));
        ans = (ans * tmp1) % MOD;
    }

    test cout << " Out fun : " << i << ' ' << ans << "\n";
    return ans;
}

int main()
{
    cin >> n >> k;

    int m = n-1;
    while(m--)
    {
        int x, y;
        cin >> x >> y;;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    cout << (dfs(1, 1, k-1) * k) % MOD << "\n";
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const ll INF = 1e10;
ll dp[110][100100];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,W;
    cin >> N >> W;
    rep(i,110)rep(j,100100) dp[i][j] = INF;
    VLL v(N), w(N);
    rep(i,N) cin >> w[i] >> v[i];
    dp[0][0] = 0;
    rep(i,N){
      rep(j,100100){
        if(dp[i][j] != INF) dp[i+1][j+v[i]] = min(dp[i][v[i] + j], dp[i][j] + w[i]);
        dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
      }
    }
    ll ans = 0;

    rep(i,100100) if(dp[N][i] <= W) ans = i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 86272
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Name:- OMHARI 
  Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY)
  Email:- omharicu@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include<bits/stdc++.h>
using namespace std; 

#define F               first
#define S               second
#define ull             unsigned long long
#define ll              long long
#define ul              unsigned long
#define db              double
#define ST              string
#define pb              push_back
#define mp              make_pair
#define el              "\n"
#define vll             vector <ll>
#define vl              vector <long int>
#define vi              vector <int>
#define all(v)          (v.begin(), v.end()) 
#define rall(v)         (v.rbegin(), v.rend()) 
#define is_sort(v)      is_sorted all(v)
#define max_of(v)       *max_element all(v)
#define min_of(v)       *min_element all(v)
#define itos(s)         to_string(s)
#define cntone(x)       __builtin_popcountll(x)
#define cntzro(x)       __builtin_clz(x)
#define For(i, a, b)    for(int i=a; i<b; i++)
#define Forr(i, a, b)    for(int i=a; i>=b; i--)
const ll mod = 1e9+7;

void solve()
{
    ll n, ans=0;
    cin>>n;
    vll v(n+1), sum(n+1);
    For(i, 1, n+1) cin>>v[i], sum[i]=v[i];

    For(i, 1, n+1)
    sum[i]=(sum[i-1]+sum[i]);

    For(i, 1, n)
    {
        ll tt = ((v[i]%mod)*((sum[n]-sum[i])%mod))%mod;
        ans=(ans+tt)%mod;
    }
    //ans=(ans%mod+((v[i]%mod)*((sum[n]-sum[i])%mod))%mod)%mod;

    cout<<(ll)ans%mod;
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    /***************-Code starts from here-***************/
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0; 
} 

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7) cout << "YES";
    else cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;typedef vector<int> ivec;typedef vector<string> svec;

i64 n,ans=0;
void dfs(i64 x,int a,int b,int c){
	if(x>n) return;
	if(a&&b&&c) ans++;
	dfs(x*10+3,1,b,c);
	dfs(x*10+5,a,1,c);
	dfs(x*10+7,a,b,1);
}

int main(){
	cin >> n;
	dfs(0,0,0,0);
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 256
r1, r2 = 0, 0
while True:
    try:
        a,b,c = map(int, raw_input().split(','))
        if (a**2 + b**2) == c**2:
            r1 += 1
        elif a == b:
            r2 += 1
    except EOFError:
        break
print r1
print r2

Measured memory_bytes: 4224