akhauriyash/Code-Regression huggingface dataset:
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}



ll n,k,q;
vector<ll> A;

ll cul(ll x){
    vector<priority_queue<ll,vector<ll>,greater<ll>>> X;
    priority_queue<pll,vector<pll>,greater<pll>> Q;
    ll l=0;
    for(ll i=0;i<=n;i++){
        if(i==n || A[i]<x){
            if(i-l>=k){
                X.push_back(priority_queue<ll,vector<ll>,greater<ll>>());
                for(ll j=l;j<i;j++){X.back().push(A[j]);}
                Q.push({X.back().top(),X.size()-1});
            }
            l=i+1;
        }
    }
    ll mx=x;
    for(ll i=0;i<q;i++){
        if(Q.empty()){return E;}
        pll w=Q.top(); Q.pop();
        mx=w.F;
        X[w.S].pop();
        if(X[w.S].size()>=k){Q.push({X[w.S].top(),w.S});}
    }
    return mx-x;
}


int main(){
    cin>>n>>k>>q;
    A.resize(n);
    cin>>A;
    ll ans=E;
    for(auto &I:A){ans=min(ans,cul(I));}
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
T = [list(map(int,input().split())) for i in range(n)]

T.sort(key = lambda x: x[0])

def calc_parent(T,data):
    for i in range(n):
        if T[i][1] == data or T[i][2] == data:
            return T[i][0]
    return -1

def calc_sibling(T,data):
    if T[calc_parent(T,data)][1] == data:
        return T[calc_parent(T,data)][2]
    elif T[calc_parent(T,data)][2] == data:
        return T[calc_parent(T,data)][1]
    else:
        return -1

def calc_degree(T,data):
    count = 0
    if T[data][1] != -1:
        count += 1
    if T[data][2] != -1:
        count += 1
    return count

def calc_depth(T,data):
    depth = 0
    while calc_parent(T,data) != -1:
        data = calc_parent(T,data)
        depth += 1
    return depth

def calc_height(T,data):
    if data == -1:
        return -1
    else:
        return max(1+calc_height(T,T[data][1]),
                    1+calc_height(T,T[data][2]))

def calc_type(T,data):
    if calc_parent(T,data) == -1:
        return "root"
    elif calc_degree(T,data) == 0:
        return "leaf"
    else:
        return "internal node"

for i in range(n):
    print("node "+str(i), end="")
    print(": parent = "+str(calc_parent(T,i)),end="")
    print(", sibling = "+str(calc_sibling(T,i)), end="")
    print(", degree = "+str(calc_degree(T,i)), end="")
    print(", depth = "+str(calc_depth(T,i)), end="")
    print(", height = "+str(calc_height(T,i)), end="")
    print(", "+str(calc_type(T,i)))



Measured memory_bytes: 5632
def resolve():
    H, W = list(map(int, input().split()))
    if H == 1 or W == 1:
        print(1)
        return

    ans = int(H * W / 2)
    if ((H * W) % 2 == 1):
        ans += 1
    print(ans)
    return
 
resolve()

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    char n[4];
    int ans=0;
    scanf("%s",n);
    for(int i=0; i<3; i++){
        if(n[i]=='7'){
            ans=1;
        }
    }
    if(ans==1)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 1728
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int h[1001] = {}, cnt, i, m, n,j;
	while (~fscanf(stdin,"%d%d", &n, &m), n||m) {
		memset(h, 0, sizeof(h));
		cnt = 0;
		i = n;
		j = 0;
		while (1) {
			i++;
			j++;
			if (i == n + 1) i = 1;
			while (h[i]) { i++; if (i == n + 1) i = 1;}
			if(j==m) h[i] = 1,cnt++,j=0;
			if (cnt == n - 1) break;
		}
		for (i = 1; i <= n; i++) if (!h[i]) P(d, i);
	}
	return 0;
}

Measured memory_bytes: 604
/*--------------------------------
		Anshul Gangwar
	Chandigarh University
--------------------------------*/
#include<bits/stdc++.h>
using namespace std;

#define ll 			long long
#define For(i,n) 	for(int i = 0;i < n;i++)
#define fr(i,a,b)	for(int i = a;i <= b;i++)
#define Rfor(i,n) 	for(int i = n-1;i >= 0;i--)
#define endl         '\n'


int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// #endif
	string s;
	cin >>s;
	int ans = true;
	For(i,(int)s.length())
	{
		if((i+1)%2 != 0)
		{
			if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
				// cout<<"1-> "<<s[i]<<" "<<i<<endl;
			ans = false;
			}
		}
		else if((i+1)%2 == 0)
		{
			if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
			ans = false;
			// cout<<s[i]<<" "<<i<<endl;
			}
		}
	}
	if(ans)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc048c()
}

