akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1LL << 60;
int n;
const int MAX_N = 400;
long long int a[MAX_N + 1];
long long int dp[MAX_N + 1][MAX_N + 1];

long long int dfs(int l, int r)
{
    if (dp[l][r])
    {
        return dp[l][r];
    }

    long long int cost = INF;
    long long int s = 0;
    for (int i = l; i <= r; i++)
    {
        s += a[i];
    }
    for (int i = l; i < r; i++)
    {
        cost = min(cost, dfs(l, i) + dfs(i + 1, r));
    }
    dp[l][r] = cost + s;
    return dp[l][r];
}

int main()
{
    cin >> n;
    long long int s = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        dp[i][i] = a[i];
        s += a[i];
    }
    cout << dfs(1, n) - s << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    string s;
    cin >> s;
    map<string,ll> m;
    m["SUN"] = 7;
    m["MON"] = 6;
    m["TUE"] = 5;
    m["WED"] = 4;
    m["THU"] = 3;
    m["FRI"] = 2;
    m["SAT"] = 1;
    cout << m[s] << endl;
}

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

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

  long long A, B;
  cin >> A >> B;
  vector<long long> twoEx(41);
  twoEx[0] = 2;
  for(int i = 1; i < 41; i++){
    twoEx[i] = twoEx[i-1] * 2;
  }
  bitset<40> ans;
  bitset<40> a(A);
  bitset<40> b(B);
  if((B - A + 1) % 2 == 0){
    ans.set(0, (B-A+1)%4);
  } else{
    if(A % 2 == 0){
      ans.set(0, (B-A+1)/2%2);
    } else{
      ans.set(0, (B-A+2)/2%2);
    }
  }
  a >>= 1;
  b >>= 1;
  for(int i = 1; i < 40; i++){
    long long x = 0, y = 0;
    if(a[0]){
      x = ((A / twoEx[i] + 1) * twoEx[i]) - A;
    }
    if(b[0]){
      y = B % twoEx[i] + 1;
    }
    ans.set(i, (x + y) % 2);
    a >>= 1;
    b >>= 1;
  }
  cout << ans.to_ullong() <<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
	ll a[7];
	REP(i,7) cin >> a[i];

	ll ans = a[1];
	ll p0 = 0, p1 = 0;

	p0 += 2 * (a[0] / 2);
	p0 += 2 * (a[3] / 2);
	p0 += 2 * (a[4] / 2);

	if (a[0] > 0 && a[3] > 0 && a[4] > 0) {
		p1 += 3;
		a[0]--;
		a[3]--;
		a[4]--;
		p1 += 2 * (a[0] / 2);
		p1 += 2 * (a[3] / 2);
		p1 += 2 * (a[4] / 2);
	}

	cout << ans + max(p0, p1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int d = 0;
    for (int i = a; i <=b; i++) {
        if (c%i == 0) {
            d++;
        }
    }
    cout << d <<endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long n,d;
  cin >> n >> d;
  long long a,b;
  int count=0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a*a + b*b <= d*d){
      count++;
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3596
n=int(input())
flag=True
a=0
l=[]
for i in range(n):
    b=a
    l.append(b)
    a=list(input())
    if i>0:
        if a[0]!=b[-1] or a in l:
            flag=False
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import sys, math
input= sys.stdin.readline

N = int(input())
A_lst = list(map(int, input().split()))
lst=[0]*(10**6+1)

# 割れる最大の素数を出す
for i in range(2, 10**6+1):
  if not lst[i]:
    for j in range(i, 10**6+1, i):
      lst[j] = i
      
# not coprimeか判定する
ans = 'not coprime'
GCD = A_lst[0]
for i in range(N):
  GCD = math.gcd(GCD, A_lst[i])
  
if GCD != 1:
  print(ans)
else:
  ans = 'setwise coprime'
  post = 1
  visited = [0]*(10**6+1)
  for i in range(N):
    a = A_lst[i]
    while a > 1:
      dv = lst[a]
      if visited[dv]:
        post = 0
        break
      while a % dv == 0:
        a //= dv
      visited[dv] = 1
  
  if post:
    ans = 'pairwise coprime'
  print(ans)

Measured memory_bytes: 127780
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

vector<string> grid;
int H, W;

int get(int x, int y) {
  if (x < 0 || x >= H || y < 0 || y >= W) {
    return 0;
  } else {
    return grid[x][y] == '#';
  }
}

void solve() {
  cin >> H >> W;

  grid.resize(H);

  for (auto &s: grid) {
    cin >> s;
  }

  for (int x = 0; x < H; x++) {
    for (int y = 0; y < W; y++) {
      if (grid[x][y] == '#') {
        cout << '#';
        continue;
      }

      int cnt = 0;
      for (int dx : {-1, 0, 1}) {
        for (int dy : {-1, 0, 1}) {
          cnt += get(x+dx, y+dy);
        }
      }
      cout << cnt;
    }
    cout << endl;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define MOD (ll) (1e9+7)
int main()
{
     ll n;
     cin>>n;
     ll ar[n];
     ll su = 0;
     for(int i=0;i<n;i++)
     {
     	cin>>ar[i];
     	su+=ar[i];
     }
     ll avg = su/n;
     ll avg1 = avg+1;
     ll avg2 = avg-1;
     ll ans1 = 0,ans2=0,ans=0;
     for(int i=0;i<n;i++)
     {
     	ll dif = abs(avg-ar[i]);
     	ans+=pow(dif,2);
     }
     for(int i=0;i<n;i++)
     {
     	ll dif1 = abs(avg1-ar[i]);
     	ans1+=pow(dif1,2);
     }
     for(int i=0;i<n;i++)
     {
     	ll dif2 = abs(avg2-ar[i]);
     	ans2+=pow(dif2,2);
     }
     ll fin = min({ans,ans1,ans2});
     cout<<fin<<"\n";
}

Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,a[100000];
	scanf("%d",&n);
	fill(a,a+100000,0);
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		a[x-1]++;
	}
	int cnt = 0;
	for(int i=0;i<100000;i++){
		if(a[i]>1) cnt += a[i] - 1;
	}
	int ans = n - (cnt + 1) / 2 * 2;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for(int i=0;i<N;i++)cin >> S[i];
  sort(S.begin(), S.end());
  for(string s : S)cout << s;
  cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 100;
const int INF = 1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L

int main() {
	ll N, K; cin >> N >> K;
	ll tmp1 = N % K;
	ll tmp2 = tmp1 - K;
	if ( tmp2 < 0 ) {
		tmp2 = tmp2 * (-1);
	}
	ll ans = min(tmp1, tmp2);
	cout << ans << endl;
}

Measured memory_bytes: 3488
#include <iostream>
#include<map>
using namespace std;
string s;
int d,dp[100005][2][105];
int solve(int index, int less,int sum)
{
    if (index == s.size())
        return !(sum%d);
    if (dp[index][less][sum] != -1)
        return dp[index][less][sum];
    int ans = 0;
    for (int i = 0; i <=9 ; i++)
    {
        if(less||s[index]-'0'>i)
        ans=(ans% 1000000007 +solve(index+1 , 1 ,(sum+i)%d)% 1000000007)% 1000000007;
        else if(s[index]-'0'==i)
        {
           ans=(ans%1000000007+solve(index + 1, 0 ,(sum+i)%d)% 1000000007)% 1000000007;
        }
    }
    return dp[index][less][sum]=ans;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
    for (int i = 0; i < 100005; i++)
        for (int j = 0; j < 2; j++)
            for (int k = 0; k < 105; k++)
                dp[i][j][k] = -1;
    cin >> s >>d;
    cout << (solve(0,0,0)-1+1000000007)%1000000007;
    return 0;
}


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

#define NMAX 3005
using namespace std;

long long v[NMAX], dp[NMAX][NMAX];

long long solve(int st, int dr){
    if(st > dr)
        return 0;
    if(st == dr)
        return v[st];
    if(dp[st][dr] != -1)
        return dp[st][dr];
    long long rez = v[st] - solve(st + 1, dr);
    rez = max(rez, v[dr] - solve(st, dr - 1));
    dp[st][dr] = rez;
    return dp[st][dr];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> v[i];

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

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


Measured memory_bytes: 70912
import java.io.*;
import java.util.*;

public class Main {
  private static InputReader in;
  private static PrintWriter out;

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out, true);

    int n = in.nextInt();
    long L = in.nextInt();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) a[i] = in.nextInt();
    boolean ok = false;
    int start = -1;
    for (int i = 0; i+1 < n; i++) {
      if (a[i]+a[i+1] >= L) {
        ok = true;
        start = i;
        break;
      }
    }
    if (!ok) out.println("Impossible");
    else {
      out.println("Possible");
      for (int i = 0; i < start; i++) out.println(i+1);
      for (int i = n-2; i > start; i--) out.println(i+1);
      out.println(start+1);
    }
    
    out.close();
    System.exit(0);
  }

  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();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }
  }


}


