akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int max = 0;
    int second;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] >= max){
            second = max;
            max = a[i];
        }else if(a[i] > second){
            second = a[i];
        }
    }
    for(int i = 0;i < n;i++){
        if(a[i] == max)cout << second << endl;
        else cout << max << endl;
    }
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == 5 && b == 7 && c == 5)
    cout << "YES" << endl;
  else if (a == 7 && b == 5 && c == 5)
    cout << "YES" << endl;
  else if (a == 5 && b == 5 && c == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m,p=map(int,input().split())
edge = [[] for i in range(m)]
for i in range(m):
  a,b,c=map(int,input().split())
  edge[i]=[a-1,b-1,-c+p]
d=[float("inf")]*n
d[0]=0

for _ in range(n):
  for i in range(m):
    e0,e1,e2=edge[i]
    d[e1]=min(d[e1],d[e0]+e2)
ans1=d[-1]
for _ in range(n):
  for i in range(m):
    e0,e1,e2=edge[i]
    if d[e1]>d[e0]+e2:
      d[e1]=-float("inf")
ans2=d[-1]
print(-1 if ans1!=ans2 else max(0,-ans1))


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

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int X[n], Y[m];
	for (int i = 0; i < n; i++) {
		cin >> X[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> Y[i];
	}
	sort(X, X + n);
	sort(Y, Y + m);
	int z = x + 1;
	z = max(z, X[n - 1] + 1);
	if (z <= min(y, Y[0])) cout << "No War\n";
	else cout << "War\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

uint64_t gcd(uint64_t a, uint64_t b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
  uint64_t A, B;
  cin >> A >> B;

  cout << lcm(A,B) << endl;

  return 0;
}


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

const long long N = 2e5+7;
int a[N];
bool b[N];
int n;

bool check(int m) {
    for (int i=1; i<2*n; i++)   b[i] = a[i] > m;

    int closest[2] = {N, N};
    for (int i=1; i<2*n; i++) {
        if (i > 1 && b[i] == b[i-1])              closest[b[i]] = min(closest[b[i]], abs(n-i));
        if (i + 1 < 2*n && b[i] == b[i+1])        closest[b[i]] = min(closest[b[i]], abs(n-i));
    }

    if (closest[0] == closest[1]) {
        assert(closest[0] == N);
        return (1-n%2)^b[n];
    }
    else if (closest[0] > closest[1])   return 1;
    else    return 0;
}

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

    cin>>n;
    for (int i=1; i<2*n; i++) cin>>a[i];

    int lo = 1, hi = 2*n-1;
    while (lo < hi) {
        int mid = (lo+hi)/2;
        if (check(mid))     lo = mid+1;
        else                hi = mid;
    }
    cout<<lo<<endl;

}


Measured memory_bytes: 4600
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

constexpr int64_t kMaxNumberOfTowns = 200000;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32_t K;
  string S;
  cin >> K >> S;
  const int32_t length = static_cast<int32_t>(S.length());
  if (length <= K) {
    cout << S << endl;
  } else {
    const string aaa = "...";
    cout << S.substr(0, K) + aaa << endl;
  }

  return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
#define dbg(x) cout<<#x<<" = "<<x<<endl
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+5;
char str[maxn];
int a[maxn];
int b[maxn];
int main()
{
    scanf("%s",str);
    int len=strlen(str);
    for(int i=0;i<len;i++) b[i]=str[i]-'a';
    for(int i=0;i<26;i++)
    {
        for(int j=0;j<len;j++)
        {
            if(b[j]==i) a[j]=1;
            else a[j]=-1;
        }
        int st,en,pos=0;
        int maxx=-100005;
        int sum=0;
        for(int j=0;j<len;j++)
        {
            sum+=a[j];
            if(sum>maxx)
            {
                maxx=sum;
                st=pos;
                en=j;
            }
            else if(sum==maxx)
            {
                if(j-pos+1>en-st)
                {
                    maxx=sum;
                    st=pos;
                    en=j;
                }
            }
            if(sum<0)
            {
                pos=j+1;
                sum=0;
            }
            if(en-st+1>=2&&maxx>0)
            {
                printf("%d %d\n",st+1,en+1);
                return 0;
            }
        }
//        dbg(maxx);
//        cout<<en<<" "<<st<<endl;
    }
    printf("-1 -1\n");

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
	
typedef long long ll;
typedef unsigned long long ull;
typedef long double db;
	
#define MOD 1000000007
#define mini 18446744073709551615
#define ff first
#define ss second
#define pb push_back
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
	//cin>>T;
	while(T--)
	{
		ll n;
		cin>>n;
		cout<<!n;
	}
	return 0;
}

Measured memory_bytes: 3608
#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;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n;
	cin>>n;
	ll arr[n+1];
	REP(i,0,n+1){
		cin>>arr[i];
	}
	ll arr1[n+1] = {0};
	arr1[n] = arr[n];
	if(arr[n] == 0){
		cout<<-1<<endl;
		return 0;
	}

	REPI(i,1,n){
		ll v = arr1[i+1] + arr[i];
		ll used = (v+1)/2;
		// cout<<used<<endl;

		if(pow(2,i) - arr[i] < 0){
			cout<<-1<<endl;
			return 0;
		}
		// cout<<pow(2,i-1) - arr[i-1]<<endl;
		if(pow(2,i-1) - arr[i-1] >= used){
			arr1[i] = arr1[i+1] + arr[i];
		}
		else {
			arr1[i] = 2*(pow(2,i-1) - arr[i-1]);
			if(arr1[i] < 0){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	arr1[0] = 1;
	REP(i,0,n){
		if(arr1[i] - arr[i] < 0){
			cout<<-1<<endl;
			return 0;
		}
		if((arr1[i] - arr[i])*2 < arr1[i+1]){
			arr1[i+1] = (arr1[i] - arr[i])*2;
		}
	}
	REP(i,0,n+1){
		if(arr1[i] - arr[i] < 0){
			cout<<-1<<endl;
			return 0;
		}
	}
	ll sum = 0;
	REP(i,0,n+1){
		// cout<<arr1[i]<<" ";
		sum += arr1[i];
	}
	cout<<sum<<endl;
	return 0;
}




Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int arr[N], L[N], R[N];
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); 
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	sort(arr, arr + n);
	int ans = 1e17;
	for(int i = 0; i <= n - k; i++){
		ans = min(ans, arr[i + k - 1] - arr[i]);
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;

int main()
{
	string s,t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	vector<string>w{s,t};
	sort(w.begin(), w.end());
	cout << (w[0] == s && s != t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,n,m;
	vector<ll>v1(5);
	cin>>v1[0]>>v1[1]>>v1[2]>>v1[3]>>v1[4];
	fl(i,5) {
		if(v1[i]==0) {
			cout<<i+1;
			return;
		}
	}
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=2e5+5;
const int INF=0x3f3f3f3f;
template<class T>bool gmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>bool gmin(T &a,T b){return a>b?a=b,1:0;}

ll n,q,t,a,r[MAX],X;
int main()
{
    scanf("%lld%lld",&X,&n);
    for(int i=1;i<=n;i++)scanf("%lld",&r[i]);
    scanf("%lld",&q);
    ll minsand=0,maxsand=X,val=0,k=1,sign=-1;
    while(q--)
    {
        scanf("%lld%lld",&t,&a);
        while(k<=n&&r[k]<=t)
        {
            ll v=sign*(r[k]-r[k-1]);
            minsand+=v;
            maxsand+=v;
            val+=v;
            gmax(minsand,0ll);
            gmin(minsand,(ll)X);
            gmax(maxsand,0ll);
            gmin(maxsand,(ll)X);
            sign*=-1;
            k++;
        }
        ll now=val+a;
        gmax(now,minsand);
        gmin(now,maxsand);
        now+=sign*(t-r[k-1]);
        gmax(now,0ll);
        gmin(now,(ll)X);
        printf("%lld\n",now);
    }
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
int n , k , l;
int a , b;
int parent1[N];
int parent2[N];
vector < int > v[N];
int sum[N];
int ans[N];
int find(int node , int parent[]){
    if(node != parent[node]){
        parent[node] = find(parent[node] , parent);
    }
    return parent[node];
}
int main(){
    scanf("%d %d %d" , &n , &k , &l);
    for(int i = 1 ; i <= n ; ++i){
        parent1[i] = i;
        parent2[i] = i;
    }
    while(k--){
        scanf("%d %d" , &a , &b);
        parent1[find(a , parent1)] = find(b , parent1);
    }
    while(l--){
        scanf("%d %d" , &a , &b);
        parent2[find(a , parent2)] = find(b , parent2);
    }
    for(int i = 1 ; i <= n ; ++i){
        v[find(i , parent1)].emplace_back(i);
    }
    for(int i = 1 ; i <= n ; ++i){
        if(!v[i].empty()){
            for(int node : v[i]){
                ++sum[find(node , parent2)];
            }
            for(int node : v[i]){
                ans[node] = sum[find(node , parent2)];
            }
            for(int node : v[i]){
                --sum[find(node , parent2)];
            }
        }
    }
    for(int i = 1 ; i <= n ; ++i){
        printf("%d%c" , ans[i] , " \n"[i == n]);
    }
}

Measured memory_bytes: 14080
#include <iostream>

using namespace std;

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  int a1,b1,c1;
  int cnt=0;
  a1=a;
  b1=b;
  c1=c;
  while(1){
    if((a1%2==1)||(b1%2==1)||(c1%2==1)){
      cout << cnt << endl;
      return 0;
    }
    cnt++;
    a1 = (b+c)/2;
    b1 = (a+c)/2;
    c1 = (a+b)/2;
    if((a1==b1)&&(b1==c1)){
      cout << -1 << endl;
      return 0;
    }
    a=a1;
    b=b1;
    c=c1;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int hen[3];
	int count;
	int i;
	int j;
	int k;
	
	scanf("%d", &count);
	for (i = 0; i < count; i++){
		scanf("%d%d%d", &hen[0], &hen[1], &hen[2]);
		for (j = 0; j < 3; j++){
			for (k = j + 1; k < 3; k++){
				if (hen[j] < hen[k]){
					int temp;
					temp = hen[j];
					hen[j] = hen[k];
					hen[k] = temp;
				}
			}
		}
		if (hen[0] * hen[0] == hen[1] * hen[1] + hen[2] * hen[2]){
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	
	return (0);
}

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

#define INF 250000001

using namespace std;

int main(){
    int N, C;
    cin >> N >> C;
    int D[C][C];
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            cin >> D[i][j];
        }
    }
    int l[3][C];
    for(int i=0; i<3; i++){
        for(int j=0; j<C; j++) l[i][j] = 0;
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            int c;
            cin >> c;
            l[(i+j)%3][--c]++;
        }
    }
    int ans = INF;
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            for(int k=0; k<C; k++){
                int temp = 0;
                if(i==j || j==k || k==i) temp = INF;
                else{
                    for(int m=0; m<C; m++){
                        temp += D[m][i] * l[0][m] + D[m][j] * l[1][m] + D[m][k] * l[2][m];
                    }
                }
                ans = min(ans, temp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}



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

    int n, r;
    cin>>n>>r;

    if (n>=10){
        cout<<r<<"\n";
        return 0;
    }
    cout<<r+100*(10-n)<<"\n";

    return 0;
    
}





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

typedef long long ll;

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
//  --------------------------------------

	int M, D; cin >> M >> D;
	int d1 = 2, d10 = 2;
	int ans = 0;

	if (M >= 4 && D >= 22)
	{
		while (d1 + d10 * 10 <= D)
		{
			if (d1 * d10 <= M)
			{
				ans += 1;
			}
			
			d1 += 1;

			if (d1 == 10)
			{
				d1 = 2;
				d10 += 1;
			}
		}
		
	}

	cout << ans << "\n";	
	
}

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

using namespace std;

int main()
{
    long long int n,k;
    cin>>n>>k;
    long long MOD=1000000007;
    long long int sum=0;
    long long int mini=0;
    long long int maks=0;
    while(k<=(n+1))
    {
        mini=k*(k-1)/2;
        maks=k*(2*n-k+1)/2;
        sum=(sum+(maks-mini+1))%MOD;
        mini=0;
        maks=0;
        k++;
    }
    cout<<sum<<endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        vi v(3);
        rep(i,3)cin>>v[i];
        sort(all(v));
        cout<<v[0]+v[1]<<endl;
}

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

int main() {
int64_t   a,s,ans;
int f;
	cin >>  a ;
double b;
 cin >>  b;
	if (a<10000){
	f=a;
	ans = a*b;
	    cout << ans << endl;
	}
	else{
	f=a%100;
	f=f*b;
	a=a/100;
	b=b*100;
	s=b;
	ans = a*s +f;
	     cout << ans << endl;
	}
}

Measured memory_bytes: 3716
import math
X= []

N,D = (int(a) for a in input().split())
for i in range(N) :
    x = list(map(int,input().split()))
    X.append(x)

f = 0
leng = 0

for i in range(N) :
    for j in range(i+1,N) : 
        for k in range(D):
            leng += (X[j][k] - X[i][k])**2
        ans = math.sqrt(leng)
        leng = 0
        if ans == int(ans) :
            f += 1
print(f)





Measured memory_bytes: 3064
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

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

		int[] l = new int[n+1];
		int[] r = new int[n+1];
		
		l[0] = 0;
		l[1] = a[0];
		r[n] = 0;
		r[n-1] = a[n-1];
		for(int i = 1;i < n;i++){
			l[i+1] = gcd(l[i],a[i]);
		}
		for(int i = n-2; i >= 0;i--){
			r[i] = gcd(a[i],r[i+1]);
		}
		
		
		int ans = Math.max(r[1], l[n-1]);
		for(int i = 0;i+1 < n;i++){
			ans = Math.max(ans,gcd(l[i],r[i+1]));
		}
		for(int i = n-1;i >= n;i--){
			ans = Math.max(ans,gcd(l[i],r[i-1]));
		}
		System.out.print(ans);
	}
	
	
	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	




static String deletestr(String base,String remove){
	boolean flag = true;
	for(int i = 0;i < remove.length();i++){
		if(i == base.length()){
			flag = false;
			break;
		}
		if(base.charAt(i) - remove.charAt(i) != 0 && base.charAt(i) - remove.charAt(i) != 32 &&remove.charAt(i) - base.charAt(i)  != 32){
			flag = false;
			break;
		}
	}

	if(flag){
		base = base.substring(remove.length());
	}

	return base;

}



}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 50396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    map<ll,int> m;
    while(n--){
        ll a;cin>>a;
        if(m[a]){cout<<"NO";return 0;}
        m[a]++;
    }
    cout<<"YES";
}

Measured memory_bytes: 12800
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    s = input()
    l = len(s)
    counter = Counter()
    ans = 1

    for i in range(l):
        char = s[i]
        ans += i - counter[char]
        counter[char] += 1

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    set<int> S, T;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        S.insert(a);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;
        T.insert(a);
    }
    set<int> isec;
    set_intersection(S.begin(), S.end(), T.begin(), T.end(), inserter(isec, isec.end()));
    cout << isec.size() << endl;
}