fun abc048c() {
    val (n, x) = readLine()!!.split(' ').map { it.toLong() }
    val aList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()

    var answer = 0L
    for (i in 0 until aList.lastIndex) {
        val value = aList[i]
        val diff = value + aList[i + 1] - x
        if (diff > 0) {
            val remain = diff - aList[i + 1]
            aList[i + 1] = Math.max(0, aList[i + 1] - diff)
            aList[i] = Math.max(0, remain)
            answer += diff
        }
    }

    println(answer)
}


Measured memory_bytes: 73980
#include<bits/stdc++.h>
#define F	first
#define S	second
using namespace std;
typedef pair<int,int>P;
int main(void){
	int n;
	int h,m;
	int time[50][6];
	int MAX=-1,HMAX=-1;
	int cnt;
	int sum;
	P p[51];
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<6;j++){
			cin>>h>>m;
			m+=h*60;
			time[i][j]=m;
		}
	}
	for(int i=0;i<1441;i++){
		for(int j=0;j<1441;j++){
			cnt=0;
			for(int k=0;k<n;k++){
				if(time[k][0]<=i&&time[k][1]>=i&&time[k][2]<=j&&time[k][3]>=j){
					p[cnt].F=time[k][4];
					p[cnt].S=1;
					cnt++;
					p[cnt].F=time[k][5]+1;
					p[cnt].S=-1;
					cnt++;
				}
			}
			sort(p,p+cnt);
			sum=0;
			for(int l=0;l<cnt;l++){
				sum+=p[l].S;
				MAX=max(MAX,sum);
			}
			HMAX=max(HMAX,MAX);
		}
	}
	cout<<HMAX<<endl;	
	return 0;
}
			
			
			
	


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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int ans=0,f=0,f2=0;
	reverse(s.begin(), s.end());
	for (auto i = s.begin(); i != s.end(); ++i)
	{
		int d=(*i)-'0';
		if (f==1)
		{
			d++;
			f=0;
		}
		if (d<=4)
		{
			ans+=d;
		}
		else if (d==5)
		{
			++i;
			auto j=i;
			--i;
			if (j!=s.end()&&(*j)-'0'>=5)
			{
				ans+=10-d;
				f=1;
			}
			else
			{
				ans+=d;
			}
		}
		else
		{
			ans+=10-d;
			f=1;
		}
	}
	cout<<ans+f<<endl;
	return 0;
}