Measured memory_bytes: 27232
#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;
const int MOD = (int)1e9 + 7;

int main(){
  double ans = 0;
  int n;
  cin >> n;
  rep(i,n){
    double num;
    string buf;
    cin >> num >> buf;
    if(buf == "JPY") ans += num;
    else ans += num * 380000.0;
  }
  cout<< setprecision(8) << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
    int   A,B,C;
    cin >> A >> B >> C;
    
    if(A<C && C<B){
      cout << "Yes" << endl;
    }
    else if(B<C &&C<A){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }  
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int A, B;
	char str[20];
	bool valid = true;
	
	scanf("%d %d", &A, &B);
	scanf("%s", str);
	
	if(str[A] != '-') {
		valid = false;
	}
	
	for(int i = 0; str[i] != '\0'; i++) {
		if(i != A) {
			if(str[i] < '0' || str[i] > '9') {
				valid = false;
				break;
			}
		}
	}
	
	(valid) ? puts("Yes") : puts("No");
	return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==1)
        cout<<"No\n";
    else
    {
        int x=n/2,i;
        for(i=0;i<x;i++)
        {
            if(s[i]!=s[i+x])
                break;
        }
        if(i==x)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}

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

int main() {
  long long int H,W;
  cin >> H >> W;
  if(H == 1 || W == 1){
  	cout << 1 << endl;
  }
  else{
    cout << (H*W+1)/2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int inf = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  int dp[n][n];
  int dp0[n][n];
  fill(dp[0], dp[n], inf);
  fill(dp0[0], dp0[n], inf);
  for (int i = 0; i < n; i++) {
    dp[i][i] = 0;
    dp0[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dp[a][b] = c;
    dp[b][a] = c;
    dp0[a][b] = c;
    dp0[b][a] = c;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (dp[i][j] < dp0[i][j] && dp0[i][j] != inf) {
        ans++;
        //       cout << i << " " << j << " " << dp[i][j] << " " << dp0[i][j] <<
        //       endl;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {

    int N, a, b, c;
    cin >> N;
    c=N%10;
    b=((N%100)-c)/10;
    a=(N-c-10*b)/100;
if(a==7||b==7||c==7){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}
}

Measured memory_bytes: 3596
// Problem : A - Coffee
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}

	const int N=1e6+10;
	//------------------FIXED------------------
	
	void main()
	{
		char str[10];scanf("%s",str+1);puts(str[3]==str[4] and str[5]==str[6]?"Yes":"No");
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	// freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	//debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

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

int main() {
  ll n; cin>>n;
  if(n%2==1){cout<<0;}
  else{
    ll a,ans=0,i=1;
    while(true){
      ll p=pow(5,i);
      a=n/p; 
      if(a%2==0){a/=2;}
      else{a=(a-1)/2;}
      ans+=a;
      i++;
      if(n<p)break;
    }
    cout<<ans;
    
  }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007

int power(int base, int exp) {
	if(!exp) return 1LL;
	else return base*power(base,exp-1);
}

int32_t main()
{
    fastio

    int num;
    cin>>num;
    num--;
   string s;
   for(char c='a';c<='z';c++) s+=c;
   	string ans;
   int turn=0;
   while(num>=0) {
   	// cout<<num<<
   	// cout<<num%(power(26,exp))<<"\n";
   	int x=num%26;
   	// cout<<x<<"\n";
   
   	// if(!turn)
    ans+=s[x];
   	// num=num-26*(num/26)
   	// else ans+=s[(x-1)%26];
   	num/=26;
   	num--;
   	// cout<<num<<"\n";
   }
   	// ans+=s[(num%26)-1];
   reverse(ans.begin(),ans.end());
   cout<<ans;
    return 0;


}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int a[3][3];

int main(void)
{
    rep(i, 3)rep(j, 3)
    {
        cin >> a[i][j];
    }
    int n; cin >> n;
    rep(i, n)
    {
        int b; cin >> b;
        rep(j, 3)rep(k, 3)
        {
            if(a[j][k] == b) a[j][k] = -1;
        }
    }
    rep(i, 3)
    {
        bool flag = true;
        rep(j, 3)
        { 
            if(a[i][j] != -1) flag = false;
            if(j == 2){
                if(flag){
                    puts("Yes"); 
                    return 0;
                }
            }
        }
    }
    rep(i, 3)
    {
        bool flag = true;
        rep(j, 3)
        { 
            if(a[j][i] != -1) flag = false;
            if(j == 2){
                if(flag){
                    puts("Yes"); 
                    return 0;
                }
            }
        }
    }
    if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1){
        puts("Yes");
        return 0;
    }
    if(a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1){
        puts("Yes");
        return 0;
    } 
    puts("No");
    return 0;
}



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

int main() { 
  int n,h;
  int mx=0;
  int count=0;
  scanf("%d %d",&n,&h);
  for(int i=1;i<n;i++){
    int hh=0;
    scanf("%d",&hh);
  	if(hh<=h){
    	count++;
    }else{
    	mx=max(count,mx);
    	count=0;
    }
    h=hh;
  }
  mx=max(count,mx);
  printf("%d\n",mx);
}


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

//for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//abbreviati
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//constant
const int INF = 1<<30;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet**************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
************************************************/

//adjacency list
vector<int> to[100005];

template<class T>inline bool chmin(T &a,T b){ if(a>b){a=b; return 1;} return 0;}
template<class T>inline bool chmax(T &a,T b){ if(a<b){a=b; return 1;} return 0;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    vector<ll> h(100006);
    rep(i,0,n) cin >> h[i];
    vector<ll> dp(100006,INFL);
    //vector<ll> cost(1000006);
    // rep(i,1,n){
    //     if(i==1) cost[i]=abs(h[i]-h[i-1]);
    //     else if(cost[i-1]+abs(h[i]-h[i-1])>cost[i-2]+abs(h[i]-h[i-2])){
    //         cost[i]=cost[i-2]+abs(h[i]-h[i-2]);
    //     }else{
    //         cost[i]=cost[i-1]+abs(h[i]-h[i-1]);
    //     }
    // }
    dp[0]=0;
    rep(i,1,n){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1){
            chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        }
    }


    cout << dp[n-1] ENDL;



    
    return 0;
}

Measured memory_bytes: 7128
while text = STDIN.gets
  text.chomp!
  while true 
    if text.include?("the") or text.include?("this") or text.include?("that") then
      puts text
      break
    end
    text = text.chars.map { |item| if item.match(/[a-yA-Y]/) then (item.ord+1).chr elsif item == "z" then "a" elsif item == "Z" then "A" else item end }.join("")
  end
end

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll c[30],s[400][30],las[30],t[400];

int main()
{
	int D;
	cin >> D;
	rep(i,26)
	{
		cin >> c[i];
	}
	rep(i,D)
	{
		rep(j,26)
		{
			cin >> s[i][j];
		}
	}
	ll now = 0;
	for (ll i = 0; i < D; ++i)
	{
		ll best = -1 * 1e10;
		ll bestv = 0;
		rep(j,26)
		{
			ll tmp = 0;
			tmp += s[i][j];
			rep(k,26)
			{
				if (k != j)
				{
					tmp -= c[k] * (i+1 - las[k]);
				}
			}
			if (tmp > best)
			{
				best = tmp;
				bestv = j;
			}
		}
		//cout << bestv+1 << endl;
		now += best;
		t[i] = bestv;
		las[bestv] = i+1;
	}

	rep(i,200000)
	{
		ll del = rand() % (D-1);
		ll r = rand() % (D-del);
		swap(t[r],t[r+del]);
		ll tmp2 = 0;
		rep(j,30)
		{
			las[j] = 0;
		}
		rep(j,D)
		{
			tmp2 += s[j][t[j]];
			las[t[j]] = j+1;
			rep(k,26)
			{
				tmp2 -= c[k] * (j+1 - las[k]);
			}
		}
		if (tmp2 > now)
		{
			now = tmp2;
		}
		else swap(t[r],t[r+del]);
	}
	rep(i,D)
	{
		cout << t[i]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(b/a, c) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i+1 < n; i++ {
		sort.Sort(sort.Float64Slice(a))
		na := make([]float64, 0)
		for j := 2; j < len(a); j++ {
			na = append(na, a[j])
		}
		na = append(na, (a[0]+a[1])/2)
		a = na
	}
	fmt.Println(a[0])
}


Measured memory_bytes: 512
n=int(input()) #รับจำนวน node ทั้งหมด
m=[[0]*n for i in range(n)] #สร้าง array matrix 0 ขนาดเท่าจำนวน node

for i in range(n):
    tmp=list(map(int,input().split())) #วน loop ตามจำนวน node รับค่าข้อมูลแต่ละ node
    #ตน 0 คือ node , ตน 1 คือ จำนวน vertex ตน 2 เป็นต้นไปคือ vertex
    for j in tmp[2:]:
        m[i][j-1]=1
    #แสดงผล node และ vertex ที่มีความสัมพันธ์กัน ใส่ 0 เมื่อไม่เกิดความสัมพันธ์ ใส่ 1 เมื่อเกิด
    #Show เป็น Matrix    
for i in range(n):
    print(" ".join(list(map(str,m[i]))))



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

int main(){
    int a,b,c,k;
    int m = 0;
    cin >> a >> b >> c >> k;
    if(k>0){
       while(k > 0 && a > 0){
           k--; a--; m++;
       }
   }
   if(k>0){
       while(k > 0 && b > 0){
           k--; b--; 
       }
   }
   if(k>0){
       while(k > 0 && c > 0){
           k--; c--; m--;
       }
   }
    cout << m <<endl;
    
}

Measured memory_bytes: 3636
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((ll)2e5+5)
#define MOD ((ll)1e9 + 7)
#define INF ((ll)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<ll,ll>
#define mid ((l+r)/2)

ll n,k;
map <ll,ll> mp;

bool check(ll t)
{
	double total = 0;
	for (auto x : mp)
	{
		ll cost = 0;
		if(x.first > t)
			cost = (x.first / t) - (x.first%t==0);
		total += cost * x.second;
	}

	return total <= k;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for (ll i = 0; i < n; ++i)
	{
		ll a;
		cin >> a;
		mp[a]++;
	}

	ll l=1, r=1e18;

	while(l < r)
	{
		if(check(mid))
			r = mid;
		else
			l = mid+1;
	}

	cout << fixed << (ll)(ceil(l)) << endl;
}

/* stuff you should look for
	* ll overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

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

 int main() {
   int N, ans = 0;
   cin >> N;

   vector<int> L(N);

   rep(i, 0, N) cin >> L.at(i);

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

   rep(i, 0, N - 2) {
     rep(j, i + 1, N - 1) {
       int lb = distance(L.begin(), lower_bound(L.begin(), L.end(), L.at(i) + L.at(j))) - 1;
       ans += lb - j;
     }
   }

   cout << ans << endl;
 }


Measured memory_bytes: 256
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
  int i,j,minj,barray[37],sarray[37],n,box,flg;
  char bcarray[37][3],scarray[37][3],cbox;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",bcarray[i]);
    scarray[i][0] = bcarray[i][0];
    scarray[i][1] = bcarray[i][1];
    
    barray[i] = atoi(&bcarray[i][1]);
    sarray[i] = atoi(&scarray[i][1]);
  }
  
 

/*bubble sort*/

  
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(barray[j] < barray[j-1]){
	box = barray[j];
	barray[j] = barray[j-1];
	barray[j-1] = box;
	cbox = bcarray[j][0];
	bcarray[j][0] = bcarray[j-1][0];
	bcarray[j-1][0] = cbox;
	cbox = bcarray[j][1];
	bcarray[j][1] = bcarray[j-1][1];
	bcarray[j-1][1] = cbox;
      }
    }
  }
  for(i=0;i<n;i++){ 
   for(j=0;j<2;j++){ 
     printf("%c",bcarray[i][j]);
   }
    if( i == n-1) printf("\n");
    else printf(" ");
  }
  printf("Stable\n");
  
  /* selection sort*/
  
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++) if(sarray[j] < sarray[minj]) minj =j;
    if(i != minj){
      box = sarray[i];
      sarray[i] = sarray[minj];
      sarray[minj] = box;
      cbox = scarray[i][0];
      scarray[i][0] = scarray[minj][0];
      scarray[minj][0] = cbox; 
      cbox = scarray[i][1];
      scarray[i][1] = scarray[minj][1];
      scarray[minj][1] = cbox; 
    }
  }
  flg=0;
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){ 
     printf("%c",scarray[i][j]);
    }
    if( i == n-1) printf("\n");
    else printf(" ");
    if(scarray[i][0] != bcarray[i][0] || scarray[i][1] != bcarray[i][1]) flg=1; 
  }
  
  if(flg == 0)  printf("Stable\n");
  else  printf("Not stable\n"); 
  return 0;
}

