akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int a[200];
int main(){
int b,ans=0,s;
cin>>b;
for(int i=0;i<b;i++)
cin>>a[i];
for(int i=0;i<b;i++)
if(a[i]%2==1)
{cout<<ans;
system("pause");
return 0;
}
ans++;
s=a[0];
for(int i=1;i<b;i++)
s=max(s,a[i]);
for(int j=0;j<s;j++){
for(int i=0;i<b;i++){
a[i]=a[i]/2;
if(a[i]%2==1)
{cout<<ans;
system("pause");
return 0;
}}
ans++;
s/2;}
system("pause");
return 0;
}

Measured memory_bytes: 504
abc = "abcdefghijklmnopqrstuvwxyz".split("")
n = gets.to_i
s = Array.new()
c = Array.new()
n.times do |i|
  s[i] = gets.chomp
  c[i] = Hash.new()
  for ch in abc do
    c[i][ch] = s[i].count(ch)
  end
end
dd = ""
for ch in abc do
  min = 999
  n.times do |i|
    if min > c[i][ch]
      min = c[i][ch]
    end
  end
  if min != 999
    dd += ch * min
  end
end
puts dd


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;

int opinion[16], fopinion[16], A[16];
int main()
{
    ll N;
    int x, y;
    cin >> N;
    int maxi = (1 << N);
    //cout << maxi << endl;
    rep(i, N){
        cin >> A[i];
        rep(j, A[i]){
            cin >> x >> y;
            if (y == 1){
                opinion[i] |= (1 << (x - 1));
            } else {
                fopinion[i] |= (1 << (x - 1));
            }
            //cout << opinion[i] << endl;
        }
    }
    
    
    int ans = 0;
    for (int i = 0; i < maxi; i++){
        int sset = 0, fset = 0;
        int num = 0;
        for (int k = 0; k < N; k++){
            if (i & (1 << k)){
                //fprintf(stderr, "i = %d, k = %d\n", i, k);
                sset |= opinion[k];
                fset |= fopinion[k];
                num++;
            }
        }
        //fprintf(stderr, "i = %d, sset = %d, and = %d\n", i, sset, i & sset);
        if (((i & sset) == sset) && (i & fset) == 0){
            ans = max(ans, num);    
            //fprintf(stderr, "HIT, i = %d, sset = %d %d, fset = %d\n", 
            //    i, sset, i & sset, fset);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  m = 1
  for _ in range(n,1,-1):
    m *= _
  
  cnt = 1
  for i in range(2,n+1):
    tmp = 1
    while m % i == 0:
      m //= i
      tmp += 1
    cnt *= tmp
  print(cnt%mod)
if __name__ == '__main__':
  main()

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	ll left = 0, right = A[N - 1] + 1;
	ll centre;
	vector<ll> ans;
	while(right - left > 1) {
		centre = (left + right) / 2;
		ll cnt = 0;
		for(int i = 0; i < N; i++) cnt += ceil((double)A[i] / (double)centre) - 1;
		if(cnt > K) left = centre;
		else {
			ans.push_back(centre);
			right = centre;
		}
	}
	cout << ans.back() << endl;
	return 0;
}

Measured memory_bytes: 4828
N, M, C = map(int, input().split())
a = []
for i in range(N+1):
    a.append(list(map(int, input().split())))

count = 0
sum = 0
for i in range(1, N+1):
    sum = 0
    for j in range(M):
        sum += int(a[0][j]) * int(a[i][j])
    if sum + int(C) > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <stdio.h>

int main() {
  int i, ans;
  char s[2*10*10*10*10*10 + 1], t[2*10*10*10*10*10 + 1];

  scanf("%s", s);
  scanf("%s", t);

  ans = 0;
  while (s[i]) {
  	if (s[i] != t[i])
      ans++;
    i++;
  }

  printf("%d", ans);
  return (0);
}


Measured memory_bytes: 2116
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    ll N;
    cin >> N;
    ll H[N];
    REP(i, N) {
    	cin >> H[i];
    }
    string ans = "Yes";
    if (N == 1) 
    {
    	ans = "Yes";
    }
	else 
	{
	    for (int i = N - 2; i >= 0; --i) {
    		if (H[i] <= H[i + 1]) continue;
    		else if (H[i] - H[i + 1] == 1) {
    			H[i]--;
    			continue;
    		}
    		else {
    			ans = "No";
    			break;
    		}
	    }
	}
    
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

// linear search
bool search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) {
    i++;
  }
  return i != n;
}