Measured memory_bytes: 1412
#include<stdio.h>
int main()
{
	int n, a, b, sum, i;
	while(~scanf("%d %d", &n, &a))
	{
		sum = a;
		for(i=1; i<n-1; i++)
		{
			scanf("%d", &b);
			if(b<a) sum+=b;
			else sum += a;
			a=b;
		}
		sum+=a;
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 256
// AOJ Volume 0 Problem 0022

#include <stdio.h>

int aoj0022(int n)
{
    int i;
	int a[5000];
	int sum_all;
	int sum_rear;
	int max_front;
	int max_rear;
	int index_max_front;
	int index_max_rear;
	
	scanf("%d", &a[0]);
	sum_all = max_front = a[0];
	index_max_front = 0;
	
	for (i = 1; i < n; i++){
		scanf("%d", &a[i]);
		sum_all += a[i];
		if (max_front < sum_all){
			max_front = sum_all;
			index_max_front = i;
		}
	}
	
	sum_rear = 0;
	max_rear = a[n - 1];
	index_max_rear = n - 1;
	for (i = n - 1; i >= 0; i--){
		sum_rear += a[i];
		if (max_rear < sum_rear){
			max_rear = sum_rear;
			index_max_rear = i;
		}
	}
	
//	printf("%d->%d  %d->%d\n", max_front, index_max_front, max_rear, index_max_rear);
	
	if (index_max_rear <= index_max_front){
		return (max_rear + max_front - sum_all);
	}
	if (max_front > max_rear){
		return (max_front);
	}
	return (max_rear);
}

int main(void)
{
    int n;
    
    while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		printf("%d\n", aoj0022(n));
    }
	
	return (0);
}

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

const int MOD = 998244353;

long long inv[500005 << 1];
long long fac[500005 << 1];
long long facinv[500005 << 1];

long long power(long long a, long long b) {
  a %= MOD;
  b %= MOD;
  long long res = 1;
  while(b) {
    if(b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

long long C(long long m, long long n) {
  if(n == m) return 1;
  if(m == 0) return 1;
  if(m > n) return 0;
  return fac[n] * facinv[m] % MOD * facinv[n - m] % MOD;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if(n < m) {
    std::swap(n, m);
  }
  fac[0] = fac[1] = 1;
  inv[1] = 1;
  facinv[0] = facinv[1] = 1;
  for(int i = 2; i <= n + m; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
    facinv[i] = facinv[i - 1] * inv[i] % MOD;
  }
  long long ans = 0;
  for(int i = 1; i <= m; ++i) {
    ans = (ans + C(i, i << 1) * C(n - i, n + m - (i << 1))) % MOD;
    ans %= MOD;
  }
  ans *= power(C(n, n + m) << 1, MOD - 2) % MOD;
  ans %= MOD;
  ans = (ans + n + MOD) % MOD;
  printf("%lld\n", ans);
  return 0;
}


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

void Main()
{
  ll N, T;
  cin >> N >> T;
  vector<ll> t(N);
  rep(i,N) {cin >> t[i];}
  ll tot = 0;
  rep(i,N-1) {
    if (t[i+1] - t[i] >= T) tot += T;
    else tot += t[i+1] - t[i];
  }
  tot += T;
  cout << tot << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

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

import static java.lang.Integer.*;

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter prnt = new PrintWriter(System.out);
        st = new StringTokenizer(read.readLine());
        int A = parseInt(st.nextToken()), B = parseInt(st.nextToken()), C = parseInt(st.nextToken());
        int k = parseInt(read.readLine());

        for (int i = 0; i < k; i++) {
            if (A > B || A == B) {
                B = 2 * B;
            } else if (B > C || B == C) {
                C = 2 * C;
            }
        }
        if (A < B && B < C) {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    }
}

Measured memory_bytes: 32728
#include<stdio.h>
#define g getchar()
inline void r(int *x){
	char c=g;
	while(c<'0')c=g;
	while(c>='0'){*x=*x*10+c-48;c=g;}
}
int x[100000];
int n,a,b;
long d;
int main(){
	r(&n);r(&a);r(&b);r(&x[0]);
	for(int i=1;i<n;i++){
		r(&x[i]);
		long e=(long)a*(x[i]-x[i-1]);
		d+=e>b?b:e;
	}
	printf("%ld\n",d);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n,m;
    cin>>n>>m;
    if(n<=m/2) {
        m=m-n*2;
        cout<<n+m/4<<endl;
    }
    else {
        cout<<m/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int A,s1,s2,s3;
 cin >> A;
  s1 = A;
  s2 = A/10;
  s3 = A/100;
 cout << s1%2+s2%2+s3%2 << endl ;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
ab = [tuple(map(int,input().split())) for _ in range(M)]
ab.sort(key=lambda x: x[1])
ans = 0
s = 0 #最新の切断点
for i in range(M):
    a, b = ab[i]
    if a >= s: # aを今の最新の切断点で対処できないなら、
        #そのaに対するb(これは必ず対処できる)で切る
        s = b
        ans += 1
print(ans)


Measured memory_bytes: 90964
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
        int n;
        cin >> n;
        vector <int> v(n,0),ans(n,0);
        rep(i,n) cin >> v[i];
        int ans2=0;
        int mina=1000000000;
        int maxa=0;
        while(1) {
                if(accumulate(v.begin(), v.end(), 0)==0||mina==maxa) break;
                rep(i, n) {
                        if(v[i]!=0) {mina=min(mina,v[i]);}
                }
                maxa = *std::max_element(v.begin(), v.end());
                ans2=mina;
                rep(i,n) {
                        if(v[i]!=mina) v[i]%=mina;
                }

        }
        cout << ans2 << endl;

}


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

using namespace std;

map< pair<int,int> , int > mp;
long long h,w,n;
long long ans[10],tot = 0;

int main()
{
    scanf("%lld %lld %lld",&h,&w,&n);
    for(int i = 0; i<n; ++i)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        --a; --b;
        for(int i = max(0,a-2); i<=a && i+2<h; ++i) 
            for(int j = max(0,b-2); j<=b && j+2<w; ++j)
                ++mp[ make_pair(i,j) ];
    }
    for(auto it = mp.begin(); it != mp.end(); ++it)
    {
       ++ans[it->second];
       ++tot;
    }
    tot = ( h - 2 ) * ( w - 2 ) - tot;
    printf("%lld\n",tot);
    for(int i = 1; i<10; ++i)
        printf("%lld\n",ans[i]);
    return 0;
}


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

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll res = 0;
  string p = "BGR";
  do {
    for (int i = 0; i < n; i++) {
      if (s[i] != p[1]) continue;
      int lft = 0;
      vector<int> cnt(n, 0);
      for (int j = 0; j < i; j++) {
        if (s[j] == p[0]) {
          ++lft;
          cnt[j] = 1;
        }
      }
      for (int j = i + 1; j < n; j++) {
        if (s[j] == p[2]) {
          int add = lft;
          if (i - (j - i) >= 0)
            add -= cnt[i - (j - i)];
          res += add;
        }
      }
    }
  } while (next_permutation(p.begin(), p.end()));
  cout << res << '\n';
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    int p[n];
    int ans=0,tmp=INF;
    rep(i,n){
        cin>>p[i];
        if(tmp>=p[i]) ans++;
        tmp=min(tmp,p[i]);
    } 

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int n = b - a;
    int x = 0;
    for(int i = 1;i <= n;i++){
      x += i;
    }
    System.out.println(x - b);
  }
}


Measured memory_bytes: 22612
public class Main{
  static int topx = 0;
  static int topy = 0;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int w, h, i, j, res;
    char[][] field;
    int[][] count;
    int[] nowx, nowy;
    String str;

    for(;;){
      w = sc.nextInt(); h = sc.nextInt();
      if(w == 0 && h == 0)break;
      field = new char[h][w]; count = new int[h][w];
      nowx = new int[h * w + 1]; nowy = new int[h * w + 1];
      for(i = 0;i < h;i++)for(j = 0;j < w;j++)count[i][j] = 0;
      res = 0;

      for(i = 0;i < h;i++){
        str = sc.next();
        for(j = 0;j < w;j++){
          field[i][j] = str.charAt(j);
          if(field[i][j] == '@'){
            pushx(nowx, i); pushy(nowy, j); count[i][j]++; res++;
          }
        }
      }

      for(;;){
        if(topx == 0)break;
        i = seetopx(nowx); j = seetopy(nowy);
        if(i != 0 && field[i - 1][j] == '.' && count[i - 1][j] == 0){
          pushx(nowx, i - 1); pushy(nowy, j); count[i - 1][j]++; res++;
        }else if(j != 0 && field[i][j - 1] == '.' && count[i][j - 1] == 0){
          pushx(nowx, i); pushy(nowy, j - 1); count[i][j - 1]++; res++;
        }else if(i != h - 1 && field[i + 1][j] == '.' && count[i + 1][j] == 0){
          pushx(nowx, i + 1); pushy(nowy, j); count[i + 1][j]++; res++;
        }else if(j != w - 1 && field[i][j + 1] == '.' && count[i][j + 1] == 0){
          pushx(nowx, i); pushy(nowy, j + 1); count[i][j + 1]++; res++;
        }else{
          i = popx(nowx); j = popy(nowy);
        }
      }

      out.println(res);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int popx(int[] stack){
    return stack[--topx];
  }
  private static void pushx(int[] stack, int a){
    stack[topx++] = a; return;
  }
  private static int seetopx(int[] stack){
    return stack[topx - 1];
  }
  private static int popy(int[] stack){
    return stack[--topy];
  }
  private static void pushy(int[] stack, int a){
    stack[topy++] = a; return;
  }
  private static int seetopy(int[] stack){
    return stack[topy - 1];
  }
}

Measured memory_bytes: 31988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int[] A)
        {
            return A.Select(a => a - 1).Sum();
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] A = ReadInts();
            Console.WriteLine(Solve(A));
        }
    }
}