Measured memory_bytes: 584
#include <stdio.h>

int main()
{
	int u, v, w, N, dist[301][301] = {}, flag[301][301] = {};
	scanf("%d", &N);
	for (u = 1; u <= N; u++) {
		for (w = 1; w <= N; w++) scanf("%d", &(dist[u][w]));
	}
	for (v = 1; v <= N; v++) {
		for (u = 1; u < N; u++) {
			for (w = u + 1; w <= N; w++) {
				if (dist[u][v] + dist[v][w] == dist[u][w]) flag[u][w]++;
				else if (dist[u][v] + dist[v][w] < dist[u][w]) break;
			}
			if (w <= N) break;
		}
		if (u < N) break;
	}
	if (v <= N) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	long long ans = 0;
	for (u = 1; u < N; u++) {
		for (w = u + 1; w <= N; w++) if (flag[u][w] == 2) ans += dist[u][w];
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 200005, MOD = 1e9+7, H = 5e8+4;
int n, p, len[MX], id[MX];
ll a;
vector<int> G[MX];
struct P{ll z,o;};
deque<P> qu[MX];
void merge(P &a, P&b){a.o = (a.o*b.z + a.z*b.o) % MOD; a.z = a.z*b.z % MOD;}
void rev(P &a){a.z = (MOD - a.o + 1) % MOD;}
void dfs(int u){
	int f = id[u] = u, s = 0;
	for(int &nx: G[u]){
		dfs(nx);
		if(len[f] < len[nx]){
			s = len[f];
			swap(f,nx);
		}else if(s < len[nx]) s = len[nx];
		rep(i,len[nx]) merge(qu[id[f]][i], qu[id[nx]][i]);
	}
	rep(i,s) rev(qu[id[f]][i]);
	qu[id[f]].push_front({H,H});
	id[u] = id[f];
	len[u] = len[f] + 1;
}
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &p);
		G[p].push_back(i+1);
	}
	dfs(0);
	for(P t: qu[id[0]]) a += t.o;
	a %= MOD;
	for(ll k = n+1, b = 2; k; k /= 2, (b*=b)%=MOD) if(k&1) (a*=b)%=MOD;
	printf("%lld\n", a);
}

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