int main() {
  int i, n, A[10000+1], q, key, sum = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> A[i];
  }
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> key;
    if (search(A, n, key)) {
      sum++;
    }
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>

int A[20000000];

int partition(int, int);

main(){
  int k, r, mid;
  int i;

  scanf("%d", &k);

  for(i = 0; i < k; i++){

    scanf("%d",&A[i]);

  }

  r = k - 1;

  mid = partition(0, r);

  for(i =0; i < mid; i++){

    printf("%d ",A[i]);

  }
  printf("[%d] ", A[mid]);

  for(i = mid+1; i <= r; i++){
    printf("%d", A[i]);
    if(i != r)printf(" ");
  }

  printf("\n");

  return 0;

}


int partition(int p, int r){

int i = 0 , j, ex=0;


for(j = p; j < r; j++){
  if(A[j] <= A[r] ){
    
    ex = A[i];
    A[i] = A[j];
    A[j] = ex;
    i++;
  } 
 }

ex = A[r];
A[r] = A[i];
A[i] = ex;

return i;
}

Measured memory_bytes: 996
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
long long int a[111111];
long long int b[111111];
vector<long long int> c;

int main(void){
  long long int i,j,k,t,tmp;
  long long int maxt;
  long long int N,T;

  cin>>N>>T;
  for(i=1;i<=N;i++){
    cin>>a[i];
  }
  b[1]=a[1];

  for(i=2;i<=N;i++){
    b[i]=min(b[i-1],a[i]);
    c.push_back(a[i]-b[i]);
  }

  maxt=*max_element(c.begin(),c.end());
  t=0;
  for(i=0;i<c.size();i++){
    if(c[i]==maxt) t++;
  }
  cout<<t<<endl;
  return 0;
}

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

typedef long long ll;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 1 << 19, B = 1 << 9;

int v[N], w[N], n, Q;
ll dp[B+10][100010], ans;

int tot, nd[N], lu, L;

void dfs(int nw, ll sw, ll sv) {
    if (nw > tot) {
        ans = max(ans, sv + dp[lu][L - sw]);
        return;
    }
    if (sw + w[nd[nw]] <= L)
        dfs(nw + 1, sw + w[nd[nw]], sv + v[nd[nw]]);
    dfs(nw + 1, sw, sv);
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i] >> w[i];
    }
    memset(dp, 0xcf, sizeof(dp));
    const int MAXL = 100000;
    for (int j = 0; j <= MAXL; j++) dp[0][j] = 0;
    for (int i = 1; i <= B && i <= n; ++i) {
        int p = i >> 1;
        for (int j = 0; j <= MAXL; j++)
            dp[i][j] = dp[p][j];
        for (int j = w[i]; j <= MAXL; j++) {
            dp[i][j] = max(dp[i][j], dp[p][j - w[i]] + v[i]);
        }
    }
    cin >> Q;
    while (Q--) {
        int u;
        cin >> u >> L;
        tot = 0;
        while (u > B) nd[++tot] = u, u >>= 1;
        ans = 0;
        lu = u;
        dfs(1, 0, 0);
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 413552
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 3000

vector<vector<int>> lines(3000);
vector<int> color(3000);
vector<int> dist(3000);
int n;

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i=0; i<n; i++){
        dist[i]=3000;
    }
    dist[s]=0;
    int u;
    while(!q.empty()){
        u=q.front();
        q.pop();
        int v;
        for(int i=0; i<lines[u].size(); i++){
            v=lines[u][i];
            if(dist[v] > dist[u]+1){
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }
}

int main() {
    int x;
    int y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> dist_num(n, 0);

    for(int i=0; i<n; i++){
        if(i>0){
            lines[i].push_back(i-1);            
        }
        if(i<n-1){
            lines[i].push_back(i+1);            
        }
        if(i==x){
            lines[i].push_back(y);
        }
        if(i==y){
            lines[i].push_back(x);
        }
    }

    for(int i=0; i<n; i++){
        bfs(i);
        for(int j=0; j<n; j++){
            dist_num[dist[j]]++;
        }
    }

    for(int i=1; i<n; i++){
        cout << dist_num[i]/2 << endl;
    }

    //for(int i=0; i<n; i++){
    //    for(int j=0; j<lines[i].size(); j++){
    //        cout << lines[i][j] << " ";
    //    }
    //    cout << endl;
    //}

    return 0;
}

Measured memory_bytes: 384
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<ll> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    ll sum=0;
    for (int i = 0; i < m; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
        sum+=temp;
    }
    if(n-sum>=0)
    cout << n-sum<< "\n";
    else
    cout<<-1<<"\n";
}



Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define bit(n) (1LL<<(n))