Measured memory_bytes: 13328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

typedef pair<double, pair<int, int> > pdii;

long long d(int x, int y) {
    return 1ll * x * x + 1ll * y * y;
}

int main() {
    int n;
    cin >> n;
    pdii lxy[n*2];
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        lxy[i] = {atan2(y, x), {x, y}};
    }
    sort(lxy, lxy+n);

    for (int i = 0; i < n; i++) {
        lxy[i+n] = lxy[i];
    }

    int j = 0;
    int dx = 0, dy = 0;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (j < i) {
            dx = dy = 0;
            j = i;
        }
        while (j < i + n && d(dx + lxy[j].second.first, dy + lxy[j].second.second) >= d(dx, dy)) {
            dx += lxy[j].second.first;
            dy += lxy[j].second.second;
            j++;
        }
        ans = max(ans, d(dx, dy));
        dx -= lxy[i].second.first;
        dy -= lxy[i].second.second;
    }

    cout << fixed << setprecision(15) << sqrt(ans) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

D med(vector<D> v){
    int s = v.size();
    if(s % 2) return v[(s+1)/2-1];
    else return (v[s/2-1]+v[s/2+1-1])/2.0;
}

int main(){
    int n; cin >> n;
    vector<D> a(n), b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    sort(ALL(a));
    sort(ALL(b));
    D maxi = med(b);
    D mini = med(a);
    int ans = 0;
    if(n % 2) ans = maxi - mini + 1.0;
    else ans = (maxi - mini)*2.0 + 1.0;
    cout << ans << endl;
}


Measured memory_bytes: 8080
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int H,W,N; cin >> H >> W >> N;
    if(H > W) swap(H,W);
    int sum = 0;
    rep(i,H){
        sum += W;
        if(sum >= N){
            cout << i+1 << endl;
            return 0;
        }
    }
}
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,a[5],maxs=0;
  cin>>n;
  for(int i=0;i<5;i++){
    cin>>a[i];
    if(n%a[i]!=0) maxs=max(maxs,n/a[i]+1);
    else maxs=max(maxs,n/a[i]);
  }
  cout<<maxs+4<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b){
	int r=a%b;
	while(r!=0){
		a=b;
		b=r;
		r=a%b;
	}

	return b;
}

