akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=result.begin();i!=result.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
//#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int ms(int arr[], int n) 
{ 
    multiset<int> last; 
    for (int i = 0; i < n; i++) { 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
        if (it == last.begin()) 
            last.insert(arr[i]); 
  
        else { 
            it--; 
        last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 
  
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    cout<<ms(a,n);

    return 0;
}


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

namespace ConsoleApp76 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = st[0];
            long K = st[1];

            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            //普通の累積和
            var V = new long[N + 1];
            V[0] = 0;
            for (long i = 0; i < N; i++) {
                V[i + 1] = V[i] + a[i];
            }

            //正の整数だけをカウントした累積和
            var W = new long[N + 1];
            W[0] = 0;
            for (long i = 0; i < N; i++) {
                W[i + 1] = W[i] + Math.Max(0, a[i]);
            }

            long ans = 0;

            for (int i = 0; i + K <= N; i++) {
                long sum = 0;

                sum = W[N] - W[i + K] + W[i];

                sum += Math.Max(0, V[i + K] - V[i]);

                ans = Math.Max(ans, sum);
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 32220
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;

// to format a document: ctrl + K -> ctrl + D

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

    ll cnt  = 0;
    ll Anum = 0;

    for (int i = 0; i < s.length() - 1;) {
        if (s[i] == 'A') {
            Anum++;
            i++;
        }
        else if (s[i] == 'B' && s[i + 1] == 'C') {
            cnt += Anum;
            i += 2;
        }
        else {
            Anum = 0;
            i++;
        }
    }


    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double ans=w*h/2;
    cout<<fixed<<setprecision(10)<<ans<<endl;
    if(2*x==w && 2*y==h) cout<<1<<endl;
    else cout<<0<<endl;
    
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main() {
	fastio();

	LL n;
	cin >> n;

	vector<LL> a(n);

	LL net = 0;

	for (auto &e : a) {
		cin >> e;
		net ^= e;
	}

	vector<LL> b(n);

	for (LL i = 0; i < n; ++i) {
		b[i] = (net ^ a[i]);
	}

	for (auto e : b) {
		cout << e << " ";
	}
	cout << "\n";

}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  vector<int> C(N);
  for (int i = 0; i < N; i++) cin >> C[i];
  
  int ret = -1;
  for (int mask = 0; mask < (1 << N); mask++) {
    int cost = 0;
    int value = 0;
    for (int i = 0; i < N; i++) {
      if ((1 << i) & mask) {
        cost += C[i];
        value += V[i];
      }
      ret = max(ret, value - cost);
    }
  }
  cout << ret << endl;
}

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

using namespace std;
using ll = long long;

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

    int freq['z'+1] = {};
    string s; cin >> s;

    for(char &it:s) freq[it]++;
    for(int i='a'; i<='z'; i++)
        if(freq[i]&1) return cout << "No", 0;

    cout << "Yes";
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        String S = scan.next();
        char[] data = S.toCharArray();
        int group = 1;
        char current = data[0];
        for (int i = 1; i < data.length; i++) {
            if (current == data[i]) {
                continue;
            }
            current = data[i];
            group += 1;
        }
        for (int i = 0; i < K; i++) {
            if (2 < group) {
                group -= 2;
                continue;
            }
            if (group == 2) {
                group = 1;
                continue;
            }
            break;
        }
        System.out.println(N - group);
    }
}


Measured memory_bytes: 27092
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n;
    cin>>n;

    string str="";
    for(;n;n=(n-1)/26)
    {
        int x=n%26;
        if(x==0)
            str+='z';
        else
            str+=('a'+x-1);
    }

    reverse(all(str));
    cout<<str;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=100005;