int main() {
  lint H, W, K;
  cin >> H >> W >> K;

  vector<string> S(10);
  for(lint i=0; i<H; i++) cin >> S[i];

  lint ans = 0;
  for(lint sh=0; sh<bit(H); sh++)
  for(lint sw=0; sw<bit(W); sw++) {
    auto T = S;
    lint rem = 0;
    for(lint i=0; i<H; i++)
    for(lint j=0; j<W; j++) {
      if(bitset<9>(sh)[i] || bitset<9>(sw)[j]) T[i][j] = '$';
      rem += T[i][j] == '#';
    }
    if(rem == K) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
#include <stdlib.h>
#include <vector>
#define pi acos(-1)
#define MOD 1000000007
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
///s1.substr(1,3);///STARTING FROM INDEX 1, 3 LNEGTH SUBSTRING.
///s1.find("adn")///RETURNS STARTING INDEX OF THE SUBSTRING
///"adn" IF IT EXISTS IN THE STRING S1.///
///s1.find("adn",int pos);///RETURNS STARTING INDEX OF THE
///SUBSTRING "adn" SEARCHING FROM INDEX POS OF STRING s1.///
///string::npos returns a garbage value if not found...
///reverse(s1.begin(),s1.end())-> to reverse a string.
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gcd(a,b) __gcd(a,b)
using namespace std;

vector<int>adj[100005];
int vis[100005];
int vis2[100005];
//vector<ll>a1;
ll f[100005],x7=1000000005,x8,s=0;
ll f2[100005];
ll size1[200005];
ll size2[100005];
set<int>x2;
set<int>::iterator it;

int root(int a)
{
    while(f2[a]!=a){
        f2[a]=f2[f2[a]];
        a=f2[a];
    }
    return a;
}

void union1(int a,int b)
{
    int root_a=root(a);
    int root_b=root(b);
    if(root_a==root_b)return;
    else if(size1[root_a]>size1[root_b]){
        f2[root_b]=root_a;
        size1[root_a]+=size1[root_b];
    }
    else{
        f2[root_a]=root_b;
        size1[root_b]+=size1[root_a];
    }
}

map<string,ll>m2;

string removeSpaces(string str)
{
    str.erase(remove(str.begin(), str.end(), ' '), str.end());
    return str;
}

int binaryToDecimal(int n)
{
    int num = n;
    int dec_value = 0;

    // Initializing base value to 1, i.e 2^0
    int base = 1;

    int temp = num;
    while (temp) {
        int last_digit = temp % 10;
        temp = temp / 10;

        dec_value += last_digit * base;

        base = base * 2;
    }

    return dec_value;
}
//x8=x7;
ll g[5];
void dfs(ll a)
{
    if(vis[a])return;
    vis[a]=1;x7=min(x7,f[a]);//s-=f[a];
    for(int j=0;j<adj[a].size();j++){
        dfs(adj[a][j]);
    }
}

int main()
{
    long long int t,i,q,h,w,n,a,k1,k2,d,e,m,b,c,x1=1000000005,x3=0,x4=0,x5=0,x6=0;
    //string s2,s3,s4,s5,s6,s7;
    cin>>n>>m;
    if(n*500>=m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	double a;
	cin >> a;
	cout <<setprecision(6)<<fixed<< a*a* M_PI << " " << 2 * a*M_PI << endl;
	cin >> a;
	return 0;
}

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

const int N = 110;
int a[N], n, m;
int oddnum[2];

int main() {
  int odd = 0, tot = 0;
  scanf("%d%d", &n, &m);
  oddnum[0] = 1;
  oddnum[1] = m;
  for (int i = 1; i <= m; i++) {
    scanf("%d", a + i);
    if (~a[i] & 1) continue;
    oddnum[odd++] = i;
    if (odd > 2) return puts("Impossible"), 0;
  }
  swap(a[1], a[oddnum[0]]);
  swap(a[m], a[oddnum[1]]);
  if (m == 1 && a[1] == 1) return puts("1\n1\n1"), 0;
  for (int i = 1; i <= m; i++) printf("%d ", a[i]);
  if (m == 1) return printf("\n2\n%d 1\n", a[1] - 1), 0;
  printf("\n%d\n%d ", a[m] > 1 ? m : m - 1, a[1] + 1);
  for (int i = 2; i < m; i++) printf("%d ", a[i]);
  if (a[m] > 1) printf("%d\n", a[m] - 1);
  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 pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    ll setcount = n / (a + b);
    ll ans = setcount * a;

    ans += min(a, n - setcount * (a + b));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include"math.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std; 
int main(){
           int n;cin>>n;
  vector<int> d(n);
  rep(i,n)cin>>d[i];
  sort(d.begin(),d.end());
  int s=n/2;
  int x=d[s]-d[s-1];
  cout <<x<<endl;}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  string ans;
  int a=s[5]-'0',b=s[6]-'0',c=s[8]-'0',d=s[9]-'0';
  int t=1000*a+100*b+10*c+d;
  if(t>430)cout<<"TBD"<<endl;
  else cout<<"Heisei"<<endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

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

int main() {
	int n, m;
	cin >> n >> m;
	int maxl = 0;
	int minr = INF;
	FOR(i, 1, m) {
		int l, r;
		cin >> l >> r;
		maxl = max(maxl, l);
		minr = min(minr, r);
	}
	int res = 0;
	if (minr >= maxl) {
		res = minr - maxl + 1;
	}
	pv(res)
	return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}

ll MOD = 1000000007;
int main() {
	ll N;
	cin >> N;
	ll A[N + 100];
	ll cnt = 0;
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 1) {
			cnt++;
		}
	}
	if (cnt % 2)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	}
	

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)   sort(a.begin(), a.end())
const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<int> x;
    for(int i = 0; i < n; ++i) {
        int buffer;
        cin>>buffer;
        x.emplace_back(buffer);
    }

    sort(x.begin(), x.end(), greater<int>());

    int ans = 0;
    for(int i = 1; i < n; ++i) ans += x[i];

    cout << ((x[0] < ans) ? "Yes" : "No");
}