int main(){
    ll n;
    cin>>n;
    ll arr[n]; 
    for(ll i=0; i<n; i++)
        cin>>arr[i];
    sort(arr, arr+n);
    if(arr[0]==0){
        cout<<"0"<<endl;
    }
    else{
        ll prod = 1;
        bool flag = true;
        for(ll i=0; i<n; i++){
            if((prod*arr[i] <= (ll)pow(10, 18)) && (prod*arr[i] >= prod)){
                prod*=arr[i];
            }
            else{
                flag = false;
            }
        }
        if(flag){
            cout<<prod<<endl;
        }
        else{
            cout<<"-1"<<endl;
        }
    }
  	return 0;
}

Measured memory_bytes: 4332
//半数列挙で答えが8以下かを判定する.
//順列は, 16進数で表現する.
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

int n;
int a[10], decA, basePermDec;
vector<int> perms[2][5];

void dfs(int type, int depth, int maxDepth, int nowP) {
	perms[type][depth].push_back(nowP);
	if (depth == maxDepth) return;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int nextP = nowP & ((1LL << (4 * (j + 1))) - 1);
			nextP = (nextP >> (4 * i)) << (4 * i);
			nextP = nowP - nextP;
			for (int k = 0; k <= j - i; k++) {
				int idl = i + k;
				int idr = j - k;
				nextP += ((nowP >> (4 * idr)) & 15) << (4 * idl);
			}
			dfs(type, depth + 1, maxDepth, nextP);
		}
	}
}