struct edge{
	int to,next;
}e[N*2];
int head[N],tot,n;
int deg[N],q[N],DS[N],DT[N];
int vis[N],ans1[N],ans2[N];
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
int bfs(int S,int *dis){
	For(i,1,n) dis[i]=-1;
	int h=0,t=1;
	q[1]=S; dis[S]=0;
	while (h!=t){
		int x=q[++h];
		for (int i=head[x];i;i=e[i].next)
			if (dis[e[i].to]==-1){
				dis[e[i].to]=dis[x]+1;
				q[++t]=e[i].to;
			}
	}
	return q[t];
}
void work(int *q,int l,int *ans){
	*ans=0;
	int S=0;
	For(i,0,l){
		int v=deg[q[i]];
		v-=(i!=0)+(i!=l);
		For(j,1,v) ans[++*ans]=S+j+1;
		ans[++*ans]=S+1;
		S+=v+1;
	}
}
int main(){
	scanf("%d",&n);
	For(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
		++deg[x]; ++deg[y];
	}
	int S=bfs(1,DS);
	int T=bfs(S,DS);
	bfs(T,DT);
	For(i,1,n)
		if (DS[i]+DT[i]==DS[T]){
			q[DS[i]]=i;
			for (int j=head[i];j;j=e[j].next)
				vis[e[j].to]=1;
		}
	For(i,1,n)
		if (!vis[i])
			return puts("-1"),0;
	work(q,DS[T],ans1);
	reverse(q,q+DS[T]+1);
	work(q,DS[T],ans2);
	int fl=0;
	For(i,1,n){
		if (!fl&&ans1[i]!=ans2[i])
			fl=(ans1[i]<ans2[i]?1:-1);
		printf("%d ",fl==1?ans1[i]:ans2[i]);
	}
}

Measured memory_bytes: 5504
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

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

const int inf = 1e9 + 7;
#define EPS 1e-9

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int res=0;

	stack<char> st;
	rep(i, n) {
		if (st.empty() || st.top() == s[i]) {
			st.push(s[i]);
		}
		else {
			res += 2;
			st.pop();
		}
	}
	cout << res << endl;
	return 0;
}

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

