akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
template <class T> using v = std::vector<T>;
template <class T> using vv = std::vector<std::vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int N; cin >> N;
    ld totalInv = 0;
    REP(i, 0, N)
    {
        int A; cin >> A;
        totalInv += 1 / (ld)A;
    }

    cout << fixed << setprecision(10) << 1 / totalInv << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(r, &n)
	cs := make([]map[int]int, n) // []v_i -> c_i
	for h := 0; h < n; h++ {
		var u, k int
		fmt.Fscan(r, &u, &k)
		m := make(map[int]int)
		for i := 0; i < k; i++ {
			var v, c int
			fmt.Fscan(r, &v, &c)
			m[v] = c
		}

		cs[u] = m
	}

	q := make(map[int]int)
	q[0] = 0
	visited := make(map[int]struct{})
	out := make([]int, n)

	for len(q) > 0 {
		u := top(q)
		for uu, c := range cs[u] {
			// Consider the connection between u and uu.
			if _, ok := visited[uu]; ok {
				continue
			}
			if d, ok := q[uu]; !ok || d > q[u]+c {
				q[uu] = q[u] + c
			}
		}

		out[u] = q[u]
		delete(q, u)
		visited[u] = struct{}{}
	}

	for u, d := range out {
		fmt.Println(u, d)
	}
}

func top(q map[int]int) int {
	minu := -1
	min := -1
	for u, d := range q {
		if min < 0 || d < min {
			minu = u
			min = d
		}
	}

	return minu
}


Measured memory_bytes: 1596
//arc099_d.cpp
//Sun Mar  1 10:11:46 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

ll calcsn(ll x){
	ll ans = 0;
	ll n = log10(x);
	ll keta = pow(10,n);
//	cout << keta << endl;
	while (keta>=1){
		ans += x/keta;
		x = x%keta;
		keta = keta/10;
	}
	return ans;
}

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

	ll keta = 0;
	ll base = 1;
	ll num = 1;
	while (k){
		ll temp = num*base+base-1;
		ll sn = calcsn(temp);
		if (temp<=base*sn){
			cout << temp << endl;
			num++;
			k--;
		}else {
			keta++;
			base = pow(10,keta);
			num = 1;
			ll temp2 = num*base+base-1;
			while (temp2<=temp){
				num++;
				temp2 = num*base+base-1;
			}
		}
	}

}

Measured memory_bytes: 640
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;

const int MAX_N = 1000000;

