akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

int n, x, t;

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> x >> t;
  int cnt = (n + x - 1) / x;
  int ans = cnt * t;
  cout << ans << E;
  //system("pause");
  return 0;
}

Measured memory_bytes: 3648
import sys

sys.setrecursionlimit(10**8)

def find(x):	#xの根を返す
	global table
	global diff_weight
	
	if table[x] == x:
		return x
	else:
		root = find(table[x])
		diff_weight[x] += diff_weight[table[x]] #親の更新に伴う 重みの更新
		table[x] = root	#親の更新(根を直接親にして参照距離を短く)
		return table[x]

def union(x,y,w):	#xとyを diff(x,y)=w で繋げる
	w = w - weight(y) + weight(x) 
	x = find(x)	
	y = find(y)
	
	if x == y:
		return
	
	if rank[x] < rank[y]:
		x,y = y,x
		w = -w
	
	table[y] = x
	diff_weight[y] = w
	
	if rank[x] == rank[y]:
			rank[y] += 1

def check(x,y): #xとyか繋がっているか -> return bool
	if find(x) == find(y):
		return True
	else:
		return False

def weight(x):
	find(x)	#経路圧縮
	return diff_weight[x]
		
def diff(x,y): # weight(y)-weight(x)  (繋がってる前提)
	return (weight(y) - weight(x))

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

table = [i for i in range(N)]	#木の親 table[x] == x なら根	
rank  = [1 for i in range(N)]	#木の長さ
diff_weight = [0 for i in range(N)]


for i in range(M):
	a,b,D = (map(int,input().split()))
	a -= 1
	b -= 1
	if check(a,b):
		if diff(a,b) != D:
			print('No')
			sys.exit()
	else:
		union(a,b,D)
	
	
print ('Yes')

Measured memory_bytes: 9920
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll x;
  cin >> x;
  x--;
  ll ans = 1;
  ans += (x / 11) * 2;
  x %= 11;
  if (x >= 6)
    ans++;
  cout << ans << endl;
  return 0;
}


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

#include <algorithm>
#include <queue>
#include <string>
typedef long long ll;
#define REP(i,n) for(ll i = 0; i < n; i++)
using namespace std;

ll vel_max(ll t, ll start, ll end, ll limit){
  if(t<2*start){
    return 2*limit + 2*start - t;
  }else if(t<2*end){
    return 2*limit;
  }else{
    return 2*limit + t-2*end;
  }
}