int main() {
	int n,p=0,c=1;
cin>>n;
int h[n+1];
for(int i=1;i<n+1;i++)
{ cin>>h[i];
 for(int j=1;j<i;j++)
 {
   if(h[j]>h[i])
   {c=0;
   break;}   
 }
 if(c==1)
   p++;
 c=1;
}
cout<<p;
	// your code goes here
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int K;
	cin >> K;
	LL s=7;
	rep(i,K){
		if(s%K==0){
			cout << i+1 << endl;
			return 0;
		}
		s*=10;
		s+=7;
		s%=K;
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3632
import java.util.*;
 
class Main{

    void run(){
        Scanner sc=new Scanner(System.in);
        
        while(true){
            int z=sc.nextInt();if(z==-1)break;
            double q=(double)z;
            double x=q/2;
            
            while(true){
                if(Math.abs(x*x*x-q)<0.00001*q)break;
                x=x-(x*x*x-q)/(3*x*x);
                //System.out.println(x);
            }
            
            System.out.printf("%.6f\n",x);
        }
    }
    
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 17328
import sys
from functools import reduce

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N, A, B = lr()

answer = pow(2, N, MOD) - 1 

def cmb(n, r): 
    X = reduce(lambda x, y: x * y % MOD, range(n, n - r, -1))
    Y = reduce(lambda x, y: x * y % MOD, range(1, r + 1)) 
    return X * pow(Y, MOD - 2, MOD) % MOD

answer -= cmb(N, A) + cmb(N, B)
print(answer % MOD)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int A(N);
    rep(i,N)cin>>A.at(i);

    int highest = 0;
    int humidai_tot = 0;
    rep(i,N){
        if(A.at(i)>highest){
            highest=A.at(i);
        }
        if(A.at(i)<highest){
            humidai_tot+=highest-A.at(i);
        }
    }

    cout<<humidai_tot<<endl;

    return 0;
}

Measured memory_bytes: 4840
using System;
using System.Collections.Generic;
using System.Linq;

namespace Contest
{
    class ABC
    {
        static void Main()
        {
            Solve();
        }

        private static void Solve()
        {
            int[] INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int res = INPUT[0] - INPUT[1] * 2;

            if(res <= 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(res);
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13396
import heapq

N = int(input())
A = list(map(int, input().split()))
l, r = [], []
ll = 0
for i in range(3*N):
    if i < N:
        heapq.heappush(l, (A[i], i))
        ll += A[i]
    else:
        heapq.heappush(r, (A[i], i))
used = set()
rr = 0
for i in range(N):
    a, idx = heapq.heappop(r)
    used.add(idx)
    rr += a
ans = ll-rr
done = set()
for i in range(N,2*N):
    done.add(i)
    if A[i] > l[0][0]:
        ll -= l[0][0]
        heapq.heappop(l)
        heapq.heappush(l, (A[i], i))
        ll += A[i]
    if i in used:
        rr -= A[i]
        a, idx = heapq.heappop(r)
        while idx in done:
            a, idx = heapq.heappop(r)
        used.add(idx)
        rr += a
    #print(i, ll, rr, l, r)
    ans = max(ans, ll-rr)
print(ans)


Measured memory_bytes: 71736
#include <stdio.h>

int main(void)
{
	int N, A[30], B[30], C[30];
	int i;
	int s=0, b=-1;
	
	scanf("%d", &N);
	
	for(i=0; i<N; i++)	scanf("%d", &A[i]);
	for(i=0; i<N; i++)	scanf("%d", &B[i]);
	for(i=0; i<N-1; i++)scanf("%d", &C[i]);
	
	for(i=0; i<N; i++){
		//printf("%d %d %d\n", A[i], B[A[i]-1], b);
		s += B[A[i]-1];
		if(i>0 && b==A[i]-1)s+=C[b-1];
		b=A[i];
		//printf("%d\n", s);
	}
	
	printf("%d\n", s);
	
	return 0;
}

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

int main(void) {
  int n,m;
  cin >> n >> m;

  vector<pair<int,int>> v;
  for (int i = 0; i < m; i++) {
    int p,y;
    cin >> p >> y;
    v.emplace_back(p,y);
  }
  vector<pair<int,int>> v2(v);
  sort(v.begin(), v.end());


  map<pair<int,int>,string> ans;
  int j=1;
  for (int i = 0; i < m; i++) {
    if (i>0&&v[i-1].first==v[i].first) {
      j++;
    } else {
      j=1;
    }
    char s[100];
    sprintf(s, "%06d%06d",v[i].first, j);
    ans[make_pair(v[i].first,v[i].second)] = s;
  }

  for (int i = 0; i < m; i++) {
    cout << ans[v2[i]] << endl;
  }

  return 0;
}


Measured memory_bytes: 14068
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
using namespace std;

int n , v[20];

tr1::unordered_map<int,int> memo[20];

int f(int pos , int sum){
	if(sum > 10000000) return 99999999;
	return pos == n ? abs(sum) : memo[pos].count(sum) ? memo[pos][sum] : memo[pos][sum] = min( f(pos+1,sum+v[pos] ) , f(pos+1,abs(sum-v[pos])) );
}

int main(){
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++) cin >> v[i] , memo[i].clear() ;
		cout << f(0,0) << endl;
	}
}

Measured memory_bytes: 0
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*   Compro by emame©   */
//////////////////////////
#include<iostream>
#include<stack>
using namespace std;

int main() {
  int a;
  cin >> a;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    ans += pow(a, i + 1);
  }
  cout << ans;
  
}

Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next()) - 1;
		int b = Integer.parseInt(sc.next()) - 1;
		String[][] s = new String[100][100];
		int w = 0;
		for (int i = 0; i < 50; i++)
			Arrays.fill(s[i], "#");
		for (int i = 50; i < 100; i++)
			Arrays.fill(s[i], ".");
		for (int i = 0; i < a; i++) {
			s[i / 50 * 2][i % 50 * 2] = ".";
		}
		for (int i = 0; i < b; i++) {
			s[i / 50  * 2 + 51][i % 50 * 2] = "#";
		}
		System.out.println("100 100");
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++)
				System.out.print(s[i][j]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 25556
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }
    int A[N][M];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans = 0;
    int x[N];
    for(int i = 0; i < N; i++) {
        x[i] = 0;
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            x[i] += A[i][j]*B[j]; 
        }
    }

    for(int i = 0; i < N; i++) {
        if(x[i] > -C) {
            ans++;
        }
    }

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

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


int main() {
  int N,K,x,sum=0;
  cin>>N>>K;
  rep(i,N){
    cin>>x;
    int b=K-x;
    int l=min(x,b);
    l=l*2;
    sum+=l;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
// constexpr int MOD = 1e9+7;
 
int main(void){
    Cin(int, n, l);
    Cins(int, n, a);
    
    For(i, n-1){
        if(a[i] + a[i+1] >= l){
            Cout("Possible");
            for(int j = 0; j < i; j ++) Cout(j+1);
            for(int j = n-2; j >= i; j --) Cout(j+1);
            return 0;
        }
    }
    Cout("Impossible");
}


Measured memory_bytes: 1152
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

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

    int n;
    cin >> n;
    int a[n], dp[n];
    forn(i, n)cin >> a[i];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; i++){
        dp[i] = min(abs(a[i] -a[i - 2]) + dp[i - 2], abs(a[i] - a[i - 1]) + dp[i - 1]);
        deb(dp[i]);
    }
    cout << dp[n - 1];
    return 0;
}
// Write Here