Measured memory_bytes: 888
import sys
sys.setrecursionlimit(100000000)

#存在しないノードにはNILを割り当てる
NIL = -1

n = int(input())

#左子右兄弟表現で根つき木を実装していく
class Node:
    def __init__(self, p, l, r):
        self.p = p
        self.l = l
        self.r = r
        self.d = 0
        self.t = 'undifined'
        self.c = []

#T[i]にはノードiの情報を保持する
T = [Node(NIL, NIL, NIL) for _ in range(n)]

#ノードの情報を受け取りTに保持していく
for _ in range(n):
    data = [int(i) for i in input().split()]
    node_id = data[0]
    node_d = data[1]
    child = data[2:]
    if len(child) > 0:
        T[node_id].l = child[0]
    for i in range(len(child)):
        if i < len(child)-1:
            T[child[i]].r = child[i+1]
        T[child[i]].p = node_id
        T[node_id].c.append(child[i])



#仕様
#ノード番号　親ノードの番号　ノードのふかさ　ノードの種類　子ノードのリスト　をノード0から順に出力する

#ノードの深さを求める関数
def setDepth(root_id, depth):
    T[root_id].d = depth
    l = T[root_id].l
    r = T[root_id].r
    if l != NIL:
        setDepth(l, depth+1)
    if r != NIL:
        setDepth(r, depth)