int main(void){
	int a, b;
	scanf("%d %d", &a, &b);

	printf("%d\n", gcd(a, b));

	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
int main (){
int i,j,n,m,x,y,a,b,max=-100,min=100;
  scanf ("%d%d%d%d",&n,&m,&x,&y);
for (i=0;i<n;i++){
scanf ("%d",&a);
  if (max<a){
 max=a; 
  }
}
for (i=0;i<m;i++){
  scanf ("%d",&b);
 if (min>b){
 min=b; 
  }
}
if (max>x && max<min && min<y+1){
printf ("No War");
}
  else {
  printf ("War");
  }
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define T() long long t;cin>>t;for(long long i=1;i<=t;i++)
#define INF (int)MAX_INT
#define INFS (int)MIN_INT
#define mod 1000000007
#define FOR(a, b, n) for(int a = b; a < n; a++)
#define REP(a,c, b) for(int a = c; a < b; a++)
#define FORD(a, b, c) for(int a = b; a >= c; a--)
#define REPD(a, c,b) for(int a = b-1; a >= c; a--)
#ifdef HOHOHO
#define DEBUG(x) cerr << #x << " : " << x << '\n'
#define DEBUGV(x) cerr << #x << " : { "; REP(_it, x.size()) cerr << x[_it] << ' '; cerr << "}" << '\n'
#define DEBUGA(x, y) cerr << #x << " : { "; REP(_it, y) cerr << x[_it] << ' '; cerr << "}" << '\n'
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define CHECKPOINT cerr << "OK LINE #" << __LINE__ << '\n'
#else
#define DEBUG(x) {}
#define DEBUGV(x) {}
#define DEBUGA(x, y) {}
#define PRINTF(...) {}
#define CHECKPOINT {}
#endif
#define RESET(a, b) memset(a, b, sizeof a)
#define EPS 1e-9
#define m_p make_pair
#define pb push_back
#define fi first
#define se second
#define RALL(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define ALL(x, y) x, x+y
#define SZ(x) ((int)x.size())
#define  pi(a)  pair<a, a> 
#define  vi(a)  vector<a> 
#define  vii vector<pi>
#define  vs vector<string>
template<class T> T sqr(T x){ return x*x; }
template<class T> T binPow(T p, int q, int MOD) {
    if(q == 1) return p % MOD;
    if(q & 1) return p*(binPow(p, q-1, MOD) % MOD) % MOD;
    else return sqr(binPow(p, q/2, MOD) % MOD) % MOD;
}
 
ll nxt() {
    ll temporaryVariable;
    cin >> temporaryVariable;
    return temporaryVariable;
}
const double PI = acos(-1.0);
#define MAXN 100001
const int G = 2e5 + 5;
 
 
 
int main(){
  ios::sync_with_stdio(false);
  
  string s;cin>>s;
  cout<<s;
  
  if(s.back()=='s')
    cout<<"es"<<endl;
  else
    cout<<'s'<<endl;
 
    #ifdef HOHOHO   
    fprintf(stderr, "%.3lf\n", clock() / (double) CLOCKS_PER_SEC );
#endif
}
 



Measured memory_bytes: 3648
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val a = sc.nextLong
  val b = sc.nextLong

  val res = a * b / gcd(a,b)

  println(res)



  def gcd(a: Long, b: Long): Long ={
    (a,b) match{
      case (x,y) if y == 0 => x
      case (x,y) if x < y  => gcd(y, x)
      case (x,y)           => gcd(y, x % y)
    }
  }

}

Measured memory_bytes: 27464
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc,bc;
LL ar[500][500];
LL br[1000001];
LL cr[500005];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n;
        for(i=0; i<=1000005; i++)
        {
            br[i]=0;
        }
        for(i=0; i<n; i++)
        {
            cin>>cr[i];
            br[cr[i]]++;
        }
        if(br[1]==1)
        {
            cout<<1<<endl;
            return 0;
        }
        if(br[1]>1)
        {
            cout<<0<<endl;
            return 0;
        }
        k=0;
        for(i=0; i<n; i++)
        {
            o=cr[i];
            l=1;
            for(j=1; j<=sqrt(o); j++)
            {
                if(o%j==0)
                {
                    if(j==o)
                    {
                        if(br[j]>1)
                        {
                            l=0;
                            break;
                        }
                    }
                    else if(o==o/j)
                    {
                        if(br[o/j]>1)
                        {
                            l=0;
                            break;
                        }
                    }
                    else if(j!=o && br[j]>0)
                    {
                        l=0;
                        break;
                    }
                    else if(o/j!=o && br[o/j]>0)
                    {
                        l=0;
                        break;
                    }
                }
            }
            k+=l;

        }
        cout<<k<<endl;
    }

    return 0;
    //IN
    //AL
}