Measured memory_bytes: 4416
// シェルソート
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

const int MAX_N = 1000000;

int cnt = 0;
vector<int> G;

void insertionSort(int A[], int n, int g);
void shellSort(int A[], int n);

int main(void)
{
    int N;
    int ary_sequence[MAX_N];

    cin >> N;

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

    shellSort(&ary_sequence[0], N);

    cout << G.size() << endl;

    for(int i = G.size() - 1; i >= 0; i--)
    {
        cout << G[i];

        if( i )
        {
            cout << " ";
        }
    }

    cout << endl;
    cout << cnt << endl;

    // 最終結果の表示
    for(int i = 0; i < N; i++)
    {
    	cout << ary_sequence[i] << endl;
    }

    return 0;

}

// シェルソートを実施する関数
void shellSort(int A[], int n)
{
    // 挿入ソートを実施する間隔
    // 数列 : G = {1, 4, 13, 40, 121, 364,・・・・}を生成
    for(int h = 1 ; ;)
    {
        if( h > n )
        {
            break;
        }

        G.push_back(h);
        h = ( 3 * h ) + 1;
    }

    for(int i = G.size() - 1; i >= 0; i--)
    {
        // 逆順にG[i] = gを指定
        insertionSort(&A[0], n, G[i]);
    }

    return;
}

// 挿入ソートを実施する関数
// g : 挿入ソートを実施する間隔
void insertionSort(int A[], int n, int g)
{
    int v, j;

    for(int i = g; i < n; i++)
    {
        // 挿入する値をラッチする
        v = A[i];
        // 比較対象の要素No.を設定する
        j = i - g;

        while( j >= 0 && A[j] > v )
        {
            // vよりも値が大きいは後ろにコピーして、前の要素へ戻る
            A[j + g] = A[j];
            j = j - g;

            // 交換回数のカウント
            cnt++;
        }

        // 値のソートで、値を入れるべき所に値を入れる
        A[j + g] = v;

    }

    return;
}



Measured memory_bytes: 7044
N = int(input())
A = list(map(int,input().split()))
A.sort()
d = {}
n = A[-1]
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    i = 0
    for j in A:
        if i == j:
            isPrime[i] = False
            continue
        i = j
        if isPrime[i]:
            for j in range(i * 2, n + 1, i):
                isPrime[j] = False
    return isPrime
P = makePrimeChecker(n)
i = 0
ans = 0
for j in A:
    if i == j:
        continue
    else:
        i = j
        if P[i]:
            ans += 1
print(ans)

Measured memory_bytes: 32068
#include<iostream>
using namespace std;
int n,k;
char s[11],t;
string f;
main(){
    cin>>n>>s>>k;
    t=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]==t)f+=t;
        else f+='*';
    }
    cout<<f<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s=scanner.next();
		int cnt=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='1')cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 22868
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int a[1100];

int main(){
	int i, j, n, k;
	
	scanf("%d", &n);

	long long int a = 2, b = 1, c = 1;
	for (i = 1; i < n; i++) {
		c = a + b;
		a = b;
		b = c;
	}
	printf("%lld\n", c);

	return 0;
}


Measured memory_bytes: 128
N = int(input())
list_v = list(map(int,input().split()))
list_c = list(map(int,input().split()))

list_V_C =[]

for i in range(N):
    list_V_C.append(list_v[i]-list_c[i])

aaa_max =0
for i in list_V_C:
    aaa_max += max(0,i)

print(aaa_max)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define Max 100005
typedef long long llong;
int n,k;
llong T[Max];

//K辆最大运载量为P的卡车能装多少件货物 
int check(llong P)
{
	int i=0;
	for(int j=0;j<k;j++)
	{
		llong s=0;
		while(s+T[i]<=P)
		{
			s +=T[i];
			i++;
			if(i==n) return n;
		}
	}
	return i;
	
}

int solve(llong max){
	 llong left =max-1,right = 10000*n;
	 llong mid;
	 while(right - left>1) //注意这里不是left>right,因为那样会陷入死循环 
	 {
	 	mid =(left+right)/2;
		 int v =check(mid);  
		 if(v>=n) 
		 right =mid;
		 else 
		 left = mid; 
	 }
	 return right;//这里返回的rigth即为极限值 
	
}                                            

