akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngll(chrono::steady_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	long long n, k, x = 1;
	cin >> n >> k;
	int res = 1;
	while(x * k <= n){
		x *= k;
		++ res;
	}
	cout << res;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 256
N = int(input())
A_LIST = list(map(int, input().split()))

sorted_list = sorted(A_LIST)[::-1]

n_half = N // 2 + N % 2
pts = 0
for a in sorted_list[:n_half - 1]:
    pts += a

circle = sorted_list[1:n_half] + [sorted_list[n_half - 1]]
    
for i in range(N - n_half):
    pts += circle[i]
        
print(pts)

Measured memory_bytes: 31464
#http://sucrose.hatenablog.com/entry/2016/11/06/234635
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

def main():
    n = int(input())

    divtable = num_divisors_table(n)
    
    ans = 0
    for c in range(1,n):
        t = divtable[n-c]
        ans += t

    print(ans)
    
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 75416
import bisect

def main():
    S = input()
    dS = {c : [] for c in 'abcdefghijklmnopqrstuvwxyz'}

    for i, s in enumerate(S):
        dS[s].append(i)

    #

    T = input()
    ans = 0

    p = 0

    for t in T:
        if not dS[t]:
            print(-1)
            return
        if dS[t][-1] < p:
            p = 0
            ans += len(S)
        idx = bisect.bisect_left(dS[t], p)
        p = dS[t][idx] + 1
    
    print(ans + p)

main()



Measured memory_bytes: 7540
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
struct RollingHash {
    int n;
    string s;
    const ll mod1 = 1000000007LL, mod2 = 1000000009LL, base1 = 1007LL,
             base2 = 1009LL;
    vector<ll> hash1, hash2, pow1, pow2;
    RollingHash(const string& str) {
        s = str;
        n = str.length();
        hash1.resize(n + 10);
        hash2.resize(n + 10);
        pow1.resize(n + 10, 1);
        pow2.resize(n + 10, 1);
        for(int i = 0; i < n; i++) {
            hash1[i + 1] = (hash1[i] + s[i]) * base1 % mod1;
            hash2[i + 1] = (hash2[i] + s[i]) * base2 % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    pair<ll, ll> get(int l, int r) {
        ll t1 = (hash1[r] - hash1[l] * pow1[r - l] % mod1 + mod1) % mod1;
        ll t2 = (hash2[r] - hash2[l] * pow2[r - l] % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    RollingHash rs(s), rt(t);
    int n = s.length(), m = t.length();
    for(int i = 0; i <= n - m; i++) {
        if(rs.get(i, i + m) == rt.get(0, m)) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 36412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{

    static void Main(string[] args)
    {
        int[] input = GetInputsInt();

        int S = Math.Abs(input[0] - input[1]);
        if(S%2 == 1)
        {
            Console.WriteLine("IMPOSSIBLE");
            return;
        }
        int ss = S / 2;
        if(input[0] - ss == input[1] - ss)
        {
            Console.WriteLine(ss);
        }
        else
        {
            Console.WriteLine(Math.Max(input[0], input[1]) - ss);
        }
    }

    

    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long GetInputLong()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


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

const int N = 1005;
const int M = 200005;
const int INF = 1000000000;
typedef long long i64;

vector<int> E[N];
int edge[M][2];
int ma[N][N], mi[N][N];
bool vis[N];

void dfs(int s, int now, int k, bool mark) {
    if (vis[now] || now == s) return ;
    vis[now] = true;
    if (mark) mi[s][now] = k;
    else ma[s][now] = k;
    for (auto i = E[now].begin(); i != E[now].end(); ++i) {
        dfs(s, *i, k, mark);
    }
}
int main ()
{
    int n, m, v;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        scanf("%d %d", &edge[i][0], &edge[i][1]);
        E[edge[i][0]].push_back(edge[i][1]);
    }
    for (int i = 1; i <= n; ++i) {
        memset(vis, false, sizeof(vis));
        int num = 0;
        for (auto j = E[i].begin(); j != E[i].end(); ++j) {
            dfs(i, *j, ++num, true);
        }
        memset(vis,false, sizeof(vis));
        reverse(E[i].begin(), E[i].end());
        num = E[i].size();
        for (auto j = E[i].begin(); j != E[i].end(); ++j) {
            dfs(i, *j, num--, false);
        }
    }
    for (int i = 1; i <= m; ++i) {
        if ((mi[edge[i][1]][edge[i][0]] > 0) == (ma[edge[i][0]][edge[i][1]] != mi[edge[i][0]][edge[i][1]])) {
            puts("same");
        }
        else {
            puts("diff");
        }
    }
    return 0;
}


Measured memory_bytes: 12160
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int n;
int h[100001];
int dp[100001];

int main() {
    cin >> n;
    rep(i, n) cin >> h[i];
    rep(i, 100001) dp[i] = inf;
    dp[0] = 0;
    rep(i, n - 2) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    chmin(dp[n - 1], dp[n - 2] + abs(h[n - 2] - h[n - 1]));
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 50
vector<int> adj[N+1];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i = 1; i <= n; i++) {
        cout << adj[i].size() << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
  int n, m;
  vector<long long> a;
  
  cin >> n >> m;
  
  for(int i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    a.push_back(temp);
  }
  make_heap(a.begin(), a.end());
  
  while(m > 0) {
    pop_heap(a.begin(), a.end());
    long long max = a.back();
    a.pop_back();
    max /= 2;
    m--;
    a.push_back(max);
    push_heap(a.begin(), a.end());
  }
  
  long long result = 0;
  for(int i = 0; i < n; i++) {
    result += a[i];
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,ans = 0;
	cin >> a >> b >> c;
	for (;;) {
		if ((a&1) || (b&1) || (c&1)) { printf("%d\n",ans); break; }
		if (a == b && b == c) { puts("-1"); break; }
		
		ans++;
		int na = (b + c) >> 1;
		int nb = (a + c) >> 1;
		int nc = (a + b) >> 1;
		a = na, b = nb, c = nc;				
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,t;
  cin>>a>>b>>t;
  t+=0.5;
  int cnt=1;
  int sum=0;
  while(a*cnt<=t){
    sum+=b;
    cnt++;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
count=0
sum=0
for i in range(n):
  sum = sum + a[i]
for i in range(n):
  if a[i] >= sum*(1/(4*m)):
    count +=1
  else:
    pass

if count>=m:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
using namespace std;
int main(){
  int N,M; cin>>N>>M;
  priority_queue<int> A;
  long long ans = 0;
  for(int i=0;i<N;i++){
    int t;
    cin>>t;
    ans += t;
    A.push(t);
  }

  for(int i=0;i<M;i++){
    int t = A.top();
    A.pop();
    if(t%2==0){
      ans -= t/2;
    }else{
      ans -= t/2 + 1;
    }
    A.push(t/2);
  }

  cout<<ans<<endl;

}


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

int main(){
    ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    // not buy ab pizza;
    ll cost = a * x + b * y;
    ll z = 0;
    for (ll i = 2; i < 2*(x+y); ){
        ll k = max(z, (x - i/2)) * a + max(z, (y - i/2)) * b + i * c;
        cost = min(cost, k);
        i += 2;
    }
    cout << cost << endl;
}

Measured memory_bytes: 3588
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N, K = sc.nextInt
  val x = Array.fill(N)(sc.nextInt)

  val a = x.map(x => x * 2)
  val b = x.map(x => (K - x) * 2)
  val z = (a zip b).map(x => Array(x._1, x._2).min).sum
  println(z)
}


Measured memory_bytes: 25504
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

int a,b,c;

int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(!(a&1) || !(b&1) || !(c&1)){ puts("0"); return 0; }
	if(a>b) swap(a,b);
	if(a>c) swap(a,c);
	if(b>c) swap(b,c);
	printf("%lld",1ll*a*b);
	return 0;
}

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

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


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int n;
int m;
string id;
int a[11];

ll ans = 0;
ll tmp = 0;

vector<pair<ll, ll>> vvv;

void solve(int k, ll sum) {
    if (k >= vvv.size()) {
        if ((sum + tmp) % 10 == 0) ans++;
        return;
    }

    int i = vvv[k].first;
    if (i%2) {
        // 2倍
        for (int j=0; j<m; ++j) {
            ll tmpv = a[j] * 2;
            while (tmpv >= 10) {
                tmpv = tmpv / 10 + tmpv % 10;
            }
            solve(k + 1, sum + tmpv);
        }
    }
    else {
        for (int j = 0; j < m; ++j) {
            ll tmpv = a[j];
            solve(k + 1, sum + tmpv);
        }
    }
    return;
}

int main() {
    cin >> n;
    cin >> id;
    cin >> m;
    rep(i, m) cin >> a[i];
    reverse(id.begin(), id.end());
    rep(i, id.size()) {
        if (id[i] == '*') {
            vvv.emplace_back(i, id[i]-'0');
            continue;
        }
        if (i%2) {
            ll k = (id[i] - '0') * 2;
            while (k >= 10) {
                k = k/10 + k%10;
            }
            tmp += k;
        }
        else {
            tmp += (id[i] - '0');
        }
    }
    //cerr << tmp << endl;
    solve(0, 0);
    cout << ans << endl;
}


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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

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

#define inf 1000000000

  int n,A,B,C,ans = 0;
  int l[8];

int dfs(int cur, int a, int b, int c){

  if(cur == n){
    if(!a||!b||!c) return inf;
    return abs(a-A) + abs(b-B) + abs(c-C);
  }

  int len = dfs(cur+1, a, b, c);

  len = min(len,dfs(cur+1, a + l[cur], b, c) + (a ? 10 : 0));
  len = min(len,dfs(cur+1, a, b + l[cur], c) + (b ? 10 : 0));
  len = min(len,dfs(cur+1, a, b, c + l[cur]) + (c ? 10 : 0));

  return len;

}

int main(){

  scanf("%d%d%d%d",&n,&A,&B,&C);
  for(int i = 0; i < n; ++i){
    scanf("%d",l+i);
  }

  ans = dfs(0,0,0,0);
  printf("%d",ans);

  return 0;
}


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

int main(){
  int A, B, C;

  cin >> A >> B >> C;

//AとCどちらが大きいか判定する
if (A < C){
  if(B < C && A < C){
    cout << "No";
  }else{
    cout << "Yes";
  }
}else{
    if(B > C && A > C){
      cout << "No";
    }else{
      cout << "Yes";
  }
}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int i,x;
    string s;
    cin>>x>>s;
    for(i=0;i<s.size();i++)
    {
        s[i]=s[i]+x;
        if(s[i]>'Z')
            s[i]-=26;

        cout<<s[i];
    }
}


Measured memory_bytes: 256
N,K=map(int,input().split())
td=[list(map(int,input().split())) for _ in range(N)]
td=[[td[i][0]-1,td[i][1]] for i in range(N)]

hozon_a=[[] for _ in range(N)]
hozon_b=[[] for _ in range(N)]

td.sort(key=lambda x:x[1],reverse=True)
for i in range(K):
    hozon_a[td[i][0]].append(td[i][1])
for i in range(K,N):
    if hozon_a[td[i][0]]==[] and hozon_b[td[i][0]]==[]:
        hozon_b[td[i][0]].append(td[i][1])

cnt=len([None for a in hozon_a if a!=[]])
ans=sum([sum(hozon_a[i]) for i in range(N)])+cnt**2

hozon_aa=[hozon_a[i][1:] for i in range(N) if len(hozon_a[i])>1]
hozon_aa=[e for inner_list in hozon_aa for e in inner_list]
hozon_bb=[hozon_b[i][0] for i in range(N) if hozon_b[i]!=[]]

hozon_aa.sort(reverse=True)
hozon_bb.sort(reverse=False)

cnt1=cnt
temp=ans
for i in range(min(K-cnt,len(hozon_aa),len(hozon_bb))):
    temp+=hozon_bb.pop()-hozon_aa.pop()+2*cnt1+1
    cnt1+=1
    if ans<temp:
        ans=temp
print(ans)

Measured memory_bytes: 45688
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
ll n, a, s, ans;
map<ll, ll> mp;
int main() {
	map<ll, ll>::iterator it;
	scanf("%lld", &n);
	mp[0] = 1;
	while(n--) {
		scanf("%lld", &a);
		s += a;
		mp[s]++;
	}
	for(it=mp.begin(); it!=mp.end(); it++) ans += it->second * (it->second-1) / 2;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;
     
    public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String strN = sc.next();
    		
    		int N = Integer.parseInt(strN);
    		
    		String strNs[] = strN.split("");
    		
    		int sumN = 0;
    		
    		for (int i = 0; i < strN.length(); i++) {
    			int tmp = Integer.parseInt(strNs[i]);
    			
    			sumN += tmp;
    		}
    		
    		if (N % sumN == 0) {
    			System.out.println("Yes");
    		} else {
    			System.out.println("No");
    		}
    		
    	}
    }

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, X, Y = MAP()
ABC = []
for i in range(N):
    a, b, c = MAP()
    ABC.append((a, b, c))

MAX = 407
# dp[i][j][k] := i個目まで見て、物質Aをj、物質Bをk含んだ状態での最小コスト
dp = list3d(N+1, MAX, MAX, INF)
dp[0][0][0] = 0
for i in range(N):
    a, b, c = ABC[i]
    for j in range(MAX):
        for k in range(MAX):
            dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
            if j+a < MAX and k+b < MAX:
                dp[i+1][j+a][k+b] = min(dp[i+1][j+a][k+b], dp[i][j][k] + c)

j = X
k = Y
ans = INF
while j < MAX and k < MAX:
    # 混合比がX:Yになるところから最小を取る
    ans = min(ans, dp[N][j][k])
    j += X
    k += Y
if ans == INF:
    print(-1)
else:
    print(ans)


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

const int N = 205;

int dis[N][N];

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

void MAIN() {
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> R(r);
  for (auto &i : R) {
    cin >> i;
  }
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= n; j++) {
    dis[i][j] = 2e9;
  }
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    dis[u][v] = dis[v][u] = w;
  }
  for (int k = 1; k <= n; k++)
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= n; j++) {
    chmin(dis[i][j], dis[i][k] + dis[k][j]);
  }
  int ans = 2e9;
  sort(all(R));
  do {
    int cal = 0;
    for (int i = 0; i < r - 1; i++) {
      cal += dis[R[i]][R[i + 1]];
    }
    ans = min(ans, cal);
  } while (next_permutation(all(R)));
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main() {
	int A;
  int B;
  cin >> A;
  cin >> B;
  if(A<10){
    if(B<10){
      cout << A*B;
    }else{
      cout << "-1";
    }
  }else{
    cout << "-1";
  }
	return 0;
}


Measured memory_bytes: 3672
n = int(input())

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

ans_1 = 0
ans_2 = 0
x_sum = sum(x_list)

x_sum = x_sum // n

for x in x_list:
    ans_1 += (x-x_sum)**2
    ans_2 += (x-x_sum - 1)**2
    continue

print(min(ans_1,ans_2))


Measured memory_bytes: 2940
S = int(input())
A = [0]*(S+1)
A[0] = 1
MOD = 10**9+7

if S<=2:
    print(A[S])
    exit()

for i in range(3,S+1):
    for j in range(i-2):
        A[i] += A[j]
    A[i]%=MOD
print(A[S])

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

int main()
{
    string s;
    cin >> s;
    int count = 1;
    sort(s.begin(),s.end());
    for(int i = 1;i < s.length();i++){
        if(s[i-1] != s[i]){
            count++;
        }
    }
    if(s[1]!=s[2]&&count == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
nm = [int(n) for n in input().split()]
c = [0] * nm[0]
for i in range(nm[1]):
    ab = [int(num) for num in input().split()]
    c[ab[0] - 1] += 1
    c[ab[1] - 1] += 1
for i in range(nm[0]):
    print(c[i])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
	// your code goes here
	int k;
	cin>>k;
    int a[k+2];
    a[1]=7;
    for(int i=2;i<=k;i++){
        a[i]=(a[i-1]*10+7)%k;
    }
    bool flag=0;
    int ans;
    for(int i=1;i<=k;i++){
        if(a[i]%k==0){
            flag=1;
            ans=i;
            break;
        }
    }
    if(flag)
        cout<<ans;
    else
        cout<<"-1";
}

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

int main() {
  vector<string> s(3);
  for (int i = 0; i < 3; ++i) cin >> s[i];
  int n = s[0].size() + s[1].size() + s[2].size();
  vector<vector<vector<bool>>> goods(3, vector<vector<bool>>(3, vector<bool>(n + 1)));
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (i == j) continue;
      for (int k = 0; k < s[i].size(); ++k) {
        bool ok = true;
        for (int p = 0; p < s[j].size() && k + p < s[i].size(); ++p) {
          char a = s[i][k + p];
          char b = s[j][p];
          if (a != '?' && b != '?' && a != b) ok = false;
        }
        goods[i][j][k] = ok;
      }
    }
  }
  vector<int> ord(3);
  iota(ord.begin(), ord.end(), 0);

  int res = n;

  do {
    string a = s[ord[0]];
    string b = s[ord[1]];
    string c = s[ord[2]];
    for (int i = 0; i <= n; ++i) {
      for (int j = i; j <= n; ++j) {
        bool ok = true;
        int kv = max(a.size(), max(i + b.size(), j + c.size()));
        if (i < a.size()) {
          ok &= goods[ord[0]][ord[1]][i];
        }
        if (j < a.size()) {
          ok &= goods[ord[0]][ord[2]][j];
        }
        if (j - i < b.size()) {
          ok &= goods[ord[1]][ord[2]][j - i];
        }
        if (ok) res = min(res, kv);
      }
    }
  } while (next_permutation(ord.begin(), ord.end()));

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair

vector<int> v;

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a, b, c, x, y;
    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
    int ab = min(a + b, 2*c);
    int mn = min(x, y);
    LL res = mn * ab;
    LL mxtemp = max(x, y)*ab;
    x -= mn;
    y -= mn;
    if(x > 0)res += x * a;
    if(y > 0)res += y * b;
    res = min(mxtemp, res);
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<cmath>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    int cnt = 0;
    int m = n;
    while(m > 0){
        m /= 10;
        cnt++;
    }
    for(int i = 1; i < cnt; i += 2){
        ans += (int)pow(10, i) - (int)pow(10, i - 1);
    }
    if(cnt % 2 == 1){
        for(int i = (int)pow(10, cnt - 1); i <= n; i++){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* written by : vipin kumar */
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#define int long long int
#define mod 1000000007
int binary_search(int arr[],int start,int end,int val)
{
	if(start>end)
	   return -1;
	else
	{
		int mid=(start+end)/2;
		if(arr[mid]<=val)
		{
			int x=mid;
			int y=binary_search(arr,mid+1,end,val);
			if(y==-1)
			   return x;
			else
			   return y;
		}
		else
		   return binary_search(arr,start,mid-1,val);
	}
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     int n,m,k;
     cin>>n>>m>>k;
     int arr1[n+1],arr2[m+1];
     int j;
     for(j=1;j<=n;j++)
     {
		 cin>>arr1[j];
	 }
	 for(j=1;j<=m;j++)
	 {
		 cin>>arr2[j];
	 }
	 int prefix1[n+1]={0};
	 int prefix2[m+1]={0};
	 prefix1[1]=arr1[1];
	 prefix2[1]=arr2[1];
	 for(j=2;j<=n;j++)
	 {
		 prefix1[j]=arr1[j]+prefix1[j-1];
	 }
	 for(j=2;j<=m;j++)
	 {
		 prefix2[j]=arr2[j]+prefix2[j-1];
	 }
	 int answer=0;
	 for(j=0;j<=n;j++)
	 {
		 if(prefix1[j]<=k)
		 {
			 int here=j;
			 int left=k-prefix1[j];
			 int index=binary_search(prefix2,0,m,left);
			 here+=index;
			 answer=max(answer,here);
		 }
	 }
	 cout<<answer<<endl;
}


Measured memory_bytes: 9840
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  string c;
  cin >> c;
  int cnt = 0;
  REP(i, N) if(c[i] == 'R') cnt++;
  int ans = 0;
  REP(i, cnt) if(c[i] == 'W') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3784
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(n)       for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
    #ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    long long h, n = 1, t = 1; cin >> h;
    while(h>1)
        n *= 2, h /= 2, t += n;

    cout << t;
    return 0;
}

unsigned long long pow(long long base, long long power){
    if(power==0) return 1;
    if(power==1) return base;

    unsigned long long ans = pow(base, power/2);
    ans *= ans; /// ans = (ans%mod)*(ans%mod);

    if(power&1) return ans*base; /// (ans%mod)*(base%mod);
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(n+1)
        if(isPrime[i]) c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((b1[:, :], i8, i8, i8, i8), cache=True)
def main(wall, Sx, Sy, Tx, Ty):
    INF = 1 << 30
    H, W = wall.shape
    S = Sx * W + Sy
    T = Tx * W + Ty
    dist = np.full(H * W, INF, np.int64)
    deq = np.empty(H * W + 100, np.int64)
    dist[S] = 0
    deq[0], l, r = S, 0, 1
    while l < r:
        v, l = deq[l], l + 1
        vx, vy = divmod(v, W)
        # そのままあるく
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            wx, wy = vx + dx, vy + dy
            if not (0 <= wx < H):
                continue
            if not (0 <= wy < W):
                continue
            if wall[wx, wy]:
                continue
            w = wx * W + wy
            if dist[w] <= dist[v]:
                continue
            dist[w] = dist[v]
            deq[l - 1], l = w, l - 1
        # ワープする
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                wx, wy = vx + dx, vy + dy
                if not (0 <= wx < H):
                    continue
                if not (0 <= wy < W):
                    continue
                if wall[wx, wy]:
                    continue
                w = wx * W + wy
                if dist[w] <= dist[v] + 1:
                    continue
                dist[w] = dist[v] + 1
                deq[r], r = w, r + 1
    ans = dist[T]
    if ans == INF:
        ans = -1
    return ans

H, W = map(int, readline().split())
Sx, Sy = map(lambda x: int(x) - 1, readline().split())
Tx, Ty = map(lambda x: int(x) - 1, readline().split())
wall = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'#'

print(main(wall, Sx, Sy, Tx, Ty))


Measured memory_bytes: 117936
#include "bits/stdc++.h"
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main() {
	int n;
	cin>>n;
	int sum=(n%1000000000/100000000)+(n%100000000/10000000)+(n%10000000/1000000)+(n%1000000/100000)+
	(n%100000/10000)+(n%10000/1000)+(n%1000/100)+(n%100/10)+(n%10);
	if(n%sum==0){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

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

    ll ans = 0;
    for (int b = 1; b <= N; b++){
        int div = N/b;
        int mod = N%b;
        ans += max(b-K,0)*div + max(mod-K+1, 0);
        if (K == 0) ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;ll k;
    cin>>n>>k;
    vector<ll> a(n),f(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>f[i];
    sort(all(a));
    sort(all(f),greater<ll>());
    
    vector<pair<ll,ll>> vec(n);
    rep(i,n) {
        vec[i]={a[i]*f[i],f[i]};
    }
    sort(all(vec));
    reverse(all(vec));
    
    //最大値をmid以下にできるか？
    ll ng = -1, ok = LINF;
    while (ok - ng > 1) {
        ll mid = (ng + ok) / 2;
        
        ll cnt=0;
        rep(i,n) {
            ll p=vec[i].first,f=vec[i].second;
            cnt+=max((ll)0,((p-mid)+f-1)/f);
        }
        
        (cnt<=k ? ok : ng) = mid;
    }
    
    cout<<ok<<endl;
    //rep(i,n) {ll a,b,c;tie(a,b,c)=vec[i];cout<<a<<" "<<b<<" "<<c<<endl;};
}


Measured memory_bytes: 6528
import java.io.*;
import java.util.*;

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int k = in.nextInt();
            long preA[] = new long[n + 1];
            long preB[] = new long[m + 1];
            int max = 0;
            for (int i = 1; i < n + 1; i++){
                preA[i] = preA[i - 1] + in.nextInt();
            }
            for (int i = 1; i < m + 1; i++){
                preB[i] = preB[i - 1] + in.nextInt();
            }
            int cnt = 0;
            int i = 0;
            while (i <= n){
                if (preA[i] <= k){
                    i++;
                }
                else{
                    break;
                }
            }
            i--;
            max = i;
            int j = 1;
            for (int t = i; t >= 0; t--){
                while (j <= m){
                    if (preB[j] + preA[t] <= k){
                        j++;
                    }
                    else{
                        break;
                    }
                }
                j--;
                if (j == m){
                    max = Math.max(max, t + m);
                    break;
                }
                else{
                    max = Math.max(max, t + j);
                }
            }
            out.println(max);
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

Measured memory_bytes: 62416
#include <bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
int n,d,cnt;
int main()
{
//	freopen("1.in","r",stdoin)
	cin>>n>>d;
	for(reg int i=1;i<=n;i++)
	for(reg int j=10;j<=d;j++)
	{
		reg int x=j/10,x2=j%10;
		if(x*x2==i&&x>=2&&x2>=2)cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int b[n];
  memset(b,0,sizeof(b));
  int i;
  for(i=1;i<n;i++)
  {
    cin>>a[i];
    b[a[i]-1]++;
  }
  for(i=0;i<n;i++)
    cout<<b[i]<<endl;
  return 0;
}

Measured memory_bytes: 5144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scannerR = new Scanner(System.in);
		int r = scannerR.nextInt();

		if (0<=r && r<1200) {
			System.out.println("ABC");
		}else if (1200<=r && r<2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
			}




	}

}


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

int main () {
    int a,b;
    cin >> a >> b;
    bool f = 0;
    for (int i = 0; i <= a; i++) {
        int j = a - i;
        if (b == i * 2 + j * 4) f = 1;
    }
    cout << (f?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
signed main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  ll ans=0;
  rep(i,m) {
    cin >> a[i];
    ans += a[i];
  }
  cout << max(n-ans,(ll)-1) << endl;
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }
    if (S == "Cloudy") {
        cout << "Rainy" << endl;
    }
    if (S == "Rainy") {
        cout << "Sunny" << endl;
    }
}

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

#define endl '\n'
#define ll long long


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,cnt=0,i,j;
	cin >> n;
	string s;
	cin >> s;
	int x=s.size();
	if(x%2==1) cnt=1;
	for(i=0,j=n/2;i<n/2,j<n;i++,j++)
	{
		if(s[i]!=s[j])
		{
			cnt=1;
			break;
		}
	}
	if(cnt==1) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    
    vector<pint> a;
    REP(i, N) {
        int tmp;
        cin >> tmp;
        a.push_back(make_pair(tmp, i));
        // cout << tmp << i << endl;
        
    }

    sort(ALL(a));

    // REP(i, N) cout << a[i].first << a[i].second << endl;
    

    REP(i, N) cout << a[i].second + 1 << endl;

    return 0;
}

Measured memory_bytes: 1780
s = list(input())
t = list(input())
counter = 0
hey = ""
while len(s) > counter:
    if s == t:
        hey = "yes"
        break
    else:
        hey = s[len(s)-1]
        s.pop(len(s)-1)
        s.insert(0,hey)
    counter += 1
if hey == "yes":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#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();}
int N;
double dp[310][310][310];
double rec(int i ,int j, int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if(i == 0  && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if(i > 0) res += rec(i-1,j,k) * i;
    if(j > 0) res += rec(i+1,j-1,k) * j;
    if(k > 0) res += rec(i,j+1 ,k-1) * k;
    res += N;
    res *= 1.0/(double)(i+j+k);
    return dp[i][j][k] = res;
}

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

    cin >> N;
    int _1 = 0, _2 = 0 ,_3 = 0;
    rep(i,N){
        int a;
        cin >> a;
        if(a == 1) _1++;
        if(a == 2) _2++;
        if(a == 3) _3++;
    }
    memset(dp,-1,sizeof(dp));

    cout<< fixed << setprecision(10) << rec(_1,_2,_3) << endl;
    return 0;
}


Measured memory_bytes: 233088
S = gets.chomp
s = ""
(S.size).times do |i|
  if(s=="" && S[i]=="B")then
    #nothing
  elsif(S[i]=="0" || S[i]=="1")then
    s += S[i]
  elsif(s.size==1 && S[i]=="B")then
    s = ""
  elsif(S[i]=="B")then
    s = s[0..(s.size-2)]
  end
  #puts "#{i} : #{s}"
end

puts s


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  priority_queue<int> q;
  rep(i, n) q.push(a[i]);
  int cnt = 0;
  while(cnt < m) {
    int p = q.top(); q.pop();
    q.push(p/2);
    cnt++;
  }
  ll ans = 0;
  while(!q.empty()) {
    ans += q.top(); q.pop();
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1276
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
print(lcm_list([int(input()) for i in range(n)]))

Measured memory_bytes: 5460
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include<functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>

#define LL long long
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)

using namespace std;

int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}


int gcd(int i,int j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;

}

int tNoEP(){
	LL N,M;

	cin >> N >> M;

	loutp((N*(N-1))/2+(M*(M-1)/2));

	return 0;
}

bool isKaibun(string s){



	for(LL i = 0,j = s.length()-1; i < j;i++,j--){

		if(s[i] != s[j]) {
			return false;
		}

	}

	return true;
//	string rs = s;
//	reverse(s.begin(), s.end());
//
//	if(rs == s)
//		return true;
//	else
//		return false;
}

int SP(){

	string s;

	cin >> s;

	LL N = s.length();

	if(isKaibun(s) &&
			isKaibun(s.substr(0, (N-1)/2  )) &&
				isKaibun(s.substr((N+3)/2 -1 , N)))
		printf("Yes");
	else
		printf("No");

	return 0;

}

int MV(){

	LL L;

	cin >> L;

	double root = L/3.0;

	printf("%8.12f", root*root*root);

	return 0;
}

LL factor(LL n){


	int x_x = 1;

	if(n > 0){
		return n*factor(n-1);
	}
	else return x_x;

}
LL comb2(LL n){

	return n*(n-1)/2;

}

int BK(){
	LL N;
	N = linp();


	LL A[N] = {0};
	LL B[N] = {0};


	rep(i,0,N){
		A[i] = linp();
		B[A[i]-1]++;
	}

	LL allcom = 0;//何も抜き出さない場合

	rep(i,0,N){

		allcom += comb2(B[i]);
	}

	rep(k, 0 ,N){
		cout << allcom - comb2(B[A[k]-1]) + comb2(B[A[k]-1]-1) << endl;
	}

	return 0;

}

signed main() {

	//tNoEP();
	//SP();
	//MV();
	BK();
	return 0;
}




Measured memory_bytes: 5760
#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++)
typedef long long ll;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for (int i = 0; i < tx-sx; i++) cout << "R";
    for (int i = 0; i < ty-sy; i++) cout << "U";
    for (int i = 0; i < tx-sx; i++) cout << "L";
    for (int i = 0; i < ty-sy; i++) cout << "D";
    cout << "D";
    for (int i = 0; i <= tx-sx; i++) cout << "R";
    for (int i = 0; i <= ty-sy; i++) cout << "U";
    cout << "L";
    cout << "U";
    for (int i = 0; i <= tx-sx; i++) cout << "L";
    for (int i = 0; i <= ty-sy; i++) cout << "D";
    cout << "R" << endl;
}


Measured memory_bytes: 256
H,W = list(map(int,input().split()))
A = [list(input()) for _ in range(H)]
x = 0
y = 0
A[y][x] = 'x'
while True:
    if x < W-1 and A[y][x+1] == '#':
        x = x+1
        A[y][x] = 'x'
    elif y < H-1 and A[y+1][x] == '#':
        y = y+1
        A[y][x] = 'x'
    elif y < H-1 and A[y+1][x] == '.':
        print('Impossible')
        exit()
    else:
        break
for a in A:
    if '#' in a:
        print('Impossible')
        exit()
print('Possible')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    vector<vector<int>> g(n);
    g[x].emplace_back(y);
    g[y].emplace_back(x);
    for (int i = 0; i < n - 1; i++) {
        g[i].emplace_back(i + 1);
        g[i + 1].emplace_back(i);
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        vector<int> dis(n, 1e9);
        queue<int> que;
        que.push(i);
        dis[i] = 0;
        while (!que.empty()) {
            for (int j = que.size(); j > 0; j--) {
                int v = que.front();
                que.pop();
                for (int to : g[v]) {
                    if (dis[to] != 1e9) continue;
                    dis[to] = dis[v] + 1;
                    que.push(to);
                }
            }
        }
        for (int j = 0; j < n; j++) {
            ans[dis[j]]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
    int l;
    char s [10009];
    scanf("%s",s);
    l=strlen(s);
    if(s[l-1]!='s')
    printf("%ss\n",s);
    else
    printf("%ses\n",s);
       
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
int n, p[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        int a;
        cin>>a;
        p[a]=i;
    }
    int ans=0, now=0;
    for(int i=1; i<=n; i++)
    {
        if(p[i]<p[i-1])now=1;
        else now++;
        ans=max(ans, now);
    }
    cout<<n-ans<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

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

    int a;

    int mini, maxi;
    long sum;
    mini = 2000000;
    maxi = -2000000;
    sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        mini = min(a, mini);
        maxi = max(a, maxi);
        sum += a;
    }

    cout << mini << " " << maxi << " " << sum << endl;
}


Measured memory_bytes: 3112