#rootの番号を求める関数
def getRoot():
    for i in range(n):
        p = T[i].p
        if p == NIL:
            return i

#ノードの種類を求める関数
def setNodeType(node_id):
    #親がNILならばrootで確定する
    if T[node_id].p == NIL:
        T[node_id].t = 'root'
        return
    #親が存在して、子が存在しない場合はleaf
    if T[node_id].l == NIL:
        T[node_id].t = 'leaf'
        return 
    #それ以外はinternal node
    T[node_id].t = 'internal node'

def allSetNodeType():
    for i in range(n):
        setNodeType(i)

def outPutNodeInfo(node_id, p_node_id, depth='nil', node_type='nil', child_list='nil'):
    res = "node {}: parent = {}, depth = {}, {}, {}".format(node_id, p_node_id, depth, node_type, child_list)
    print(res)


#問題の答えを出力するための関数
def outPutAns():
    for i in range(n):
        node_id = i
        p_node_id = T[i].p
        depth = T[i].d
        node_type = T[i].t
        child_list = T[i].c
        outPutNodeInfo(node_id, p_node_id, depth, node_type, child_list)



def main():
    setDepth(getRoot(), 0)
    allSetNodeType()
    outPutAns()
main()


Measured memory_bytes: 136880
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	myout(N + (N * N) + (N * N * N));
}

Measured memory_bytes: 30168
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;

vector<int> toInt(string &in){
	vector<int> a;
	for(int i = 0; i < in.size(); i++) a.push_back(in[i]-'0');
	return a;
}

int main(){
	string in;
	while(cin >> in){
		if(cin.eof()) break;
		vector<int> a = toInt(in);
		while(a.size()!=1){
			vector<int> b;
			for(int i = 1; i < a.size(); i++){
				int tmp = a[i]+a[i-1];
				while(tmp>=10) tmp %= 10;
				b.push_back(tmp);
			}
			a = b;
		}
		cout << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <map>

using namespace std;

const long long abs_max = 1000000000000000000LL;

map<long long, long long> best_result; 

long long a, b, c, d;

long long get_ans(long long n) {
  if (best_result.find(n) != best_result.end())
    return best_result[n];
  //cout << "n: " << n << "\n";
  // for 5
  long long prev = n - n % 5;
  long long next = prev + 5;
  //cout << "prev/5 = " << prev/5 << "; next/5 = " << next/5 << "\n";
  long long prev_ans_5 = get_ans(prev / 5) + c + (n - prev) * d;
  long long next_ans_5 = abs_max;
  if (next / 5 != n)
    next_ans_5 = get_ans(next / 5) + c + (next - n) * d;
  // for 3
  prev = n - n % 3;
  next = prev + 3;
  //cout << "prev/3 = " << prev/3 << "; next/3 = " << next/3 << "\n";
  long long prev_ans_3 = get_ans(prev / 3) + b + (n - prev) * d;
  long long next_ans_3 = abs_max;
  if (next / 3 != n)
    next_ans_3 = get_ans(next / 3) + b + (next - n) * d;
  // for 2
  prev  = n - n % 2;
  next = prev + 2;
  //cout << "prev/2 = " << prev/2 << "; next/2 = " << next/2 << "\n";
  long long prev_ans_2 = get_ans(prev / 2) + a + (n - prev) * d;
  long long next_ans_2 = abs_max;
  if (next / 2 != n)
    next_ans_2 = get_ans(next / 2) + a + (next - n) * d;
  // for +1
  long long no_multi = abs_max;
  if (abs_max / n >= d)
    no_multi = n * d;
  best_result[n] = min(prev_ans_5, 
    min(next_ans_5, 
    min(prev_ans_3,
    min(next_ans_3,
    min(prev_ans_2,
    min(next_ans_2,
    no_multi))))));
  //cout << "n: " << n << "; best_result: " << best_result[n] << "\n";
  return best_result[n];
}

int main() {
  int t;
  cin >> t;
  for (int tt = 0; tt < t; tt++) {
    best_result.clear();
    long long n;
    cin >> n >> a >> b >> c >> d;
    best_result[0] = 0;
    best_result[1] = d;
    get_ans(n);
    cout << best_result[n] << "\n";
  }
  return 0;
}


Measured memory_bytes: 4664
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        p: [i64; n],
    }
    let mut p = p;
    p.sort();
    p[n - 1] = p[n - 1] / 2;
    let ans = p.iter().fold(0, |sum, i| sum + i);
    println!("{}", ans);
}


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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   string a, b; cin >> a >> b;
   if(a.size() > b.size())
   {
      cout << "GREATER" << nl;
      return 0;
   }
   else if(a.size() < b.size())
   {
      cout << "LESS" << nl;
      return 0;
   }
   else
   {
      for(int i = 0; i < a.size(); i++)
      {
         if(a[i] < b[i])
         {
            cout << "LESS" << nl;
            return 0;
         }
         if(a[i] > b[i])
         {
            cout << "GREATER" << nl;
            return 0;
         }


      }
   }
   cout << "EQUAL" << nl;
   return 0;

}


