akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include<iostream>
#include <cmath>
using namespace std;

int main(void){
	int n;
	long a[200000];
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	long **dp;
	dp = (long**)malloc(sizeof(long*)*(n+1));
	for(int i=0;i<=n;i++) {
		dp[i] = (long*)malloc(sizeof(long)*5);
		for(int j=0;j<5;j++)dp[i][j] = 1000000000;
	}
for(int i=0;i<=5;i++)dp[0][i] = 0;
	for(int i=1;i<=n;i++){
		dp[i][0] = dp[i-1][0] + a[i-1];
		for(int j=1;j<5;j++){
			for(int k=0;k<=j;k++){
				dp[i][j] = min(dp[i][j], dp[i-1][k]);
			}
		}
		dp[i][1] += (a[i-1] == 0 ? 2 : (a[i-1] & 1));
		dp[i][2] += (a[i-1] % 2 == 0);
		dp[i][3] += (a[i-1] == 0 ? 2 : (a[i-1] & 1));
		dp[i][4] += a[i-1];
	}
	long ans = 1000000000;
	for(int i=0;i<5;i++) ans = min(ans, dp[n][i]);
	cout << ans << endl;
	return 0;
}

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

namespace A114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());


            if (x == 3 || x == 5 || x == 7)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<iostream>
#define INF 10000005
using namespace std;
int a[20][20];
int n;
int dis[20];
int Dij(int v0)
{
    //cout<<"   "<<v0<<endl;
    bool s[20];
    for(int i=0;i<=n;i++)
    {
        dis[i]=a[v0][i];s[i]=false;
    }
    dis[v0]=0;s[v0]=1;
    for(int i=1;i<=n;i++)
    {
        int mmin=INF;int u=v0;
        for(int j=0;j<=n;j++)
            if(!s[j]&&dis[j]<mmin){u=j;mmin=dis[j];}
        s[u]=1;
        for(int j=0;j<=n;j++){
            if(!s[j]&&a[u][j]<INF)
                if(dis[j]>dis[u]+a[u][j]){dis[j]=dis[u]+a[u][j];}
            //cout<<dis[j]<<endl;
        }
    }
    int sum=0;
    for(int i=0;i<=n;i++)
        sum+=dis[i];
    return sum;

}
int main()
{
    while(1)
    {
        int m;n=0;
        scanf("%d",&m);if(m==0)break;
        for(int i=0;i<20;i++)
            for(int j=0;j<20;j++)
                a[i][j]=INF;
        for(int i=0;i<m;i++)
        {
            int p,q,r;scanf("%d%d%d",&p,&q,&r);
            a[p][q]=r;a[q][p]=r;
            n=max(n,p);n=max(n,q);
        }
        int mmin=INF,p;
        //cout<<n<<endl;
        for(int i=0;i<=n;i++)
        {
            int x=Dij(i);//cout<<x<<endl;
            if(x<mmin){mmin=x;p=i;}
        }
        printf("%d %d\n",p,mmin);
    }
}



Measured memory_bytes: 3200
n = int(input())
d = input().split()
for i in range(n):
	d[i] = int(d[i])
re = 0
for i in range(n):
	for j in range(i+1,n):
		if i == j:
			break
		else:
			re += d[i]*d[j]


print(re)


