akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());

    int bad=-1;
    ll sum=0;
    for(i=0; i<n-1; i++) {
        sum+=a[i];
        if(a[i+1]>sum*2) {
            bad=i;
        }
    }
    printf("%d\n", n-1-bad);

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
sort(s.begin(),s.end());
if(s=="abc"){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[51],t[51];
  scanf("%s %s",s,t);
  int a=0;
  while(1){
    if(s[a]=='\0'){break;}
    printf("%c",s[a]);
    if(t[a]=='\0'){break;}
    printf("%c",t[a]);
    a++;
  }
  return 0;}

Measured memory_bytes: 128
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        long count = 0;
        char prev = ' ';

        for(int i=0; i < s.Length;) {
            if (prev == s[i]) {
                prev = ' ';
                if(i == s.Length - 1) {
                    i += 1;
                } else {
                    count++;
                    i += 2;
                }
            } else {
                prev = s[i];
                count++;
                i++;
            }
        }

        return count;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
#define PB push_back
#define INF 1000000001
#define INFL 1000000000000000001
#define M 1000000007
int main(void){
	int n,m;
	cin>>n>>m;
	int l=-INF,r=INF;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		l=max(l,a);
		r=min(r,b);
	}
	cout<<max(0,r-l+1)<<endl;
}


Measured memory_bytes: 256
n = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
temp = list(map(lambda x, y: abs(x-y), X, Y))
result = []
for i in [1,2,3]:
    print(sum(list(map(lambda x: x**i, temp)))**(1/i))
print(max(temp))


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
ll dp[3001][3001][4];
ll fun( vector<vector<ll>>&v,int R,int C,int i,int j,int cap){
   if(i==R-1 && j==C-1){
      if(cap>0) return v[i][j];
      else return 0;
   }
   if(dp[i][j][cap]!=-1) return dp[i][j][cap];
   if(i==R-1){
      if(v[i][j]>0 && cap>0){
            return dp[i][j][cap]=max(v[i][j]+fun(v,R,C,i,j+1,cap-1),fun(v,R,C,i,j+1,cap));
      }else{
         return dp[i][j][cap]=fun(v,R,C,i,j+1,cap);
      }
   }
   if(j==C-1){
      if(v[i][j]>0 && cap>0){
            return dp[i][j][cap]= v[i][j]+fun(v,R,C,i+1,j,3);
      }else{
            return dp[i][j][cap]=fun(v,R,C,i+1,j,3);
      }
   }
   if(v[i][j]>0 && cap>0){
      return dp[i][j][cap]=max(v[i][j]+fun(v,R,C,i,j+1,cap-1),max(v[i][j]+fun(v,R,C,i+1,j,3),
                             fun(v,R,C,i,j+1,cap)));
   }else{
      return dp[i][j][cap]=max(fun(v,R,C,i,j+1,cap),fun(v,R,C,i+1,j,3));
   }
}
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t=1;
   // cin>>t;
   while(t--){
	   ll r,c,k;
      cin>>r>>c>>k;
      vector<vector<ll>>v(r,vector<ll>(c));
      for(int i=0;i<r;i++){
         for(int j=0;j<c;j++){
            v[i][j]=0;
         }
      }
      while(k>0){
         ll x,y,val;
         cin>>x>>y>>val;
         v[x-1][y-1]=val;
         k--;
      }
      for(int i=0;i<=3000;i++){
         for(int j=0;j<=3000;j++){
            for(int k=0;k<=3;k++){
               dp[i][j][k]=-1;
            }
         }
      }
   ll ans=fun(v,r,c,0,0,3);
   cout<<ans<<'\n';
}
   return 0;
}



Measured memory_bytes: 355824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 5050
int a[N]={0};
int  main(){
    ll n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a,a+n);//排序，容易知道一定是最小的那几个是不需要的
    ll sum = 0;
    ll p = n;

    for(ll i=n-1; i>=0; i--){
        if(sum+a[i]<k){
            sum +=a[i];
        }
        else{
            p = i;
        }
    }
    cout<<p<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+5;