int main()
{
	cin>>n>>k;
	cin>>T[0];
	llong max = T[0];
	for(int i =1;i<n;i++)
	{
		cin>>T[i];
		if(max<T[i])
		max =T[i];
	}
	llong ans = solve(max);
	cout<<ans <<endl;
	return 0;
 } 




                                                            


Measured memory_bytes: 3884
#%%
N = int(input())
S = list(input())

T = S.copy()

flag = False

#print(S)


for i in range(N):
    flag = False
    i = 0
    while True:
        if i > len(S) - 1:
            break
        if S[i] == '(':
            tmp = i
            flag = True
        if flag and S[i] == ')':
            S.pop(i)
            S.pop(tmp)
            flag = False
        i += 1

#print(S)
#print(T)

a = S.count('(')
b = S.count(')')

ans = '('*b + ''.join(T) + ')'*a
print(ans)

Measured memory_bytes: 3064
N = int(input())
A = []
cnt = 0
for i in range(N) :
    x, y, z = map(int, input().split())
    a, c = min(x, y, z), max(x, y, z)
    b = x + y + z - a - c
    if [a, b, c] in A :
        cnt += 1
    else :
        A.append([a, b, c])
print(cnt)


Measured memory_bytes: 5716
#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int n, a[2000], res;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  for (int k = 0; k < n; ++k) for (int j = 0; j < k; ++j) for (int i = 0; i < j; ++i) {
    res += a[i] + a[j] > a[k];
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N;
  cin>>N;
  int MIN = INF;
  int MAX = -1*INF;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    chmin(MIN,A);
    chmax(MAX,A);
  }
  cout<<MAX-MIN<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	
  	double ans = 0;
	int n,a,b;
  	cin >> n;
  	int p=1;
 	for(int i=1;i<=n;i++) p*=i;
  
  	vector<pair<int,int > > data;
	vector<int> v;
  	for(int i=1;i<=n;i++) v.push_back(i);
 	for(int i=0;i<n;i++) {
    	cin >> a >> b;
      	data.push_back(make_pair(a,b));
 	}
  	int c = 1;
  
  	do {
    	for(int i=1;i<n;i++) {
        	int x = data[v[i-1]-1].first  - data[v[i]-1].first;
          	int y = data[v[i-1]-1].second - data[v[i]-1].second;
          
          	ans += sqrt(x*x + y*y);
        }
      	//cout << c << endl;
        //c++;
    } while(next_permutation(v.begin(), v.end()));
  
  	printf("%f", ans/p);
}

Measured memory_bytes: 3880
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int keta(int x) {
	int ans = 0;
	while (x) {
		x /= 10;
		ans++;
	}
	return ans;
}
int kk[100], test[213456];
signed main() {
	int n, m, a, ans = 0; cin >> n >> m;
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = a;
	}
	for (int h = 1; h < n; h++) {
		if (test[h - 1] + test[h] > m) {
			ans += test[h - 1] + test[h] - m;
			test[h] = max(test[h] - (test[h - 1] + test[h] - m), (long long)0);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>m;
typedef map<char,ll>mc;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] ={-1,+1,0,0,+1,-1,+1,-1};
ll dy[] ={0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
bool vis[mx];
vi adj[mx];
int main()
{
    speed;
    ll a,b;
    cin>>a;
    b=ceil(a/double(1000));
    cout<<(b*1000)-a<<endl;
}



Measured memory_bytes: 6100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    double l;
    cin >> l;
    double ans= l/3;
    cout << fixed << setprecision(6) << ans*ans*ans;
    
}









Measured memory_bytes: 256
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
using namespace std;

const int MOD = 1e9 + 7;

int h, w;
int dp[1002][1002];
char t[1002][1002];

int main() {
  while (cin >> h >> w) {
    for (int i = 0; i < h; i++) {
      cin >> t[i];
      fill(dp[i], dp[i] + w, 0);
    }

    dp[0][0] = 1;

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (dp[i][j] == 0) continue;

        if (i + 1 < h && t[i + 1][j] == '.') {
          dp[i + 1][j] += dp[i][j];
          dp[i + 1][j] %= MOD;
        }

        if (j + 1 < w && t[i][j + 1] == '.') {
          dp[i][j + 1] += dp[i][j];
          dp[i][j + 1] %= MOD;
        }
      }
    }

    cout << dp[h - 1][w - 1] << endl;
  }
}