Measured memory_bytes: 13052
#include<bits/stdc++.h>
#include<atcoder/all>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

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

ll N;

void solve() {
  cin >> N;
  vector<PLL> z(N); // {x,y}
  vector<ll> y_to_orig_ix(N+10);
  rep(i, N) {
    cin >> z[i].first >> z[i].second;
    y_to_orig_ix[ z[i].second ] = i;
  }
  sort(begin(z),end(z));

  dsu dsu(N+10);
  set<ll> s;
  rep(i, N) {
    ll x = z[i].first, y = z[i].second;
    //cout << i << " " << x << " " << y << endl;
    auto jt = s.lower_bound(y);
    if (jt == s.begin()) {
      // 移動不可
      s.insert(y);
    } else {
      // 移動可能
      for (auto it = s.begin(); it != jt; it++) {
        dsu.merge(y, *it);
      }
    }
  }

  vector<ll> ans(N);
  rep(i, N) {
    ll y = z[i].second;
    ans[ y_to_orig_ix[y] ] = dsu.size(y);
  }
  rep(i, N) {
    cout << ans[i] << endl;
  }
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


Measured memory_bytes: 13852
#include<bits/stdc++.h>
using namespace std;
const int N=3009;
int n,t,a[N],b[N],dp[N][N];
int main(){
  cin>>n>>t;
  for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
  for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)if(a[i]<a[j]||(a[i]==a[j]&&b[i]>b[j]))swap(a[i],a[j]),swap(b[i],b[j]);
  int ans=0;
  for(int i=1;i<=n;i++)
    for(int j=t-1;j>=0;j--){
      int tmp=0;
      if(j+a[i]<t)tmp=dp[i-1][j+a[i]];
      dp[i][j]=max(dp[i-1][j],b[i]+tmp);
      ans=max(ans,dp[i][j]);
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 35584
#include<iostream>
using namespace std;
  
class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){roll(1, 2, 4, 3);}//
  void roll_y(){roll(0, 2, 5, 3);}// to W
  void roll_x(){roll(0, 1, 5, 4);}// to N
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j];  f[j] = f[k]; f[k] = f[l]; f[l] = t;
  } 
};
bool eq( Cube c1, Cube c2 ){
  for ( int i = 0; i < 6; i++ )
    if ( c1.f[i] != c2.f[i] ) return false;
  return true;
}
 
bool equal( Cube c1, Cube c2 ){
  for ( int i = 0; i < 6; i++){
   for ( int j = 0; j < 4; j++){
    if ( eq(c1, c2) ) return true;
     c1.roll_z();
}
if ( i % 2 == 0 ) c1.roll_y();
else c1.roll_x();
}
 return false;
}
 Cube C[100]; int n;

 bool check(){
  for ( int i = 0; i < n-1; i++)
   for ( int j = i+1; j < n; j++) if ( equal(C[i], C[j]) ) return false;
  return true;
}
int main(){
  cin >> n;
 
  for ( int j = 0; j < n; j++ ) 
  for ( int i = 0; i < 6; i++ ) cin >> C[j].f[i];
  
  if ( check() ) cout << "Yes" << endl;
  else cout << "No" << endl;
 
return 0;
}
  



Measured memory_bytes: 3104
s = list(input())
ans = []
for i, x in enumerate(s):
  if s[i] == 'R':
    if s[i-1] == 'L':
      if i > 0:
        even = (r + 1) // 2 + l // 2
        odd = r // 2 + (l + 1) // 2 
        ans += [0] * (r - 1) + [even, odd] + [0] * (l - 1)
      r = 1
      l = 0
    else:
      r += 1
  else:
    l += 1
else:
  even = (r + 1) // 2 + l // 2
  odd = r // 2 + (l + 1) // 2 
  ans += [0] * (r - 1) + [even, odd] + [0] * (l - 1)
    
print(*ans)

Measured memory_bytes: 7092
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