int main(int argc, char* argv[]) {
	int n, ans = 0;
	set<int> s;
	map<int, int> count;
	cin >> n;
	vector<int> a(n), ng(MAX_N + 1);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		count[a[i]] += 1;
		if (count[a[i]] == 1) {
			for (int j = a[i] * 2; j <= MAX_N; j += a[i]) {
				ng[j] = 1;
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		ans += count[a[i]] == 1 && ng[a[i]] == 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17156
import bisect

def last(d,i):
    x = bisect.bisect_right(last_hol[i],d,)
    #print(x,last_hol[i])
    if x == 0:
        return 0
    else:
        return last_hol[i][x-1]

d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(d)]
last_hol = {i:[] for i in range(1,27)}
t = []
for i in range(d):
    ti = int(input())
    last_hol[ti].append(i+1)
    t.append(ti)
ans = 0
a = [0]*d
for i in range(d):
    ti = t[i]
    ans += s[i][ti-1]
    for j in range(1,27):
        ans -= c[j-1]*(i+1-last(i+1,j))
    print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    map<int, vector<int>> g;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    deque<int> que;
    que.push_back(1);
    rep(i, 2)
    {
        deque<int> next;
        while (!que.empty())
        {
            auto cur = que.front();
            que.pop_front();
            for (auto x : g[cur])
            {
                next.push_back(x);
            }
        }
        que = next;
    }
    for (auto x : que)
    {
        if (x == n)
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long
#define vi vector<int>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	cout<<a+b+c+d+e+f-min(min(a,b),min(c,d))-min(e,f)<<"\n";
	return 0;
}

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

int main(void) {
    int N;
    cin >> N;
    vector<int> h(N);
    vector<int> hc(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    int ans = 0;
    int pos = 0;
    int next;
    for (;;) {
        if (pos == N) {
            break;
        }
        if (hc[pos] == h[pos]) {
            ++pos;
            continue;
        }
        next = pos;
        for (int i = pos + 1; i < N; ++i) {
            if (hc[i] < h[i]) {
                next = i;
            }
            else {
                break;
            }
        }
        for (int i = pos; i <= next; ++i) {
            ++hc[i];
        }
        ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
X = int(input())
if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)
else:
    assert False

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

int main()
{
        string t;
        cin >> t;
        for (int i = 0; i < t.length(); ++i) {
                if (t[i] >= 'A' && t[i] <= 'Z') {
                        t[i] = 'a' + (t[i] - 'A');
                }
        }

        long long ans = 0;
        while (1) {
                string S;
                cin >> S;
                if (S == "END_OF_TEXT") break;
                for (int i = 0; i < S.length(); ++i) {
                        if (S[i] >= 'A' && S[i] <= 'Z') {
                                S[i] = 'a' + (S[i] - 'A');
                        }
                }
                if (S == t) ans++;

        }
        cout << ans << endl;
}



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

int main()
{
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    if (i <= K) sum += X;
    else sum += Y;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
from heapq import heapify, heappop as pop, heappush as push

N = int(input())
a = list(map(int, input().split()))

l = a[:N]
m = a[N:N*2]
r = [x * -1 for x in a[N*2:]] # 中身は負

heapify(l)
heapify(r)

ll = [sum(l)]
for em in m:
    l_min = pop(l)
    if l_min < em:
        ll.append(ll[-1] - l_min + em)
        push(l, em)
    else:
        ll.append(ll[-1])
        push(l, l_min)

rr = [sum(r)] # 中身は負
for em in reversed(m):
    r_max = pop(r) * -1
    if r_max > em:
        rr.append(rr[-1] + r_max - em)
        push(r, em * -1)
    else:
        rr.append(rr[-1])
        push(r, r_max * -1)

print(max(a + b for a, b in zip(ll, reversed(rr))))


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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
//typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll dp[100010][2];
ll a[100010];

int main(){
  /**入力**/
  int n;
  cin >> n;
  REP(i,n) {
    cin >> a[i+1];
  }
  REP(i,n+1) REP(j,2) dp[i][j] = -INF;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = max(dp[i][0], dp[i-1][0] + a[i]);
    dp[i][0] = max(dp[i][0], dp[i-1][1] - a[i]);
    dp[i][1] = max(dp[i][1], dp[i-1][0] - a[i]);
    dp[i][1] = max(dp[i][1], dp[i-1][1] + a[i]);
  }
  cout << dp[n][0] << endl;
  return 0;
}



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

int main() {
	// your code goes here
	long long d,n,k;
	cin>>d>>n;
	if(d==0)
	{
	    if(n==100)
	    cout<<101<<endl;
	    else
	    cout<<n;
	}
	else if(d==1)
	{
	    if(n==100)
	    cout<<10100;
	    else
	    cout<<n*100;
	    
	}
	else if(d==2)
	{
	  if(n==100)
	  cout<<1010000;
	  else
	  cout<<n*10000;
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	string s;
	cin >> s;
	int size = s.size();
	int cnt = 0;
	rep(i,size) {
		if (s[i] == 'o') cnt++;
	}
	if (cnt + 15 - size >= 8) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    A=list(map(int,input().split()))
    cnt=0
    for k,v in enumerate(A):
        if k%2==0 and v%2==1:
            cnt+=1
    print(cnt)
    
resolve()

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

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

int main()
{
    int n;
    long long int buf;
    cin >> n >> buf;

    vector<int> a(n);

    rep(i, n)
    {
        cin >> a[i];
        --a[i];
    }

    vector<bool> visited(n, false);
    vector<int> prev;
    int now = 0;

    while (!visited[now])
    {
//        cerr << " --- " << now << " " << prev.size() << endl;
        visited[now] = true;
        prev.push_back(now);
        now = a[now];
    }

    int loop_idx = -1;
    rep(i, prev.size())
    {
        if (prev[i] == now)
        {
            loop_idx = i;
            break;
        }
    }
  //  cerr << "aaaaaa " << loop_idx << endl;
    int loop_num = prev.size() - loop_idx;

    if(buf < loop_idx){
        cout << prev[buf] + 1 << endl;
    }else{
        buf -= loop_idx;
        int k = buf % (prev.size() - loop_idx);
        cout << prev[k+loop_idx] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5128
var
  n,x,y,t,x1,y1,t1,i,s:longint;
begin
  readln(n);
  x:=0; y:=0;
  for i:= 1 to n do
    begin
      readln(t1,x1,y1);
      if (x=x1)and(y=y1)then begin writeln('No'); exit; end;
      if abs(x-x1)+abs(y-y1)=t1-t then begin x:=x1;y:=y1;t:=t1;end
                                  else
                                    begin
                                      if abs(x-x1)+abs(y-y1)<t1-t
                                        then
                                         begin
                                          s:=(t1-t)-(abs(x-x1)+abs(y-y1));
                                          if odd(s) then
                                                      begin
                                                        writeln('No');
                                                        exit;
                                                      end
                                                    else
                                                      begin
                                                        x:=x1;
                                                        y:=y1;
                                                        t:=t1;
                                                      end;
                                         end
                                        else
                                          begin
                                            writeln('No');
                                            exit;
                                          end

                                    end;
    end;
  writeln('Yes');
end.

Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define sz(x) (int)(x.size())
#define pb push_back
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define endl "\n"
#define int long long

const int N = (int)(1e6) + 322;
const long long inf = (long long)(1e18) + 123;
const int mod = (int)(1e9) + 7;
const double EPS = 1e-9;



signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int l = 0, r = sz(s) - 1;
    int cnt = 0;
    while (l < r) {
        if (s[l] != s[r]) cnt++;
        l++;
        r--;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 384
n,c=list(map(int,input().split()))
xv=[list(map(int,input().split())) for _ in range(n)]

cr=[0]*(n+1)
cl=[0]*(n+1)

for i in range(n):
    cr[i+1]=cr[i]+xv[i][1]
    cl[n-i-1]=cl[n-i]+xv[n-i-1][1]

leftmax=[0]*(n+1)

for i in range(n-1,-1,-1):
    leftmax[i]=max(leftmax[i+1],cl[i]-2*(c-xv[i][0]))

rightmax=[0]*(n+1)

for i in range(n):
    rightmax[i+1]=max(rightmax[i],cr[i+1]-2*xv[i][0])

ans=0
for i in range(n):
    ans=max(ans,cr[i+1]-xv[i][0]+leftmax[i+1])
    ans=max(ans,cl[n-i-1]-c+xv[n-i-1][0]+rightmax[n-i-1])

print(ans)

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

using namespace std;

int main() {

	int n, w;
	cin >> n >> w;

	long long weights[n];
	long long vals[n];
	for (int i = 0; i < n; i++) {
		cin >> weights[i] >> vals[i];
	}

	// Minimum weight for x value from the first y items
	long long maximumValue = 1000 * 100;
	long long result[maximumValue + 1][n+1];

	result[0][0] = 0;
	for (int v = 1; v < maximumValue + 1; v++) {
		result[v][0] = 2e9;
	}

	for (int m = 1; m < n+1; m++) {

		long long weight = weights[m-1];
		long long val = vals[m-1];

		for (int v = 0; v < maximumValue + 1; v++) {
			result[v][m] = result[v][m-1];
		}

		for (int v = val; v < maximumValue + 1; v++) {
			result[v][m] = min(result[v][m], result[v - val][m-1] + weight);
		}

	}

	// for (int v = 0; v < 300; v+=10) {
	// 	for (int m = 0; m < n+1; m++) {
	// 		cout << result[v][m] << " ";
	// 	}
	// 	cout << endl;
	// }

	long long finalResult = 2e9;
	for (int v = 0; v < maximumValue + 1; v++) {
		if (result[v][n] <= w) {
			finalResult = v;
		}
		// finalResult = min(finalResult, result[v][n]);
	}

	cout << finalResult << endl;

	// cout << result[w][n] << endl;

}

Measured memory_bytes: 79104
#include <cctype>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    char s[65536];
    fgets(s, 65536, stdin);
    for (int i = 0; i < strlen(s); ++i) {
        if (isalpha(s[i]))
            putchar(toupper(s[i]));
        else
            putchar(s[i]);
    }
    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//vc alp(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'};
//cout<<""<<endl;
int main(){
  ll A,B,K;cin>>A>>B>>K;
  if(K<(B-A)/2+1){
    for(int i=0;i<K;i++){
      cout<<A<<endl;
      A++;
    }
    ll C=B-K+1;
    for(int i=0;i<K;i++){
      cout<<C<<endl;
      C++;
    }
  }
  else{
    for(ll i=A;i<=B ;i++)cout<<i<<endl;
  }
 
}


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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  ll X,A,B;
  cin >> X >> A >> B;
  if(B > A){//賞味期限をすぎて食べる時
    if(B-A > X) cout << "dangerous" << endl;
    else cout << "safe" << endl;
  }
  else cout << "delicious" << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define ll long long
#define all(x) x.begin(),x.end()
using namespace std;
const int LIM = 1e6+3;
int arr[LIM+3];
int Ans[LIM+3];
bool Vis[LIM+3];
std::vector<int> Mul[LIM+3];
int n, k;
std::vector<int> V;
bool check(int x)
{
  int Sum = 0, kk = k;
  V.clear();
  for(int i = 0;i<n;i++)
    {
      int rem = arr[i]%x;
      V.push_back(rem);
    }
  sort(all(V));
  int l = 0, r = V.size()-1;
  while(l<=r)
  {
    int rem = V[l];
    Sum += rem; kk-=rem;
    while(r > l && Sum >= x - V[r]) Sum -= x - V[r],r--;
    l++;
  }
  if(Sum || kk < 0)return false;
  return true;
}
int main(){
  cin >> n >> k;
  int Mx = 0; int Sum = 0;
  for(int i = 0;i<n;i++)
  {
    scanf("%d",&arr[i]);
    Mx = max(Mx, arr[i]);
    Sum += arr[i];
  }
  int ans = 1;
  for(int i = 1; i * i <= Sum; i++)
  {
    if(Sum % i == 0)
    {
      if(check(i))
        ans = max(ans, i);
      if(check(Sum / i))
        ans = max(ans, Sum / i);
    }
  }
  cout << ans << endl;
 
}

Measured memory_bytes: 26880
n,m = map(int,input().split())
nnum = []
mnum = []
for i in range(n):
    nnum.append(list(map(int,input().split())))
for j in range(m):
    mnum.append(int(input()))
for k in range(n):
    ans = 0
    for l in range(m):
        ans += nnum[k][l]*mnum[l]
    print(ans)


Measured memory_bytes: 6008
#include<stdio.h>
int main(void)
{
	int t,n,i;
	for (i=0;i<4;i++)
	{
		scanf ("%d%d",&t,&n);
		if (t==1)
		printf ("%d\n",6000*n);
		else if (t==2)
		printf ("%d\n",4000*n);
		else if (t==3)
		printf ("%d\n",3000*n);
		else
		printf ("%d\n",2000*n);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	final Scanner sc = new Scanner(System.in);
	int r=sc.nextInt();
	int c=sc.nextInt();
	int[][] Ar=new int[r+1][c+1];
	for(int i=0;i<r;i++){
	    for(int j=0;j<c;j++){
		Ar[i][j]=sc.nextInt();
		Ar[i][c]+=Ar[i][j];
		Ar[r][j]+=Ar[i][j];
		Ar[r][c]+=Ar[i][j];
	    }
	}
	for(int i=0;i<=r;i++){
	    for(int j=0;j<=c;j++){
		System.out.print(Ar[i][j]);
		if(j!=c) System.out.print(" ");
	    }
	    System.out.println("");
	}
    }
}

Measured memory_bytes: 39516
from collections import deque
N, H = map(int, input().split())
a, b = [], []
for _ in range(N):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
a.sort()
b.sort()
maxa = a[-1]
que = deque(b)
cnt = 0
while H > 0:
    if not que:
        cnt += -(-H//maxa)
        break
    maxb = que.pop()
    if maxb > maxa:
        cnt += 1
        H -= maxb
    else:
        cnt += -(-H//maxa)
        break
print(cnt)

Measured memory_bytes: 12028
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main(){
	int N,cnt=0,ans=0;
	cin >> N;
	string S;
	cin >> S;
	
	for(int i=1;i<N;i++){
    cnt=0;
		
		for(char x='a';x<='z';x++){
			bool left=false,right=false;
			
			for(int j=0;j<i;j++)
				if(S[j]==x)
					left=true;
			
			for(int j=i;j<N;j++)
				if(S[j]==x)
					right=true;
			
			if(left&&right)
				cnt+=1;
		}
		if(ans<cnt)
			ans=cnt;
	}
	cout << ans << endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b;
    cin >> a >> b;
    if(a+b < 24) cout << a + b << endl;
    else cout << a + b - 24 << endl;

    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    int check[101] = {-1};
    pii index[101];

    int arr[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> arr[i][j];
            check[arr[i][j]] = 1;
            index[arr[i][j]] = {i,j};
        }
    }

    int n;
    cin >> n;

    while(n--){
        int x; cin >> x;
        if(check[x]==1){
            arr[index[x].ff][index[x].ss] = -1;
        }
    }
    int val;
    for(int i=0;i<3;i++){
        val = 0;
        for(int j=0;j<3;j++){
            val += arr[i][j];
        }
        if(val==-3) break;
    }

    if(val==-3) puts("Yes");

    else {
        for(int i=0;i<3;i++){
            val = 0;
            for(int j=0;j<3;j++){
                val += arr[j][i];
            }
            if(val==-3) break;
        }

        if(val==-3) puts("Yes");
        else {
            val = 0;
            for(int i=0;i<3;i++){
                val += arr[i][i];
            }

            if(val==-3) puts("Yes");
            else {

                val = 0;
                val += arr[0][2];
                val += arr[1][1];
                val += arr[2][0];

                if(val==-3) puts("Yes");
                else puts("No");
            }

        }
    }








    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N, M;
deque<int>q;
vector<int>E[101010];
set<int>visited;
int stfl = 0;
void pr() {
	puts(q.size());
	fore(x, q)cout << x+1 << " ";
	cout << endl;
	exit(0);
}
void dfs(int now){
	int st = q.front();
	int en = q.back();
	if (stfl == 0) {
		fore(x, E[st]) {
			if (!visited.count(x)) {
				visited.insert(x);
				q.push_front(x);
				dfs(x);
			}
		}
	}
	stfl = 1;
	fore(x, E[en]) {
		if (!visited.count(x)) {
			visited.insert(x);
			q.push_back(x);
			dfs(x);
		}
	}
	pr();
}

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

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		E[A].pb(B);
		E[B].pb(A);
	}
	q.push_back(0);
	visited.insert(0);
	dfs(0);

	return 0;
}

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

int main(){

        int R;

        cin >> R;

        if(0<=R && R<1200){
                cout << "ABC";
        }else if(1200<=R && R<2800){
                cout << "ARC";
        }else{
                cout << "AGC";
        }


        return 0;
}

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

using namespace std;



int solve(){

    string str;
    
    cin >> str;
    
    unsigned long num = str.size();
    
    for(int i = 0; i < num-1; i++){
        string ac;
        ac = ac + str[i] + str[i+1];
        
        if (ac == "AC") {
            cout << "Yes" << endl;
            return 0;
        }
        
    }
    
    cout << "No" << endl;
    
    return 0;
}



int main() {
    // insert code here...
    //cout << "Hello, World!\n";
    
    solve();
    
    
    //return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
struct P {
    int a,b;
    bool operator <(const P &t) const {
        return a*(t.b+1)>t.a*(b+1);
    }
}p[N];
ll pre[N];
int n,t,cnt=0,tot=0;
int cal() {
    ll f[35];
    for(int i=0;i<35;i++) f[i]=(i?1e9:0);
    for(int i=0;i<cnt;i++) {
        for(int j=30;j>=0;j--) {
            if(f[j]==1e9) continue;
            f[j+1]=min(f[j+1],(f[j]+1)*(p[i].a+1)+p[i].b);
            if(f[j+1]>t) f[j+1]=1e9;
        }
    }
    int ans=0;
    for(int i=0;i<32;i++) {
        if(f[i]!=1e9) {
            int x=t-f[i];
            int l=1,r=tot,y=-1;
            while(l<=r) {
                int mid=(l+r)>>1;
                if(pre[mid]<=x) y=mid,l=mid+1;
                else r=mid-1;
            }
            if(y!=-1) ans=max(ans,i+y);
            else ans=max(ans,i);
        }
    }
    return ans;
}
int main() {
    //freopen("in.txt","r",stdin);
    scanf("%d%d",&n,&t);
    for(int i=0,a,b;i<n;i++) {
        scanf("%d%d",&a,&b);
        if(a==0) pre[++tot]=b;
        else p[cnt++]={a,b};
    }
    sort(p,p+cnt),sort(pre+1,pre+tot+1);
    for(int i=1;i<=tot;i++) pre[i]+=pre[i-1]+1;
    printf("%d\n",cal());
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
int i,a,b;
	for(i=0;i<4;i++){
	scanf("%d %d",&a,&b);
	if(a==1){
	b=b*6000;
	}if(a==2){
	b=b*4000;
	}if(a==3){
	b=b*3000;
	}if(a==4){
	b=b*2000;
	}
	printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 1028
b=input().split()
K=int(b[1])
a=input()
count=0
for  i in range(len(a)) :
  if i!=len(a)-1 and a[i]=='R' and a[i+1]=='R':
    count+=1
  elif i!=0 and a[i]=='L' and a[i-1]=='L' :
    count+=1
    
for i in range(K) :
  count+=2

if count>=len(a)-1 :
  print(len(a)-1)
else :
  print(count)


Measured memory_bytes: 39920
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
int N,K;
string S;
int main(){
    cin >> N >> S >> K;
    rep(i,N) if(S[i] != S[K-1]) S[i] = '*';
    cout << S << endl;
}

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

long a,b,ans=-1;
double ra=0.08,te=0.1;

int main() {
	cin>>a>>b;
	long i;
	for(i=1;i<=1000;++i) {
		if((long)(i*ra)==a && (long)(i*te)==b)
			break;
	}
	if(i==1001) printf("-1\n");
	else printf("%ld\n",i);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int cnt=0;
int l[500000];
int r[500000];
void merge(int A[],int n,int left,int mid, int right){
	int i;
	int n1=mid-left;
	int n2=right-mid;
	for(i=0; i<n1; i++){
		l[i]=A[left+i];
	}
	for(i=0; i<n2; i++){
		r[i]=A[mid+i];
	}
	
	l[n1]=r[n2]=1000000000;
	
	 i=0;
	int j=0;
	int k;
	
	for(k=left; k<right;k++){
		cnt++;
		if(l[i]<=r[j]){
			A[k]=l[i++];
		}else{
			A[k]=r[j++];
		}
	}
}

void mergeSort(int A[],int n,int left, int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(void){
	int A[500000],n,i;
	cnt=0;
	
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	mergeSort(a,n,0,n);
	
	for( i = 0; i < n-1; i++ ){
		printf( "%d ", a[i] );
	}
	printf( "%d\n", a[n-1] );
	
	printf( "%d\n", cnt );
	
	return 0;
}


	


Measured memory_bytes: 5764
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  if(n%4==0){
  	cout<<"Yes"<<endl;
  	return 0;
  }
  while(n>0){
  	if(n%7==0){
  		cout<<"Yes"<<endl;
  		return 0;
  	}else{
  		n-=4;
  	}
  }
  cout<<"No"<<endl;
  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);

        final int N = sc.nextInt();

        for (int i = 0; i < N; i++) {
            final int A = sc.nextInt();
            if (A % 2 == 0 && (A % 3 != 0 && A % 5 != 0)) {
                System.out.println("DENIED");
                return;
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<math.h>

using namespace std;
int main()
{
	int n;
	double  a,x,y,z,r,i,j,rad;
	
	for(;;)
	{
		cin >> x >> y >> z;
		if(x==0 && y==0 && z==0)
			break;
		cin >> n;
		x/=2;
		y/=2;
		z/=2;
		if(x>y)
		{
			a=x;
			x=y;
			y=a;
		}
		if(x>z)
		{
			a=x;
			x=z;
			z=a;
		}
		if(y>z)
		{
			a=y;
			y=z;
			z=a;
		}
		if(x<y)
		{
			a=x;
			x=y;
			y=a;
		}
		for(i=0;i<n;i++)
		{
			cin >> r;
			if(sqrt(x*x+y*y)<r)
				cout << "OK" << endl;
			else
				cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> v[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int ans = 0;
    
    rep(i, N) {
        int t, d;
        cin >> t >> d;
        t--;
        v[t].push_back(d);
    }
    rep(i, N) sort(v[i].begin(), v[i].end());
    priority_queue<int> que1, que2;
    priority_queue<int, vector<int>, greater<int>> que3;
    rep(i, N) {
        if(v[i].size()) {
            que1.push(v[i].back()); 
            v[i].pop_back();
        }
    }
    rep(i, N) for(auto& e: v[i]) que2.push(e);
    rep(i, N) for(auto& e: v[i]) que3.push(e);
    int sum1 = 0, sum2 = 0;
    rep(i, K) {
        if(que2.size()) {
            sum2 += que2.top(); que2.pop();
        }
    }
    while(que3.size() > K) que3.pop();
    //cout << que3.size() << " " << que2.size() << endl;
    rep(i, N) {
        if(que1.size() == 0) break;
        //cout << que1.top() << " " << que3.top() << " " << que3.size() + i + 1  << " ";
        sum1 += que1.top(); que1.pop();
        while(que3.size() && i + 1 + que3.size() > K) {
            sum2 -= que3.top(); que3.pop();
        }
        if(i + 1 + que3.size() > K) break;
        //cout << que3.size() + i + 1 << " " << sum1 << " " << sum2 << " " << sum1 + sum2 + (i + 1) * (i + 1) << endl;
        ans = max(ans, sum1 + sum2 + (i + 1) * (i + 1));
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 6904
s = input()

if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}


signed main() {
	int n, k;
	scnaf("%d %d", &n, &k);
	int can[10] = {};
	REP(i, k) {
		int a;
		scnaf("%d", &a);
		can[a] = 1;
	}

	for (;; n++) {
		int buf = n;
		bool f = 1;
		while (buf) {
			if (can[buf%10])
				f = 0;
			buf /= 10;
		}
		if (f) {
			printf("%d\n", n);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
char s[105];
bool vis[30],a[105],b[105];
int N;

void Solve() {
    scanf("%s",s + 1);
    N = strlen(s + 1);
    for(int i = 1 ; i <= N ; ++i) vis[s[i] - 'a'] = 1;
    int ans = N;
    for(int t = 0 ; t < 26 ; ++t) {
	if(vis[t]) {
	    int cnt = 0;
	    memset(a,0,sizeof(a));
	    for(int i = 1 ; i <= N ; ++i) a[i] = (s[i] == 'a' + t);
	    while(1) {
		bool f = 1;
		for(int i = 1 ; i <= N - cnt; ++i) {
		    f = f & a[i];
		}
		if(f) break;
		memset(b,0,sizeof(b));
		for(int i = 1 ; i <= N - cnt - 1; ++i) {
		    b[i] = a[i] || a[i + 1];
		}
		++cnt;
		memcpy(a,b,sizeof(a));
		
	    }
	    ans = min(ans,cnt);
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <set>

int main() {
	int n;
	int a[100000];
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	std::multiset<int> color;
	color.insert(a[0]);
	for(int i = 1; i < n; i++) {
		auto ittr = color.lower_bound(a[i]);
		if(ittr != color.begin()) {
			ittr--;
			color.erase(ittr);
		}
		color.insert(a[i]);
	}

	printf("%d\n", color.size());

	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

ll mod = 1000000007;

ll modpow(ll a, ll n, ll mod){
  if(n == 1) return a;
  ll ret = modpow(a, n / 2, mod);
  if(n % 2 == 0) ret = (ret * ret) % mod;
  else ret = (((ret * ret) % mod) * a) % mod;
  return ret;
}

ll gakugen(ll x, ll mod){
  return modpow(x, mod - 2, mod);
}


vector<ll> elatostenesnohurui(ll n){
  vector<ll> elatostenes(n + 1, 0);
  for(ll i = 2; i <= n; i++){
    if(elatostenes[i] == 0){
      elatostenes[i] = -1;
      for(ll j = i * i; j <= n; j++){
        if(j % i == 0){
          elatostenes[j] = i;
        }
      }
    }
  }
  return elatostenes;
}

map<ll, ll> soinsubunkai(ll x, vector<ll>& elatostenes){
  map<ll, ll> soinsu;
  while(x >= 2 && elatostenes[x] != -1){
    soinsu[elatostenes[x]]++;
    x /= elatostenes[x];
  }
  soinsu[x]++;
  return soinsu;
}

void solve(){
  ll n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<ll> elatostenes = elatostenesnohurui(1000005);

  map<ll, ll> mp;
  for(int i = 0; i < n; i++){
    map<ll, ll> soinsu = soinsubunkai(a[i], elatostenes);
    for(auto it = soinsu.begin(); it != soinsu.end(); it++){
      ll num = it->first, beki = it->second;
      if(mp.find(num) == mp.end()){
        mp[num] = beki;
      }
      else{
        mp[num] = max(mp[num], beki);
      }
    }
  }
  ll lcm = 1;
  for(auto it = mp.begin(); it != mp.end(); it++){
    lcm = (lcm * modpow(it->first, it->second, mod) % mod);
  }
  ll ans = 0;
  for(int i = 0; i < n; i++){
    ll gakua = gakugen(a[i], mod);
    ans = (ans + (lcm * gakua) % mod) % mod;
  }
  cout << ans << endl;

  return;
}

int main(){
  solve();
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int ans=0;
  while(N!=0){
    ans+=N%10;
    N=N/10;
  }
  if(ans==1) cout << 10 << endl;
  else cout << ans << endl;
}

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

using namespace std;

#define FOR(i,l,r) for( int i = l; i <= r; i++ )
#define vi vector<int>
#define vvi vector<vi>
#define st string

int mod = 1e9+7;

void addMod( int & a, int b ) {
    a += b;
    if( a >= mod ) a -= mod;
}

int main() {
    st k; cin>>k;
    int d; cin>>d;
    vvi dp(d,vi(2,0));
    int len = k.length();
    FOR(digit,0,k[0]-'0') {
        dp[digit%d][(digit<k[0]-'0')] += 1;
    }
    FOR(i,1,len-1) {
        vvi n_dp(d,vi(2,0));
        FOR(smaller_already,0,1) {
            FOR(digit,0,9) {
                if( !smaller_already && digit > k[i]-'0' ) break;
                FOR(rems,0,d-1) {
                    addMod(n_dp[(rems+digit)%d][smaller_already||(digit<k[i]-'0')],dp[rems][smaller_already]);
                }
            }
        }
        dp = n_dp;
    }
    // FOR(i,0,d-1) FOR(j,0,1) cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
    int ans = (dp[0][0]+dp[0][1]-1+mod)%mod;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    ll now = 100;
    int ans = 0;
    ll x;
    cin >> x;
    while(now<x){
        now*=1.01;
        ans++;
    }
    cout << ans << endl;

}


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

using ll = long long;

int main() {
   string s;
   cin >> s;
   string t = s[0] + string(s.size()-1, '9');
   ll a = stoll(s), b = stoll(t);

   ll maxSum = s[0] - '0' + (s.size() - 1)*9;
   if (a == b) {
      cout << maxSum << endl;
   } else {
      cout << maxSum -1 << endl;
   }

   return 0;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;
    ll num = sqrt(n);
    num *= num;

    // 処理
    cout << num << endl;

    // 出力

    return 0;
}


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

int main(){
  int n,q,C = 0,i,j;
  int *S;
  int *T;

  scanf("%d",&n);
  S = (int *)malloc(sizeof(int) * (n+1));
  for(i = 0;i < n;i++)
    scanf("%d",&S[i]);
  
  scanf("%d",&q);
  T = (int *)malloc(sizeof(int) * q);
  for(i = 0;i < q;i++)
    scanf("%d",&T[i]);

  for(i = 0;i < q;i++){
    S[n] = T[i];
    for(j = 0;j < n;j++){
      if(S[j] == S[n]){
	C++;
	break;
      }
    }
  }

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

  free(S);
  free(T);
  return 0;
}



Measured memory_bytes: 2104
import itertools
from math import gcd

K = int(input())

ans = 0
G = [[None] * (K + 1) for _ in range(K + 1)]
for a in range(1, K + 1):
    for b in range(1, K + 1):
        G[a][b] = gcd(a, b)


for a, b, c in itertools.product(range(1, K + 1), repeat=3):
    ans += G[G[a][b]][c]
print(ans)


Measured memory_bytes: 9352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,K,A,B,p=1;
  cin >> N >> K;
  for(int i =0; i < N; ++i){
    A = p*2;
    B = p+K;
    p=min(A,B);
  }
  cout << p << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
 int a,b,c,d,g;
 for(int f=1;;f++){
 g=0;
 scanf("%d %d",&a,&b);
  if(a==0&&b==0)
    break;
 for(c=1;c<=a;c++)
   for(d=c+1;d<=a;d++)
   if(d<b-c-d&&b-c-d<=a)
    g++;
printf("%d\n", g);
 }
return 0;
}


Measured memory_bytes: 2700
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define GetArray(ty,v,n) vector<ty> v(n);cin_arr(v,n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr,pred) f(arr.begin(),arr.end(),pred)
#define ArrExpr(f, arr,expr) f(arr.begin(),arr.end(),[](auto x){return expr;})
#define Acc(init,arr,pred) accumulate(arr.begin(),arr.end(),init,pred)

void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

template<class Arr>
void cin_arr(Arr& v,int n) {
	for (int i = 0; i < n; i++)
		cin >> v[i];
}


int main() {
	Get(int, n)
		GetArray(int, v, n)
		co << Acc(9999, v, [](auto acc, auto x) {
		int count = 0;
		while (x % 2 == 0)
		{
			x /= 2;
			count++;
		}
		return min({ count,acc });
	}) << en
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

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

  int exponential, max_exponential = 1;
  for(int i = 1; i < 32; i++){
    for(int j = 2; j < 10; j++){
      exponential = pow(i, j);

      if(exponential > x){
        break;
      }
      else{ //exponential <= x;
        if(exponential >= max_exponential){
          max_exponential = exponential;
        }
      }
    }
  }
  cout << max_exponential << endl;
}


Measured memory_bytes: 256