bool isMatch(int depth1, int depth2) {
	vector<int> &a = perms[0][depth1];
	vector<int> &b = perms[1][depth2];
	int i, j;
	
	if (a.size() == 0 || b.size() == 0) return false;
	
	j = 0;
	for (i = 0; i < a.size(); i++) {
		for (; j < b.size(); j++) {
			if (a[i] <= b[j]) {
				break;
			}
		}
		if (j < b.size() && a[i] == b[j]) return true;
	}
	return false;
}

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) { cin >> a[i]; a[i]--; }
	for (i = 0; i < n; i++) decA += a[i] << (4 * i);
	for (i = 0; i < n; i++) basePermDec += i << (4 * i);
	dfs(0, 0, 4, basePermDec);
	dfs(1, 0, 4, decA);

	for (i = 0; i < 2; i++) {
		for (j = 0; j < 5; j++) {
			sort(perms[i][j].begin(), perms[i][j].end());
			perms[i][j].erase(unique(perms[i][j].begin(), perms[i][j].end()), perms[i][j].end());
		}
	}
		
	int ans = 9;
	for (i = 0; i <= 4; i++) {
		for (j = 0; j <= 4; j++) {
			if (isMatch(i, j)) {
				ans = min(ans, i + j);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 101072
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n, k;
        cin >> n >> k;
        int d[101];
        int sunuke[101] = {0};
        int a[101][101];
        int dd, aa;

        for(int i = 0; i < k; i++){
                cin >> dd;
                d[i] = dd;
                for(int j = 0; j < dd; j++){
                        cin >> aa;
                        sunuke[aa] = 1;
                }
        }

        int ans = 0;
        for(int i = 1; i <= n; i++){
                if(sunuke[i] == 0)ans++;
        }
        cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        boolean flag = false;
        if (a == 5 && b == 5 && c == 7) flag = true;
        if (a == 5 && b == 7 && c == 5) flag = true;
        if (a == 7 && b == 5 && c == 5) flag = true;
        if (flag) System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 21844
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let h: usize = read();
    let w: usize = read();
    
    let mut ans: usize  = 0;

    if h % 2 == 0 {
        if w % 2 == 0 {
            ans += w / 2;
            ans *= h 
        } else {
            let odd = w / 2 + 1;
            let even = w / 2;
            ans = odd * (h / 2) + even * (h/2);
        }
    } else {
        if w % 2 == 0 {
            ans += w / 2;
            ans *= h 
        } else {
            let odd = w / 2 + 1;
            let even = w / 2;
            ans = odd * (h / 2 + 1) + even * (h/2);
        }
    }

    if h == 1 || w == 1 {
        ans = 1;
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
<?php

function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

$shichigosan_numbers = [];

for ($i = 1; $i <= 9; $i++) {
    for ($j = 0, $lim = pow(3, $i) - 1; $j <= $lim; $j++) {
        $str_three = str_pad(base_convert($j, 10, 3), $i, '0', STR_PAD_LEFT);
        $array_three = str_split($str_three);
        $array_three = array_map(function($digit) {
            return ['3', '5', '7'][(int)$digit];
        }, $array_three);
        $count_3 = $count_5 = $count_7 = 0;
        foreach ($array_three as $v) {
            if ($v === '3') {
                $count_3++;
            } else if ($v === '5') {
                $count_5++;
            } else {
                $count_7++;
            }
        }
        if ($count_3 !== 0 && $count_5 !== 0 && $count_7 !== 0) {
            $shichigosan_numbers[] = (int)implode('', $array_three);
        }
    }
}

$n = input('intval');
$count = 0;

foreach ($shichigosan_numbers as $num) {
    if ($num <= $n) $count++;
}

echo $count . "\n";

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

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

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

  ll E = C*D / gcd(C, D);
  cout << B - A + 1 - (B/C - (A+C-1)/C + 1) - (B/D - (A+D-1)/D + 1) + (B/E - (A+E-1)/E + 1) << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

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

    int n;
    cin >> n;

    vector<int> v(n), c(n);
    for (int &v_i : v) cin >> v_i;
    for (int &c_i : c) cin >> c_i;

    int max_diff = 0;
    for (int s = 1; s < 1 << n; ++s) {
        int sum_v = 0, sum_c = 0;
        for (int i = 0; i < n; ++i) {
            if (s >> i & 1) {
                sum_v += v[i];
                sum_c += c[i];
            }
        }
        max_diff = max(max_diff, sum_v - sum_c);
    }

    cout << max_diff << endl;

    return 0;
}


Measured memory_bytes: 256
def f_must_be_rectangular(N, Positions):
    # 参考: https://atcoder.jp/contests/abc131/submissions/6086451
    # x軸, y軸をまとめて1つのリストで扱う
    import sys
    sys.setrecursionlimit(10**7)

    vertex_maxsize = 10**5 + 5
    target = [[] for _ in range(2 * vertex_maxsize)]
    is_visited = [False] * (2 * vertex_maxsize)
    count = [0] * 2
    for x, y in Positions:
        y += vertex_maxsize  # 1つのリストで扱う都合上、ずらす
        target[x].append(y)
        target[y].append(x)

    def dfs(v):
        if is_visited[v]:
            return
        is_visited[v] = True
        count[v // vertex_maxsize] += 1  # vがx軸とy軸のどっちを指しているか
        for u in target[v]:
            dfs(u)  # 頂点vに接続されている頂点へ向かう

    ans = 0
    for i in range(2 * vertex_maxsize):
        if is_visited[i]:
            continue
        count = [0] * 2
        dfs(i)  # 頂点iにつながっている頂点を調べる
        # x座標とy座標のそれぞれについて、ペアにすると矩形が完成する
        # 座標がいくつあるか。その積が解となる
        ans += count[0] * count[1]
    return ans - N  # 最初に与えられた座標の分、引く

N = int(input())
Positions = [[int(i) for i in input().split()] for j in range(N)]
print(f_must_be_rectangular(N, Positions))

Measured memory_bytes: 111780
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    ans += tmp - 1;
  }

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


Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<Long> v(n);
  fore(i, 0, n) cin >> v[i];
  sort(all(v));
  int ans = 0;
  fore(i, 0, n) fore(j, i + 1, n) fore(k, j + 1, n) {
    if (v[i] == v[j] || v[j] == v[k]) continue;
    if (v[k] < v[i] + v[j]) {
      ans++;
    }
  }
  cout << ans << '\n';

  return 0;
}

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

long long gcd(long long a,long long b) {
  if (a > b) {
    swap(a,b);
  }
  if (b%a == 0) return a;
  return gcd(a,b%a);
}

long long lcm(long long a,long long b) {
  long long x;
  x = a / gcd(a,b);
  x *= b;
  return x;
}

long long mod = 1000000007;

int main() {
  long long N;
  cin >> N;
  
  long long n2 = 1;
  
  for (int i=0; i<N*2-2; i++) {
    n2 *= 2;
    n2 %= mod;
  }
  
  vector<long long> C(N);
  
  for (int i=0; i<N; i++) {
    cin >> C[i];
  }
  
  sort(C.begin(),C.end());
  reverse(C.begin(),C.end());
  
  long long ans = 0;
  
  for (int i=0; i<N; i++) {
    ans += C[i] * (i+2);
    ans %= mod;
  }
  
  ans *= n2;
  ans %= mod;
  
  cout << ans << endl;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

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

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

using namespace std;

string tr = "keyence";

bool sol(string str, int i) {
	for (int k = 0; k <= i; k++) {
		if (str[k] != tr[k]) {
			return false;
		}
	}
	int j = 1;
	for (int k = str.size() - tr.size()+i+1; k < str.size(); k++) {
		if (str[k] != tr[i+j]) {
			return false;
		}
		j++;
	}
	return true;
}

int main() {
	
	string str;
	cin >> str;

	bool flag = false;
	for (int i = 0; i < tr.size(); i++) {
		if (sol(str, i)) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[100001], a[100001];
int main (){
long long n;
cin >> n;
for(int i = 1; i <= n; ++i){
    cin >> a[i];
}
dp[2] = abs(a[1] - a[2]);
for (int i = 3; i <= n; ++i){
    dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
}
cout << dp[n];
return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a > b){
        ans += a;
        a -= 1;
    }else{
        ans += b;
        b-=1;
    }
    if(a > b){
        ans += a;
        a -= 1;
    }else{
        ans += b;
        b-=1;
    }
    pr(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

int main(void){
    int A, B;
    scanf("%d %d", &A, &B);
    
    if((A+B)%2 == 0){
        printf("%d \n", (A+B)/2);
    }else printf("IMPOSSIBLE \n");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<map>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
#define inf 1000000007
char s[105];
int i,w=0,n,d;
int main()
{
    scanf("%s",s);
    int n=strlen(s);
    for(i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1]){w=1;break;}
    }
    if(!w){
        d=(n-1)/2;
        for(i=0;i<d/2;i++)
       {
        if(s[i]!=s[d-i-1]){w=1;break;}
        }
    }
        if(w)printf("No\n");
        else printf("Yes\n");
}


Measured memory_bytes: 256
open System
open System.Collections.Generic
open System.Linq
open System

let Puts = Console.WriteLine : 'a -> unit
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])

let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)

let ReadIntDouble () = ReadDouble () |> FuncDouble int int

let ensmallen l = l % 1000000007L

let manhattan x y = abs (fst x - fst y) + abs (snd x - snd y)


// main code

let oRaw = Console.ReadLine()
let e = Console.ReadLine()

let (o:seq<char>, theLastLetter:char list) =
    if oRaw.Length <> e.Length
        then (Seq.take e.Length oRaw, [Seq.last oRaw])
        else (oRaw |> seq, [])
Seq.zip o e |> Seq.collect (fun (a, b) -> [a;b]) |> fun s -> Seq.append s theLastLetter |> String.Concat |>Puts


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

int main() {
  int a, b;
  cin >> a >> b;
  vector<int> v = {300000,200000,100000};
  int money;

  money = v[a-1] + v[b-1];
  if(a == 1 && b == 1) money += 400000;
  cout << money << endl;

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,N) for(int i=1;i<=N;i+=1)
using namespace std;
int main() {
  long long N;
  cin>>N;
  vector<long long>x,y;
  rep(i,sqrt(N)) if(N%i==0) {
    x.push_back(i);
    y.push_back(N/i);
  }
  auto dist=[&](int i) {
    return x[i]+y[i]-2;
  };
  long long B = dist(0);
  for(long long i=1; i<x.size( );i+=1) {
    long long A= dist(i);
    B=min(A,B);
  }
  cout<<B<<endl;
}
 
    

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	int a,b;
	cin >> a >> b;
	int kuti = 1;
	int counts = 0;
	while(kuti < b){
		kuti += a -1;
		counts++;
	}
	cout << counts << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

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

    for (ll i = 1; i < S.length(); ++i) {
        bool u = true;

        if ((S.length() - i) % 2 == 1)
            continue;
        ll d = (S.length() - i) / 2;
        REP(j, d) {
            if (S[j] != S[d + j]) {
                u = false;
                break;
            }
        }

        if (!u)
            continue;

        cout << d * 2LL << endl;
        break;
    }
    return 0;
}

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

int main(){
  int a,b,area,perimeter;
  cin>>a>>b;
if (a<b){
  cout<<"a < b"<<endl;
  }
else if(a>b){
  cout<<"a > b"<<endl;
  }
else{
  cout<<"a == b"<<endl;  
  }
}



Measured memory_bytes: 3104