signed main() {
	int k, r;
	cin >> k >> r;
	if (k >= 10) cout << r << endl;
	else cout << r + 100 * (10 - k) << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> h(n+k+1),dp(n+k+1,INF);
    rep(i,0,n)cin>>h[i];
    dp[0]=0;
    rep(i,0,n){
        rep(j,1,k+1){
            dp[i+j]=min(dp[i]+abs(h[i+j]-h[i]),dp[i+j]);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys


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


S = input()
T = input()
dp = [[0]*(len(T)+1) for j in range(len(S)+1)]
# dp[i][j] := i,j までの最大のもの。(length)
for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            if dp[i+1][j] >= dp[i][j+1]:
                dp[i+1][j+1] = dp[i+1][j]

            elif dp[i+1][j] < dp[i][j+1]:
                dp[i+1][j+1] = dp[i][j+1]
X, Y = len(S), len(T)
ans = []
while dp[X][Y]:
    if S[X-1] == T[Y-1]:
        ans.append(S[X-1])
        X -= 1
        Y -= 1
    else:
        if dp[X-1][Y] >= dp[X][Y-1]:
            X -= 1
        else:
            Y -= 1
            continue
ans.reverse()
print("".join(ans))

Measured memory_bytes: 144336
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<int>> map(h + 2, vector<int>(w + 2, -1));
    for (int i = 1; i <= h; i++) {
        string s;
        cin >> s;

        for (int j = 1; j <= w; j++) {
            if (s[j - 1] == '.') {
                map[i][j] = 0;
            }
        }
    }

    vector<vector<int>> row_lr(h + 2, vector<int>(w + 2, -1));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (map[i][j] == 0) {
                row_lr[i][j] = row_lr[i][j - 1] + 1;
            }
        }
    }

    vector<vector<int>> row_rl(h + 2, vector<int>(w + 2, -1));
    for (int i = 1; i <= h; i++) {
        for (int j = w; j >= 1; j--) {
            if (map[i][j] == 0) {
                row_rl[i][j] = row_rl[i][j + 1] + 1;
            }
        }
    }

    vector<vector<int>> col_tb(h + 2, vector<int>(w + 2, -1));
    for (int i = 1; i <= w; i++) {
        for (int j = 1; j <= h; j++) {
            if (map[j][i] == 0) {
                col_tb[j][i] = col_tb[j - 1][i] + 1;
            }
        }
    }

    vector<vector<int>> col_bt(h + 2, vector<int>(w + 2, -1));
    for (int i = 1; i <= w; i++) {
        for (int j = h; j >= 1; j--) {
            if (map[j][i] == 0) {
                col_bt[j][i] = col_bt[j + 1][i] + 1;
            }
        }
    }

    int max = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (map[i][j] == 0) {
                int sum = row_lr[i][j] + row_rl[i][j] + col_tb[i][j] + col_bt[i][j] + 1;
                if (max < sum) {
                    max = sum;
                }
            }
        }
    }

    cout << max << endl;
}


Measured memory_bytes: 78848
#include <bits/stdc++.h>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define gcd(x,y) __builtin_gcd(x,y)
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek=998244353;

int main() {
mipletsplay;
int n;
cin>>n;
vector <int> b(n-1);
for (int i=0;i<n-1;i++)
cin>>b[i];
ll sum=0;
for (int i=0;i<n-2;i++)
{
sum+=min(b[i],b[i+1]);
}
sum+=b[0];
sum+=b[n-2];
cout<<sum;}

Measured memory_bytes: 256
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

ll X,Y,A,B,C;

void solve(){
	cin>>X>>Y>>A>>B>>C;
    ll a[A] , b[B] , c[C];
    vector<ll> values;
    ll sum = 0;

    for(ll i = 0 ; i<A ; i++)
        cin>>a[i];

    for(ll i = 0 ; i<B ; i++)
        cin>>b[i];

    for(ll i = 0 ; i<C ; i++)
        cin>>c[i];


    sort(a , a+A); sort(b , b+B); sort(c , c+C);

    for(ll i = A-1 ; i>A-1-X; i--)
        values.push_back(a[i]);

    for(ll i = B-1 ; i>B-1-Y ; i--){
        values.push_back(b[i]);
    }

    for(ll i = 0 ; i<C ; i++)
        values.push_back(c[i]);

    sort(values.rbegin() , values.rend());

    for(ll i = 0 ; i<X+Y ; i++)
        sum+=values[i];


    cout<<sum<<'\n';
 
  
}



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

	return 0;
}

Measured memory_bytes: 9636
# include <iostream>
using namespace std;
int N, h[100010];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> h[i];
  
  int max_num = 0;
  int tmp_max = 0;
  for (int i = 0; i < N - 1; i++) {
    if (h[i] >= h[i + 1]) {
      tmp_max++;
      if (tmp_max > max_num) max_num = tmp_max;
    }
    else {
      if (tmp_max > max_num) max_num = tmp_max;
      tmp_max = 0;
    }
  }
  
  cout << max_num << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, k;
    cin >> n >> k;
    int m, a;
    rep(i, n) {
        cin >> a;
        if (a == 1) m = i;
    }
    int l = m + 1, r = n - m;
    l--;
    r--;
    k--;
    cout << min((n - 1 + k - 1) / k, (l + k - 1) / k + (r + k - 1) / k) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
using namespace std;