Measured memory_bytes: 3532
import math
a,b,V = map(int, input().split())

if V == a*a*b:
    print(0)
else:    
    if V >= a * a * b / 2:
        theta = math.atan( a**3 / (2 * (a**2 * b - V)) )

    else:
        theta = math.atan(2 * V / (a * b**2))

    print(90 - theta * 180 / math.pi)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    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...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll i,n,m,a,b,p = MAX;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,n){
        cin>>a>>b;
        if(b <= m)
            p = min(p,a);
    }
    if(p == MAX) cout<<"TLE";
    else
        cout<<p;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n;
    cin >> n;
    for(int i = 0; i <= n; i++){
        if(1.08 * i - double(n) < 1 && 1.08 * i - double(n) >= 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String s = in.readLine();
    String t = s.substring(0,n/2);
    System.out.println((t+t).equals(s)?"Yes":"No");
  }
}

Measured memory_bytes: 22996
N,M=map(int,input().split())
import heapq
L=[]
R=[]
for i in range(M):
  l,r=map(int,input().split())
  heapq.heappush(L, -l)
  heapq.heappush(R, r)
l=heapq.heappop(L)
r=heapq.heappop(R)
if -l>r:
  print(0)
else:
  print(r+l+1)

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

using namespace std;

inline int read()
{
	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 n,a,b;
int main()
{
	n=read(); a=read(); b=read();
	if((a-b)&1) puts("Borys");
	else puts("Alice");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> void chmax(T& a, const T& b) { if (b > a) a = b; }
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}
signed main() {
    ll n, m, ans = 0;
    cin >> n >> m;
    for (ll i = 1; i * i <= m; i++) {
        if (m % i != 0) continue;
        if (i * n <= m) chmax(ans, i);
        ll i2 = m / i;
        if (i2 * n <= m) chmax(ans, i2);
    }
    cout << ans << LF;
    return 0;
}


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

int main()
{
  int N, r[1000], w[1000];
  bool dp[1000];
  
  while(scanf("%d", &N), N) {
    for(int i = 0; i < N; i++) {
      scanf("%d %d", r + i, w + i);
    }
    int sum = accumulate(r, r + N, 0);
    int* big = max_element(r, r + N);
    int add = 0;
  
    if(*big * 2 > sum) {
      int space = *big * 2 - sum;
      swap(w[big - r], w[N - 1]);
      memset(dp, false, sizeof(bool) * (space + 1));
      dp[0] = true;
      for(int i = 0; i < N - 1; i++) {
        for(int j = space; j >= w[i]; j--) {
          dp[j] |= dp[j - w[i]];
        }
      }
      for(int i = space; i >= 0; i--) {
        if(dp[i]) {
          add = space - i;
          break;
        }
      }
    }
    printf("%d\n", sum + accumulate(w, w + N, 0) + add);
  }
}

Measured memory_bytes: 1204
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;
struct Node {
	int key;
	Node* right, * left, * parent;
};

Node* root, * NIL;

Node* find(Node* u, int k){
	while (u != NIL && k != u->key)	{
		if (k < u->key) {
			u = u->left;
		}
		else {
			u = u->right;
		}
	}
	return u;
}

void insert(int k){
	Node* y = NIL;
	Node* x = root;
	Node* z;
	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL){
		y = x;
		if (z->key < x->key){
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL){
		root = z;
	}
	else{
		if (z->key < y->key){
			y->left = z;
		}
		else{
			y->right = z;
		}
	}

}
void inorder(Node* u){
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node* u)
{
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n, i, x;
	string com;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		cin >> com;
		if (com[0] == 'f'){
			scanf("%d", &x);
			Node* t = find(root, x);
			if (t != NIL)printf("yes\n");
			else printf("no\n");
		}
		else if (com == "insert"){
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 22024
#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;

int n,m;
vector<int> a[200001];
vector<bool> vis(200001,false); 

void dfs(int node,int d){
    if(vis[node]||d>2){
        return ;
    }
    vis[node]=true;
    for(int i=0;i<a[node].size();i++){
        dfs(a[node][i],d+1);
    }
}

int main(){

    cin>> n >> m;

    rep(i,m){
        int s,t;
        cin >> s >> t;
        a[s].push_back(t);
        a[t].push_back(s);
    }

    dfs(1,0);

    if(vis[n]){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define mp map<ll,ll>
#define mpi map<ii,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#include <unordered_map> 
#define ump unordered_map<ll,ll>
int main()
{ 
	fast 
	ll n;
	long double ans=0;
	cin>>n;
	ll i;
	ll a[MAX];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ans=a[0];
	for(i=1;i<n;i++)
	{
		ans=(ans+a[i])/2;
	}
	cout<<setprecision(8)<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=min((x[i]-x[i-1])*a,b);
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main(){
   long long H, W;
   std::cin >> H >> W;

   long long ans = H*W;
   for(long long i=1; i<H; ++i){
      long long S0 = W * i;
      long long S1 = W/2 * (H-i);
      long long S2 = (W-W/2) * (H-i);
      long long max = std::max(S0,std::max(S1,S2));
      long long min = std::min(S0,std::min(S1,S2));
      ans = std::min(ans,max-min);

      S1 = W * ((H-i)/2);
      S2 = W * (H-i-(H-i)/2);
      max = std::max(S0,std::max(S1,S2));
      min = std::min(S0,std::min(S1,S2));
      ans = std::min(ans,max-min);
   }
   for(long long i=1; i<W; ++i){
      long long S0 = H * i;
      long long S1 = H/2 * (W-i);
      long long S2 = (H-H/2) * (W-i);
      long long max = std::max(S0,std::max(S1,S2));
      long long min = std::min(S0,std::min(S1,S2));
      ans = std::min(ans,max-min);

      S1 = H * ((W-i)/2);
      S2 = H * (W-i-(W-i)/2);
      max = std::max(S0,std::max(S1,S2));
      min = std::min(S0,std::min(S1,S2));
      ans = std::min(ans,max-min);
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main(){
    ld H,W;
    cin >> H >> W;
    if(H<0) H*(-1);
    ll x,y;
    cin >> x >> y;
    printf("%lf %d\n", double(H)*double(W) / 2, x + x == H&&y + y == W);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    ll p;
    cin>>p;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans=p;
    // if(n==2)
    // {
    //     ll g=abs(a[0]-a[1]);
    //     g=min(g,p-g);
    //     cout<<g;
    //     return;
    // }
    for(i=0;i<n-1;i++)
    {
        ll x=a[i];
        ll y=a[i+1];
        ans=min(ans,p-(abs(x-y)));
    }
    ll g=p-a[n-1];
    ans=min(ans,p-(a[0]+g));
    cout<<ans;
    
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

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




int main(){
	string s,t;
	cin>>s>>t;
	vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));//dp[i][j] sのi文字目、tのj文字目まで
	for(int i=1;i<=s.size();i++){
		for(int j=1;j<=t.size();j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	string ans = "";
	int x=s.size(),y=t.size();
	while(x>0&&y>0){
		if(dp[x][y]==dp[x-1][y])x--;
		else if(dp[x][y]==dp[x][y-1])y--;
		else{
			ans=t[y-1]+ans;
			x--;y--;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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


int main() {
    int N;
    cin >> N;
    string s = to_string(N);
    int n = s.length();
    int v = 0;
    int a = s[0] - '0';
    int b = s.back() - '0';
    rep(i, n-2) v += pow(10, i);
    vector<vector<int>> w(10, vector<int>(10));
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i == j && i <= N) w[i][j]++;
            w[i][j] += v;
            if (i > a) continue;
            else if (i < a) w[i][j] += pow(10, n-2);
            else w[i][j] += (N - (a * pow(10, n-1) + j)) / 10 + 1;
        }
    }
    ll ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += w[i][j] * w[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
apple = []
for _ in range(n):
    apple.append(int(input()))
a = sum(apple)
b = sorted(apple)
count = 0
if str(a)[-1] != "0":
    print(a)
else:
    for i in b:
        c = a
        c -= i
        if str(c)[-1] != "0":
            print(max(c, 0))
            break
        else:
            count += 1
            if count == len(apple):
                print(0)

Measured memory_bytes: 3064
program ABC_089_C_March
   implicit none
   integer(8) N, i, j, k, a(1:5)
   integer(8)countN
   character(1) c, m(1:5)
   character(10), allocatable :: S(:)
   read(*, *) N
   allocate(S(1: N))
   do i = 1, N
       read(*, *) S(i)
   end do
   m(1) = 'M'
   m(2) = 'A'
   m(3) = 'R'
   m(4) = 'C'
   m(5) = 'H'
   a(:) = 0
   do j = 1, 5
       do i = 1, N
	       read(S(i), '(a1)') c
		   if( c == m(j) ) then
		       a(j) = a(j) + 1
		   end if
	   end do
   end do
   countN = 0
   do k = 1, 3
       do j = k, 3
	       do i = j, 3
		       countN = countN + a(k)*a(j+1)*a(i+2)
		   end do
	   end do
   end do
   write(*, *) countN
end program ABC_089_C_March

Measured memory_bytes: 1536
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r;};
struct Node T[MAX];
int n, H, D[MAX];

int getDepth(int u){
  int d = 0;
  for(; T[u].p != NIL ;d++) u = T[u].p;
  return d;
}

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if ( T[u].p == NIL ) printf("root, ");
  else if ( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

main(){
  int i, j, d, v, c, l;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  
  H = 0;
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    if ( D[i] > H ) H = D[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}


Measured memory_bytes: 3416
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep2(i, n) for(ll i = 2; i <=(ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll 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 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;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n, x, m;
    cin >> n >> x >> m;
    ll leastidx[3*m+1];
    ll sum[3*m+1];
    rep0(i, 3*m) leastidx[i] = 0;
    sum[0] = 0;
    ll a = x;
    ll ans = 0;
    rep1(i, n){
        //cout << a << endl;
        sum[i] = sum[i-1] + a;
        if(leastidx[a] > 0){
            ll s_cycle = leastidx[a];
            ll cycle_len = i - s_cycle;
            ll cycle_sum = sum[i] - sum[s_cycle];
            ll cycle_num = (n - i) / cycle_len;
            ll left = (n - i) % cycle_len;
            ans = sum[i] + cycle_sum*cycle_num + sum[s_cycle+left] - sum[s_cycle];
            cout << ans << endl;
            return 0;        
        }
        leastidx[a] = i;
        a = (a*a) % m;
    }
    ans = sum[n];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5872
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	total := 0
	for i := 0; i < N; i++ {
		total += A[i]
	}
	ok := false
	num := ceil(total, 4*M)
	for i := 0; i < M; i++ {
		if A[i] < num {
			break
		}
		if i == M-1 {
			ok = true
		}
	}
	if ok {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

char s;

int main()
{
    for (size_t i = 0; i < 19; i++) {
        cin >> s;
        if (i == 5 || i == 13) {
            cout << " ";
        } else {
            cout << s;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256