Measured memory_bytes: 5120
n = int(input())
a  = [int(_) for _ in input().split()]
aa = [abs(_) for _ in a]

ans = 0
cnt = 0
for i in a:
    if i < 0:
        cnt += 1
    ans += abs(i)
if cnt % 2 == 0:
    print(ans)
else:
    ans -= abs(min(aa)) * 2
    print(ans)

Measured memory_bytes: 14412
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int main(){
    int n,i,x,ans=0,tmp=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&x);
        if(x!=i) ans+=(tmp+1)/2,tmp=0;
        else tmp++;
    }
    ans+=(tmp+1)/2;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    cout<<(N - 1)/2<<endl;
}

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

using namespace std;

int main(){
	char map[100][100];
	int w, h, x = 0, y = 0, lx, ly, c;

	while (1){
		c = 0;

		cin >> h >> w;

		if (w == 0 && h == 0)break;

		//input
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> map[i][j];
			}
		}

		//detect
		while(1){
			c++;
			
			if (c > w*h){
				lx = -1;
				ly = -1;
				break;
			}

			switch (map[y][x]){
			case '>':x++; break;
			case '<':x--; break;
			case '^':y--; break;
			case 'v':y++; break;
			}

			if (map[y][x] == '.'){
				lx = x; ly = y;
				break;
			}
		}

		if (lx == -1 && ly == -1){
			cout << "LOOP" << endl;
		}
		else{
			cout << lx << ' ' << ly << endl;
		}

		x = y = 0;
	}

	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll n,m;

ll A[305][305];
ll pos[305];

ll freq[305];//frequency of a particular sport
map<ll,set<ll>,greater<ll>> my;//list of sports with a given frequency 
bool done[305];

int main()
{
  finp;
  cin>>n>>m;

  afor(i,1,n)
  {
    afor(j,1,m)
    {
      cin>>A[i][j];
    }
    pos[i] = 1;
    freq[A[i][1]]++;
  }

  afor(i,1,m)
  {
    if(!freq[i])continue;
    my[freq[i]].insert(i);
  }

  ll ans = (*my.begin()).first;
  
  afor(z,1,m-1)
  {
    int spo = *((my.begin()->second).begin());
    done[spo] = true;
    (my.begin()->second).erase(spo);
    if((my.begin()->second).size() == 0)my.erase(my.begin());


    //if(!my.size())break;
    

    afor(i,1,n)
    {
      if(!done[A[i][pos[i]]])continue;
      while(done[A[i][pos[i]]])
      {
        pos[i]++;
      }
      assert(pos[i] <= m);
      ll fv = A[i][pos[i]];

      if(freq[fv])
        {
          my[freq[fv]].erase(fv);
          if(!my[freq[fv]].size())my.erase(freq[fv]);
        }
      freq[fv]++;
      my[freq[fv]].insert(fv);
    }
  

    ans = min(ans,my.begin()->first);
    

  }
  cout<<ans;
  
return 0;
}

Measured memory_bytes: 1024
s = gets.chomp
a = s.slice(0, 2).to_i
b = s.slice(2, 2).to_i
judge_a = (a >= 1 && a <= 12)
judge_b = (b >= 1 && b <= 12)
if judge_a && judge_b
  puts "AMBIGUOUS"
elsif !judge_a && !judge_b
  puts "NA"
elsif judge_a
  puts "MMYY"
else
  puts "YYMM"
end


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