//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int main(){
    init;
    string s,t;
    cin>>s>>t;
    int X,Y,i,j,k,l;
    X = s.size();
    Y = t.size();

    int dp[X+1][Y+1];
    for(i=0;i<=Y;i++){
        dp[0][i] = 0;
    }
    memset(dp,0,sizeof(dp));

    for(i = 1;i <= X;i++){
        for(j=1; j<=Y;j++){
            if(s[i-1] == t[j-1]){
                if(dp[i][j] < 1 + dp[i-1][j-1]){
                    dp[i][j] = 1 + dp[i-1][j-1];
                    //st[i][j] = st[i-1][j-1] + s[i-1];
                }
            }
            else{
                if(dp[i][j] < dp[i-1][j]){
                    dp[i][j] = dp[i-1][j];
                    //st[i][j] = st[i-1][j];
                }
                if(dp[i][j] < dp[i][j-1]){
                    dp[i][j] = dp[i][j-1];
                    //st[i][j] = st[i][j-1];
                }
            }
        }
    }

    char lcs[dp[X][Y] + 1];
    lcs[dp[X][Y]]='\0';
    i = X,j = Y,k = dp[X][Y];
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1])
        {
            lcs[k-1] = s[i-1];
            i--;
            j--;
            k--;
        }
        else if(dp[i][j-1] > dp[i-1][j]){
            j--;
        }
        else i--;
    }
    cout<<lcs<<endl;
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define N 200005

using namespace std;

long long n, m, v, p;
long long a[N];

bool check(int pos) {
	long long tmp = (v - p - pos + 1) * m, MAX = a[pos] + m;
	for (int i = pos + 1; i <= n - p + 1; ++i) {
		if (a[i] > MAX) return false;
		tmp -= MAX - a[i];
	}

	if (tmp <= 0) return true;
	else return false;
}

int main() {
	scanf("%lld%lld%lld%lld", &n, &m, &v, &p);
	for (int i = 1; i <= n; ++i) scanf("%lld", a + i);
	sort(a + 1, a + n + 1);

	int l = 1, r = n - p + 1, mid, ans;
	while (l <= r) {
		mid = l + r >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}

	printf("%lld\n", n - ans + 1);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

void solve()
{

}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int n,k;
cin>>n>>k;
vii a(n);
rep(i,0,n-1)cin>>a[i];
int ans=0;
sort(all(a));
rep(i,0,k-1)ans+=a[i];
ol(ans);
return 0;
}



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

const int MN = 20123, INF = 5012345, MOD = 1000 * 1000 * 1000 + 7;
int inv[INF], fict[INF], invf[INF], dp[MN][MN];

void fact() {
	fict[0] = inv[0] = invf[0] = 1;
	fict[1] = inv[1] = invf[1] = 1;
	for (int i = 2; i < INF; i++) {
		inv[i] = 1ll * inv[MOD % i] * (MOD - MOD / i) % MOD;
		fict[i] = 1ll * fict[i - 1] * i % MOD;
		invf[i] = 1ll * invf[i - 1] * inv[i] % MOD;
	}
}

int chose(int a, int b) {
	return 1ll * fict[b] * invf[a] % MOD * invf[b - a] % MOD;
}

int main() {
	fact();
	int n, k;
	cin >> n >> k;
  	if (k == 1)
      return cout << 1, 0;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= n; j++) {
			if (j > i)
    	          continue;
			dp[i][j] = dp[i - 1][j];
			if (j)
				dp[i][j] = (dp[i][j] + 1ll * dp[i][j - 1] * chose(k - 2, n * k - (j - 1) * (k - 1) - i - 1) % MOD) % MOD;
        }
	cout << 1ll * dp[n][n] * fict[n] % MOD;
}


Measured memory_bytes: 215424
#include<stdio.h>
int main(void){
    int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '+'){
            printf("%d\n",a+b);
        }else if(op == '-'){
            printf("%d\n",a-b);
        }else if(op == '*'){
            printf("%d\n",a*b);
        }else if(op == '/'){
            printf("%d\n",a/b);
        }else if(op == '?'){
            break;
        }
    }
    return 0;
}


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

int main(){
   int k,s;
   cin >> k >> s;
   int ans=0;
   for (int x=0;x<=k;x++){
            for (int y=0;y<=k;y++){
               if (s-x-y<=k&&s-x-y>=0)ans++;
            }
         }
   cout << ans << endl;
}

Measured memory_bytes: 256
def maximum_profit(n):
    maxv = min(n) - max(n)
    minv = n[0]
    for i in range(1, len(n)):
        maxv = n[i] - minv if maxv < n[i] - minv else maxv
        minv = n[i] if minv > n[i] else minv
    return maxv

if __name__ == '__main__':
    n = []
    for _ in range(int(input())):
        n.append(int(input()))
    print(maximum_profit(n))



Measured memory_bytes: 13588