akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
struct P{
    int a,b;
};
P p[100010];
int cmp(P x,P y){
    return x.a<y.a;
}
int main(){
    int n,m,i,j;
    long long k;
    cin >> n >> m;
    for(i=0;i<n;i++){
        cin >> p[i].a >> p[i].b;
    }
    sort(p,p+n,cmp);
    j=m;
    k=0;
    for(i=0;i<n;i++){
        if(p[i].b<j){
            j-=p[i].b;
            k+=1ll*p[i].a*p[i].b;
        }
        else{
            k+=1ll*p[i].a*j;
            break;
        }
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;
std::vector<int> v;
int n;
int memo[50][100005];
int solve(int indx,int x){
	if(x>n)return 1e9;
	if(x==n)return 0;
	if(indx==sz(v)-1)return n-x;
	int &ret = memo[indx][x];
	if(~ret)return ret;
	ret = solve(indx+1,x);
	int g = min(solve(indx,x+v[indx])+1,solve(indx+1,x+v[indx])+1);
	ret=min(ret,g);
	return ret;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	

	scanf("%d",&n);
	memset(memo,-1,sizeof(memo));
	int curr = 9;
	while(curr<=n)v.pb(curr),curr*=9;
	curr = 6;
	while(curr<=n)v.pb(curr),curr*=6;
	v.pb(1);
	printf("%d\n",solve(0,0));
}	



Measured memory_bytes: 20608
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

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

    if (n == 1)
        return cout << p << endl, 0;
    rep(i, 2, sqrt(p) + 1)
    {
        ll cnt = 0;
        while (p % i == 0)
        {
            p /= i;
            cnt++;
        }
        ans *= pow(i, cnt / n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
import sys
import math
from functools import cmp_to_key

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)


def main():
    n, x, m = map(int, input().split())
    s = [0] * int(1e5 + 10)
    dp = [x]
    s[x] = 1
    a = x
    for i in range(int(1e5+10)):
        a = a * a % m
        if s[a]:
            first = dp[:dp.index(a)]
            dp = dp[dp.index(a):]
            break
        else:
            dp.append(a)
            s[a] = 1
    ans = sum(first[:n])
    n -= len(first)
    if n <= 0:
        print(ans)
        return
    cyc = sum(dp)
    if a == 0:
        print(ans + sum(dp[:n]))
        return
    ans += cyc * (n // len(dp))
    for i in range(n % len(dp)):
        ans += dp[i]
    print(ans)


main()


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool chkmax(int &x,int y){return x<y?x=y,true:false;}
bool chkmin(int &x,int y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int a[5];

int main(){
	for(int i=1;i<=3;i++) a[i]=readint();
	sort(a+1,a+4);
	if(a[1]%2==0||a[2]%2==0||a[3]%2==0) printf("0\n");
	else printf("%lld\n",1ll*a[1]*a[2]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
int main() {
    ll N;
    cin >> N;
    vector<ll> num(N);
    vector<ll> bai(N);
    ll now = 0;
    rep(i,N)cin >> num[i] >> bai[i];
    for(ll i = N - 1;i>=0;i--){
        if((num[i] + now) % bai[i] != 0){
        now += bai[i] - (num[i] + now) % bai[i];
    }
    }
    cout << now << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int length = arr.length + 2;
        int[] inputs = new int[length];
        for (int i = 1; i < length - 1; i++) {
            inputs[i] = arr[i - 1] - '0';
        }
        int[][] dp = new int[length][2];
        dp[0][0] = 0;
        dp[0][1] = Integer.MAX_VALUE / 10;
        for (int i = 1; i < length; i++) {
            int x = inputs[length - i - 1];
            dp[i][0] = Math.min(getCount(x) + dp[i - 1][0], getCount(x + 1) + dp[i - 1][1]);
            dp[i][1] = Math.min(getReturn(x) + dp[i - 1][0], getReturn(x + 1) + dp[i - 1][1]);
        }
        System.out.println(dp[length - 1][0]);
    }
    
    static int getCount(int x) {
        switch (x) {
            case 0:
                return 0;
            case 1:
                return 1;
            case 2:
                return 2;
            case 3:
                return 3;
            case 4:
                return 4;
            case 5:
                return 5;
            case 6:
                return 6;
            case 7:
                return 7;
            case 8:
                return 8;
            case 9:
                return 9;
            case 10:
                return 1;
        }
        return 0;
    }
    
    static int getReturn(int x) {
        switch (x) {
            case 0:
                return Integer.MAX_VALUE / 10;
            case 1:
                return 9;
            case 2:
                return 8;
            case 3:
                return 7;
            case 4:
                return 6;
            case 5:
                return 5;
            case 6:
                return 4;
            case 7:
                return 3;
            case 8:
                return 2;
            case 9:
                return 1;
            case 10:
                return 0;
        }
        return 0;
    }
}

Measured memory_bytes: 72236
import math
def gcd(a, b, c):
    return math.gcd(math.gcd(a, b), c)

n = int(input())
res = 0

for i in range(n):
    for j in range(i, n):
        for k in range(j, n):
            if i == j and j == k:
                res = res + gcd(i + 1, j + 1, k + 1)
            elif i == j or j == k:
                res = res + gcd(i + 1, j + 1, k + 1) * 3
            else:
                res = res + gcd(i + 1, j + 1, k + 1) * 6

print(res)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
using namespace std;
int sum[maxn], prime[maxn], tot, mod = 1e9 + 7;
bool check[maxn];
void init(int n){
    tot = 0; sum[1] = 1;
    for(int i = 2; i <= n; i++){
        if(!check[i]) {
            prime[tot++] = i;
            sum[i] = i - 1;
        }
        for(int j = 0; j < tot && prime[j] <= n / i; j++){
            check[i * prime[j]] = 1;
            if(i % prime[j])
                sum[i * prime[j]] = sum[i] * (prime[j] - 1);
            else{
                sum[i * prime[j]] = sum[i] * prime[j];
                break;
            }
        }
    }
    for(int i = 1; i<= n; i++) sum[i] = (sum[i] + sum[i - 1]) % mod;
}
ll qpow(ll a, ll n){
    ll ans = 1;
    for(a %= mod; n; n >>= 1){
        if(n & 1) ans = ans * a % mod;
        a = a * a % mod;
    }
    return ans % mod;
}
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    init(maxn - 1);
    int n, k; scanf("%d%d", &k, &n);
    ll ans = 0;
    for(int i = 1, r; i <= n; i = r + 1){
        r = min(n / (n / i), n);
        ans += qpow(n / i, k) * (sum[r] - sum[i - 1]) % mod;
        ans %= mod;
    }
    printf("%lld\n", (ans + mod) % mod);
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, k;
  cin >> n >> k;
  vll a(n);
  vin(a);

  map<ll, ll> kind;
  vrep(i, a){
    if(kind.count(i)) kind[i]++;
    else kind[i] = 1;
  }

  vll kindv(0);
  vrep(i, kind) kindv.push_back(i.second);
  sort(all(kindv), greater<ll>());
  ll size = kindv.size();
  cout << n - accumulate(kindv.begin(), kindv.begin()+ min(k, size), 0) << endl;
}

Measured memory_bytes: 16500
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

int main(void) {
	uint32_t N;

	scanf("%"PRIu32, &N);

	printf("AB%s", N < 1000 ? "C" : "D");

	return 0;
}


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

// #define int long long

signed main()
{
    int i=0, j=0, k=0, ans=0;
    int N, A[200005]={0};
    cin>>N;
    for(i=2;i<=N;i++){
        cin>>A[i];
    }

    int a[200005]={0};
    for(j=2;j<=N;j++){
        a[A[j]]++;
    }

    for(k=1;k<=N;k++)
        cout<<a[k]<<endl;
    return 0;
}

Measured memory_bytes: 5196
N = int(input())
A = list(map(int, input().split()))
Amax = max(A)
lis = [0]*(Amax+1)
lis2 = [False]*(Amax+1)
for i in range(N):
  lis[A[i]] += 1
setwise = False
for t in range(2,Amax+1):
  if lis2[t]==True:
    continue
  p = t
  cnt = 0
  while p<=Amax:
    lis2[p] = True
    cnt += lis[p]
    p += t
  if cnt==N:
    print('not coprime')
    break
  if 2<=cnt<N:
    setwise=True
else:
  if setwise==True:
    print('setwise coprime')
  else:
    print('pairwise coprime')


Measured memory_bytes: 207484
#include<iostream>
using namespace std;
int main(void){
int A,B,sum,j;
sum=0;
cin>>A>>B;
for(j=0; j<2; j++){
    if(A>=B){
        sum+=A;
        A--;
    }else{
        sum+=B;
        B--;
    }
}
cout<<sum<<endl;

return 0;
}   

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << '\n';
}

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

using namespace std;
typedef long long ll;
#define int ll

template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b)
{
    if (a > b)
        a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b)
{
    if (a < b)
        a = b;
}

#define REP(i, n) for (int i = 0; i < n; ++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

const ll LLINF = (1LL << 60);
const int INF = (1LL << 30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    vector<int> v;

    REP(i, 3)
    {
        int n;
        cin >> n;
        v.push_back(n);
    }

    SORT(v);

    if (v[0] == v[1])
    {
        if (v[1] != v[2])
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    else
    {
        if (v[1] == v[2])
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }

    return 0;
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

string s;
int n,m;
int main() {
    scanf("%d%da",&n,&m);
    vector<int>a(m);
    vector<int>b(m);
    rep(i,0,m){
        cin >> a[i] >> b[i];
    }
    int num[n+1] = {0};
    rep(i,0,m){
        num[a[i]]++;
        num[b[i]]++;
    }
    rep(i,1,n+1){
        printf("%d\n",num[i]);
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ0001
{
    class Program
    {
        static void Main()
        {
            var mountains = new int[10];
            for (var i = 0; i < 10; i++)
            {
                mountains[i] = int.Parse(Console.ReadLine() ?? "");
            }
            foreach (var mountain in mountains.OrderByDescending(i => i).Take(3))
            {
                Console.WriteLine(mountain);
            }
        }
    }
}

Measured memory_bytes: 6348
dat = input().split()
a = int(dat[0])
op = dat[1]
b = int(dat[2])

while (op != "?"):
    if (op=="+"):
        print(a+b)
    if (op=="-"):
        print(a-b)
    if (op=="*"):
        print(a*b)
    if (op=="/"):
        print(int(a/b))
    
    dat = input().split()
    a = int(dat[0])
    op = dat[1]
    b = int(dat[2])


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    if(S.at(0)==S.at(1) || S.at(1)==S.at(2) || S.at(2)==S.at(3) ){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define int long long
signed main()
{
	set<int> s;
	map<int,int> cache;
	s.insert(0);
	cache[0] = 0;
	for(int i = 1;i <= 2000;++i)
	{
		int r = i * i * i * i * i;
		s.insert(r);
		cache[r] = i;
		s.insert(-r);
		cache[-r] = -i;
	}
	int x;cin >> x;
	for(set<int>::iterator it = s.begin();it != s.end();++it)
	{
		if(s.count(x + (*it)))
		{
			cout << cache[x + (*it)] << " " << cache[(*it)];
			return 0;
		}
	}
    return 0;
}


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

typedef complex<double> xy_t;

int M, N, VM[500], VN[500];


double area( int V[], int L ) {

	double suma = 0, sumv = 0;

	for ( int i = 0; i < L - 1; i++ ) {
	
		suma += sin( V[i] * atan( 1 ) / 45 );
		sumv += V[i];
	
	}
	
	suma += sin( ( 360 - sumv ) * atan( 1 ) / 45 );
	
	return suma;

}

int main() {
	
	while ( cin >> M && M ) {
	
		for ( int i = 0; i < M - 1; i++ ) { cin >> VM[i]; }
		cin >> N;
		for ( int i = 0; i < N - 1; i++ ) { cin >> VN[i]; }
		
		double am = area( VM, M );
		double an = area( VN, N );
		
		if ( abs( am - an ) < 1e-8 ) { cout << 0 << endl; }
		else if (am > an) { cout << 1 << endl; }
		else { cout << 2 << endl; }
	
	}
	
}

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

int main(){
  int n,k,num=1;
  cin >> n >> k;
  int i=1,tw=1;
  for(i=0;;i++){
    if(tw>=k)break;
    tw*=2;
  }
  
  for(int j=0;j<n;j++){
    if(j<i)num*=2;
    else num +=k;
  }
  cout << num << endl;
}

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

int32_t main(){
    int n;
    cin >> n;
    int a, b, c;
    cin >> a >> b >> c;
    vector<vector<int>> dp(2, vector<int>(3));
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for(int i=1; i<n; i++){
        cin >> a >> b >> c;
        dp[1][0] = a + max(dp[0][1], dp[0][2]);
        dp[1][1] = b + max(dp[0][0], dp[0][2]);
        dp[1][2] = c + max(dp[0][0], dp[0][1]);
        dp[0] = dp[1];
    }
    cout << max(dp[0][0], max(dp[0][1], dp[0][2])) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n][n - 1];
    int gamenum = n * (n - 1) / 2;
    vector<vector<int>> g(gamenum);
    map<pair<int, int>, int> mp;
    int cnt = 0;
    rep(i, 0, n) {
        rep(j, 0, n - 1) {
            cin >> a[i][j];
            a[i][j]--;
            int mn = min(i, a[i][j]);
            int mx = max(i, a[i][j]);
            if (mp.find(make_pair(mn, mx)) == mp.end()) {
                mp[make_pair(mn, mx)] = cnt;
                cnt++;
            }
        }
    }
    rep(i, 0, n) {
        rep(j, 0, n - 2) {
            int from = mp[make_pair(min(i, a[i][j]), max(i, a[i][j]))];
            int to = mp[make_pair(min(i, a[i][j + 1]), max(i, a[i][j + 1]))];
            g[from].push_back(to);
        }
    }

    int in[gamenum] = {};
    rep(i, 0, gamenum) {
        rep(j, 0, g[i].size()) {
            in[g[i][j]]++;
        }
    }

    bool finished[gamenum] = {};
    vector<int> order;
    int dist[gamenum];
    int mxdist = -1;
    rep(i, 0, gamenum) dist[i] = 1;
    rep(i, 0, gamenum) {
        if (in[i] == 0 && !finished[i]) {
            queue<int> que;
            que.push(i);
            finished[i] = true;
            order.push_back(i);
            while (!que.empty()) {
                int now = que.front();
                que.pop();
                for (int next : g[now]) {
                    in[next]--;
                    if (in[next] == 0 && !finished[next]) {
                        que.push(next);
                        finished[next] = true;
                        order.push_back(next);
                    }
                    if (dist[now] + 1 > dist[next]) {
                        dist[next] = dist[now] + 1;
                        mxdist = max(mxdist, dist[next]);
                    }
                }
            }
        }
    }

    if ((int)order.size() != gamenum) {
        cout << -1 << endl;
    } else {
        cout << mxdist << endl;
    }
    return 0;
}


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N = 3005;

int n;
ld a[N], res;
ld memo[N][N];

ld coins(int idx, int head, int tail) {
	if (head < 0 || tail < 0)return 0.00;
	if (idx == n) {
		if (head == 0 && tail == 0) return 1.00;
		else return 0.00;
	}
	if (memo[idx][head] != -1.00) return memo[idx][head];
	ld ans = 0.00;
	if (head) {
		ans += (coins(idx + 1, head - 1, tail) * a[idx]);
	}
	if (tail) {
		ans += (coins(idx + 1, head, tail - 1) * (1.00 - a[idx]));
	}
	return memo[idx][head] = ans;
}

void solve() {
	int i, j, k, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			memo[i][j] = -1;
		}
	}
	for (i = n / 2 + 1; i <= n; i++) {
		res += coins(0, i, n - i);
	}
	cout << setprecision(10) << fixed;
	cout << res;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 141568
#include<bits/stdc++.h>
using namespace std;
 
int64_t GCD(int64_t x,int64_t y){
  if(y == 0) return x;
  else return GCD(y,x%y);
}
int64_t LCM(int64_t x, int64_t y){
  return x  / GCD( x, y)*y;
}
 
int main(){
  int N;
  cin >> N;
  int64_t ans = 1;
  for(int i = 0; i < N; i++){
    int64_t T;
    cin >> T;
    ans = LCM(ans, T);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  long double A, B, X;
  cin >> A >> B >> X;

  long double ok = kPI / 2.0;
  long double ng = 0.0;
  REP(i, 0, 100000) {
    long double mid = (ok + ng) / 2.0;
    long double ans = 0.0;
    if (mid > kPI / 2.0 - 0.0000000001) {
      ans = 0.0;
    } else {
      if (A * tan(mid) <= B) {
        ans = A * A * B - A * A * A * tan(mid) / 2.0;
      } else {
        ans = B * B / tan(mid) * A / 2.0;
      }
    }

    if (ans < X) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok / kPI * 180 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        char x;
        cin>>x;
        if((ll)(x - 'A') <= 26) cout<<'A';
        else cout<<'a';
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>

using namespace std;

int main(){
  string a;
  cin >> a;
  int cnt = 0;
  int i = 0;
  while(a.size() > i+1){
  	if(a[i] != a[i+1]){
      	a.erase(i,2);
    	cnt++;
      	if(i>0) i--;
    }else{
      i++;
    }
  }
  cout << 2 * cnt << endl;
}

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

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

int a[100], n, neg, pos, mx = -1e9, pm, mn = 1e9, pn; 
vector<ii> sol;

void do_pos() {
	for(int i = 1; i < n; i++) 
		sol.push_back({i, i + 1}); 
}
void do_neg() {
	for(int i = n - 1; i >= 1; i--) 
		sol.push_back({i + 1, i});
}

int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]); 
		neg += a[i] <= 0; 
		pos += a[i] >= 0;
		if(a[i] > mx) mx = a[i], pm = i;
		if(a[i] < mn) mn = a[i], pn = i;
	}
	if(neg == n) do_neg(); 
	else if(pos == n) do_pos(); 
	else if(abs(mx) > abs(mn)) {
		for(int i = 0; i < n; i++) 
			sol.push_back({pm + 1, i + 1});
		do_pos(); 
	} else {
		for(int i = 0; i < n; i++) 
			sol.push_back({pn + 1, i + 1});
		do_neg();
	}
	printf("%d\n", sol.size());
	for(auto x : sol) 
		printf("%d %d\n", x.first, x.second);
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W = MAP()
N = INT()
a = LIST()

cnt = 0
ans = [[-1]*W for _ in range(H)]
tmp = a.pop(0)
color = 1
flg = 0

for i in range(H):
	for j in range(W):
		if i%2 == 1:
			j = -j-1
		ans[i][j] = color
		tmp -= 1
		if tmp == 0:
			if not a:
				break
			tmp = a.pop(0)
			color += 1



for i in ans:
	print(" ".join([str(x) for x in i]))


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

int main() {
  int r, c, count;
  cin >> r >> c;
  vector<vector<int> > v(r, vector<int>(c));

  for(int i = 0; i < r; ++i) {
    for(int j = 0; j < c; ++j) {
      cin >> v.at(i).at(j);
    }
  }


  for(int i = 0; i < r; ++i) {
    count = 0;
    for(int j = 0; j < c; ++j) {
      cout << v.at(i).at(j) << " ";
      count += v.at(i).at(j);
    }
    cout << count << endl;
    v.at(i).push_back(count);
  }

  int rr = v.at(0).size();
  int cc = v.size();

  vector<vector<int> > vv(rr, vector<int>(cc));

  for(int i = 0; i < v.size(); ++i) {
    for(int j = 0; j < v.at(0).size(); ++j) {
      vv.at(j).at(i) = v.at(i).at(j);
    }
  }

  for(int i = 0; i < vv.size(); ++i) {
    count = 0;
    for(int j = 0; j < vv.at(0).size(); ++j) {
      count += vv.at(i).at(j);
    }
    if(i == vv.size() - 1) cout << count;
    else cout << count << " ";
  }
  cout << endl;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

int dp[303][303][303];
int N,M;
int L[333],R[333],X[333];

vpint qs[333];

signed main(){
    cin>>N>>M;
    rep(i,M)cin>>L[i]>>R[i]>>X[i],L[i]--;

    rep(i,M){
        qs[R[i]].pb({L[i],X[i]});
    }

    for(auto t:qs[1]){
        if(t.se!=1){
            cout<<0<<endl;
            return 0;
        }
    }
    dp[1][N][N]=3;
    for(int i=1;i<N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                if(dp[i][j][k]==0)continue;
                if(j==N&&k==N){
                    add(dp[i+1][N][N],dp[i][j][k]);
                    add(dp[i+1][i-1][N],dp[i][j][k]*2%mod);
                }
                else if(k==N){
                    add(dp[i+1][j][N],dp[i][j][k]);
                    add(dp[i+1][i-1][N],dp[i][j][k]);
                    add(dp[i+1][i-1][j],dp[i][j][k]);
                }
                else{
                    add(dp[i+1][j][k],dp[i][j][k]);
                    add(dp[i+1][i-1][k],dp[i][j][k]);
                    add(dp[i+1][i-1][j],dp[i][j][k]);
                }
            }
        }
        for(auto &t:qs[i+1]){
            for(int j=0;j<=N;j++){
                for(int k=0;k<=N;k++){
                    if(dp[i+1][j][k]==0)continue;
                    if(t.se==3){
                        if(k==N||t.fi>k)dp[i+1][j][k]=0;
                    }
                    else if(t.se==2){
                        if(j==N||t.fi>j||(k!=N&&t.fi<=k))dp[i+1][j][k]=0;
                    }
                    else if(t.se==1){
                        if(j!=N&&t.fi<=j)dp[i+1][j][k]=0;
                    }
                }
            }
        }
    }

    int ans=0;
    rep(i,N+1)rep(j,N+1)add(ans,dp[N][i][j]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 215296
#include<iostream>

using namespace std;

int main(){
  int sx , sy , tx , ty;

  cin >> sx >> sy >> tx >> ty;
  
  string go_r = "";
  string go_u = "";
  string back_l = "";  
  string back_d = "";
  
  for(int i = sx ; i < tx ; i++ )
      go_r += 'R';
  for(int i = sy ; i < ty ; i++ )
      go_u += 'U';
  for(int i = tx  ; i > sx ; i-- ) 
      back_l += 'L';
  for(int i = ty  ; i > sy ; i-- )
      back_d += 'D';
  string OUT = go_r + go_u + back_l + back_d + 'L' + go_u + 'U' + go_r + 'R' + 'D' + 'R' + 'D' + back_d + back_l + 'L' + 'U';
  cout << OUT << endl;
  
  return 0;
}

Measured memory_bytes: 256
def cal(W, H, x, y, r):
    right =  x + r
    left = x - r
    top =  y + r
    bottom = y - r
    if (right > W or left < 0 or top > H or bottom < 0):
        return "No"
    else:
        return "Yes"


W, H, x, y, r = map(int, input().split())
print(cal(W,H,x,y,r))

Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> used(1000010, 0);
    rep(i, n)
    {
        cin >> a[i];
        used[a[i]]++;
    }

    ll ans = 0;
    rep(i, n)
    {
        vector<ll> b = divisor(a[i]);
        int f = 1;
        for (auto it : b)
        {
            if ((used[it] > 0 && it < b[b.size() - 1]) || (used[it] > 1 && a[i] == it))
            {
                f = 0;
                break;
            }
        }
        if (f) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12712
unittest
{
	assert( [ "4 3", "4 3 -4 -2" ].parse.expand.solve == -8 );		// 追加ケース
	assert( [ "10 40", "-5 -4 -3 -2 1 0 0 0 0 0" ].parse.expand.solve == 6 );		// 追加ケース
	
	assert( [ "4 3", "3 3 -4 -2" ].parse.expand.solve == -6 );
	assert( [ "10 40", "5 4 3 2 -1 0 0 0 0 0" ].parse.expand.solve == 6 );
	assert( [ "30 413", "-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0" ].parse.expand.solve == 448283280358331064 );
	
	assert( ( [ "200000 19999900000" ] ~ iota( 1, 200001 ).map!( ( a ) => a.to!( string ) ).join( " " ) ).parse.expand.solve == 39999800000 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	// マイナス、ゼロ、プラスに分類
	auto as_s = as.sort();
	auto ts = as_s.trisect( 0 );
	auto ms = ts[ 0 ].retro.array;
	auto zs = ts[ 1 ];
	auto ps = ts[ 2 ].array;
	
	// 積がマイナス、ゼロ、プラスになるペアの数を計算
	auto mc = ms.length.signed * ps.length.signed;
	auto pc = ms.length.signed * ( ms.length.signed - 1 ) / 2 + ps.length.signed * ( ps.length.signed - 1 ) / 2;
	auto zc = as.length.signed * ( as.length.signed - 1 ) / 2 - mc - pc;
	
	// 積がマイナスになるペア (m,p) の場合
	if( k <= mc )
	{
		return binarySearch!( delegate( x )
		{
			auto t = 0L;
			auto i = 0L;
			foreach_reverse( j, m; ms )
			{
				while( i < ps.length && x < m * ps[ i ] ) i++;
				t += ps.length.signed - i;
			}
			return ( k <= t );
		} )( -10L ^^ 18, 0L );
	}
	k -= mc;
	
	// 積がゼロになるペア (z,m)or(z,z)or(z,p) の場合
	if( k <= zc ) return 0;
	k -= zc;
	
	// 積がプラスになるペア (m,m)or(p,p) の場合
	return binarySearch!( delegate( x )
	{
		auto t = 0L;
		auto i = 0L;
		foreach_reverse( j, m; ms )
		{
			while( i < ms.length && m * ms[ i ] <= x ) i++;
			t += i - ( j < i );		// (自分,自分)のペアは除外
		}
		i = 0L;
		foreach_reverse( j, p; ps )
		{
			while( i < ps.length && p * ps[ i ] <= x ) i++;
			t += i - ( j < i );		// (自分,自分)のペアは除外

		}
		t /= 2;		// (x,y)と(y,x)で二重カウントしているので半分除外
		return ( k <= t );
	} )( 0L, 10L ^^ 18 );
}

// 二分探索
auto binarySearch( alias pred )( long x_min, long x_max )
if( is( typeof( pred( x_min ) ) : bool ) )
{
	import std.math : abs;
	
	auto ng = x_min;
	auto ok = x_max;
	while( 1 < abs( ok - ng ) )
	{
		auto x = ( ok + ng ) / 2;
		if( pred( x ) ) ok = x;
		else            ng = x;
	}
	return ok;
}


Measured memory_bytes: 11696
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cini(n);
    cout<<n+n*n+n*n*n<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


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

typedef pair<int, int> P;

int dp[1010][1010];

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

	int N;
	while(cin >> N, N) {
		vector<P> book;
		int rsum = 0, wsum = 0;
		for(int i = 0; i < N; i++) {
			int r, w;
			cin >> r >> w;
			book.push_back({ r, w });
			rsum += r;
			wsum += w;
		}

		sort(book.begin(), book.end());
		P B = book.back();
		book.pop_back();
		rsum -= B.first, wsum -= B.second;

		if(B.first <= rsum) {
			cout << rsum + B.first + wsum + B.second << endl;
			continue;
		}

		memset(dp, 0, sizeof dp);
		dp[0][0] = 1;
		N--;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 1000; j++) {
				if(!dp[i][j]) continue;
				dp[i + 1][j] = 1;
				if(j + book[i].second < 1000) {
					dp[i + 1][j + book[i].second] = 1;
				}
			}
		}

		int rem = B.first - rsum;
		int t = 0;
		for(int j = 0; j <= rem; j++) {
			if(dp[N][j]) t = j;
		}

		cout << 2 * B.first + B.second + wsum - t << endl;
	}
}

Measured memory_bytes: 7120
#include<stdio.h>

int main(void){

char str[1010];

int i,sum;

scanf("%s",str);

while(str[0]!='0'){

i=0;

sum=0;

while(str[i]){

sum+=str[i]-'0'; i++;

}

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

scanf("%s",str);

}

return 0;

}

Measured memory_bytes: 536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}

int main()
{
	ios_base::sync_with_stdio(false);

	ll b, c , n, k=0;
	cin >> n;
	vll a(n);
	rep(i, n) {
		cin >> a[i];
		a[i]--;
		k += a[i];
	}
	cout << k << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int f=n,fx=0;
  while(f!=0){
    fx+=f%10;
    f/=10;
  }
  if(n%fx==0)
    puts("Yes");
  else
    puts("No");
  return 0;
}


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

public class Hello
{
    public static void Main()
    {
        var A_B_H_M = Console.ReadLine().Trim().Split();
        var A = double.Parse(A_B_H_M[0]);
        var B = double.Parse(A_B_H_M[1]);        
        var H = double.Parse(A_B_H_M[2]);        
        var M = double.Parse(A_B_H_M[3]);        

        var th = 2 * Math.PI * (60 * H + M) / 720;
        var tm = 2 * Math.PI * (M / 60);

        var xh = A * Math.Cos(th);
        var yh = A * Math.Sin(th);
        var xm = B * Math.Cos(tm);
        var ym = B * Math.Sin(tm);
        
        var dx = xh - xm;
        var dy = yh - ym;

        var ans = Math.Sqrt(dx * dx + dy * dy);
        Console.WriteLine(ans);
   }
}

Measured memory_bytes: 28008
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define Pause system("pause")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 10;
const int start = 2050;
ll a[maxn], b[maxn];
ll dp[4200][4200];
ll p[8200], inv[8200];
ll qp(ll a,ll b,ll mod)
{
    ll ans = 1;
    while(b)
    {
        if(b&1)
        {
            ans = ans * a % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
void init()
{
    p[0] = 1;
    inv[0] = 1;
    for (int i = 1; i <= 8150; i++)
    {
        p[i] = p[i - 1] * (i) % mod;
        inv[i] = qp(p[i], mod - 2, mod);
    }
}
ll C(ll n,ll x)
{
    return p[n] * inv[x] % mod * inv[n - x] % mod;
}
int main()
{
    init();
    IOS;
    int n;
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        dp[start - a[i]][start - b[i]]++;
    }
    for (int i = 1; i <= 4100; i++)
    {
        for (int j = 1; j <= 4100; j++)
        {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] + dp[i][j] % mod;
            dp[i][j] %= mod;
        }
    }
    ll ans = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        ans += dp[a[i]+start][b[i]+start] % mod;
        //cout << ans << endl;
        ans -= C(2 * (a[i] + b[i]), 2 * a[i]) % mod;
        //cout << ans << endl;
        ans %= mod;
    }
    //cout << ans << endl;
    cout << (ans*qp(2,mod-2,mod) % mod + mod) % mod << endl;
    return 0;
}


Measured memory_bytes: 141448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	string s;
	cin>>s;
	s[5]=' ';
	s[13]=' ';
	cout<<s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    set<char> S;
    rep(i,0,4) S.insert(s[i]);
    if(sz(S)==2) {
        int cnt=0;
        rep(i,0,4){
            if(s[i]==s[0]) cnt++;
        }
        if(cnt==2) cout <<"Yes"<<"\n";
        else cout <<"No"<<"\n";
    }
    else cout <<"No"<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N, T, i, cst = 9999, cnt = 0;
    int c[1000];
    int t[1000];
    
    scanf("%d %d", &N, &T);
    
    for(i = 0; i < N; i++){
        scanf("%d %d", &c[i], &t[i]);
    }
    
    for(i = 0; i < N; i++){
        if(T >= t[i] && c[i] <= cst){
            cst = c[i];
        }else{
            cnt = cnt + 1;
        }
    }
    
    if(cnt == N){
        printf("TLE\n");
    }else if(cnt < N){
        printf("%d\n", cst);
    }
    
}


Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
//	2xy+x+y=A
//	x(2y+1)=A-y;
//	x=(A-y)/(2y+1) -> search y
//  if y<=x then 2y^2+2y<=A -> y^2<=A
	int n;
	cin>>n;
	int out=0;
	while(n--){
		ll A;
		cin>>A;
		bool h=false;
		ll y=1;
		while(y*y<=A){//A-y>=2*y+1){
			if((A-y)%(2*y+1)==0){
				h=true;
				break;
			}
			y++;
		}
		if(!h)out++;
	}
	cout<<out<<endl;
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MAX = 1000000;
const int MOD = 1000000007;

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

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

ll modpow(ll a, ll n, ll p){
	if(n==0) return 1;
	if(n%2) return (a*modpow(a, n-1, p))%p;
	if(!(n%2)){
		ll t=modpow(a, n/2, p);
		return (t*t)%p;
	}
}

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
  ll N; cin >> N; int a, b; cin >> a >> b; ll ans = 1;
  ans = modpow(2, N, mod);
  ll amod=1, bmod=1;
  rep(i, a){
    amod*=(N-i); amod%=mod;
  }
  ll tmpa = 1;
  rep(i, a){
    tmpa*=(i+1); tmpa%=mod;
  }
    amod*=modinv(tmpa, mod); amod%=mod;
  rep(i, b){
    bmod*=(N-i);  bmod%=mod; 
  }
  ll btmp=1;
  rep(i, b){
    btmp*=(i+1); btmp%=mod;
  }
  bmod*=modinv(btmp, mod); bmod%=mod;
  ans-=amod; if(ans<0) ans+=mod; ans%=mod;
  ans-=bmod; if(ans<0) ans+=mod; ans%=mod;
  ans--; if(ans<0) ans+=mod; ans%=mod;
  cout << ans << endl;
}

Measured memory_bytes: 256