const int mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,k,ans=0;
    cin>>n>>k;
    while(n--) {
    	int x;
    	cin>>x;
    	ans += (x>=k);
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100

int main(){

	char buf[BUF_SIZE] = {0};
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	int array[ARRAY_SIZE] = {0};

	for(int i = 0; i < n; i++){
		cin >> array[i];
	}

	for(int k = 0;k < n; k++){
		if(k != n-1){
			printf("%d ",array[k]);
		}else{
			printf("%d\n",array[k]);
		}
	}

	int v = 0;
	int j = 0;
	for(int i = 1; i < n; i++){
		v = array[i];
		j = i-1;
		while(j >= 0 && array[j] > v){
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = v;
		for(int k = 0;k < n; k++){
			if(k != n-1){
				printf("%d ",array[k]);
			}else{
				printf("%d\n",array[k]);
			}
		}
	}

}



Measured memory_bytes: 3212
n=int(input())
blist=list(map(int,input().split()))

ans=blist[0]
for idx in range(n-2):
    if blist[idx]<=blist[idx+1]:
        ans+=blist[idx]
    else:
        ans+=blist[idx+1]
ans+=blist[-1]
print(ans)

Measured memory_bytes: 38256
//ubiquidity
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;

/* Iterative Function to calculate (x^y)%p in O(log y) */
long long int power(long long int x, long long int y)
{
    long long int ans = 1;
    while (y--)
    {
        ans = (ans * x) % mod;
    }
    return ans;
}
int main()
{
    long long int n;
    cin >> n;
    long long int k;
    //cout << power(10, n) << " " << endl;
    k = (power(10, n) - 2 * (power(9, n)) % mod + power(8, n) + mod) % mod;
    cout << k << " " << endl;
    return 0;
}

Measured memory_bytes: 3636
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (n); i++)

int main() {
	cout << fixed << setprecision(10);
	int a, b, x;
	cin >> a >> b >> x;
	double w;
	if (a * a * b >= 2 * x) {
		w = atan((a * b * b / (2.0 * x)));
	}
	else {
		w = atan(2.0 * (a * a * b - x) / (a * a * a));

	}
	cout << 180 * w / acos(-1) << endl;
	return 0;
}

Measured memory_bytes: 4104
import sys
from collections import defaultdict

input = lambda: sys.stdin.readline().rstrip()

N = int(input())

d = defaultdict(int)

for i in range(N):
    word = input()
    d[word] += 1

M = int(input())

for i in range(M):
    word = input()
    d[word] -= 1

sorted_d = sorted(d.items(), key=lambda x:x[1], reverse=True)

if sorted_d[0][1] <= 0:
    print(0)
else:
    print(sorted_d[0][1])

Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
typedef long long int ll;
int main()
{
  int a,b;

  cin>>a>>b;
  if(a%b==0)
        cout<<a/b<<endl;
  else
  {
      cout<<ceil(double(a)/b)<<endl;
  }
}


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

ans = 100000
titen = 0

for i in range(N):
    res = abs((T - H[i]*0.006) - A)
    if res < ans:
        ans = res
        titen = i+1        
print(titen)

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

int main() {
	int n, a, b;
	std::cin >> n >> a >> b;
	if ((a != b && n < 2) || b < a) {
		std::cout << 0 << std::endl;
		return 0;
	}
	std::cout << (b - a) * (n - 2ll) + 1 << std::endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

// int main(){
//   ll n,a;
//   cin >> n >> a;
//   ll x[n];
//   REP(i,n){
//     cin >> x[i];
//   }
//   ll ans = 0;
//   REP(i,1<<n){
//     ll sum = 0;
//     ll cnt = 0;
//     REP(j,n){
//       if((i>>j)&1){
//         sum+=x[j];
//         cnt++;
//       }
//     }
//     if(sum==a*cnt){
//       ans++;
//     }
//   }
//   cout << ans-1 << endl;
//   return 0;
// }

int main(){
  ll n,a;
  cin >> n >> a;
  ll x[n+1];
  x[0] = 0;
  REP(i,n){
    cin >> x[i+1];
  }
  ll cnt[n+1][n+1][50*50+1];
  //x[i]まででj個使い、和がkとなる組合せ
  REP(i,n+1){
    REP(j,n+1){
      REP(k,50*50+1){
        if(i==0&&j==0&&k==0){
          cnt[i][j][k]=1;
        }else if(i>=1&&k<x[i]){
          cnt[i][j][k]=cnt[i-1][j][k];
        }else if(i>=1&&j>=1&&k>=x[i]){
          cnt[i][j][k]=cnt[i-1][j][k]+cnt[i-1][j-1][k-x[i]];
        }else{
          cnt[i][j][k]=0;
        }
      }
    }
  }
  ll ans = 0;
  for(ll i=1; i<=n; i++){
    ans += cnt[n][i][a*i];
  }
  cout << ans << endl;
}


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

int getMax(string s, char letter){
  int result = 0;
  
  s = letter + s + letter;
  int left = 0;
  for(int right = 1; right < s.size(); right++){
    if(s[right] == letter){
      result = max(result, right - left - 1);
      left = right;
    }
  }
  
  return result;
}

int main(){
  string s;
  cin >> s;
  int ans = 1e6;
  for(char letter = 'a'; letter <= 'z'; letter++){
    ans = min(ans, getMax(s, letter));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
# -*- coding utf-8 -*-
import sys
s=list(str(input()))
x=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for i in range(len(x)):
    if x[i] in s:
        pass
    else:
        print(x[i])
        sys.exit()


print("None")


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>


using namespace std;

int main()
{
    string S;
    cin>>S;
    int x=S.size();
   for(int i=0;i<x;i++)
    {
        S[i]='x';
   }
    cout<<S;

    return 0;
}


Measured memory_bytes: 256
x=int(input())
y=int(input())
while x != y:
    if (x == 1 and y == 2) or (y==1 and x==2):
        print(3)
        break
    elif (x == 1 and y == 3) or (y==1 and x==3):
        print(2)
        break
    elif (x == 2 and y == 3) or (y==2 and x==3):
        print(1)
        break

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

ll solve(ll& a, ll& b){
  ll ret = 0;
  if(a == b){
    ret = a;
    a = 0;
    b = 0;
    return ret;
  }
  if(b > a){
    if(b%a==0){
      ret = (b/a)*2LL*a - a;
      a = 0;
      b = 0;
      return ret;
    }else{
      ret = (b/a)*2LL*a;
      b = b%a;
      return ret;
    }
  }
  else if(b < a){
    if(a%b==0){
      ret = (a/b)*2LL*b - b;
      a = 0;
      b = 0;
      return ret;
    }else{
      ret = (a/b)*2LL*b;
      a = a%b;
      return ret;
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  ll N, X;
  cin >> N >> X;
  {
    ll ret = X + (N-X);
    ll a = X, b = N-X;
    while(true){
      ll tmp = solve(a, b);
      if(tmp == 0) break;
      ret += tmp;
    }
    cout << ret << endl;
  }
  return 0;
}



Measured memory_bytes: 256
r, g, b, n = gets.split.map(&:to_i)
cnt = 0
(0..n).map do |i|
  (0..n).map do |j|
    cnt += 1 if n-(r*i)-(g*j) >= 0 && (n-(r*i)-(g*j))%b == 0
  end
end

puts cnt

Measured memory_bytes: 79740
#include <bits/stdc++.h>
using namespace std;
int mx[105];
vector<int> v[105],d;
pair<int,int> get(int node,int p)
{
	pair<int,int> ret(0,node);
	for (int u:v[node])
	{
		if (u!=p)
		ret=max(ret,get(u,node));
	}
	ret.first++;
	return ret;
}
bool dfs(int node,int p,int e)
{
	if (node==e)
	{
		d.push_back(node);
		return 1;
	}
	for (int u:v[node])
	{
		if (u!=p && dfs(u,node,e))
		{
			d.push_back(node);
			return 1;
		}
	}
	return 0;
}
void go(int node,int p,int dep)
{
	int c=0;
	for (int u:v[node])
	{
		if (u!=p)
		{
			c++;
			go(u,node,dep+1);
		}
	}
	mx[dep]=max(mx[dep],c);
}
long long calc(int h)
{
	long long l=1;
	for (int i=0;i<h-1;i++)
	l*=mx[i];
	return l;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	auto f=get(1,0),s=get(f.second,0);
	dfs(f.second,0,s.second);
	int h=(d.size()+1)/2;
	long long ans=LLONG_MAX;
	if (d.size()%2)
	{
		go(d[h-1],0,0);
		ans=min(ans,calc(h));
		for (int u:v[d[h-1]])
		{
			memset(mx,0,sizeof(mx));
			go(d[h-1],u,0);
			go(u,d[h-1],0);
			ans=min(ans,2*calc(h));
		}
	}
	else
	{
		go(d[h],d[h-1],0);
		go(d[h-1],d[h],0);
		ans=min(ans,2*calc(h));
	}
	printf("%d %lld",h,ans);
}

Measured memory_bytes: 3856
use std::io::Read;
 
fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.lock().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse::<usize>().unwrap();

    for i in 0..10 {
        if 1<<i > n {
            println!("{}", 1<<(i-1));
            break;
        }
    }
}


Measured memory_bytes: 2128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#define rep(i,l,r) for(i=l;i<r;i++)
#define repb(i,r,l) for(i=r;i>l;i--)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
const int mod=1000000007;
using namespace std;
bool sortlr(pll &a,pll &b){
    if(a.first!=b.first){
        return a.first<b.first;
    }
    else{
        return a.second<b.second;
    }
}

int main(){
    int a,b;
    cin>>a>>b;
    int i;
    int ma=max(a,b);
    int mi=min(a,b);
    rep(i,0,ma){
        cout<<mi;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
struct tree{
    int l;
    int r;
    bool root;
};
tree map[100000];
void pre(int now){
    printf(" %d",now);
    if(map[now].l!=-1)pre(map[now].l);
    if(map[now].r!=-1)pre(map[now].r);
}
void in(int now){
    if(map[now].l!=-1)in(map[now].l);
    printf(" %d",now);
    if(map[now].r!=-1)in(map[now].r);
}
void post(int now){
    if(map[now].l!=-1)post(map[now].l);
    if(map[now].r!=-1)post(map[now].r);
    printf(" %d",now);
}
int main(){
    int n,l,r,v;
    scanf("%d",&n);
    for(int i=0;i<n;i++)map[i].root=true;
    for(int i=0;i<n;i++){
        scanf("%d%d%d",&v,&l,&r);
        map[v].l=l;
        map[v].r=r;
        if(l!=-1)map[l].root=false;
        if(r!=-1)map[r].root=false;
    }
    for(int i=0;i<n;i++)if(map[i].root){
        printf("Preorder\n");
        pre(i);
        printf("\nInorder\n");
        in(i);
        printf("\nPostorder\n");
        post(i);
        printf("\n");
        return 0;
    }
}

Measured memory_bytes: 2724
n, m = map(int, input().split())
Q = []
for _ in range(m):
    q = list(map(int, input().split()))
    Q.append(q)
p = list(map(int, input().split()))
ans = 0
#　全てのスイッチパターンを列挙
for pattern in range(2 ** n):
    #p = bin(p)
    for i in range(len(Q)):
        on_cnt = 0
        for j in range(1, len(Q[i])):
            if ((pattern >> (Q[i][j] - 1)) & 1):
                on_cnt += 1
        if on_cnt % 2 != p[i]:
            break
    else:
        ans += 1
print(ans)


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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 comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    set< string > st;
    map<string, int> mp;
    for( int i = 0; i < n; ++i ) {
        string s;
        cin >> s;
        ++mp[s];
        st.insert(s);

    }

    int mx = 0;
    for( auto it = st.begin(); it != st.end(); ++it) {
        mx = max(mx, mp[(*it)]);

    }

    for( auto it = st.begin(); it != st.end(); ++it ) {
        if( mp[(*it)] == mx ) {
            cout << *it << endl;

        }

    }
    return 0;
}



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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0;i < s.size() - 1;i++) {
		if (s[i] != s[i + 1])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;cin>>s;
  long long ans = 0;
  for(int i = 0; (1<<s.size()-1) > i; i++){
    long long tmp = s[0]-'0';
    vector<long long> a;
    for(int j = 0; s.size()-1 > j; j++){
      if(i & (1<<j)){
        //+
        a.push_back(tmp);
        tmp = 0;
      }
      tmp = tmp * 10 + s[j+1]-'0';
    }
    a.push_back(tmp);
    long long sm = 0;
    for(int j = 0; a.size() > j; j++){
      sm += a[j];
    }
    ans += sm;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var S = lines[0].split("")
    var T = lines[1].split("")

    for (var i = 0; i < T.length; i++){
        if(S.join("") === T.join("")){console.log("Yes"); return(0)}
        var x = S.pop()
        S.unshift(x);
    }
    console.log("No");
});

Measured memory_bytes: 9548
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int ans[4];
int main() {
    /*int n;cin >> n;
    rep(i, n) {
        int a;cin >> a;
        ans[a%4]++;
    }
    if(ans[1]+ans[3]+ans[0]==n&&ans[1]+ans[3]-1<=ans[0]) cout << "Yes" << endl;
    else if(ans[1]+ans[3]>ans[0]||(ans[2]>ans[0]&&ans[2])) cout << "No" << endl;
    else cout << "Yes" << endl;*/
    int n;cin >> n;
    rep(i, n) {
        int a;cin >> a;
        ans[a%4]++;
    }
    n-=max(ans[2]-1,0);
    ans[2]-=max(ans[2]-1,0);
    if(ans[2]==1&&ans[1]+ans[3]>ans[0]) cout << "No" << endl;
    else if(ans[2]==0&&ans[1]+ans[3]-1>ans[0]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  rep (i, N) cin >> a[i];
  rep (i, N) a[i]--;
  vector<int> S(N + 1);
  rep (i, N) S[i + 1] = (S[i] + a[i]) % K;
  map<int, int> mp;
  ll ans = 0;
  queue<int> q;
  rep (j, N + 1) {
    ans += mp[S[j]];
    mp[S[j]]++;
    q.push(S[j]);
    if (q.size() == K) {
      mp[q.front()]--;
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12032
#include<iostream>
#include<set>
#include<string>

int main(){
    
    std::string in;
    std::cin >> in;

    std::set<char> s(in.begin(), in.end());

    if(in.size() != s.size()){
        std::cout << "no" << std::endl;
    }else{
        std::cout << "yes" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <map>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;

int main() {
	map<string,int> mp;
	int n,j=0;
	string s;
	char c[20];
	cin >> n;
	for (int i = 0;i < n;i++) {
		scanf("%s", c);
		if (c[0] == 'i') {
			cin >> s;
			mp.insert(make_pair(s, j));
			j++;
		}
		else {
		  cin >> s;
		  cout << ((mp.find(s) != mp.end()) ? "yes" : "no") << endl;
		}
	}
}

Measured memory_bytes: 36952
#include <cstring>
#include <cstdio>

typedef long long LL;
const int N=100005;

int fail[N],n,t;
LL cnt[90][26],f[90],ans[26];
char s[N*2];

void count(int pos,LL *a){
	for (int i=1;i<=pos;i++) a[s[i]-'a']++;
}

void calc(LL pos){
	if (pos<=n){
		count(pos,ans);
		return;
	}
	int m=0;
	for (;f[m+1]<=pos;m++);
	for (int i=0;i<26;i++) ans[i]+=cnt[m][i];
	calc(pos-f[m]);
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1)/2;
	fail[0]=-1;
	for (int i=1,j=-1;i<=n;fail[i++]=++j)
		for (;j>=0 && s[j+1]!=s[i];j=fail[j]);
	t=n-fail[n];
	f[0]=t;count(t,cnt[0]);
	f[1]=n;count(n,cnt[1]);
	LL l,r;
	scanf("%lld%lld",&l,&r);
	for (int i=2;f[i-1]<=r;i++){
		f[i]=f[i-1]+f[i-2];
		for (int j=0;j<26;j++) cnt[i][j]=cnt[i-1][j]+cnt[i-2][j];
	}
	calc(l-1);
	for (int i=0;i<26;i++) ans[i]*=-1;
	calc(r);
	for (int i=0;i<26;i++) printf("%lld ",ans[i]);
}

Measured memory_bytes: 768
#include <stdio.h>
 
#define TIME_MIN (2)
#define TIME_MAX (200000)
#define VALUE_MIN (1)
#define VALUE_MAX (1000000000)
#define FAILURE   (-1000000001)
#define SUCCESS   (0)
 
int get_int(int *p_num, int min, int max);
int judge_constraint(int test_num, int min, int max);
int max_profit(int size);
 
int main(void)
{
    int time_cnt;
    int rslt;
     
    if(get_int(&time_cnt, TIME_MIN, TIME_MAX) == FAILURE)
    {
        return FAILURE;
    }
 
    if((rslt = max_profit(time_cnt)) == FAILURE)
    {
        return FAILURE;
    }
    
    printf("%d\n", rslt);
     
    return SUCCESS;
}
 
int max_profit(int size)
{
    int min;
    int max;
    int current;
    int i;
     
    /* init  */
    if(get_int(&current, VALUE_MIN, VALUE_MAX) == FAILURE)
    {
        return FAILURE;
    }
    min = current;
    max = VALUE_MAX * -1;
     
    /* calc */
    for(i = 1; i < size; i++)
    {
        if(get_int(&current, VALUE_MIN, VALUE_MAX))
        {
            return FAILURE;
        }
        if(max < current - min)
        {
            max = current - min;
        }
        if(min > current)
        {
            min = current;
        }
    }
     
     
    return max;
}
 
int get_int(int *p_num, int min, int max)
{
    scanf("%d", p_num);
     
    if(judge_constraint(*p_num, min, max) == FAILURE)
    {
        return FAILURE;
    }
     
    return SUCCESS;
}
int judge_constraint(int test_num, int min, int max)
{
    if(test_num < min || test_num > max)
    {
        return FAILURE;
    }
     
    return SUCCESS;
}

Measured memory_bytes: 1852
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    vector<int> w(n);
    for (int i = 0; i < m; ++i) {
        int pp;
        string s;
        cin >> pp >> s;
        --pp;
        if (s == "AC") {
            p[pp] = 1;
        } else if (!p[pp]) {
            ++w[pp];
        }
    }
    for (int i = 0; i < n; ++i) {
        if (p[i] == 0) {
            w[i] = 0;
        }
    }
    cout << accumulate(p.begin(), p.end(), 0) << " " << accumulate(w.begin(), w.end(), 0) << "\n";
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int prof = 0;
    int arr1[n];
    int arr2[n];
    for(int i = 0; i < n; i++)
    {
        cin>>arr1[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin>>arr2[i];
    }
    
    for(int i = 0; i < n; i++)
    {   
        prof = max(prof, prof + arr1[i] - arr2[i]);
    }
    cout<<prof;
    return 0;
}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int N;

int A[102];

int c;

int main(){
	cin.tie(0);
	
	cin>>N;
	rep(i, N)cin>>A[i];
	
	bool f = true;
	while(f) {
		f = false;
		rfor_(i, 1, N) {
			if(A[i] < A[i-1]) {
				int s = A[i];
				A[i] = A[i-1];
				A[i-1] = s;
				c++;
				f = true;
			}
		}
	}
	
	rep(i, N)cout<<(i>0?" ":"")<<A[i];
	cout<<endl<<c<<endl;
	
	return 0;
}



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


def maximum_profit(profits):
    max_v = profits[1] - profits[0]
    min_v = profits[0]

    for j in range(1, len(profits)):
        max_v = max(max_v, profits[j]-min_v)
        min_v = min(min_v, profits[j])

    print(max_v)


def to_int(v):
    return int(v)


if __name__ == '__main__':
    l = to_int(input())
    profits = [to_int(input()) for i in range(l)]

    maximum_profit(profits)

Measured memory_bytes: 15668
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int[] num = new int[2*k-1];
        int len = num.length;
        int sum = x-k+1;


        for(int i = 0;i<len;i++){
            num[i] = sum;
            sum++;
            
        }

        for(int i = 0;i<len;i++){
            System.out.print(num[i]+" ");
        }


    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define pb push_back
#define ins insert
#define F first
#define S second
#define var auto
using namespace std;
typedef long long ll;
const int Max = 1e5 + 10;
const int Mod = 1e9 + 7;


bool seen[Max];
vector<pair<int,int> > N[Max];

bool ok = true;
int dist[Max];

void DFS(int v)
{
	seen[v] = true;

	for(auto u : N[v])
	{
		if(seen[u.F])
			ok &= dist[u.F] == dist[v] + u.S;
		else
		{
			dist[u.F] = dist[v] + u.S;
			DFS(u.F);
		}
	}
}

int main()
{
	int n , m;cin >> n >> m;
	for(int i = 0; i < m ; i++)
	{
		int l , r , d;cin >> l >> r >> d;
		N[l].pb({r , d});
		N[r].pb({l , -d});
	}
	for(int i = 1; i <= n ; i++)
	{
		if(!seen[i])
		{
			dist[i] = 0;
			DFS(i);
		}
	}
	if(ok)
		cout << "Yes\n";
	else
		cout << "No\n";
}



Measured memory_bytes: 15340
/*||>>>> Praveen Ojha <<<<>>>> 18 June 2019 <<<<>>>> 17:50:21 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<(double)(w*h)/2<<" ";
	cout<<(x*2==w && y*2==h)<<"\n";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
	double x1, x2, y1, y2, distance;
	cin >> x1 >> y1 >> x2 >> y2;

	distance = sqrt(pow(x2 - x1, (double)2) + pow(y2 - y1, (double)2));

	cout << fixed << setprecision(8) << distance << endl;
	return 0;
}


Measured memory_bytes: 3268
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Tue Jan 28 21:13:31 2020
//
package main

import "fmt"

var N int

func dbg(n int) int {
	fmt.Println(n)
	return n
}

func top(n int) int {
	for k := 0; ; k++ {
		if n/10 == 0 {
			return n
		}
		n /= 10
	}
}

type pair struct {
	x int
	y int
}

func main() {
	fmt.Scan(&N)
	ans := 0

	m := map[pair]int{}
	for i := 1; i <= N; i++ {
		t := top(i)
		b := i % 10
		m[pair{t, b}]++
	}
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			ans += m[pair{i, j}] * m[pair{j, i}]
		}
	}
	fmt.Println(ans)
}


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

int main(int argc, char *argv[]) {
  int A, B, K;
  cin >> A >> B >> K;
  int count = 0;
  while(true) {
    if(A % 2 == 1) {
      A--;
    }
    B += A / 2;
    A -= A / 2;
    count++;
    if(count == K) {
      cout << A << " " << B << endl;
      break;
    }
    if(B % 2 == 1) {
      B--;
    }
    A += B / 2;
    B -= B / 2;
    count++;
    if(count == K) {
      cout << A << " " << B << endl;
      break;
    }
  }
  return 0;
}


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

int main(){
	string s;
  	cin >> s;
  	int count = 0;
 	for(int i = 0; i < s.size() ; i++) {
      if(s[i] == '1'){
        count++;
      }	
    }
  	cout << count << endl;
}

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

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String str = br.readLine();
        int num = Integer.parseInt(br.readLine());

        for(int i = 0; i < num; i++){
            String[] input = br.readLine().split(" ");
            int a = Integer.parseInt(input[1]);
            int b = Integer.parseInt(input[2]);

            switch(input[0]){
                case "print":
                    System.out.println(str.substring(a , b+1));
                    break;
                case "reverse":
                    int cycle = (b-a)/2;
                    char[] hoge = str.toCharArray();
                    for(int j = 0; j <= cycle; j++){
                        char tmp = str.charAt(a+j);
                        hoge[a+j] = hoge[b-j];
                        hoge[b-j] = tmp;
                    }
                    str = String.valueOf(hoge);
                break;
                case "replace": 
                    StringBuilder sb = new StringBuilder(str);
                    sb.replace(a , b+1 , input[3]);
                    str = sb.toString();
                break;
            }
        }

    }
}

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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	vector<int> v;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);

	sort(v.begin(), v.end());

	cout << v[0] << " " << v[2] << endl;

	return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    map<int, int> mp;
    mp[0] = 1;
    int now = 0;
    rep(i, 0, n){
        now += a[i];
        mp[now]++;
    }
    int ans = 0;
    for(auto i : mp){
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func swap(a []int, i, j int) {
	tmp := a[i]
	a[i] = a[j]
	a[j] = tmp
}

func roll(dice []int, cmd string) {
	if cmd == "N" {
		swap(dice, 0, 1)
		swap(dice, 1, 5)
		swap(dice, 5, 4)
	} else if cmd == "W" {
		swap(dice, 0, 2)
		swap(dice, 2, 5)
		swap(dice, 5, 3)
	} else if cmd == "S" {
		swap(dice, 0, 4)
		swap(dice, 4, 5)
		swap(dice, 5, 1)
	} else if cmd == "E" {
		swap(dice, 0, 3)
		swap(dice, 3, 5)
		swap(dice, 5, 2)
	}
}

func fixUpper(dice []int, upper int) {
	for _, cmd := range strings.Split("NWWWN ", "") {
		if dice[0] == upper {
			break
		}
		roll(dice, cmd)
	}
}

func fixFront(dice []int, front int) {
	for i := 0; i <= 4; i++ {
		if dice[1] == front {
			break
		}
		swap(dice, 1, 2)
		swap(dice, 2, 4)
		swap(dice, 4, 3)
	}
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := nextInt()

	dices := make([]int, 6*n)
	for i := 0; i < 6*n; i++ {
		dices[i], _ = nextInt()
	}

	containsSame := false
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			dice1 := make([]int, 6)
			dice2 := make([]int, 6)
			copy(dice1, dices[(6*i):(6*(i+1))])
			copy(dice2, dices[(6*j):(6*(j+1))])

			// fmt.Println(dice1, dice2)

			for _, cmd := range strings.Split(" NWWWN", "") {
				roll(dice1, cmd)

				upper := dice1[0]
				front := dice1[1]

				fixUpper(dice2, upper)
				fixFront(dice2, front)

				eq := reflect.DeepEqual(dice1, dice2)
				if eq {
					containsSame = true
					break
				}
				// fmt.Println(i, j, cmd, dice1, dice2, eq)
			}
		}
	}

	msg := ""
	if !containsSame {
		msg = "Yes"
	} else {
		msg = "No"
	}
	fmt.Println(msg)
}



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

int main(){
int N;

cin>>N;
vector<long long> test(N);
for(int i=0;i<N;i++){
cin>>test.at(i);
}
long long ans=0;
for(int i=0;i<N;i++){
if(i==0){
    continue;
}
if(test.at(i-1)>test.at(i)){
    ans=ans+test.at(i-1)-test.at(i);
    test.at(i)=test.at(i-1);
}
}

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

Measured memory_bytes: 4776
from itertools import product

n = int(input())
xy = []

for i in range(n):
    a = int(input())
    xy.append([tuple(map(int, input().split())) for _ in range(a)])

ans = 0

for ts in product([1,0], repeat=n):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in xy[i]):
                break
    else:
        ans = max(ans, sum(ts))

print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<int> a(N);
  cin >> a;
  cout << accumulate(all(a), 0) - N << endl;

  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define mod  1073741824
using namespace std;
int main()
{
    string c[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    for (int i = 0; i < 7; ++i)
    {
        if (c[i] == s)
        {
            cout << 7-i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
use std::cmp::{max, min};

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let a: Vec<char> = read::<String>().chars().collect();
    let n = a.len();
    let mut v = vec![('<', 1)];
    let mut pos = 0;
    while pos < n {
        let c = a[pos];
        let count = take_while(c, &a, pos);
        v.push((c, count));
        pos += count;
    }

    v.push(('>', 1));
    let m = v.len();
    let mut ans: usize = 0;
    for i in 0..m - 1 {
        if !(v[i].0 == '<' && v[i + 1].0 == '>') {
            continue;
        }

        let l = max(v[i].1, v[i + 1].1);
        let r = min(v[i].1, v[i + 1].1);
        ans += (l * (l + 1)) / 2 + ((r - 1) * r) / 2;
    }

    println!("{}", ans);
}

fn take_while(c: char, s: &Vec<char>, pos: usize) -> usize {
    let n = s.len();
    let mut ret = 0;
    for i in pos..n {
        if s[i] != c {
            break;
        }
        ret += 1;
    }
    ret
}


Measured memory_bytes: 11876
func gcd(_ a: Int, _ b: Int, _ c: Int) -> Int {
  let ab = gcd(a, b)
  return gcd(ab, c)
}

func gcd(_ a: Int, _ b: Int) -> Int {
  if b == 0 { return a }
  return gcd(b, a % b)
}

let k = Int(readLine()!)!
var result = 0
for i in 1...k {
  for j in 1...k {
    for l in 1...k {
      result += gcd(i, j, l)
    }
  }
}
print(result)

Measured memory_bytes: 7760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            Set<Character> set = new HashSet<>();
            for (char x : s.toCharArray()) set.add(x);
            out.println(set.size() == s.length() ? "yes" : "no");

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include<stdio.h>
 
#define WHITE 0
#define BLACK 1
#define NIL -1
 
int n,d[100],pi[100],w[100][100],mincost,cost;
void prim();
int main(){
  int i,j;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	scanf("%d",&w[i][j]);
	if(w[i][j]==-1) w[i][j]=10000;
      }
  }
  prim();
  
  printf("%d\n",cost);
  return 0;
}
void prim(){
  int u,v,i,color[100];
  for(u=0;u<n;u++){
      d[u]=10000;
      pi[u]=NIL;
      color[u]=WHITE;
    }
  d[1]=0;
   
  while(1){
      mincost=10000;
      for(i=0;i<n;i++){
	if((color[i]!=BLACK)&&(d[i]<mincost)){
          mincost=d[i];
          u=i;
        }
      }
      if(mincost==10000){
      break;
    }
 
      color[u]=BLACK;
 
      for(v=0;v<n;v++){
	if((color[v]!=BLACK)&&(w[u][v]<d[v])){
          pi[v]=u;
          d[v]=w[u][v];
        }
      }
  }
  for(i=0;i<n;i++){
    cost+=d[i];
  }
}

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

int main() {
	int a, b, c; 
	cin >> a >> b >> c;

	if (a == b) {
		if (b == c) cout << 1 << endl;
		else cout << 2 << endl;
	}

	else if (a == c) {
		if (a != b) cout << 2 << endl;
	}

	else if (b == c) {
		if (a != b) cout << 2 << endl;
	}

	else cout << 3 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

#define chmax(a,b) a=max(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)

int a[5000], b[5000];

int main()
{
	int A, B; scanf("%d %d", &A, &B);

	rep(i, A) scanf("%d", &a[i]);
	rep(i, B) scanf("%d", &b[i]);

	int ma = 0;

	rep(i, B) {
		int idx = i;

		int cnt = 0;

		rep(j, A) {
			if (a[j] == b[idx]) {
				idx++;
				cnt++;
			}

			if (idx == B) break;
		}

		chmax(ma, cnt);
	}

	printf("%d\n", ma);
}

Measured memory_bytes: 1060
#include "bits/stdc++.h"
using namespace std;
int main() {
	string S;
	cin >> S;
	int N = S.size();
	N--;
	long long ans = 0;
	for (int i = 0; i < (1 << N); i++) {
		long long num = S.at(0) - '0';
		vector<bool>A(N);
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) A.at(j) = true;
			else A.at(j) = false;
		}
		for(int i = 0; i < N; i++) {
			if (!A.at(i)) {
				num *= 10;
				num += S.at(i + 1) - '0';
			}
			else {
				ans += num;
				num = S.at(i + 1) - '0';
			}
		}
		ans += num;
	}
	cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  REP(i, N) cin >> h[i];

  vector<int> dp(N, INF);
  dp[0] = 0;
  for(int i = 1; i < N; ++i) {
    for(int k = 1; k <= K; ++k) {
      if(i >= k) {
        dp[i] = min(dp[i], dp[i - k] + abs(h[i] - h[i - k]));
      }
    }
  }

  cout << dp[N - 1] << endl;


  return 0;
}



Measured memory_bytes: 1024