Measured memory_bytes: 2940
#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)){
    	cout << "No" <<endl;	
    }
  	else{
 		cout << "Yes" << endl;
  	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7 ;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX =  3e3 + 10 ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , x ,y, k , Q , ans ; string s,t;
ll a[MAX];
ll dp[MAX][MAX];

ll solve(int i , int j ){

    if(i > j)
        return 0;

    if(i == j)
        return a[i];

    ll &ret = dp[i][j];

    if(~ret)
        return ret;

    return ret = max(a[i] - solve(i + 1,j),a[j] - solve(i, j - 1));
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
 //   freopen("test.in","r",stdin);

    cin>>n;
    for(int i = 0 ; i < n ; ++i)
        cin>>a[i];

    for(int i = 0 ; i < n ; ++i)
        for(int j = 0 ; j < n ; ++j)
                dp[i][j] = -1;

    cout<<solve(0,n - 1)<<'\n';
    return 0;
}


Measured memory_bytes: 71040
from collections import Counter

N, M = map(int, input().split())
A = list(map(int, input().split()))

cnt = Counter(A)

for _ in range(M):
    b, c = map(int, input().split())
    cnt[c] += b

ans = 0
for b, c in sorted(cnt.items(), reverse=True):
    ans += min(c, N) * b
    N -= min(c, N)
    if N == 0:
        break
print(ans)

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



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

	string s;
	cin>>s;

	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes\n";
	else
		cout<<"No\n";
	
    return 0;
		
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 +7;
const int N = 100100;

int m=0;
int a[111][3];

int main(){

int L = 1<<20;
cin>>L;

int n = 20;
for(int i=n-1;i>1;i--){
    a[m][0]=i; a[m][1]=i+1; a[m][2]=0;
    m++;
    a[m][0]=i; a[m][1]=i+1; a[m][2]=(1<<(n-1-i));
    m++;
}

int S=0;
while( S < L ){

int x = 1<<18;
for(int i=2;i<=n;i++){
        if( S+x <=L ){
            a[m][0]=1; a[m][1]=i; a[m][2]=S;
            m++;
            S+=x;
            break;
        }
        x>>=1;
}

}

cout<<n<<" "<<m<<endl;
for(int i=0;i<m;i++)
    cout<<a[i][0]<<" "<<a[i][1]<<" "<<a[i][2]<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,x;
char c;
string s;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
     cin>>n>>s;
     for(int i=0;i<s.size();i++){
     	 x=((int)s[i]-64+n)%26;
     	 if(!x){
     	 	 cout<<(char)+(x+90);
		  }
		 else{
     	 c=(char)(x+64);
     	 cout<<c;
         }
	 }
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, vector<string> S){
    long long ret = 0;
    for (int i = 0; i < N; i++) {
        bool flag = true;
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                int x1 = (j + i) % N;
                int y1 = k;
                int x2 = (k + i) % N;
                int y2 = j;
                if (x1 == y1) {
                    continue;
                }
                if (S[x1][y1] != S[x2][y2]) {
                    flag = false;
                }
            }
        }
        if (flag) {
            ret++;
        }
    }
    std::cout << ret*N << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<string> S(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	cin >> S[i];
    }
    solve(N, S);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

typedef long long ll;



int main()
{
	

    ll n;
    cin>>n;
    double x = (n*1.0)/3.0;
    double res = x*x*(2*x - x);
    printf("%.8f\n",res);

    return 0;
}

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