int main(){
    ll N; cin >> N;
    ll ans = 0;
    rep(i, 0, N){
        ll a; cin >> a;
        ans += (a-1);
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    //int a = {1, 3, 5, 7, 8, 10, 12};
    //int b = {4, 6, 9, 11};
    //int c = {2}
    
    int x, y;
    cin >> x >> y;
    if ( x == 2 || y == 2 || x == 11 || x == 12){
        cout << "No";
        return 0;
    }
    
    if (x==1 || x==3 || x==5 || x==7 || x==8 || x==10) {
        if (y==3 || y==5 || y==7 || y==8 || y==10 || y==12) {
            cout << "Yes";
            return 0;
        } else {
            cout << "No";
            return 0;
        }
    } else if (x==4 || x==6 || x==9) {
        if (y==6 || y==9 || y==11) {
            cout << "Yes";
            return 0;
        } else {
            cout << "No";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	cout << abs(A[N - 1] - A[0]) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

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

    for(int i = 0; i < s.size(); ++i){
        if(i%2 == 0){
            cout << s[i];
        }
    }
    cout << endl;

}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int Q;
    cin >> Q;
    int MAXVAL = 1e5;
    vector<bool> prime(MAXVAL+1,true);
    prime[0] = false;
    prime[1] = false;
    for (int i=2;i<=MAXVAL;i++){
        for (int j=2*i;j<=MAXVAL;j+=i){
            prime[j] = false;
        }
    }
    vector<int> num(MAXVAL+1);
    for (int i=1;i<=MAXVAL;i+=2){
        if (prime[i] && prime[(i+1)/2]) num[i] = num[i-2] + 1;
        else num[i] = num[i-2];
    }
    for (int i=0;i<Q;i++){
        int l, r;
        cin >> l >> r;
        cout << num[r] - num[l-2] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1024
row_num = int(input())
nums = []
for row in range(row_num):
    nums.append(int(input()))

min_diff = nums[0]
max_diff = nums[1] - nums[0]
for i in range(1, len(nums)):
    if max_diff < nums[i] - min_diff:
        max_diff = nums[i] - min_diff
    if min_diff > nums[i]:
        min_diff = nums[i]

print(max_diff)



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

using ll = long long; 

int main() {
  ll x;
  cin >> x;

  ll ans = 0;
  ans += (x / 500) * 1000;
  x = x % 500;
  ans += (x / 5) *5;

  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int p;
  cin >> p;
  cout << p/500*500 << endl;

  return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  vector<int> c(m), d(m);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  for (int i = 0; i < m; i++) {
    cin >> c.at(i) >> d.at(i);
  }

  for (int i = 0; i < n; i++) {
    int point = 0;
    int dis = 1e+9;
    for (int j = 0; j < m; j++) {
      int tem = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
      if (dis > tem) {
        point = j;
        dis = tem;
      }
    }
    cout << point + 1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
    
    
    

    return 0;
}


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

int main(){
  string s;int k;cin>>s>>k;
  vector<string> ans(k+1,"zzzzz");
  
  for(int i=1;i<=k;i++){
    REP(j,s.size()-i+1){
      bool f=0;
      string t=s.substr(j,i);
      REP(p,k) if(ans.at(p)==t) f=1;
      for(int m=k-1;m>=0;m--){
        if(!f&&ans.at(m)>t){
          ans.at(m+1)=ans.at(m);
          ans.at(m)=t;
        }
      }
    }
  }
  //REP(i,k) cout<<ans.at(i)<<endl;
  cout<<ans.at(k-1);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n = 0;
    int qntdiv = 0;
    int divi = 0;

    scanf("%d",&n);

    for (int i = 1; i <= n; ++i ){
        if (i & 1){
            for (int j = 1; j <= i; ++j ){
                if (i % j == 0 ){
                    ++qntdiv;
                    if (qntdiv == 8){
                        ++divi;
                        }
                    }
                }
                qntdiv = 0;
            }
        }
    printf("%d\n",divi );
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N+1);
  for(int i=1;i<=N;i++)cin>>A[i];
  vector<int>b(N+1);
  for(int i=N;i>=1;i--){
    int sum=0;
    for(int j=i*2;j<=N;j+=i){
      sum^=b[j];
    }
    b[i]=sum^A[i];
  }
  vector<int>ans;
  for(int i=1;i<=N;i++){
    if(b[i])ans.push_back(i);
  }
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]<<" ";
  }
  return 0;
}

Measured memory_bytes: 5336
N,K = map(int,input().split())
h = list(map(int,input().split()))
DP = [float('inf')]*N
DP[0] = 0
for i in range(N):
    for j in range(K):
        if i+j+1 < N:
            DP[i+1+j] = min(DP[i+j+1],DP[i]+abs(h[i]-h[i+j+1]))
print(DP[-1])


Measured memory_bytes: 55264
n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for _ in range(q)]

# table[i] = i文字目以下のsにACは部分文字列として何回現れるか
table = [None] * (n+1)
table[0] = 0
table[1] = 0
for i in range(2, n+1):
    if s[i-2:i] == 'AC':
        table[i] = table[i-1] + 1
    else:
        table[i] = table[i-1]

for l, r in lr:
    print(table[r] - table[l])

Measured memory_bytes: 19772