akhauriyash/Code-Regression huggingface dataset:
import sys

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

INF = 10**9 + 7

N, M = map(int, readline().split())
key = [()] * M

for i in range(M):
    a, b = map(int, readline().split())
    c = map(int, readline().split())
    num = 0
    for j in c:
        num += 1 << (j - 1)
    key[i] = (num, a)


def solve():

    dp = [INF for _ in range(2**N)]
    dp[0] = 0

    for i in range(M):
        num, a = key[i]
        for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

    if dp[2**N - 1] == INF:
        ans = -1
    else:
        ans = dp[2**N - 1]

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3268
#include<cstdio>
#define MAX 5000000
#define SENTINEL 2000000000
int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
    int n1 = mid -left;
    int n2 = right -mid;
    for(int i=0; i<n1; i++) L[i] = A[left+i];
    for(int i=0; i<n2; i++) R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;

    int i=0, j=0;
    for(int 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(right-left > 1){
        int mid = (left+right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}
int main(){
    int S[MAX], n, i;

    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", &S[i]);

    mergeSort(S, n, 0, n);

    for(int i=0; i< n; i++){
        if(i) printf(" ");
        printf("%d", S[i]);
    }
    printf("\n");

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

    return 0;
}


Measured memory_bytes: 6480
#include<bits/stdc++.h>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
#define int              long long
#define ps(x,y)         fixed<<setprecision(y)<<x //how much precision is required
#define max(x,y)        ((x>y)?x:y)
#define min(x,y)        ((x<y)?x:y)
#define pb              push_back
#define mp              make_pair
#define vi              vector<int>
#define pii             pair<int,int>
#define setbits(x)      __builtin_popcountll(x)// how many 1 are present
#define zrobits(x)      __builtin_ctzll(x)//how many zero are present from left to first 1.
#define w(x)            int x; cin>>x; while(x--)
#define PI 3.1415926535897932384626
const int mod = 1000000007;//1e9+7

int32_t main()
{

int r;
cin>>r;
double ans;
ans=2*PI*r;  
cout<<ps(ans,25);  
}
 

Measured memory_bytes: 3788
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL A, B;
	cin >> A >> B;

	if (A <= 9 && B <= 9) {
		O(A * B);
	}
	else {
		O(-1);
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())

i = 1
ans = []

for i in range(N+1):
    if i%3 == 0 and i%5 == 0:
        i = 'FizzBuzz'
    elif i%3 == 0:
        i = 'Fizz'
    elif i%5== 0:
        i = 'Buzz'
    else:
        ans.append(i)

print(sum(ans))

Measured memory_bytes: 30024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int h, w;
    cin >> h >> w;
    int c[10][10];
    rep(i, 10) rep(j, 10) cin >> c[i][j];

    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    ll ans = 0;
    rep(i, h) rep(j, w){
        if (a[i][j] != -1) ans += c[a[i][j]][1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>
#include <ctype.h>

int main(void) {
    char moji;
    scanf("%c", &moji);

    if(isupper(moji) != 0){
        printf("A\n");
    }else if(islower(moji) != 0){
        printf("a\n");
    }
}

Measured memory_bytes: 1616
#include<stdio.h>
int main()
{
	int b[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};
	int i,j,k,d,s,t,s1,d1;
	scanf("%d",&i);
	for(;i>0;i--)
	{
		scanf("%d%d",&s,&t);
		for(j=0,d=99;j<25;j++)
		{
			if(b[j]==s)
			{
				k=j+1;
				for(;k<=25&&b[k]!=t;k++);
				if(k<26&&d>k-j)
				{
					s1=j;
					d1=k;
					d=k-j;
				}
			}
		}
		for(j=s1;j<=d1;j++)
			printf("%d%s",b[j],j==d1?"\n":" ");
	}
	return 0;
}

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

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

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

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

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n),imos(n+1),ls;
    imos[0]=0;
    for(ll i = 0; i < n; i++)
    {
        cin>>a[i];
        imos[i+1]=imos[i]+a[i];
    }
    
    for(ll r = 1; r <= n; r++)
    {
        for(ll l = 0; l < r; l++)
        {
            ls.push_back(imos[r]-imos[l]);
        }    
    }
    ll ans=0;

    
    for(int bitsft = 41; bitsft >= 0; bitsft--)
    {
        ll bit=(1LL<<bitsft);
        ll cnt=0;
        ll tmp=ans+bit;
        for(int i = 0; i < ls.size(); i++)
        {
            if((tmp & ls[i])==tmp) cnt++;
        }
        if(cnt>=k) ans=tmp;
    }
    

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll, int> mp;
    for (ll i = 1; i <= n; i++)
    {
        auto tmp = prime_factor(i);
        for (auto a : tmp)
        {
            mp[a.first] += a.second;
        }
    }
    ll ans = 0;
    ll p = 0, q = 0;
    for (auto a : mp)
    {
        if (a.second >= 74)
        {
            p++;
        }
    }
    ans += p;
    p = 0, q = 0;
    for (auto a : mp)
    {
        if (a.second >= 2)
        {
            p++;
            if (a.second >= 24)
            {
                q++;
            }
        }
    }
    ans += q * (p - 1);
    p = 0, q = 0;
    for (auto a : mp)
    {
        if (a.second >= 4)
        {
            p++;
            if (a.second >= 14)
            {
                q++;
            }
        }
    }
    ans += q * (p - 1);
    p = 0, q = 0;
    for (auto a : mp)
    {
        if (a.second >= 2)
        {
            p++;
            if (a.second >= 4)
            {
                q++;
            }
        }
    }
    ans += (q * (q - 1) / 2) * (p - 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	bool flag = 0;
	cin >> n;
	vs vans(n);
	REP(i, n) cin >> vans[i];
	cin >> m;
	vs  v(m);
	REP(i, m) cin >> v[i];
	REP(i, m)
	{
		REP(j, n)
		{
			if (v[i] == vans[j]) {
				if (flag == 0) {
					cout << "Opened by " << v[i] << endl;
					flag = 1;
				} else if (flag == 1) {
					cout << "Closed by " << v[i] << endl;
					flag = 0;
				}
				break;
			}
			if (j == n - 1) {
				cout << "Unknown " << v[i] << endl;
			}
		}
	}
}

Measured memory_bytes: 3240
n=int(input())
t=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=t[i]

m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  sumi=sum-t[p-1]+x
  print(sumi)
  

Measured memory_bytes: 38384
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main() //input->compute->output
{
        int N, K;
        cin >> N >> K;
        vector<int> vec(N);
        for (int i = 0; i < N; i++)
        {
                cin >> vec[i];
        }

        sort(vec.begin(), vec.end());
        int ans = (int)1e9 + 5000;
        for (int i = 0; i < N - K + 1; i++)
        {
                int cnt;
                cnt = abs(vec[i] - vec[i + K - 1]);
                ans = min(ans, cnt);
        }

        cout << ans << endl;

        return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  
  }
  
  int Ans = 0;
  
  for(int i = 0; i < N; i++){
  if(h.at(i) >= K) Ans ++;
  }
  
  cout << Ans << endl;
  
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define M 50000000
#define found 1
char H[M];

int getChar(char ch ){
	if( ch == 'A') 
		return 1;
	else if( ch == 'C') 
		return 2;
	else if( ch == 'G') 
		return 3;
	else if( ch == 'T') 
		return 4;
	
	return 0;
}

int getKey(char str[] ){
	int i;
	int key = 0, base = 1;
	for ( i=0; '\0'!=str[i]; i++ ) {
		key += base*( getChar( str[i] ) );
		base *= 5;
	}
	return key;
}

int find( char str[] ){
	if( found == H[ getKey( str ) ] ) 
		return found;
	else 
		return 0;
	
}

void insert(char str[] ){
	H[ getKey(str) ] = found;
	return;
}

int main() {

	int i, a;
	char str[14], com[9];
	
	scanf("%d", &a);
	for ( i = 0; i < a; i++ ) {
		scanf( "%s %s", com, str );
		if ( com[0] == 'i' )
			insert(str);
		else {
			if( find(str) ){
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
    return 0;
}



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

int main()
{
    int i;
    int turn = 0;
    int idx[3] = {0, 0, 0};
    string s[3];
    rep(i, 3) cin >> s[i];

    while (1)
    {
        if (s[turn].length() == idx[turn])
        {
            cout << (char)('A' + turn) << endl;
            break;
        }
        idx[turn] += 1;
        turn = s[turn][idx[turn] - 1] - 'a';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
int a,b,c,n,ans;
int main()
{
	cin>>a>>b>>c>>n;
	ft(i,0,a)
	  ft(j,0,b)
	    ft(k,0,c)
	      if(i*500+j*100+k*50==n) ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
cnt=0
for i in range(a,b+1):
    s=list(str(i))
    key="Yes"
    for j in range(len(s)//2):
        if s[j]!=s[len(s)-1-j]:
            key="No"
            break
    if(key=="Yes"):
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  char a, b; cin >> a >> b;
  bool ah = a == 'H';
  bool bh = b == 'H';
  if (ah == bh) cout << "H" << endl;
  else cout << "D" << endl;
}


Measured memory_bytes: 3560
n,y = map(int,input().split())
a = 0
for i in range (n + 1):
    for j in range(n + 1):
        k = n - i - j
        if k >= 0 and i*10000 + j*5000 + k*1000 == y:
            print("{0} {1} {2}".format(i,j,k))
            a = 1
            break
    if a == 1:
        break
if a == 0:
    print("-1 -1 -1")

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

int main() {
    std::cout<<std::fixed<<std::setprecision(100);
    double a, b;
    cin >> a >> b;
    cout << (int)a / (int)b << " " << (int)a % (int)b << " " << a / b << endl;
}



Measured memory_bytes: 3284
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if((b - a) == (c - b)){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        
        sc.close();
        
    }
}


Measured memory_bytes: 22484
a, b = [int(i) for i in input().split()]

def calc(a, b):
    if (abs(a - b) == 0) | (abs(a - b) == 1):
        return a + b
    else:
        if a > b:
            return a + (a - 1)
        else:
            return b + (b - 1)

print(calc(a, b))


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s, t;
    int a,b,c,d,e, n, m, k; cin >> s;

    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << '\n';

    else cout <<"No"   << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

 int a[100], n, i;

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

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

 for(i = n - 1; i >= 0; i--)
 {
     printf("%d", a[i]);
     if(i!=0)printf(" ");
 }
 printf("\n");

 return 0;

}

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

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; i++) cin >> a[i];
    for (int i = 0; i < t - 1; i++) {
        sort(a.begin(), a.end());
        for (int j = 0; j < t - 1; j++) {
            if (a[t - 1] > a[j]) {
                a[t - 1] -= a[j];
                a[j] = 0;               
            } else {
                a[j] -= a[t - 1];
                a[t - 1] = 0;
                break;
            }
        }
    }
    cout << max(0, a[t - 1] - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
    long N;
    std::cin >> N;
    long a[10000];
    for(long i=0; i<N; i++){
        std::cin >> a[i];
    }
    long temp=0;
    long counter=0;
    for(long i=0; i<N; i++){
        temp=0;
        while(a[i]%2==0){
            temp++;
            a[i]=a[i]/2;
        }
        counter+=temp;
    }
    std::cout << counter << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define nx '\n'
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define foi(i) for(auto i=v.begin();i!=v.end();i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
  int x, n, m;
  cin>>n;
  ll int res=0;
  vector<int>v;
  for(int i=0;i<n;i++){
      int a;
      cin>>a;
      v.push_back(a);
  }
  int max1=v[0];
  for(auto i:v){
      max1=max(i,max1);
        res+=max1-i;
  }
cout<<res;
  
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    // }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




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

const int MAXN = 200005;

int n;
char s[MAXN];

int main(){
	scanf("%s", s);
	n = strlen(s);
	
	int i = n - 1, j = 0;
	long long res = 0;
	while(i >= 0){
		if(i > 0 && s[i] == 'C' && s[i - 1] == 'B'){
			j++;
			i -= 2;
		}else{
			if(s[i] == 'A'){
				i--;
				res += j;
			}else{
				j = 0;
				i--;
			}
		}
	}
	printf("%lld\n", res);
	
	return 0;
}


Measured memory_bytes: 384
def main():
    dic = {}
    n = int(input())
    for i in range(n):
        s = input().rstrip()
        if s in dic.keys():
            dic[s] += 1
        else:
            dic[s] =  1
    m = 0
    for v in dic.values():
        if m < v:
            m = v
    s_dic = sorted(dic.items(), key=lambda x:x[0])
    for k, v in s_dic:
        if v == m:
            print(k)

if __name__ == "__main__":
    main()

Measured memory_bytes: 46556
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
template<typename ll_t,ll_t mod>
class basic_modint{
public:
    ll_t x_;
    basic_modint(ll_t x=0):x_((x%mod+mod)%mod){}
    basic_modint& operator+=(const basic_modint a)       { if((x_+=     a.x_)>=mod)x_-=mod; return *this; }
    basic_modint& operator-=(const basic_modint a)       { if((x_+= mod-a.x_)>=mod)x_-=mod; return *this; }
    basic_modint& operator*=(const basic_modint a)       { (x_*=a.x_)%=mod; return *this; }
    basic_modint  operator+ (const basic_modint a) const { basic_modint res(*this); return res+=a; }
    basic_modint  operator- (const basic_modint a) const { basic_modint res(*this); return res-=a; }
    basic_modint  operator* (const basic_modint a) const { basic_modint res(*this); return res*=a; }
    basic_modint  pow(ll_t t) const { if(t==0)return 1; basic_modint a = pow(t>>1); a*=a; if(t%2==1)a*=(*this); return a; }
    basic_modint  inv() const { return pow(mod-2); }
    basic_modint& operator/=(const basic_modint a)       { return (*this) *= a.inv(); }
    basic_modint  operator/ (const basic_modint a) const { basic_modint res(*this); return res/=a; }
    friend istream& operator>>(istream& ist, basic_modint& a) { ist>>a.x_; return ist; }
    friend ostream& operator<<(ostream& ost, basic_modint& a) { ost<<a.x_; return ost; }
};
using mint = basic_modint<ll,ll(1e9+7)>;
mint x[401][401]={},dp[401][401]={};
int main(){
    int n,c;
    cin >> n >> c;
    vector<int> a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    //x[i][j]=a[i]^j+...+b[i]^j
    rep(i,n)rep(j,c+1)rep2(k,a[i],b[i]+1)x[i][j]+=((mint)k).pow(j);
    //dp[i][j]=i変数j次の単項式の和
    dp[0][0]=1;
    rep2(i,1,n+1){
        rep(j,c+1){
            rep(k,j+1){
                dp[i][j]+=dp[i-1][k]*x[i-1][j-k];
            }
        }
    }
    cout << dp[n][c] << endl;
    return 0;
}

Measured memory_bytes: 2816
<?php
list($n) = ints();
$a = ints();
$cnt = [];
for ($i = 0; $i < $n; ++$i) {
    if (isset($cnt[$a[$i]])) $cnt[$a[$i]]++;
    else $cnt[$a[$i]] = 1;
}
$ans = 0;
foreach ($cnt as $i => $v) {
    if ($i <= $v) $ans += $v - $i;
    else $ans += $v;
}
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 19188
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"["; 
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif     
    int t=1;
    // cin>>t;
    while(t--)
    {
        string s;cin>>s;
        ll sum=0;
        f(i,0,si(s))
        {
          sum+=(s[i]-'0');
        }
        if(sum%9)
        cout<<"No";
        else
        {
          cout<<"Yes";
        }
        
    }
} 

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int main() {
   ll i,j,k;
    ll s[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
  cout <<s[k-1]  << endl;
}


Measured memory_bytes: 256
def main():
    A, B, C, X, Y = map(int, input().split())

    if X >= Y:
        tmp = min(Y * C * 2 + (X-Y) * A, X * C * 2)
    else:
        tmp = min(X * C * 2 + (Y-X) * B, Y * C * 2)

    print(min(A*X+B*Y, tmp))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  Vec(Q,lli,N,0);
  rep(i,0,N){
    cin >> P[i];
    Q[i]=P[i];
  }
  Sort(Q);
  rep(i,0,N){
    if(P[i]==Q[N-1])Out(Q[N-2]);
    else Out(Q[N-1]);
  }
}

Measured memory_bytes: 4736
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();        //a
		int b = sc.nextInt();        //b
		int c = sc.nextInt();        //c
		
		double Cc = c * Math.PI/180;
		
		double S = (a*b)*Math.sin(Cc) / 2; // 面積
		double L = a + b + Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(Cc)); // 周の長さ
		double h = b * Math.sin(Cc); //高さ
		
		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}
}



Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
long long Q,H,S,D,N,ans,k,kk,kkk;
int main()
{
    cin>>Q>>H>>S>>D>>N;
    k=min(Q*4,min(H*2,S));
    if(k*2<=D)
    {
    	cout<<k*N<<endl;
	}
	else
	{
		cout<<((N%2)*k)+N/2*D<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

struct state {
	ll n1, n2, n3;
	ll en1, en2, en3;
};

int main(){
	string S;
	cin >> S;
	int K;
	cin >> K;

	vector<state> dp(S.size());

	dp[0].en1 = 1;
	dp[0].n1 = S[0]-'1';
	dp[0].en2 = dp[0].en3 = dp[0].n2 = dp[0].n3 = 0;
	for(int i=1; i<S.size(); i++){
		dp[i].en1 = S[i]=='0'?dp[i-1].en1:0;
		dp[i].en2 = S[i]=='0'?dp[i-1].en2:dp[i-1].en1;
		dp[i].en3 = S[i]=='0'?dp[i-1].en3:dp[i-1].en2;

		dp[i].n1 = dp[i-1].n1 + 9 + (S[i]=='0'?0:dp[i-1].en1);
		dp[i].n2 = dp[i-1].n2 + dp[i-1].n1 * 9 + dp[i-1].en1 * max(S[i]-'1', 0)
			+ (S[i]=='0'?0:dp[i-1].en2);
		dp[i].n3 = dp[i-1].n3 + dp[i-1].n2 * 9 + dp[i-1].en2 * max(S[i]-'1', 0)
			+ (S[i]=='0'?0:dp[i-1].en3);
		debug(i, dp[i].en1, dp[i].en2, dp[i].en3, dp[i].n1, dp[i].n2, dp[i].n3);
	}

	state s = dp[S.size()-1];
	if(K==1) cout << s.n1 + s.en1 << endl;
	if(K==2) cout << s.n2 + s.en2 << endl;
	if(K==3) cout << s.n3 + s.en3 << endl;

	return 0;
}


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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


//naosu
long int gcd(long int a,long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

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

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

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

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

  return;
}


long int lcm(long int a,long int b){
  return a/gcd(a,b)*b;
}


long int f(long int n,long int c,long int d){
  long int cnt=n/c+n/d-n/lcm(c,d);
  return n-cnt;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int MOD=1e9+7; 
  /*
  long int kai[2000000];
  long int rekai[2000000];
  
  kai[0]=1;
  kai[1]=1;
  rekai[0]=1;
  rekai[1]=1;
  for(int i=2;i<2000000;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=MOD;

    rekai[i]=rekai[i-1]*modinv(i,MOD);
    rekai[i]%=MOD;
  }
  */

  long int n;
  scanf("%ld",&n);

  char s[n];
  char t[n];
  scanf("%s%s",s,t);

  long int ans=3;

  for(int i=0;i<n;i++){
    if(i==0){
      if(s[i]!=t[i]){
        i++;
        ans*=2;
      }
    }

    else{
      if(s[i-1]==t[i-1]){
        if(s[i]!=t[i]){
          i++;
        }
        ans*=2;
        ans%=MOD;
      }
      else{
        if(s[i]!=t[i]){
          ans*=3;
          ans%=MOD;
          i++;
        }
      }
    }
  }

  printf("%ld\n",ans);

  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
int main()
{
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    REP(i,N)cin >> A[i];
    if(H <= accumulate(A.begin(),A.end(),0))cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
import collections

n = int(input())
a = list(map(int, input().split()))
a.sort()
ac = collections.Counter(a)

#print(ac)

maxcnt = 0
for i in range(n):
    cnt = ac[a[i]] + ac[a[i]+1] + ac[a[i]+2]
    if cnt > maxcnt:
        maxcnt = cnt

print(maxcnt)

Measured memory_bytes: 14564
#include <stdio.h>

int main(void){
	int n,m,i,o;
	while(1){
        scanf("%d %d",&n,&m);
        if(!n)break;
        int score[100];
        char atari[100][9],a[1000][9];
        for(i=0;i<n;i++){
            scanf("%s %d",atari[i],&score[i]);
        }
        for(o=0;o<m;o++){
            scanf("%s",a[o]);
        }
        int ans=0;
        int j,k;
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                for(k=7;k>=0&&atari[i][k]!='*';k--){
                    if(atari[i][k]!=a[j][k]){
                        break;
                    }
                }
                if(atari[i][k]=='*'||k<0){
                    ans+=score[i];
                   // break;
                }
            }
        }
		printf("%d\n",ans);
	}
	return 0;
}
					

Measured memory_bytes: 612
ls = STDIN.map{|l| l.split(',').map(&:to_i)}
ls.map!.with_index{|l, i| (0...i-(ls.size/2)).to_a.map{nil} + l + (0...(ls.size/2)-i).to_a.map{nil}}

dp = Array.new(ls.size+1).map{Array.new}
m = 0
(0...ls.size).each do |n|
  ls[n].each_with_index do |v, i|
    unless v.nil?
      dp[n][i] = [(n-1>=0&&!dp[n-1][i].nil?) ? dp[n-1][i] : 0, (n-1>=0&&i-1>=0) ? dp[n-1][i-1] : 0].max + ls[n][i] 
      m = dp[n][i] if dp[n][i] > m
    end
  end
end
p m

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N;
    cin >> N;

    vector<pair<ll,ll>> pfact;

    ll c;
    for(ll p=2; p*p<=N; ++p) {
        c = 0;
        while(N % p == 0) {
            ++c;
            N /= p;
        }
        if(c > 0) pfact.pb({p, c});
    }
    if(N > 1) pfact.pb({N, 1});

    ll n, cnt = 0;
    FORR(p,pfact) {
        n = 1;
        while(true) {
            if(n*(n+1)/2 <= p.second && p.second < (n+1)*(n+2)/2) break;
            ++n;
        }
        cnt += n;
    }
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, l, sum=0;
    scanf("%d%d", &n, &l);
    vector<int>vc;
    for(int i=1; i<=n; i++)
        vc.push_back(l+i-1);
    sort(vc.begin(), vc.end());
    if(vc[0]>=0)
    {
        for(int i=1; i<n; i++)
            sum+=vc[i];
    }
    else if(vc[0]<=0 && vc[n-1]>0)
    {
        for(int i=0; i<n; i++)
            sum+=vc[i];
    }
    else if(vc[n-1]<=0)
    {
        for(int i=0; i<n-1; i++)
            sum+=vc[i];
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

ll modinv(ll a) {
  ll M = MOD, b = M, u = 1, v = 0;
  while (b)
    u -= a / b * v, swap(u, v), a %= b, swap(a, b);
  return (u % M + M) % M;
}

void solve() {
  ll N;
  cin >> N;
  vector<ll> C(N);
  rep (i, N) cin >> C[i];
  sort(C.begin(), C.end());

  ll ans = 0;
  vector<ll> accum(N + 1);
  accum[0] = 1;
  rep (i, N) {
    accum[i+1] = (accum[i] * 2) % MOD;
  }

  ll half = modinv(2);

  rep (i, N) {
    ll tmp = accum[N];
    tmp %= MOD;
    tmp *= accum[N-1];
    tmp %= MOD;
    tmp *= C[i];
    tmp %= MOD;
    tmp *= (N - i + 1);
    tmp %= MOD;
    tmp *= half;
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 3456
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int n ,m; cin >> n >> m;
	vector<pair<int,int>> bridges;
	int a,b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		bridges.push_back(make_pair(a,b));
	}
	int count = 0;
	for (int i = 1; i <= n; i++) {
		for (auto bridge : bridges) {
			if (bridge.first == i) {
				count++;
			}
			if (bridge.second == i) {
				count++;
			}
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tr1/unordered_map>
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int N = 100;
const int mo = 998244353;

inline string get_substr(const string& x, int l, int sl) {
    string tmp, res;

    for(int i = 0; i < sl; ++i) res += '1';
    for(int i = 0; i < l; i += sl) {
        tmp = x.substr(i, sl);
        
        for(int j = 0; j < sl; ++j) {
            res[j] = ((res[j] - '0') && (tmp[j] - '0')) + '0';
        }
    }
    return res;
}

std::tr1::unordered_map<string, int> mp;

int dp(string x) {

    if(mp.count(x)) return mp[x];

    int len = x.length();
    int res = 1ll * dp(x.substr(0, len-1)) * dp(x.substr(len-1, 1)) % mo;

    for(int i = 1; i <= len; ++i) {
        for(int j = i+i; j <= len; j += i) {

            string lft = x.substr(0, len - j);
            string rht = get_substr(x.substr(len - j, j), j, i);

            res = (res + 1ll * dp(lft) * dp(rht)) % mo;
        }
    }
    return mp[x] = res;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif 

    string st;
    std::cin >> st;

    mp[""] = 1;
    mp["0"] = 1; 
    mp["1"] = 2;

    printf("%d\n", dp(st));

    return 0;
}


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

int main(){

int x;
cin >>x;
int yak[100000]={0}; //y番目の約数がd[y]に
int d=1, y=1;
while(d*d<=x){
    if(x%d==0) {
        yak[y]=d;
        y++;
    }
    d++;
}
int i=1;
while(yak[i]!=0){
    for(int a=0; a*a*a*a<x; a++){
        
        int b=a - yak[i];
        int c=a*a*a*a+ a*a*a*b+ a*a*b*b+ a*b*b*b+ b*b*b*b;
        if(c==x/yak[i]) {
            cout << a << " " << b << endl;
            return 0;
        }
    }
    i++;
}


}

Measured memory_bytes: 3984
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli a, b, c;
    cin>>a>>b>>c;
    out((b+c>a?b+c-a:0));
}

Measured memory_bytes: 3592
//g++ test1.cc　でコンパイル
//./a.out <input.txt
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;

int main(){
  ll N,Y;
  cin >>N>>Y;
  ll resa=-1,resb=-1,resc=-1;
  for(int a=0;a<=N;++a){
    for(int b=0;a+b<=N;++b){
      int c=N-a-b;
      ll total=10000*a+5000*b+1000*c;
      if (total==Y){
        cout <<a<<" "<<b<<" "<<c<<endl;
        return 0;
      }
    }
  }
  cout <<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
int h,w,n,a;
  cin>>h>>w>>n;
  if(n%max(h,w)!=0){
	cout<<n/max(h,w)+1<<"\n";
  }else{
  cout<<n/max(h,w)<<"\n";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,m,K;
int in[N],A[N];
vector<int>P;
void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=n;i>=1;i--){
		int cnt=A[i];
		for(int j=i+i;j<=n;j+=i){
			cnt^=in[j];
		}
		if(cnt==1){
			in[i]=1;
			P.push_back(i);
		}
	}
	printf("%d\n",P.size());
	for(int i=P.size()-1;i>=0;i--){
		printf("%d ",P[i]);
	}puts("");
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a >= b){
    for(int i=0; i<a; i++){ 
      cout << b;
    }
  }else{
    for(int i=0; i<b; i++){ 
      cout << a;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))
mylist = []
for i in range(n):
    tmp = abs(a - (t - h[i] * 0.006))
    mylist.append(tmp)
minVal = min(mylist)
ans = mylist.index(minVal)
print(ans + 1)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
  	int r, d;
   	long long x;
  	cin >> r >> d >> x;
  	for (int i = 1; i <= 10; i++)
    {
   		x = x * r - d;
      	cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
typedef long long ll;
using namespace std;

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

ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/g*b;
}

int main(){
  int n;
  cin>>n;
  ll ans=1ll;

  for(int i=0;i<n;i++){
    ll t;
    cin>>t;
    ans=lcm(ans,t);
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
int cnt[8];
int main()
{
	int n;
	string s;
	cin >> n >> s;
	long long ans=1;
	for (char c:s)
	{
		int a=1;
		if (c=='G')
		a=2;
		if (c=='B')
		a=4;
		if (cnt[a^7])
		{
			ans=(ans*cnt[a^7])%mod;
			cnt[a^7]--;
		}
		else if (a!=1 && cnt[1])
		{
			ans=(ans*cnt[1])%mod;
			cnt[1]--;
			cnt[a^1]++;
		}
		else if (a!=2 && cnt[2])
		{
			ans=(ans*cnt[2])%mod;
			cnt[2]--;
			cnt[a^2]++;
		}
		else if (a!=4 && cnt[4])
		{
			ans=(ans*cnt[4])%mod;
			cnt[4]--;
			cnt[a^4]++;
		}
		else
		cnt[a]++;
	}
	for (int i=2;i<=n;i++)
	ans=(ans*i)%mod;
	printf("%lld",ans);
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
int main() {
    int d,n;
    cin >> d >> n;
    if(n % 100 != 0) {
        for(int i = 0;i < d;i++) {
            n *= 100;
        }
        cout << n << endl;
    }else {
        for(int i = 0;i < d;i++) {
            n *= 100;
        }
        n += (int)pow10(2 * d);
        cout << n << endl;
    }
}


Measured memory_bytes: 512