int main()
{
    int a,f=1;
    cin>>a;

    for(int i=1; i<10; i++)
    {
        if(a%i==0)
        {
            int d=a/i;
            if(d<10)
            {
                f=0;
                break;
            }

        }

    }
    if(f==1)
        cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
    }


}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)
int main(){
    ll N;
    cin >> N;

    vll A(N);
    for (int i=0;i<N;i++) cin >> A[i];

    int num_odd = 0;
    for (int i=0;i<N;i++) if (A[i] % 2 == 1) num_odd++;

    if (num_odd % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  cout << (s.find("AC") != string::npos ? "Yes\n" : "No\n");

  return 0;
}


Measured memory_bytes: 256
#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-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> h(N);
    rep(i, N) cin >> h[i];
    sort(h.begin(), h.end());

    int ans = INF;
    rep(i, N) {
        int j = i + K - 1;
        if (N <= j) break;
        ans = min(ans, h[j] - h[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;
int main(){
    ll a,b,c;
    std::cin >> a>>b>>c;
    std::vector<ll> v;
    ll n=a+b+c;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    if(a==b&&b==c){
        if(a%2==1)std::cout << 0 << std::endl;
        else std::cout << -1 << std::endl;
    }
    else{
        int cc=0;
        ffor{
            
            bool b=0;
            rep(i,3){
                if(v[i]%2==1)b=1;
            }
            if(b)break;
            cc++;
            std::vector<ll> vv(v);
            rep(i,3){
                v[i]=(n-vv[i])/2;
            }
            /*
            erep(i,v){
                std::cout << i << ' ';
            }
            std::cout << std::endl;
            */
        }
        std::cout << cc << std::endl;
    }
}

Measured memory_bytes: 256
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, K = input_number_list()
    p = input_number_list()
    p.sort()
    ans = 0
    for i in range(K):
        ans += p[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n = int(input())
b = 0
x = 0
for i in range(n):
    a = int(input())
    b += a
    x = max(x, a)
print(b-(x//2))


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

using namespace std;
using ll=long long;

void solve() {
    int n; cin >> n;
    vector<vector<int>> L(n), R(n);
    ll res = 0;
    for (int _ = 0; _ < n; _++) {
        int k,l,r;
        cin >> k >> l >> r;
        if (k == n) {
            res += l; continue;
        }
        if (l < r) {
            res += l;
            R[n-k].push_back(r-l);
        } else {
            res += r;
            L[k].push_back(l-r);
        }
    }
    {
        priority_queue<int, vector<int>, greater<int>> hp;
        for (int i = 1; i < n; i++) {
            for (int x:L[i]) hp.push(x);
            while (hp.size() > i) {
                hp.pop();
            }
        }
        while (!hp.empty()) {
            res += hp.top(); hp.pop();
        }
    }
    {
        priority_queue<int, vector<int>, greater<int>> hp;
        for (int i = 1; i < n; i++) {
            for (int x:R[i]) hp.push(x);
            while (hp.size() > i) {
                hp.pop();
            }
        }
        while (!hp.empty()) {
            res += hp.top(); hp.pop();
        }
    }
    cout << res << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T; cin >> T;
    for (int t = 0; t < T; t++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 17772
from itertools import accumulate

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*(n+1)

if k > 41:
    k = 41

for _ in range(k):
    b = [0]*(n+1)
    for i,j in enumerate(a):
        b[max(0,i-j)] += 1
        b[min(n,i+j+1)] -= 1
    a = list(accumulate(b))
    for i in range(n+1):
        if a[i] >= n:
            a[i] = n

print(*a[:-1])

Measured memory_bytes: 182052
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

int v[2001][2001];
int n,k;
int getsize(int x1,int y1,int x2,int y2){
    return v[x2][y2] - v[x2][y1] - v[x1][y2] + v[x1][y1];
}
int main()
{
    scanf("%d%d",&n,&k);
    int a,b;
    char c;
    for(int i = 1;i <= n;i ++){
        scanf("%d%d %c",&a,&b,&c);
        a %= 2 * k,b %= 2 * k;
        b += k * (c == 'W');
        v[a % (2 * k) + 1][b % (2 * k) + 1] ++;
    }
    for(int i = 1;i <= 2 * k;i ++)
        for(int j = 1;j <= 2 * k;j ++)
            v[i][j] = v[i][j] + (v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1]);
    int ans = 0,sum;
    for(int i = 1;i <= k;i++)
        for(int j = 1;j <= k;j++){
            sum = getsize(0,0,i,j) + getsize(i,j,k + i,k + j) + getsize(k + i,k + j,2 * k,2 * k) + getsize(k + i,0,2 * k,j) + getsize(0,k + j,i,2 * k);
            ans = max(ans,max(sum,n - sum));
    }
    printf("%d\n",ans);
}


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

int main() {
  int h,w , n;
  cin >> w >> h >> n;
  vector < tuple <double,double,double >> A(n);
  for (int i=0 ; i<n ; i++){
    double a,b,c;
    cin >> a >> b >> c;
    A.at(i) = make_tuple(a,b,c) ;
  }
  double ld_x =0, ld_y = 0 , ru_x = w , ru_y = h;
  for ( int i=0 ; i<n; i++){
    double a,b,c;
    tie(a,b,c) = A.at(i) ;
    if ( c==1){
      ld_x = max(ld_x , a) ;
    }else if ( c==2){
      ru_x = min(ru_x , a) ;
    }else if ( c==3){
      ld_y = max(ld_y , b) ;
    }else if ( c==4){
      ru_y = min(ru_y , b) ;
    }
  }
  double c = (ru_x - ld_x)*(ru_y - ld_y) ;
  cout << ((ru_x <= ld_x)||(ru_y <= ld_y) ? 0 : c) << endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;


int main() {
	ll x,count=0,mem=100;
	cin >> x;
	while (x > mem) {
		count++;
		mem = mem * 1.01;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3632
import numpy as np
n,k,q = map(int,input().split())
a = [int(input()) for _ in range(q)]

b = [k for _ in range(n)]
list = [0 for _ in range(n)]

for i in a:
    list[i-1] += 1

for i in list:
    if q -k < i:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 18428
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.rank", "r", stdin);
	string str = "";
	multimap <int, int, greater<int> > result;
	while (getline (cin, str ) ){
		int team, score;
		while (str.find(',') != string::npos ){
			str = str.replace(str.find(','), 1, " ");
		} // end while
		stringstream ss(str);
		ss >> team >> score;
		if (team == 0 && score == 0){
			break;
		} // end if
		result.insert (make_pair (score, team ) );
	} // end while

	while (getline (cin, str ) ){
		int team;
		if (str.empty() ){
			break;
		} // end if	
		stringstream ss (str );
		ss >> team;
		int rank = 0;
		int score = 0;
		int pre = -1;
		int res = 0;
		multimap <int, int, greater<int> >::iterator it = result.begin();
		for (; it != result.end(); ++it){
			score = (*it).first;
			if (score != pre ){
				++rank;
			} // end if
			if ((*it).second == team ){
				res = rank;
				break;
			} // end if
			pre = score;
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

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


int main(){
  int n;
  int a;
  int b;
  int c;

  scanf("%d", &n);
  for (;n>0;n--){
    scanf("%d %d %d", &a, &b, &c);
    if (a < b){
      if ( b < c){
        if (a*a + b*b == c*c){
          printf("YES\n");
          continue;
        }
      }else{
        if (a*a + c*c == b*b){
          printf("YES\n");
          continue;
        }
      }
    }else{
      if (a < c){
        if (a*a + b*b == c*c){
          printf("YES\n");
          continue;
        }
      }else{
        if (c*c + b*b == a*a){
          printf("YES\n");
          continue;
        }
      }
    }
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {
    public static void main(String args[]){
		
	//整数nを読み取る
	Scanner sc = new Scanner(System.in);
	String s1 = sc.next();
        int n = Integer.parseInt(s1);
        
        //nが条件（３から１００００）内か確認
        if(3 <= n && n <= 10000){
        	
        	//１からnまで繰り返す
        	for(int i = 1; i <= n; i++){
        		
        		//３の倍数と３とつく数字を表示
        		if(i % 3 == 0){
        			System.out.print(" " + i);
        		}
        		else if(i % 10 == 3){
        			System.out.print(" " + i);
        		}
        		else{
        		    String si = String.valueOf(i);
        		    for(int j = 0; j < si.length() - 1; j++){
        			   char ci = si.charAt(j);
        			   if(ci == '3'){
        				   System.out.print(" " + i);
        				   break;
        			   }
        		    }
        		}
        	}
        	System.out.println("");
        }
    }
}

Measured memory_bytes: 24160
#include <bits/stdc++.h>
using namespace std; 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reprev(i,a,b) for(int i=b-1;i>=a;i--)
#define all(c) c.begin(),c.end()
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vin(a,n) vi a(n); rep(i,0,n) cin>>a[i];
#define vout(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
#define mapp map<int,int>
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define inf LLONG_MAX
#define pi 3.1415926535897932384626
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)

bool comps(const pair<int,int> &a, const pair<int,int> &b) {return (a.second<b.second);} 

int power(int x, unsigned int y)
{ 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
}

int powerp(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

signed main()
{
   
    IOS
    int n;
    cin>>n;
    vin(a,n);
    int ans=1;
    rep(i,0,n)
    {
        if(a[i]==0) {cout<<0; return 0;}
    }
    rep(i,0,n)
    {
        if(a[i]>1000000000000000000/ans) {cout<<-1; return 0;}
        ans*=a[i];
        //if(i<n-1&&a[i+1]>1000000000000000000/ans) {cout<<-1; return 0;}
    }
    cout<<ans;
    return 0;
}

// vector<vector<int>> adj;
// vector<bool> visited;
// void dfs(int v) 
// {
//     visited[v] = true;
//     for (int u : adj[v]) 
//     {
//         if (!visited[u])
//         {
//             dist[u].ff=dist[v].ff+1;
//             dist[u].ss=u;
//             dfs(u);
//         }
//     }
// }
// int binarySearch(int l, int r) 
// { 
//     while (l <= r) { 
//         int m = l + (r - l) / 2; 
  
//         //ignore left half 
//         if (!check(m)) 
//             l = m + 1; 
  
//         //ignore right half 
//         else
//             r = m - 1; 
//     }   
//     return l;
// }

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

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

	int h, w; cin >> h >> w;
	vector<string> grid;
	for(int i = 0; i < h; i++){
		string s; cin >> s;
		bool white = true;
		for(int j = 0; j < w; j++){
			if(s[j] == '#') white = false;
		}
		if(!white) grid.push_back(s);
	}
	for(int i = 0; i < w; i++){
		bool white = true;
		for(int j = 0; j < grid.size(); j++){
			if(grid[j][i] == '#') white = false;
		}
		if(white){
			for(int j = 0; j < grid.size(); j++) grid[j][i] = '0';
		}
	}
	for(int i = 0; i < grid.size(); i++){
		for(int j = 0; j < w; j++){
			if(grid[i][j] != '0') cout << grid[i][j];
		}
		cout << endl;
	}
	return 0;	
}





  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}



int main(){FIN
    ll n; cin>>n;
    ll ans = n%1000;
    if (ans>0){
        ans = 1000 - ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while(b <= a){
        b *= 2;
        k--;
    }
    //cout << a << " " << b << " " << c << "\n";
    while(c <= b){
        c *= 2;
        k--;
    }
    //cout << a << " " << b << " " << c << "\n";
    if(k < 0)cout << "No\n";
    else cout << "Yes\n";


    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int n, l; cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; i++) cin >> s.at(i);

	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		cout << s.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

void canP(bool x){
    if(x){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
}
int main(){
    int n; cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }

    Sort(a);
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int INF = 1e9;
int dp[1000][1000];

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    queue<P> que;
    rep(i,h){
        cin >> s[i];
        rep(j,w){
            dp[i][j] = INF;
            if(s[i][j] == '#'){
                que.push(P(i,j));
                dp[i][j] = 0;
            }
        }
    }
    int ans = 0;
    while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        rep(k,4){
            int ny = y + dy[k];
            int nx = x + dx[k];
            if(ny < 0 || h <= ny) continue;
            if(nx < 0 || w <= nx) continue;
            if(dp[ny][nx] != INF) continue;
            dp[ny][nx] = dp[y][x] + 1;
            que.push(P(ny, nx));
            chmax(ans, dp[ny][nx]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16388
a = int(input())
b = int(input())
c = int(input())
x = int(input())
x /= 50
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 10*i + 2*j + k == x:
                cnt += 1
print(cnt)

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)

using ll = long long; using vll = vector<ll>;

int main(void) {
    ll n; cin >> n;
    string t; cin >> t;
 
    vll l(n+1), r(n+1), in(n+1);
    rep(i, n) {
        l[i+1] = t[i] == 'M';
        r[i+1] = t[i] == 'C';
        in[i+1] = 0;
    }
    rep(i, n) {
        in[i+1] += in[i] + l[i] * r[i+1];
        l[i+1] += l[i];
        r[i+1] += r[i];
    }

    ll q; cin >> q;
    rep(_, q) {
        ll k; cin >> k;
        ll ret = 0;
        rep(i, n) if (t[i] == 'D') {
            ll j = min(n, i+k);
            ret += (-in[i]+r[i]*l[i])+in[j]-l[i]*r[j];
        }
        cout << ret << endl;
    }
 
    return 0;
}


Measured memory_bytes: 26884
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$a[-1]=0;
$a[]=0;
$s=0;
$i=0;
while($i<=$n){
  $s+=abs($a[$i]-$a[$i-1]);
  ++$i;
}
$i=0;
while($i<$n){
  echo ($s-abs($a[$i]-$a[$i-1])-abs($a[$i+1]-$a[$i])+abs($a[$i+1]-$a[$i-1])).PHP_EOL;
  ++$i;
}

Measured memory_bytes: 16884
a=gets.scan(/F*/).map &:size
x, y=gets.split.map &:to_i

x-=a.shift if a[0]>0

c=true
tx, ty=a.partition{|e| c=e>0 ? c : !c}

f=->t, g do
    s={0=>true}
    t.select{|e|e>0}.each do |d|
        n={}
        s.each{|k, _| n[k-d]=n[k+d]=true}
        s=n
    end
    s[g]
end

puts (f[tx, x] && f[ty, y] ? "Yes" : "No")


Measured memory_bytes: 76156
/*
   Author : BabaYaga42,
   BITS Pilani, Hyderabad.
   Don't give up ;)
   */  
#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
 
int32_t main()
{
	IOS;	
	int a,b;
	cin >> a >> b;
	if(a <= 8 and b <= 8)
		cout <<"Yay!";
	else
		cout << ":(";	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    cout << "ABC" << n << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	int w[300001],e[300001];
	if(s[0]=='W')
		w[0]=1;
	else
		e[0]=1;
	for(int i=1;i<n;i++)
	{
		if(s[i]=='W')
		{
			w[i]=w[i-1]+1;
			e[i]=e[i-1];
		}
		else
		{
			w[i]=w[i-1];
			e[i]=e[i-1]+1;
		}
	}
	int min=e[n-1];
	for(int i=1;i<n;i++)
	{
		int left=w[i-1];
		int right=e[n-1]-e[i];
		if(left+right<min)
			min=left+right;	
	}
	cout<<min<<endl;	
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int main(){
	ll n;
	cin >> n;
	int cnt = 0;
	ll x = 100;
	while(x < n){
		x += x /100;
		cnt++;
	}
	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//トライ木って何よ
int T[100001][2];
ll D[100001];

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


	int N;
	ll L;
	scanf("%d", &N);
	scanf("%lld", &L);
	getchar_unlocked();
	int k = 0;
	rep(i, N) {
		int mae = 0;
		ll d = -L;
		char c;
		while ((c = getchar_unlocked()) >= '0') {
			int C = c - '0';
			if (!T[mae][C]) {
				T[mae][C] = ++k;
				D[k] = d;
			}
			mae = T[mae][C];
			d++;
		}
	}
	ll kotae = 0;
	rep1(i, k) {
		kotae ^= D[i] & -D[i];
	}

	if (kotae) printf("Alice\n");
	else printf("Bob\n");

	Would you please return 0;
}

Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	ll sum = 0;
	vector<ll>T(n); REPC(&i, T) { i = in(); sum += i; }
	ll m = in();
	REP(i, m) {
		ll p = in(), x = in();
		cout << sum - T[p - 1] + x << endl;
	}
}

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

def solve(N,A,B):
    ans = 0
    for i in range(N):
        battle = min(A[i],B[i])
        B[i] -= battle
        ans += battle
        nex = min(A[i+1],B[i])
        A[i+1] -= nex
        ans += nex
    return ans
print(solve(N,A,B))

Measured memory_bytes: 18476
import numpy as np
s = list(input())

judge = 0
judge_min = 0
base = np.zeros(len(s))
for i in range(len(s)):
  if s[-(i+1)] == ">":
    judge += 1
    base[-(i+1)] = judge
  elif s[-(i+1)] == "<":
    judge = 0

ans = 0
if base[0] > 0:
  ans = base[0]
  temp = base[0]
elif base[0] == 0:
  ans = 0
  temp = 0
  
for i in range(1,len(s)):
  if (s[i-1] == ">") and (s[i] == ">"):
    temp = base[i]
  elif (s[i-1] == "<") and (s[i] == "<"):
    temp += 1
  elif (s[i-1] == ">") and (s[i] == "<"):
    temp = 0
  elif (s[i-1] == "<") and (s[i] == ">"):
    temp += 1
    if temp < base[i]:
      temp = base[i]
      
  ans += temp
  
  if (temp > base[i]) and (s[i] == ">"):
    temp -= 1
  
if s[-1] == "<":
  ans += temp+1

print(int(ans))

Measured memory_bytes: 20752
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int vis[3],a[3],vv[3];
char s[N];
bool judge()
{
    int x=0;
    int sum=vis[0]+vis[1]+vis[2];
    vv[0]=vis[0];vv[1]=vis[1];vv[2]=vis[2];
    while(sum--)
    {
        vv[a[x]]--;
        if(vv[a[x]]<0) return false;
        x=(x+1)%3;
    }
    return true;
}
int main()
{
    scanf("%s",s+1);
    for(int i=1;s[i];i++)
        vis[s[i]-'a']++;
    a[0]=0;a[1]=1;a[2]=2;
    while(true)
    {
        if(judge()) {printf("YES\n");return 0;}
        if(!next_permutation(a,a+3)) break;
    }
    printf("NO\n");
}


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

using namespace std;

const auto MOD = (long long) 1e9 + 7;

long long extgcd(long long a, long long b, long long &x, long long &y) {
    long long g = a;
    x = 1;
    y = 0;
    if (b != 0) {
        g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    }
    return g;
}

long long invMod(long long a, long long m) {
    long long x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    else return 0;
}

long long factorial(long long n, long long m) {
    if (n == 0) {
        return 1;
    } else {
        return (n * factorial(n - 1, m) + m) % m;
    }
}

long long binomial(long long n, long long k, long long m) {
    long long tmp = (factorial(n, m) * invMod(factorial(k, m), m) + m) % m;
    return (tmp * invMod(factorial(n - k, m), m) + m) % m;
}

int main() {
    long long n, blue;
    cin >> n >> blue;

    long long red = n - blue;
    for (long long i = 1; i <= blue; ++i) {
        long long ans;
        if (i > red + 1) {
            ans = 0;
        } else {
            ans = binomial(red + 1, i, MOD) *
                  binomial(blue - 1, i - 1, MOD);
        }
        cout << ans % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 384
N = int(input())
arr = list(map(int,input().split()))
cnt_arr = [0]*N
ans = 0
for i in range(N):
  if arr[i]+i+1<N:
    cnt_arr[arr[i]+i+1] += 1
  if i+1-arr[i]>0:
    ans += cnt_arr[i+1-arr[i]]

print(ans)

Measured memory_bytes: 32272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    set<int> se;
    for(int i=0; i<3; i++){
        int a; cin >> a;
        se.insert(a);
    }
    cout << se.size() << endl;
}

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

ans = 0

ave = sum(A)/N

min1 = float(max(A))
for i in range(N):
    diff = abs(float(A[i]) - ave)

    if min1 > diff:
        ans = i
        min1 = diff

print(ans)


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

const int N = 100005;

unsigned long long ans = 1;
unsigned long long arr[N];

int nd (unsigned long long x);
int fd (unsigned long long x);

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < n; i++) {
		if (arr[i] == 0) {
			cout << 0;
			exit(0);
		} 
	}
	for (int i = 0; i < n; i++) {
		int d1 = fd(ans);
		int d2 = fd(arr[i]);
		if (nd(d1 * d2) + nd(arr[i]) - 1 + nd(ans) - 1 > 19) {
			cout << -1 << '\n';
			exit(0);
		}
		else{
			ans *= arr[i];
			if (ans > (unsigned long long) (1e18)) {
				cout << -1 << '\n';
				exit(0);
			}
		}
	}
	cout << ans << '\n';
}

int nd(unsigned long long x) {
	int ans = 0;
	while (x) {
		x /= 10;
		ans++;
	}
	return ans;
}

int fd(unsigned long long x) {
	while (x >= 10) {
		x /= 10;
	}
	return x;
}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}
//--------------------------------------------------//
int n;
vector<int> adj[10010];
int c[10010];
int ans[10010];
int chk[10010];
int score;
int main() {
  use_cio();
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  rep(i, n) cin >> c[i];
  sort(c, c + n);
  rep(i, n - 1) score += c[i];
  cout << score << endl;
  int root = -1;
  rep(i, n) {
    if (adj[i].size() == 1) {
      root = i;
      break;
    }
  }
  queue<int> que;
  que.push(root);
  chk[root] = 1;
  int idx = n - 1;
  while (!que.empty()) {
    auto fr = que.front();
    que.pop();
    ans[fr] = c[idx--];
    chk[fr] = 1;
    for (auto nxt : adj[fr]) {
      if (!chk[nxt])
        que.push(nxt);
    }
  }
  rep(i, n) cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 1024
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> d(N + 1, 0);
  for (int i = 1; i <= N; ++i)
    for (int j = 1; i * j <= N; ++j) ++d[i * j];
  long long ans = 0;
  for (long long i = 1; i <= N; ++i) ans += i * d[i];
  cout << ans << '\n';
}


Measured memory_bytes: 42268
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)

	list := make([]string, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&list[i])
	}

	count := make([]int, 4)
	for i := 0; i < N; i++ {
		switch list[i] {
		case "AC":
			count[0] += 1
		case "WA":
			count[1] += 1
		case "TLE":
			count[2] += 1
		case "RE":
			count[3] += 1
		}
	}
	fmt.Println("AC x " + strconv.Itoa(count[0]))
	fmt.Println("WA x " + strconv.Itoa(count[1]))
	fmt.Println("TLE x " + strconv.Itoa(count[2]))
	fmt.Println("RE x " + strconv.Itoa(count[3]))
}

Measured memory_bytes: 6840
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
ll n  ,mx , m , a , cnt , ans , d , k;
string s;
int main(){
    cin >> n >> m >> k;
    n = abs(n);
    cnt = n / k;
    if( m < cnt )
        return cout << n - (m * k) , 0;
    n -= cnt*k;
    m -= cnt;
    if( !(m % 2) )
        return cout << abs(n) , 0;
    cout << min(abs(n - k) , abs(n + k));
}



Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll X, A, B;
    cin >> X >> A >> B;

    if (-A + B <= 0) {
        cout << "delicious" << endl;
    } else if (-A + B <= X) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



int main(void) {

    ll ans[10]={0};

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

    map<pair<int,int>,int> m;

    int dx[]={-2,-1,0,-2,-1,0,-2,-1,0};
    int dy[]={-2,-2,-2,-1,-1,-1,0,0,0};
    rep(i,n){
        int a,b;
        cin>>a>>b;
        a--;b--;
        rep(j,9){
            if(b+dx[j]<0||b+dx[j]+2>=w||a+dy[j]<0||a+dy[j]+2>=h)continue;
            m[mp(b+dx[j],a+dy[j])]++;
        }
    }

    for(auto it=m.begin();it!=m.end();it++){
        ans[it->second]++;
    }
    ans[0]=(h-2)*(ll)(w-2);
    rep(i,9){
        ans[0]-=ans[i+1];
    }
    rep(i,10){
        cout<<ans[i]<<endl;
    }


}


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

int main(void){
    char ans='0';
    std::string S;
    std::cin >> S;
    std::map<char, int> mp;
    for (int i=0; i<26; ++i){
        mp[(char)('a' + i)] = 0;
    }

    for (char c: S) ++mp[c];

    for (int i=0; i<26; ++i){
        if (mp[(char)('a' + i)] == 0){
            ans = (char)('a' + i);
            break;
        }
    }

    if (ans == '0') {
        std::cout << "None" << std::endl;
    } else {
        std::cout << ans << std::endl;
    }

    return 0;
}


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

int main() {
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  if((a + b) > (c + d))
    cout << "Left" << endl;
  else if((a + b) == (c + d))
    cout << "Balanced" << endl;
  else if((a + b) < (c + d))
    cout << "Right" << endl;
}


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

int main(){
  int c[3][3];
  
  for(int i=0; i<3; i++){
    cin >> c[i][0] >> c[i][1] >> c[i][2];
  }
  
  for(int i=0; i<3; i++){
    c[i][2] -= c[i][0];
    c[i][1] -= c[i][0];
    c[i][0] = 0;
  }
  
  int flag = 1;
  for(int i=0; i<3; i++){
    if(!(c[0][i]==c[1][i] && c[1][i]==c[2][i])){
      flag = 0;
      break;
    }
  }
  
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    int N;
    map<string, int> memo;
    string s;
    cin >> N;
    rep(i, N){
        cin >> s;
        memo[s] +=1;
    }
    
    int maxv=0;
    for(const auto& x: memo){
        int v = x.second;
        if(v>maxv) maxv=v;
    }

    for(auto it=memo.begin(); it!=memo.end(); it++){
        if(it->second == maxv) cout << it->first << endl;
    }
    

    return 0;
}

Measured memory_bytes: 23808
#include <iostream>

using namespace std;

int main()
{
  int A, B, T, cost, num;

  cin >> A >> B >> T;
  int i =0;
  i +=A;
  
  while(i<(T+0.5)){
    i +=A;
    num +=B;
  }

  cout << num <<endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))

p=sum(x)/n
import math
p1=math.floor(p)
p2=math.ceil(p)
ans1=0
ans2=0

for i in range(n):
    ans1+=(x[i]-p1)**2
    ans2+=(x[i]-p2)**2    
print(min(ans1,ans2))

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



int main(){
    int A,B,C,K;
    cin >> A >> B >> C ;
    cin >> K;
    int ans = (A + B + C - max({A,B,C})) + (max({A,B,C})*(1 << K));
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class AOddsOfOddness {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        int cnt=0;
        for(int i=1;i<=n;i++){
            if(i%2==1){
                cnt++;
            }
        }
        double ans=(double)cnt/n;
        out << setprecision(10);
        out <<ans << endl;
	}
};


int main() {
	AOddsOfOddness solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256