int main() {
  ll n;
  cin >> n;
  ll t[n+1], v[n+2];
  t[0] = 0;
  ll tsum = 0;
  REP(i,n){
    ll tm;
    cin >> tm;
    t[i+1] = t[i] + tm;
    tsum += tm;
  }
  v[0]=0;
  REP(i,n){
    cin >> v[i+1];
  }
  v[n+1]=0;
  ll velocity[2*tsum+1];
  REP(i,2*tsum+1){
    ll vmin = 20000;
    REP(j,n+2){
      ll vj;
      if(j==0){
        vj = vel_max(i,t[j],t[j],v[j]);
      }else if(j==n+1){
        vj = vel_max(i,t[j-1],t[j-1],v[j]);
      }else{
        vj = vel_max(i,t[j-1],t[j],v[j]);
      }
      if(vj<vmin){
        vmin = vj;
      }
    }
    velocity[i]=vmin;
  }
  ll distance = 0;
  REP(j,2*tsum){
    distance += velocity[j]+velocity[j+1];
  }
  cout << setprecision(17) << distance/8.0 << endl;
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 2e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code

int main()
{
	int x, y;
	cin>>x>>y;
	ll ans = 0;
	if(x == 1 && y == 1)
	{
		ans += 400000;
	}
	x = max(4 - x, 0);
	y = max(4 - y, 0);
	ans += x*100000 + y*100000;
	cout<<ans<<endl;
}


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

int main() {
	vector<int>abc(3);
	for (int i = 0; i < 3; i++)cin >> abc.at(i);
	sort(abc.begin(), abc.end());
	if (abc.at(0) == 5 && abc.at(1) == 5 && abc.at(2) == 7)cout << "YES" << endl;
	else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int len = s.length();
    int a = 0, b = 0;
    for(int i=0;i<len;i+=2){
        if(s[i] == 'h') a++;
    }
    for(int i=1;i<len;i+=2){
        if(s[i] == 'i') b++;
    }
    if(a*2 == len && b*2 == len) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL 

struct node {

  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};

typedef struct node* Node;
Node root;

Node treeSearch(Node x,int k) {
  if(x == NIL || k == x-> key) 
    return x;
  if(k < x->key)
    return treeSearch(x->left,k);
  else return treeSearch(x->right,k );
}

void insert(int k) {
  
  Node y = NIL;
  Node x = root;
  Node z;  
  
  z = malloc(sizeof(struct 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->left != NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)  
    inorder(u->right); 
}

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

int main(void) {
  
  int i,n,x;
  char c[5];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
  scanf("%s",c);
  if(c[0] == 'f') {
    scanf("%d",&x);
    if(treeSearch(root,x) != NIL)
      printf("yes\n");
    else printf("no\n");
  }
  else if(c[0] == 'i') {
    scanf("%d",&x);
    insert(x);
  }
  else if(c[0] == 'p') {
    if(root != NIL)   
      inorder(root);
    printf("\n");
    if(root != NIL)
      preorder(root);
    printf("\n");
    
  }
 }
return 0;
}

Measured memory_bytes: 19364
#include <cstdio>
#include <cstring>
using namespace std;
int t,cnt1,cnt2;
char c[100010],c1[200010],c2[200010];
bool dao;

int main(){
	scanf("%s%d",c,&t);
	int l=strlen(c);
	while(t--){
		int q;
		scanf("%d",&q);
		if(q==1)
			if(dao)dao=0;
			else dao=1;
		else {
			int x;
			char y;
			scanf("%d %c",&x,&y);
			if(x==1){
				if(dao==0)c1[++cnt1]=y;
				else c2[++cnt2]=y;
			}
			else {
				if(dao==1)c1[++cnt1]=y;
				else c2[++cnt2]=y;
			}
		}
	}
	if(!dao){
		for(int i=cnt1;i;i--)printf("%c",c1[i]);
		for(int i=0;i<strlen(c);i++)printf("%c",c[i]);
		for(int i=1;i<=cnt2;i++)printf("%c",c2[i]);
		puts("");
	} 
	else {
		for(int i=cnt2;i;i--)printf("%c",c2[i]);
		for(int i=strlen(c)-1;i>=0;i--)printf("%c",c[i]);
		for(int i=1;i<=cnt1;i++)printf("%c",c1[i]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 768
//============================================================================
// Name        : AOJ1180.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

void sortASC(int a[], int b[], int n) {
	int i, j, min_i, tmp;
	for (i = 0; i < n; i++)
		b[i] = a[i];
	for (i = 0; i < n - 1; i++) {
		min_i = i;
		for (j = i + 1; j < n; j++) {
			if (b[min_i] > b[j])
				min_i = j;
		}
		if (min_i != i) {
			tmp = b[i];
			b[i] = b[min_i];
			b[min_i] = tmp;
		}
	}
	return;
}

void sortDSC(int a[], int b[], int n) {
	int i, j, max_i, tmp;
	for (i = 0; i < n; i++)
		b[i] = a[i];
	for (i = 0; i < n - 1; i++) {
		max_i = i;
		for (j = i + 1; j < n; j++) {
			if (b[max_i] < b[j])
				max_i = j;
		}
		if (max_i != i) {
			tmp = b[i];
			b[i] = b[max_i];
			b[max_i] = tmp;
		}
	}
	return;
}

void sub(int a[], int b[], int c[], int n) {
	int i;
	for (i = 0; i < n; i++)
		c[i] = a[i];
	for (i = n - 1; i > 0; i--) {
		c[i] = c[i] - b[i];
		if (c[i] < 0) {
			c[i - 1]--;
			c[i] += 10;
		}
	}
	c[0] -= b[0];
	return;
}

int main() {
	int flag, inp, i, j, k, L, count;
	//int *a[21], *aA, *aD;
	int a[21][10], aA[10], aD[10];
	scanf("%d %d", &inp, &L);
	while (inp != 0 || L != 0) {
		/*
		for (i = 0; i <= 20; i++)
			a[i] = (int *) malloc(sizeof(int) * L);
		aA = (int *) malloc(sizeof(int) * L);
		aD = (int *) malloc(sizeof(int) * L);
		*/
		for (i = L - 1; i >= 0; i--) {
			a[0][i] = inp % 10; /* 入力された値を配列形式にして代入 */
			inp /= 10;
		}
		sortDSC(a[0], aA, L);
		sortASC(a[0], aD, L);
		flag = 0;
		for (i = 1; flag == 0 && i <= 20; i++) {
			sub(aA, aD, a[i], L);
			sortDSC(a[i], aA, L);
			sortASC(a[i], aD, L);
			for (j = 0; j < i && flag == 0; j++) {
				count = 0;
				for (k = 0; k < L; k++) {
					if (a[i][k] == a[j][k])
						count++; /*一致した配列の数を数える*/
				}
				if (count == L)
					flag = 1;
			}
		}
		i--;
		j--;
		printf("%d ", j);
		count = 0;
		for (k = 0; k < L; k++) {
			if (a[i][k] == 0)/* ０の数を数える */
				count++;
		}
		if (count == L)
			printf("0");
		else {
			for (k = 0; k < L; k++) {
				if (a[i][k] != 0) {
					while (k < L) {
						printf("%d", a[i][k]);
						k++;
					}
				}
			}

		}
		printf(" %d\n", i - j);
		scanf("%d %d", &inp, &L);
	}
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int A, B; scanf("%d%d", &A, &B);
	
	std::vector<std::string> s(100);
	for(int i = 0; i < 50; i++) s[i] = std::string(100, '.');
	for(int i = 50; i < 100; i++) s[i] = std::string(100, '#');
	A--; B--;

	for(int i = 1; i < 50; i += 2) {
		if(!B) break;
		for(int j = 1; j < 100; j += 2) {
			if(!B) break; B--;
			s[i][j] = '#';
		}
	}
	for(int i = 51; i < 100; i += 2) {
		if(!A) break;
		for(int j = 1; j < 100; j += 2) {
			if(!A) break; A--;
			s[i][j] = '.';
		}
	}

	printf("100 100\n");
	for(auto v: s) printf("%s\n", v.c_str());
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x, y, z, k; cin >> x >> y >> z >> k;
    vll a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(all(a)), sort(all(b)), sort(all(c));

    priority_queue<ll> que;
    rep(i, x) rep(j, y) {
        que.push(a[i] + b[j]);
    }
    /*
    while (que.size()) {
        cout << que.top() << endl; que.pop();
    }
    */

    priority_queue<ll> que2;
    rep(i, min(x * y, k)) {
        ll val = que.top(); que.pop();
        rep(j, z) {
            que2.push(val + c[j]);
        }
    }

    rep(i, k) {
        cout << que2.top() << endl; que2.pop();
    }
    return 0;
}

Measured memory_bytes: 43240
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b;
  cin >> a >> b;
  cout << max(a+b, max(a-b, a*b)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

int a, b;

int main(){

    cin >> a >> b;

    cout << (a*b) - a - b + 1;



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
long long moduloMultiplication(long long a,
                               long long b,
                               long long mod)
{
    long long res = 0; // Initialize result

    // Update a if it is more than
    // or equal to mod
    a %= mod;

    while (b)
    {
        // If b is odd, add a with result
        if (b & 1)
            res = (res + a) % mod;

        // Here we assume that doing 2*a
        // doesn't cause overflow
        a = (2 * a) % mod;

        b >>= 1; // b = b / 2
    }

    return res;
}
int main()
{
    fastio();
    int n;
    cin >> n;
    vector<ll> dp(n + 1, 2);
    dp[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int j = i * 2; j <= n; j += i)
        {
            dp[j]++;
        }
    }
    ll ans = 0;
    for (int i = 1; i < n; i++)
    {
        ans += dp[i];
    }
    cout << ans;
}


Measured memory_bytes: 11052
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
    string s;
    cin >> s;
    if(s.at(0)==s.at(2))cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;
int n,a[200005];
long long h;
int main()
{
	cin>>n>>a[0];
	for(int i=1;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<a[i-1]){h+=a[i-1]-a[i];a[i]=a[i-1];}
	}
	cout<<h<<endl;
	return 0;
}

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

int main(void)
{
    string S;
    //char S[5];                                                                
    cin >> S;
    //scanf("%s",S);                                                            
    if((S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3])||
       (S[0]==S[2]&&S[1]==S[3]&&S[2]!=S[3])||
       (S[0]==S[3]&&S[1]!=S[3]&&S[2]==S[1]))cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



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

int main() {
    int N;
    cin >> N;
    int min = 10000000;
    for(int i = 0; i < N; i++){
        int A;
        int min0 = 0;
        cin >> A;
        while(A % 2 == 0){
            A /= 2;
            min0++;
        }
        if(min0 < min){
            min = min0;
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define BIG 2000000007
 
#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;
 
typedef struct {
	int a;
	int b;
} hw;
 
#define N_MAX 100000
#define M_MAX 100000
 
ull n, m, k;
ull h, w;
ull va, vb, vc, vd;
// ull a[N_MAX];
// sll a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
char s[N_MAX + 1];
// char t[N_MAX + 1];
// hw arr[N_MAX];
 
void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}
 
int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}
 
int min(ull x, ull y){
	return (x < y) ? x : y;
}
 
ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}
 
ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}

int comp(const void *left, const void *right){
	if ((*(int*)left) < (*(int*)right)) {
		return -1;
	} else if ((*(int*)left) > (*(int*)right)) {
		return +1;
	} else {
		return 0;
	}
}

// int nextroute(int arr[]){
// 	int i = n - 1;
// 	int j, x;
// 	while (arr[i - 1] > arr[i]) i--;

// 	x = n;
// 	for (j = i; j < n; j++) {
// 		if (arr[j] < arr[i - 1]) continue;
// 		if (x == n || arr[x] > arr[j]) x = j;
// 	}
// 	arr[i - 1] ^= arr[x];
// 	arr[x] ^= arr[i - 1];
// 	arr[i - 1] ^= arr[x];

// 	qsort(&arr[i], n - i, sizeof(int), comp);
// 	return 0;
// }

ull solve(){
	int i, j;
	ull result;
	const size_t len = strlen(s);

	result = len * (len - 1);
	for (i = 0; i < len - 1; i++) {
		if (s[i] == 'U') {
			result += i;
		} else {
			result += (len - i - 1);
		}
	}

	printf("%llu\n", result);

	return 0;
}
 
int main(void){
	int i, j;
 
	scanf("%d%d", &i, &j);

	// solve();

	if (i == j) {
		puts("Draw");
	} else if (i == 1) {
		puts("Alice");
	} else if (j == 1) {
		puts("Bob");
	} else if (i > j) {
		puts("Alice");
	} else {
		puts("Bob");
	}
 
	return 0;
}


Measured memory_bytes: 128
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N,K;

int main(){
	cin>>N>>K;
	if(K>((N-1)*(N-2))/2){
		cout<<-1<<endl;
	}else{
		cout<<(((N)*(N-1))/2)-K<<endl;
		rep(i,N-1){
			cout<<1<<" "<<i+2<<endl;
		}
		int cnt=(((N)*(N-1))/2)-K-N+1;
		for(int i=2;i<=N;i++){
			for(int j=i+1;j<=N;j++){
				if(cnt>0){
					cout<<i<<" "<<j<<endl;
					cnt--;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int ans=1;
    for(int i=0;i<N;i++)ans*=3;
    int po=1;
    for(int i=0;i<N;i++){
        int kari;
        scanf("%d",&kari);
        if(kari%2==0)po*=2;
        }
    printf("%d",ans-po);
    return 0;
}


Measured memory_bytes: 128
N,M,C = map(int, input().split(" "))
B = list(map(int, input().split(" ")))
A = []
ret = 0
for i in range(0, N):
    A=list(map(int, input().split(" ")))
    ans = 0
    for j in range(0, M):
        ans += B[j]*A[j]
    if ans + C > 0:
        ret += 1

print(ret)

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> color(9, 0);
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    if (a < 400)
    {
      color.at(0) = 1;
    }
    else if (a < 800)
    {
      color.at(1) = 1;
    }
    else if (a < 1200)
    {
      color.at(2) = 1;
    }
    else if (a < 1600)
    {
      color.at(3) = 1;
    }
    else if (a < 2000)
    {
      color.at(4) = 1;
    }
    else if (a < 2400)
    {
      color.at(5) = 1;
    }
    else if (a < 2800)
    {
      color.at(6) = 1;
    }
    else if (a < 3200)
    {
      color.at(7) = 1;
    }
    else if (a >= 3200)
    {
      color.at(8)++;
    }
  }
  int min, max;
  min = max = 0;

  for (int i = 0; i < 8; i++)
  {
    if (color.at(i))
    {
      min++;
      max++;
    }
  }
  if (min == 0 && max == 0)
  {
    min = 1;
  }

  // if (max + color.at(8) > 8)
  // {
  //   max = 8;
  // }
  // else
  // {
  max += color.at(8);
  // }
  cout << min << " " << max << endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k, p[2000][2000], s[2001][2001];

int main() {
	cin >> n >> k;
	int l = k * 2;
	inc(i, n) {
		int x, y; string c;
		cin >> x >> y >> c;
		if(c == "B") { x += k; }
		int z = (x / k + y / k) % 2 * k;
		x %= k;
		y %= k;
		p[x + z][y]++;
	}
	
	inc1(i, l) {
	inc1(j, l) {
		s[i][j] = p[i - 1][j - 1];
	}
	}
	inc1(i, l) {
	inc1(j, l) {
		s[i][j] += s[i - 1][j];
	}
	}
	inc1(i, l) {
	inc1(j, l) {
		s[i][j] += s[i][j - 1];
	}
	}
	
	#define R(xl, xh, yl, yh) (s[xh][yh] - s[xh][yl] - s[xl][yh] + s[xl][yl])
	int ans = 0;
	incII(xx, 0, l) {
	incII(yy, 0, k) {
		int e = max(0, xx - k);
		int f = min(l, xx + k);
		setmax(ans, R(0, e, yy, k) + R(e, xx, 0, yy) + R(xx, f, yy, k) + R(f, l, 0, yy));
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 31488
#include <stdio.h>

int main(void) {
	unsigned int A, B, C;
	unsigned int gedoku, kueru, oisii, oisikunai;
	if (scanf("%u%u%u", &A, &B, &C) != 3) return 1;
	gedoku = A + B;
	if (C <= gedoku + 1) {
		/* 全部食える */
		printf("%u\n", B + C);
	} else {
		/* 毒入りが残る */
		kueru = gedoku * 2 + 1;
		oisii = B * 2;
		oisikunai = oisii < kueru ? (kueru - oisii) / 2 : 0;
		printf("%u\n", kueru - oisikunai);
	}
	return 0;
}


Measured memory_bytes: 1692
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"4 3 6"# => "safe",
// r#"6 5 1"# => "delicious",
// r#"3 7 12"# => "dangerous",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: chars,
    }
    let mut m = n.clone();
    m.reverse();

    if n == m { "Yes" } else { "No" }.to_string()
}

Measured memory_bytes: 4352
#At coder 2020/2/16 A

# スペース区切りの数の入力
A,B,C= input().split()
#A, B = map(int,input().split())
#U=input()

if A==B:
    if A==C:
        U='No'
    else:
        U='Yes'
else:
    if A==C:
        U='Yes'
    else:        
        if B==C:
            U='Yes'
        else:
            U='No'

print(U)

Measured memory_bytes: 2940
from collections import Counter, deque, OrderedDict
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N, Q = map(int, input().split())
    M = N-1  # 頂点数，辺数
    ans = [0]*N

    # グラフ入力受取 (ここでは無向グラフを想定)
    G = [[] for _ in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    seen = [False]*N

    def dfs(G, v):
        seen[v] = True
        stack = deque([v])
        while stack:
            v = stack.pop()
            for next_v in G[v]:
                if seen[next_v]:
                    continue
                seen[next_v] = True
                ans[next_v] += ans[v]
                stack.append(next_v)

    # 頂点 0 をスタートとした探索
    dfs(G, 0)
    print(*ans)


resolve()

Measured memory_bytes: 107152
#pragma GCC optimize("2,Ofast,inline")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<LL, LL>
using namespace std;
const int N = 2e5 + 10;

template <typename T> void read(T &x) {
	int f = 0;
	char c = getchar();
	while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
	for (x = 0; c >= '0' && c <= '9'; c = getchar())
		x = (x << 3) + (x << 1) + (c ^ '0');
	if (f) x = -x;
}

int n;
int ch[N][2], val[N][2];
LL L, R, mid, ans;
vector<pii> vec[N];

vector<pii> merge(vector<pii> a, vector<pii> b, int pre) {
	vector<pii> ans;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	for (int i = 0, p = 0; i < a.size(); ++i) {
		while (p < b.size() && a[i].se + b[p].fi > mid) ++p;
//		cout << i << ' ' << p << endl;
		if (p < b.size() && a[i].se + b[p].fi <= mid) {
			ans.push_back(mp(a[i].fi + pre, b[p].se + pre));
			ans.push_back(mp(b[p].se + pre, a[i].fi + pre));
		}
	}
	swap(a, b);
	for (int i = 0, p = 0; i < a.size(); ++i) {
		while (p < b.size() && a[i].se + b[p].fi > mid) ++p;
		if (p < b.size() && a[i].se + b[p].fi <= mid) {
			ans.push_back(mp(a[i].fi + pre, b[p].se + pre));
			ans.push_back(mp(b[p].se + pre, a[i].fi + pre));
		}
	}
	sort(ans.begin(), ans.end());
	for (int i = 1; i < ans.size(); ++i) {
		if (ans[i].se >= ans[i - 1].se) ans[i] = ans[i - 1];
	}
	ans.erase(unique(ans.begin(), ans.end()), ans.end());
	return ans;
}

void dfs(int x, int pre) {
	vec[x].clear();
	if (!ch[x][0]) {
		vec[x].pb(mp(pre, pre));
		// cout << x << endl;
		// cout << pre << ' ' << pre << endl;
		return;
	}
	dfs(ch[x][0], val[x][0]);
	dfs(ch[x][1], val[x][1]);
	if (vec[ch[x][0]].size() < vec[ch[x][1]].size())
		vec[x] = merge(vec[ch[x][0]], vec[ch[x][1]], pre);
	else vec[x] = merge(vec[ch[x][1]], vec[ch[x][0]], pre);
	// cout << x << endl;
	// for (int i = 0; i < vec[x].size(); ++i)
	//  	cout << vec[x][i].fi << ' ' << vec[x][i].se << endl;
}

int check() {
	dfs(1, 0);
	return (vec[1].size() > 0);
}

int main() {
	read(n);
	for (int i = 2; i <= n; ++i) {
		int f, v;
		read(f); read(v);
		if (!ch[f][0]) {
			ch[f][0] = i;
			val[f][0] = v;
		}
		else {
			ch[f][1] = i;
			val[f][1] = v;
		}
	}
	// mid = 5;
	// vector<pii> a, b, c;
	// a.push_back(mp(0, 4));
	// a.push_back(mp(4, 0));
	// b.push_back(mp(4, 11));
	// b.push_back(mp(11, 4));
	// c = merge(a, b, 0);
	// cout << c.size() << endl;
	// return 0;
	// mid = 5;
	// check();
	// return 0;
	L = 0, R = 1e15, ans = 1e15;
	while (L <= R) {
		mid = (L + R) >> 1;
		if (check()) {
			ans = mid;
			R = mid - 1;
		}
		else L = mid + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 50060
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  int N;
	      	  cin >> N;

	      	  map<int,int> mp;
	      	  REP(i,N){
	      		  int a;
	      		  cin >> a;
	      		  if(mp[a]==1) mp[a]=0;
	      		  else mp[a]++;
	      	  }

	      	  int ans=0;
	      	  foreach(mp,itr){
	      		  if((*itr).second==1) ans++;
	      	  }

	      	  cout << ans << endl;


	          return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    ll n;
    in(n);
    for(int i=sqrt(n);i>=2;i--){
        if(n%i==0){
            out(max(to_string(i).length(),to_string(n/i).length()));
            return 0;
        }
    }
    out(to_string(n).length());
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<n; i++){};
int main() {
int P,Q,R;
cin>>P>>Q>>R;
int A=P+Q;
int B=P+R;
int C=R+Q;
int g=min(A,B);
cout<<min(g,C)<<endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    if(k % 2 == 0) {
        for(int a = k / 2; a <= n; a += k / 2) {
            int bc_mod = k - a % k;
            if(bc_mod == k) bc_mod = 0;
            if(n < bc_mod) continue;
            ll x = (n - bc_mod) / k;
            if(bc_mod == 0) ans += x * x;
            else ans += (x + 1) * (x + 1);            
        }
    } else {
        for(int a = k; a <= n; a += k) {
            int bc_mod = k - a % k;
            if(bc_mod == k) bc_mod = 0;
            if(n < bc_mod) continue;
            ll x = (n - bc_mod) / k;
            if(bc_mod == 0) ans += x * x;
            else ans += (x + 1) * (x + 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n= sc.nextInt();
		int[] p = new int[n];
		
		for (int i=0;i<n;i++) {
			p[i]=sc.nextInt();
		}

		int ans = 0;
		
		for (int i=1;i<n-1;i++) {
			if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
def main():
    n = int(input())
    a = list(map(int,input().split()))

    """
    gcd = a[0]
    lcm =0
    for i in range(1,len(a)):
        gcd = math.gcd(gcd,a[i])
        lcm = reduce(mul,a[:i+1])//gcd
        print(gcd)
        #print(lcm)
        #print(a[i])
    """
    ans= 0
    for i in a:
        ans += (i-1)

    print(ans)


if __name__ == "__main__":
        main()


Measured memory_bytes: 3316
/*
t.me/ivanesipovvpered
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;

const double EPS = 1e-5;
const int mod = 1e9 + 7;
const ll INFLL = 1e18;
const int INF = 1e9;
const int maxn = 2e3 + 3;

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

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

bool is_prime(ll a){
    if (a == 2 || a == 3 || a == 5 || a == 7) return true;
    if (a % 2 == 0 || a%3 == 0 || a%5 == 0 || a%7 == 0)
        return false;
    for (ll i = 11; i * i <= a; i += 2){
        if (a % i == 0)
            return false;
    }
    return true;
}

ll binpow(ll a, int n){
    if (a == 0)
        return 1;
    if (a % 2 == 0){
        ll q = binpow(a, n / 2);
        return (q * q)  ;
    }else return (a * binpow(a, n - 1) ) ;
}


istream& operator>>(istream &in, pair<int, int> &p) {
    in >> p.fi >> p.se;
    return in;
}

ostream& operator<<(ostream &out, pair<int, int> &p) {
    out << p.fi << " " << p.se << endl;
    return out;
}



















main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            if (a[i] > a[j]) ans++;
        }
    }
    ans = (ans*k)%mod;
    int r = (k * (k - 1) / 2) % mod;
    for (int i = 0; i < n; i++){
            int fle = 0;
        for (int j = 0; j < n; j++){
            if (a[j] > a[i]) fle++;
        }
        int qe = (fle * r)%mod;
        ans = (ans + qe)%mod;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll,ll> pll;
const int INF = 1000000000;
const int maxN = 100010;
const int MOD = 1000000007;


int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(abs(n-m) >1)
	{
		printf("0\n");
		return 0;
	}
	ll p = 1;
	for(int i=1;i<=n;i++)
	{
		p = (p*i)%(ll)MOD;
	}
	ll q = 1;
	for(int i=1;i<=m;i++)
	{
		q = (q*i)%(ll)MOD;	
	}
	ll ans = 0;
	if(abs (m-n)==1)
		ans = (p*q)%(ll)MOD;
	if(m==n)
		ans = (2*(p*q)%(ll)MOD)%(ll)MOD;
	printf("%lld\n",ans);
	return 0;
} 


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

int main() {
	int a, b;
	char op;
	for(;;){
		cin >> a >> op >> b;
		switch(op){
		case '+':
			cout << a + b;
			break;
		case '-':
			cout << a - b;
			break;
		case '*':
			cout << a * b;
			break;
		case '/':
			cout << a / b;
			break;
		case '?':
			return 0;
		}
		cout << endl;
	}
}

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

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

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

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

bool dp1[MAX_N][MAX_N] = {};    // 0 から見て、 i を使う前の時点で j が作れているなら true
bool dp2[MAX_N][MAX_N] = {};    // N-1 から見て、 i を使う前の時点で j が作れているなら true
int N, K;
int A[MAX_N];

void dfs1(int i, int j) {
    if(i >= N) { return; }
    if(dp1[i][j]) { return; }
    dfs1(i+1, j);
    if(j + A[i] < K) {
        dfs1(i+1, j + A[i]);
    }
    dp1[i][j] = true;
}
void dfs2(int i, int j) {
    if(i < 0) { return; }
    if(dp2[i][j]) { return; }
    dfs2(i-1, j);
    if(j + A[i] < K) {
        dfs2(i-1, j + A[i]);
    }
    dp2[i][j] = true;
}

signed main()
{
    cin >> N >> K;
    REP(i, N) { cin >> A[i]; }
    ZERO(dp1); ZERO(dp2);
    dfs1(0, 0);
    dfs2(N-1, 0);
    ll ans = N;
    REP(i, N) {
        for(int j = K - A[i]; j < K; ++j) {
            if(j <= 0) {
                ans--;
                break;
            }
            bool isFind = false;
            for(int x = 0; x <= j; ++x) {
                if(dp1[i][x] && dp2[i][j - x]) {
                    ans--;
                    isFind = true;
                    break;
                }
            }
            if(isFind) { break; }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 49408
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll r;
	cin>>r;
	double pi;
	pi=atan(1.0)*(4.0);
	double ans;
	ans=(2.0)*(pi)*(r);
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
signed main() {
	ll ans = 0;
	string s;
	cin >> s;
	ll n = s.size();
	if (n == 1)cout << 0 << endl;
	else {
		for (int i = 0; i < n - 1; i++) {
			if (s[i] == s[i + 1]) {
				ans++;
				if (s[i] == '0')s[i + 1] = '1';
				else s[i + 1] = '0';
			}
		}
		cout << ans << endl;
	}
	ggr
}


Measured memory_bytes: 512
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main() {
int N;
cin>>N;
cout<<N*(N+1)/2<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[409],sum[409][409],siz[409][409],s[409];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s[i+1]=s[i]+a[i];
    }
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++) sum[i][j]=99999999999999999;
    }
    for(int i=0;i<n;i++)
    {
        sum[i][i]=0;
    }
    for (int ass=1;ass<=n;ass++)
    {
        for(int i=00;i+ass<n;i++)
            {
                for(int j=i;j<=i+ass;j++)
                {
                    sum[i][i+ass]=min(s[i+ass+1]-s[i-1+1]+sum[i][j]+sum[j+1][i+ass],sum[i][i+ass]);
                }
            }
    }
    cout<<sum[0][n-1];
}


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

int classify(double d){
    if(d >= 1.1)    return 0;
    if(d >= 0.6)    return 1;
    if(d >= 0.2)    return 2;
    return 3;
}

int main(){
    int ans[4][2] = {};

    double l, r;
    while(cin >> l >> r){
        ans[classify(l)][0]++;
        ans[classify(r)][1]++;
    }

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

    return 0;
}


Measured memory_bytes: 3192
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		string s = Console.ReadLine();
		
		int ans = Int32.MaxValue;
		for(int head = 0; head + 2 < s.Length; head++)
			ans = Math.Min(ans, Math.Abs(753 - Int32.Parse(s.Substring(head,3))));
		
		Console.WriteLine(ans);
	}	
}





Measured memory_bytes: 13140