Measured memory_bytes: 10044
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
using namespace std;
const int INF = 1 << 30;
int main(){
	int n, k;
	while (cin >> n >> k, n) {
		vector<int> a(n);
		for (int &x : a)cin >> x;
		int pos = 0;
		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += a[i];
		}
		int max = sum;
		for (int i = 0; i < n - k; i++) {
			sum += a[i + k] - a[i];
			max = std::max(max, sum);
		}
		cout << max << endl;
	}
	return 0;
}

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

int main(){
 int n,x,a[2010],b[2010];
 cin>>n>>x;
 for(int i=0;i<n;i++) cin>>a[i];
 ll sum,ans=1e9*2000;
 for(int i=0;i<n;i++){
  sum=(ll)i*x;
  for(int j=0;j<n;j++){
   if(!i) b[j]=a[j];
   b[j]=min(b[j],a[(j-i+n)%n]);
   sum+=b[j];
  }
  ans=min(ans,sum);
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int t,h,m,s;
    cin >> t;
    h = t/3600;
    m = (t % 3600) / 60;
    s = (t % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
public class ABC124A {
    public static void Main() {
        int A, B;
        string[] str = System.Console.ReadLine().Split(' ');
        A = int.Parse(str[0]);
        B = int.Parse(str[1]);

        if (A >= B) {
            if (A - 1 >= B) System.Console.WriteLine(2 * A - 1);
            else System.Console.WriteLine(A + B);
        } else {
            if (B - 1 >= A) System.Console.WriteLine(2 * B - 1);
            else System.Console.WriteLine(A + B);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
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 d,g;
    cin>>d>>g;
    vector<vector<int>> vec(d);
    rep(i,d){
        int p,c;
        cin>>p>>c;
        rep(j,p) vec[i].push_back(100*(i+1));
        vec[i][p-1]+=c;
    }
    
    int ans=INF;
    for(int bit=0; bit<(1<<d); bit++){
        int score=0;
        int tmp=0;
        rep(i,d){
            if(bit&(1<<i)){
                rep(j,sz(vec[i])){
                    score+=vec[i][j];
                    tmp++;
                }
            }
        }
        rrep(i,d){
            if(!(bit&(1<<i))){
                rep(j,sz(vec[i])-1){
                    if(score>=g) break;
                    score+=vec[i][j];
                    tmp++;
                }
                break;
            }
        }
        if(score>=g) ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 1000006
#define INF 2e9
using namespace std;
int ara[MAX] , dp[MAX];

int main()
{
    int n , k;
    cin>>n >> k;
    for(int i =0 ; i < n ; i++ ) cin>>ara[i];

	for(int i =1 ; i < n ; i++ ) {

        int val = INF;
        for(int j = 1 ; j <= k ; j++ ) {

			if( i - j < 0 ) continue;
            val = min(val , abs(ara[i] - ara[i-j]) + dp[i-j] );
        }
        dp[i] = val;
	}
	cout<<dp[n-1]<<endl;
	return 0;

}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0;i<n;i++) cin >> v[i];
    sort(v.begin(),v.end());
    double ans = v[0];
    for (int i=1;i<n;i++) ans = (ans + v[i])/2;
    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9+7;

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  vector<ll> sum(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i-1] + a[i-1];
  }

  vector<ll> dp(n + 1, 0);
  for (int len = 1; len <= n; len++) {
    for (int i = 0; i <= n; i++) {
      int j = i + len;
      if (j > n) {
        dp[i] = 0;
      } else {
        dp[i] = max(
          a[i] + sum[j] - sum[i+1] - dp[i+1],
          a[j - 1] + sum[j-1] - sum[i] - dp[i]);
      }
    }
  }

  printf("%lld\n", 2 * dp[0] - sum[n]);
}


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

#define int long long int
#define endl "\n"

int32_t main(){
	int n, w;
	cin >> n >> w;

	vector<int> wt(n), val(n);

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

	vector<int> dp(sum_val+1, INT_MAX);
	dp[0] = 0;

	for(int i = 0 ; i < n ; i++){
		for(int j = sum_val; j >= val[i] ;j--){
			if(wt[i] + dp[j-val[i]] <= w)
				dp[j] = min(dp[j], wt[i] + dp[j-val[i]]);
		}
	}

	int ans = -1;

	for(int i = 1; i <= sum_val; i++){
		if(dp[i] > 0 && dp[i] <= w)
			ans = max(ans, i);
	}
	cout << ans << endl;

}

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)<<'\n';
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


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

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

	for(int n; cin >> n, n;) {
		int ans = 0;
		for(int i = 1; i < n; ++i) {
			int sum = i;
			for(int j = i + 1; sum < n; ++j) {
				sum += j;
				if(sum == n)
					++ans;
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(s.at(k-1) == 'A'){
        s.at(k-1) = 'a';
    } else if(s.at(k-1) == 'B'){
        s.at(k-1) = 'b';
    } else {
        s.at(k-1) = 'c';
    }
    cout << s;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int ar[n];
  for(int i = 0; i < n; i++) cin>>ar[i];
  sort(ar,ar+n);
  float ans = (ar[0] + ar[1])/2.0;
  for(int i = 2; i < n; i++) ans = (ans + ar[i])/2.0;
  
  cout<<ans<<"\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    //input
    int n; cin >> n;
    int sum = 0;
    vector<int> a(n + 1);
    for(int i = 1; i < n + 1; i++) cin >> a[i];
    a[0] = -100000;

    int av = 0;
    for(int i = 1; i < n + 1; i++) sum += a[i];
    av = sum / n;

    long goukei1 = 0;
    long goukei2 = 0;
    long goukei3 = 0;
    for(int i = 1; i < n + 1; i++) {
        goukei1 += (a[i] - av) * (a[i] - av) ;
        goukei2 += (a[i] - av - 1) * (a[i] - av - 1) ;
        goukei3 += (a[i] - av + 1) * (a[i] - av + 1) ;
    }  
    long m = min(min(goukei1,goukei2),goukei3);

    //output
    cout << m << endl;

}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <fstream>

#define For(i,a,b) for (int i=a;i<=b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define Rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define A first
#define B second
#define uint64 unsigned long long
#define int64 long long     //%lld
#define uint unsigned int   //%u
#define M 1000000           //10^6

using namespace std;
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
bool t[101][101],p[101][101];
int a[101][101];
int main()
{	
	int n,mh,mc;
	while(cin>>n)
	{
		if(n==0)break;
		else{
		for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
		cin>>a[i][j];
		t[i][j]=0;
		p[i][j]=0;
		}
		for(int i=0;i<n;i++)
		{	mh=0;
			for(int j=1;j<n;j++)
			{
				if(a[i][j]<a[i][mh])mh=j;
			}
			for(int j=0;j<n;j++)
			{
				if(a[i][j]==a[i][mh])t[i][j]=1;
			}
		}
		for(int i=0;i<n;i++)
		{	mc=0;
			for(int j=1;j<n;j++)
			{
				if(a[j][i]>a[mc][i])mc=j;
			}
			for(int j=0;j<n;j++)
			{
				if(a[j][i]==a[mc][i])p[j][i]=1;
			}
		}
		int kt=0;
		for(int i=0;i<n;i++)
		{
		if(kt==1)break;
		for(int j=0;j<n;j++)
		{
			if(t[i][j]==1&&p[i][j]==1){
			cout<<a[i][j]<<endl;
			kt=1;
			break;
			}
			//cout<<t[i][j]<<"  ";
		}
		//cout<<endl;
		}
		if(kt==0)cout<<0<<endl;
//		for(int i=0;i<n;i++)
//		{
//		for(int j=0;j<n;j++)
//		{
//			if(t[i][j]==1&&p[i][j]==1)cout<<a[i][j]<<endl;
//			cout<<p[i][j]<<"  ";
//		}
//		cout<<endl;
//		}
	}}
}

Measured memory_bytes: 1168
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <list>
#include <cmath>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m), y(m);
	for (int i = 0; i < m; ++i) {
		cin >> x.at(i) >> y.at(i);
	}
	map<int, int> kazu;
	map<int, bool> aka;
	for (int i = 1; i <= n; ++i) {
		kazu[i] = 1;
	}
	aka[1] = true;
	for (int i = 2; i <= n; ++i) {
		aka[i] = false;
	}
	for (int i = 0; i < m; ++i) {
		kazu[x.at(i)]--;
		kazu[y.at(i)]++;
		if (aka[x.at(i)]) {
			aka[y.at(i)] = true;
			if (kazu[x.at(i)] == 0) {
				aka[x.at(i)] = false;
			}
		}
	}
	int count = 0;
	for (int i = 1; i <= n; ++i) {
		if (aka.at(i)) {
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>

int main(){
	int x, y, z;

	while (1){
		scanf("%d %d", &x, &y);
		if (x == 0&& y== 0){
			break;
		}
		else if (x >y){
			z = y;
			y= x;
			x = z;
		}
		printf("%d %d\n", x, y);

	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

string s;
cin >> s;

if(s == "AAA" || s == "BBB") cout << "No" << endl;
else cout << "Yes" << endl;
return 0;
}

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

using namespace std;

typedef long long ll;

vector<int> prime;
int n;
int z[10000];

bool is_prime(int x) {
  if(x < 2) return false;
  int y = sqrt(x);
  for (int i = 0; i < prime.size(); i++) {
    if(y < prime[i] || x == prime[i]) return true;
    if(x % prime[i] == 0) return false;
  }
  return true;
}

void solve() {
  prime.push_back(2);
  for (int i = 3; i < 10000; i += 2) {
    if(is_prime(i)) prime.push_back(i);
  }

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

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

  solve();
}

Measured memory_bytes: 3180
# coding: utf-8
# Your code here!
x = int(input())
if 400<= x <=599:
    print(8)
elif 600 <= x <=799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 9172
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;


int main() {
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d;
	cin >> n;

	cout << (n / 2) * min(8 * q, min(4 * h, min(2 * s, d))) + (n % 2) * min(4 * q, min(2 * h, s)) << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789
#define endl "\n"

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
/*
template <typename... Args>
void dbg(Args... args) {
    ((cout << args << " "), ...);
    cout << "\n";
}
*/
//--------------------------------------------------//
int n, m;
string a, b;
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int main() {
    use_cio();
    cin >> n >> m >> a >> b;
    int g = gcd(n, m);
    int nn = n / g, mm = m / g;
    rep(i, g) {
        if (a[i * nn] != b[i * mm]) {
            cout << "-1\n";
            return 0;
        }
    }
    cout << 1LL * m * n / g << endl;
    return 0;
}


Measured memory_bytes: 640
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  string s;
  string left = "qwertasdfgzxcvb", right = "yuiophjklnm";
  while (cin>>s, s!="#") {
    // 0: left, 1: right
    int ans = -1, side = -1;
    for (int i = 0; i < s.length(); i++) {
      for (int j = 0; j < left.length(); j++) {
        if (left[j] == s[i]) {
          if (side != 0) {
            ans++;
            side = 0;
          }
          break;
        }
      }
      for (int j = 0; j < right.length(); j++) {
        if (right[j] == s[i]) {
          if (side != 1) {
            ans++;
            side = 1;
          }
          break;
        }
      }
    }
    cout << ans << endl;
  }
}




Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N,H,W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}


Measured memory_bytes: 256
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
//const long long INF = 1LL << 60;
const int INF = 1e9;
using ll = long long;

int main()
{
    int x = 0;
    std::cin >> x;

    if( x == 0 )
    {
        std::cout << 1;
    }
    else
    {
        std::cout << 0;
    }
    
    
    return 0;
}

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

int main(){

    string s;

    cin >> s;

    if(s.at(s.size()-1) == 's'){
        s = s + "es";
    }else{
        s = s + "s";
    }
    cout << s <<endl;

    return 0;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,sum,sub,mul;
  cin>>a>>b;
  sum=a+b;
  sub=a-b;
  mul=a*b;
  
  int ans = max(sum,max(sub,mul));
  
  if(ans==0)
  cout<<0<<endl;
  else
  cout<<ans<<endl;
}

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

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int max = a[0], min = a[0];
			for (int i = 1; i < n; i++) {
				max = Math.Max(max, a[i]);
				min = Math.Min(min, a[i]);
			}
			Console.WriteLine(max - min);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
/*-----------------------------------
                -----------MEHEDI HASAN--------------
                -----CSE,JAHANGIRNAGAR UNIVERSITY----
                -----------------------------------*/
//--------------------------------------------------------------------//
#include<bits/stdc++.h>
#include <cassert>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
//--------------------------------------------------------------------//
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define ccc(x)      cout<<x<<" ";
#define ccp(x)      cout<<#x<<"="<<"("<<x.ff<<" "<<x.ss<<") ";
#define CC(x)       for(auto xx: x) cout<<xx<<" ";
#define CCp(x)      for(auto xx: x) cout<<"("<<xx.ff<<" "<<xx.ss<<") ";
#define ee          cout<<"\n";
#define OK          cout<<"Ok"<<"\n";
//--------------------------------------------------------------------//
#define ff          first
#define ss          second
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define ps          push
#define psb         push_back
#define psf         push_front
#define pp          pop
#define ppb         pop_back
#define ppf         pop_front
#define all(x)      x.begin(),x.end()
#define TESTS       int t;cin>>t;for(int tcase=1;tcase<=t;tcase++)
#define ordered_set tree< int, null_type, less_equal< int >, rb_tree_tag, tree_order_statistics_node_update>
//--------------------------------------------------------------------//
#define MAX (int)(3e6)
#define MOD (ll)(1e9+7)


int main()
{
    FAST
    int k,n;
    cin>>k>>n;vector <int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    int mn=INT_MAX;
    for(int i=1;i<n;i++)
    {
        mn=min(k-v[i]+v[i-1],mn);
    }
    cout<<min(v[n-1]-v[0],mn)<<endl;
    return 0;
}
//--------------------------------------------------------------------//
/*
>Check Corner Cases (n==1 or T==1)
>Overflow issues?
>LB / UB !!not found!! check?
*/
//--------------------------------------------------------------------//
/* ---INPUT---
--------(1)------
2
1 2 4

-------(2)-------


-------(3)-------
4
1 2 2
1 3 4
3 4 5

-------(4)-------



--------------
*/
//--------------------------------------------------------------------//


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

ll fact[2000010], inv[2000010], mod = 1e9 + 7;

ll fexpo(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = (ret*x)%mod;
        y/=2;
        x = (x*x)%mod;
    }
    return ret;
}

void fac(){
    fact[0] = 1;
    for(ll i = 1; i < 2000010; i++) fact[i] = i*fact[i-1]%mod;
    inv[2000009] = fexpo(fact[2000009], mod - 2);
    for(ll i = 2000008; i >= 0; i--) inv[i] = (i+1)*inv[i+1]%mod;
}

ll ncr(ll x, ll y){
    if(y > x) return 0;
    ll cnt = fact[x]*inv[x-y]%mod*inv[y]%mod;
    return cnt;
}

void solve(){
    ll k, n;
    string s;
    cin >> k >> s;
    n = s.length();
    ll cnt = 0;
    for(ll i = 0; i <= k; i++) {
        cnt += fexpo(26, i)*fexpo(25, k - i)%mod*ncr(k - i + n - 1, n-1)%mod;
    }
    cout<< cnt%mod << endl;
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fac();
  //int t;cin>>t;while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 35476
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

sat = 0
for a,b in zip(A,A[1:]):
  if b == a+1:
    sat += C[a-1]
    
print( sum(B) + sat )

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


int main() {
    string s,t,u;
    int a,b;
    cin >>s>>t>>a>>b>>u;
    s==u ? a--:b--;
    cout << a<<" "<<b <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<ll> divisors(ll n) {
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    return v;
}

map<ll, ll> prime_factorization(ll n) {
    map<ll, ll> m;
    ll x = n;
    ll d = 2;
    while (x > 1 && d * d <= n) {
        if (x % d == 0) {
            m[d]++;
            x /= d;
        } else {
            d++;
        }
    }
    if (x != 1) m[x]++;
    return m;
}

void solve() {
    ll n;
    cin >> n;
    if (n == 1) {
        cout << 0 << endl;
        return;
    }
    auto f = prime_factorization(n);
    //for (auto p : f) cout << p.first << ": " << p.second << endl;
    ll ans = 0;
    for (auto p : f) {
        ll q = p.second;
        ll c = 1;
        while (q >= c) {
            ans++;
            q -= c;
            c++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int res[100001];
vector<int> col[100001];
int sum[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int p;
		scanf("%d",&p);
		col[p-1].push_back(i);
	}
	for(int i=0;i<n;i++){
		sum[i]=-1;
	}
	int mini=0;
	for(int i=0;i<n;i++){
		sum[i]+=col[i].size();
		if(i>0)sum[i]+=sum[i-1];
		if(sum[i]<sum[mini])mini=i;
	}
	stack<int> sta;
	for(int i=0;i<n;i++){
		mini=(mini+1)%n;
		if(col[mini].size()>0){
			res[mini]=col[mini][0];
			int N=col[mini].size();
			for(int i=N-1;i>=1;i--){
				sta.push(col[mini][i]);
			}
		}else{
			int v=sta.top();
			res[mini]=v;
			sta.pop();
		}
	}
	for(int i=0;i<n;i++){
		printf("%d\n",res[i]+1);
	}
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll x,t;cin >>x>>t;
   x-=t;
   cout <<max(x,0LL)<<endl;
    return 0;
}

Measured memory_bytes: 256