akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){/*os<<"{"*/;for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?" ":"");/*os<<"}"*/;return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;
set<int> tri;
vi t(1,0);
vector<vi> vecs;

void create(int index){
    if(t[index]==n) return;
    vi tmp;
    int j=0;
    for(int i=t[index]+1;i<=t[index+1];i++,j++){
        vecs[j].pb(i);
        tmp.pb(i);
    }
    //show(j);
    vecs[j]=tmp;
    return create(index+1);
}

signed main(){
    io();

    REP(i,1,1e5){
        if(i*(i+1)/2>1e5) break;
        tri.insert(i*(i+1)/2);
        t.pb(i*(i+1)/2);
    }
    vecs.resize(tri.size()+10);
    in(n);
    if(tri.find(n)==tri.end()){
        no;
        return 0;
    }
    yes;
    int sz;
    create(0);
    rep(i,tri.size()+10){
        if(vecs[i].size()==0){
            sz=i;
            out(i);
            break;
        }
    }
    rep(i,sz){
        out(vecs[i].size(),vecs[i]);
    }

    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n,s;
vll a;

lli sum = 0;
lli ans;

int main(){
    cin >> n >> s;
    a = vll(n);
    ans = n+1;
    for(lli i = 0;i < n;i++) cin >> a[i];
    for(lli i = 0,j = 0;i < n;){
        while(i < n && sum < s) sum += a[i++];
        if(i == n && sum < s) break;
        while(j < n && sum >= s) sum -= a[j++];
        ans = min(ans,i-j+1);
    }
    cout << (ans == n+1 ? 0 : ans) << endl;
    return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> list(n);
    for(int i;i<n;i++) cin>>list[i];
    vector<int> rev(n);
    for(int i=0;i<n;i++) rev[list[i]-1]=i+1;
    for(int i=0;i<n;i++){
        if(i>0) cout<<" ";
        cout<<rev[i];
    }
    cout<<endl;
}

Measured memory_bytes: 1536
k,n = map(int,input().split())
A = list(map(int,input().split()))
A.append(A[0]+k)
B = [0 for i in range(n)]
for j in range(n):
    B[j] = A[j+1] - A[j]
#print(A)
#print(B)
B.sort()
B.pop()
#print(B)
ans = sum(B)
print(ans)

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

int main(){
  
  int N, K;
  long long Sum = 0;
  cin >> N >> K;

  for (long long i = K; i <= N + 1; i++){
    
    Sum += i * ((2 * N - i + 1)/2 - (0 + i - 1) /2) + 1;
  }
  
  Sum = Sum % 1000000007LL;
  cout << Sum << endl;
}




Measured memory_bytes: 3636
'use strict'

function main(input) {
    const args = input.split('\n');
    const A = args[0].split(' ');
    const gyou = parseInt(A[0], 10);
    const retu = parseInt(A[1], 10);

    const B = args[1].split(' ');
    const selectG = parseInt(B[0], 10);
    const selectR = parseInt(B[1], 10);

    const all = gyou * retu;
    const kuro = selectG * retu + selectR * gyou - selectG * selectR;

    console.log(all - kuro);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import sys
input = sys.stdin.readline
import math
def print_ans(H, A):
    """Test Case
    >>> print_ans(10, 4)
    3
    >>> print_ans(1, 10000)
    1
    >>> print_ans(10000, 1)
    10000
    """
    print(math.ceil(H / A))


if __name__ == '__main__':
    H, A = map(int, input().rstrip().split())
    print_ans(H, A)




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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;

  if(e - a > k){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }
}

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

int top, S[100];
 
void push(int x){
	top++;
	S[top]=x;
}
 
int pop(){
	top--;
	return S[top+1];
}
 
int main(void){
	int a, b, i, count;
	char s[100];
	top=0;
	
	count = 0;
	
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			b=pop();
			a=pop();
			push(a+b);
			count--;
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
			count--;
		}else if(s[0]=='*'){
			b=pop();
			a=pop();
			push(a*b);
			count--;
		}else{
			push(atoi(s));
			count++;
		}
	}
	
	/*for(i=0;i<count;i++){
		printf("%d\n", S[i]);
	}
	*/
	printf("%d\n",pop());
	
	return 0;
}

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

int test(int h,int w,int ans,int x,int y){
  int a[3];
  a[0]=x*w;
  a[1]=(h-x)*(w/2);
  a[2]=(h-x)*(w-(w/2));
  sort(a,a+3);
  if((a[2]-a[0])<ans){
    ans=a[2]-a[0];
  }

  a[0]=(x+1)*w;
  a[1]=(h-x-1)*(w/2);
  a[2]=(h-x-1)*(w-(w/2));
  sort(a,a+3);
  if((a[2]-a[0])<ans){
    ans=a[2]-a[0];
  }

  return ans;
}


main(){
  int h,w;
  int ans=10000000;
  cin >> h >> w;

  if(h%3==0 || w%3==0){
    cout << 0 <<endl;
  }else{
    if(h<w){
      ans=h;
    }else{
      ans=w;
    }

    ans=test(h,w,ans,h/3,w/3);
    ans=test(w,h,ans,w/3,h/3);

    cout << ans <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int a[26];
int main() {
  string s; cin >> s;
  for(char c : s) a[c-'a'] = 1;
  REP(i,26) {
    if (a[i] == 0) { cout << char('a'+i) << endl; return 0; }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   string s;
   cin >> n >> s;
   int ans=0;
   for (int i=0;i < 1000;i++){
      string tmp;
      tmp=to_string(i);
      if (i < 10) tmp="00"+tmp;
      else if (i < 100) tmp="0"+tmp;
      int pos=-1;
      rep(j,3){
         bool f=false;
         for (int q=pos+1;q < n;q++){
            if(tmp[j]==s[q]){
               f=true;
               pos=q;
               break;
            }
         }
         if (f && j==2) {
            ans++;
            //printf("tmp %s\n",tmp.c_str());
         }
         if (f) continue;
         else break;
      }  
   }
   cout << ans << endl;


   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,li=1,ri;
	cin>>n;
	vector<int>vec(n+10);
	for(int i=0;i<n;i++){
		cin>>vec.at(i);
	}
	for(int i=0;i<n;i++){
		ri=vec.at(li-1);
		li=ri;
		//cout<<li<<" ";
		if(li==2){
			cout<<i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}


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

int n;

int d[4][61];

int main(void)
{
	

		for(int i = 0; i <= 9; i++)
			d[0][i]++;
		for(int i = 0; i < 3; i++){
			for(int j = 0; j <= 9; j++){
				for(int k = 0; k <= 9*(i+2); k++){
					d[i+1][k+j] += d[i][k];
				}
			}
		}


	while(cin >> n, !cin.eof()){

		cout << d[3][n] << endl;
	}


	return 0;
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll X, Y, Z;

  void init() {
    scanf("%lld %lld %lld", &X, &Y, &Z);
  }

  void solve() {
    swap(X, Y);
    swap(X, Z);
    printf("%lld %lld %lld\n", X, Y, Z);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){
	int N;
	scanf("%d",&N);
	int S[N];
	for(int i = 0; i < N; i++) {
    scanf("%d",&S[i]);
  }
	int M;
  cin >> M;
	int Q[M];
	for(int i = 0; i < M; i++)scanf("%d",&Q[i]);
	sort(Q,Q+M);
	int left = 0,right,m,count = 0;
	for (int i = 0; i < M; i++){
		right = N-1;
		m = (left+right)/2;

		while (left <= right){
			if (S[m] == Q[i]) {
				count++;
				left= m+1;
				break;
			} else if(S[m] > Q[i]) {
				right = m-1;
			} else {
				left = m+1;
			}
			m = (left+right)/2;
		}
	}
  cout << count << endl;
}



Measured memory_bytes: 3800
n=int(input())
a=list(map(int,input().split()))
all=0
mx=0
for i in range(len(a)):
	x=int(a[i])
	if x>mx: 
		mx=x
	all=all+x
if all>2*mx : 
	print("Yes")
else : 
	print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int a,b,c,d,e;
	
	scanf("%d",&a);
	if(a<40){
		a=40;
	}
	scanf("%d",&b);
	if(b<40){
		b=40;
	}
	scanf("%d",&c);
	if(c<40){
		c=40;
	}
	scanf("%d",&d);
	if(d<40){
		d=40;
	}
	scanf("%d",&e);
	if(e<40){
		e=40;
	}
	printf("%d\n",(a+b+c+d+e)/5);
	return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,p[100010];
pair<int,int>a[100010],b[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i].first),a[i].second=i;
	for(int i=1;i<=n;++i)scanf("%d",&b[i].first),b[i].second=i;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	for(int i=1;i<=n;++i)if(a[i].first>b[i].first)return printf("No"),0;
	for(int i=1;i<n;++i)if(a[i+1].first<=b[i].first)return printf("Yes"),0;
	for(int i=1;i<=n;++i)p[a[i].second]=b[i].second;
	int cnt=0,x=1;
	do
	{
		++cnt;
		x=p[x];
	}while(x!=1);
	if(cnt==n)printf("No");
	else printf("Yes");
	return 0;
}


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

using namespace std;

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

int main(void){
	int i;

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

	string s;
	cin >> s;
	int n=s.size();
	if(n==1){
		cout << 0 << endl;
		return 0;
	}

	int ans=0;
	char c=s[0];
	for(i=1;i<n;i++){
		if(s[i]==c){
			c=s[i];
		}else{
			c=s[i];
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
	ll n,k; cin >> n >> k;
	ll ans = 0;
	while(n != 0){
	n /= k;
	ans++;
}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MAX =101010;
const int MOD = 1e9 +7;

vector<int> G[MAX],H[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];
int s,t,M,dp[MAX]={},ans=0;


void bfs(int s){
    queue<int> q;
    q.push(s);
    V[s]=true;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        out.push_back(u);
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            indeg[v]--;
            if(indeg[v]==0 && !V[v]){
                V[v]=true;
                q.push(v);
                // dp[v]=max(dp[v],dp[u]+1);
                // ans=max(ans,dp[v]);
            }
        }
    }
}

void  tsort(){
    for(int i=0;i<N;i++){
        indeg[i]=0;
    }
    for(int u=0;u<N;u++){
        for(int i=0;i<G[u].size();i++){
            int v= G[u][i];
            indeg[v]++;
        }
    }
    for(int u=0;u<N;u++){
        if(indeg[u]==0 && !V[u]) bfs(u);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N>>M;
    rep(i,N) V[i]=false;
    rep(i,M){
        cin>>s>>t;
        s--;t--;
        G[s].pb(t);
        H[t].pb(s);
    }
    tsort();
    for(int i:out){
        for(int j:H[i]){
            dp[i]=max(dp[i],dp[j]+1);
        }
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    
    return 0;
}

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

using namespace std;


int main() {
	while( true ) {
		string S;
		cin >> S;
		if( S == "#" ) {
			break;
		}
		vector<string>VS( 1 );
		for( size_t i = 0; i < S.length(); i++ ) {
			if( S[i] == '/' ) {
				VS.push_back( "" );
			} else if( S[i] == 'b' ) {
				VS[VS.size() - 1].push_back( 'b' );
			} else {
				for( size_t j = 0; j < S[i] - '0'; j++ ) {
					VS[VS.size() - 1].push_back( '.' );
				}
			}
		}
		long long int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--; c--; d--;
		VS[a][b] = '.';
		VS[c][d] = 'b';
		for( size_t i = 0; i < VS.size(); i++ ) {
			int count = 0;
			for( size_t j = 0; j < VS[i].size(); j++ ) {
				if( VS[i][j] == 'b' ) {
					if( count ) {
						cout << count;
						count = 0;
					}
					cout << "b";
				} else {
					count++;
				}
			}
			if( count ) {
				cout << count;
			}
			if( i == VS.size() - 1 ) {
				cout << endl;
			} else {
				cout << "/";
			}
		}
	}
}

Measured memory_bytes: 3228
n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(8):
    tmp = [0, 0, 0]
    for j in range(3):
        if i & (1 << j):
            tmp[j] = 1
    S = []
    for item in xyz:
        val = item[:]
        for j in range(3):
            if tmp[j]:
                val[j] *= -1
        S.append(sum(val))
    S.sort(reverse=True)
    ans = max(ans, sum(S[:m]))

print(ans)




Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int GetDigit(long long int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main() {

  int N;
  int count=0;

  cin >>N;
  long long int A[N];
  long long int ans=1;
  

  for (int i = 0; i <N ; i++) {
   cin>>A[i];
    if(A[i]==0){
      count=1;
    }
  }
  if(count==1){
   cout << 0 << endl;
  }
  else{
    for (int i = 0; i <N ; i++) {
      if(log10(A[i])+log10(ans)>18){
        count=2;
        break;
      }
      else{
      ans=ans*A[i];
      if(ans>1000000000000000000){
        count=2;
        break;
      }
      }
        
    }//for
    if(count==2){
      cout << -1<<endl;
    }
    if(count==0){
     cout <<std::setprecision(19)<< ans <<endl; 
    }
    
  }
 return 0;
}


Measured memory_bytes: 4684
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef long double ld;

void faster(){
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
	cout.tie(NULL);
}

const int MAXN = 5e1 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll n, pref, ans;
map<ll, int> cnt;

int main(){
	faster();

	cin >> n;
	pref = 0;
	cnt[pref]++;
	for(int i = 0, x; i < n; ++i){
		cin >> x;
		pref += x;
		ans += cnt[pref];
		cnt[pref]++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#define N 3005
int main(){
	int i,j,k,n,sum,a[3005];
	while(scanf("%d",&n)!=EOF){
        sum=0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
			sum+=a[i]-1;
		}	
		printf("%d\n",sum);
    }
	return 0;
}

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

int main(){
  string s; cin >> s;
  vector<bool> alp(26, 0);
  for(int i = 0; i < s.size(); i++){
    char c = s[i];
    int t = c - 'a';
    alp[t] = 1;
  }
  char ans = 0;
  for(int i = 0; i < 26; i++){
    if(!alp[i]) {
      ans = 'a' + i;
      break;
    }
  }
  if(ans == 0)  cout << "None";
  else  cout << ans;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
   
int n[26] = {0};
char m[1300];
int i, z;
   
while(1){
   
if(scanf("%s",&m) == EOF)
break;
   
for(i = 0; i < strlen(m); i++){
   
if('a' <= m[i] && m[i] <= 'z')
n[ m[i] - 'a']++;
   
if('A' <= m[i] && m[i] <= 'Z')
n[ m[i] - 'A']++;

}
}
   
for(i = 0; i < 26; i++){
z = i + 'a';
printf("%c : %d\n", z, n[i]);
}
   
return 0;
}

Measured memory_bytes: 540
#与えられる数列の中で、最大値と最小値のペアを返す

length = int(input())
List = [int(input()) for i in range(length)]

minimum = List[0]
maximum = List[1] - List[0]

for j in range(1,length):
    maximum = max(maximum, List[j]-minimum)
    minimum = min(minimum, List[j])

print(maximum)


Measured memory_bytes: 13596
''' ===============================
    -- @uthor : Kaleab Asfaw
    -- Handle : kaleabasfaw2010
    -- Bio    : High-School Student 
    ==============================='''

# Fast IO
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file): self._fd = file.fileno(); self.buffer = BytesIO(); self.writable = "x" in file.mode or "r" not in file.mode; self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b: break
            ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0; return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)); self.newlines = b.count(b"\n") + (not b); ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1; return self.buffer.readline()
    def flush(self):
        if self.writable: os.write(self._fd, self.buffer.getvalue()); self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file): self.buffer = FastIO(file); self.flush = self.buffer.flush; self.writable = self.buffer.writable; self.write = lambda s: self.buffer.write(s.encode("ascii")); self.read = lambda: self.buffer.read().decode("ascii"); self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout); input = lambda: sys.stdin.readline().rstrip("\r\n")
# Others
# from math import floor, ceil, gcd
# from decimal import Decimal as d
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n, k, lst):
	dp = [0] * n
	dp[1] = abs(lst[1] - lst[0])

	for i in range(2, n):
		minn = float("inf")
		for x in range(1, k+1):
			if i-x >= 0:
 				minn = min(minn, dp[i-x] + abs(lst[i] - lst[i-x]))
		dp[i] = minn
	return dp[n-1]

n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
print(solve(n, k, lst))

Measured memory_bytes: 86660
let solve n w d =
  let t = Array.make (w + 1) 0 in
  let rec doit = function
    | (i, _) when i = n -> Array.fold_left max 0 t
    | (i, x) when x + (snd d.(i)) > w -> doit (i + 1, 0)
    | (i, x) ->
      let (vi, wi) = d.(i) in
      t.(x+wi) <- max t.(x+wi) (t.(x) + vi);
      doit (i, x + 1) in
  doit (0, 0)

let read () = Scanf.scanf "%d %d\n" (fun x y -> (x, y))

let () =
  let (n, w) = read () in
  let d = Array.init n (fun _ -> read ()) in
  Printf.printf "%d\n" (solve n w d)

Measured memory_bytes: 2468
import Data.List
toInt::String->Int
toInt = read
rPolish::[Int]->[String]->Int
rPolish [x] [] = x
rPolish (x1:x2:xs) ("+":ys) = rPolish (x2+x1:xs) ys
rPolish (x1:x2:xs) ("-":ys) = rPolish (x2-x1:xs) ys
rPolish (x1:x2:xs) ("*":ys) = rPolish (x2*x1:xs) ys
rPolish xs (y:ys) = rPolish (toInt y:xs) ys
main = do
  getLine >>= print.(rPolish []).words



Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  cin >> s;
  for (int i = 0;i<3;i++)
  {
  if(s.at(i)=='9')
  s.at(i)='1';
  else
  s.at(i)='9';
  }
cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define PB push_back
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;
 
constexpr int INF = 1LL<<60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 11;
constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};
 
int fld[MAX_N][MAX_N], w, h, sx, sy, idx;
int hoge;
 
int Solve(int x, int y, int mask) {
    if (x == sx && y == sy) {
        if (mask) return 0;
        return 1;
    }
 
    int res = 0;
    for (int i = 0; i < 4; ++i) {
        int tx = x, ty = y;
        while (0 < tx && 0 < ty && tx <= w && ty <= h) {
            tx += dx[i];
            ty += dy[i];
            if (sx == tx && sy == ty) res += Solve(tx, ty, mask);
 
            int num = fld[tx][ty];
            if (num == -1) continue;
            if (mask & (1 << num)) {
                res += Solve(tx, ty, mask - (1 << num));
                break;
            }
        }
    }
 
    return res;
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    while (cin >> w >> h, w) {
        memset(fld, -1, sizeof(fld));
        idx = 0;
 
        for (int y = 1; y <= h; ++y) {
            for (int x = 1; x <= w; ++x) {
                int t;
                cin >> t;
                if (t == 0) continue;
                if (t == 2) {
                    sx = x;
                    sy = y;
                    continue;
                } else t = idx++;
                fld[x][y] = t;
            }
        }
        
        int ans = 0;
        for (int i = 0; i < 4; ++i) {
            int tx = sx, ty = sy;
            while (0 < tx && tx <= w && 0 < ty && ty <= h) {
                tx += dx[i];
                ty += dy[i];
                if (fld[tx][ty] == -1) continue;
                ans += Solve(tx, ty, (1 << idx) - 1 - (1 << fld[tx][ty]));
                break;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

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

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

ll solve(vector<ll> Cost, vector<ll> Weights, ll sz) {
    auto dp = make_v(4, sz + 1, 0LL);
    REP(i, 0, 3) {
        for (int j = sz; j >= 0; j--) {
            if (j >= Cost[i]) {
                chmax(dp[i][j - Cost[i]], dp[i][j] + Weights[i]);
            }
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    ll ans = 0;
    REP(i, 0, sz + 1) {
        chmax(ans, i + dp[3][i]);
    }
    dump(ans);
    return ans;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> A(3), B(3);
    REP(i, 0, 3) {
        cin >> A[i];
    }
    REP(i, 0, 3) {
        cin >> B[i];
    }

    n = solve(A, B, n);
    n = solve(B, A, n);
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 976996
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	b := make([]int, n)
	for i := n - 1; i >= 0; i-- {
		b[i] = iScan()
	}
	l, r := -1, -1
	for i := 0; i < n; i++ {
		if a[i] == b[i] {
			if l == -1 {
				l = i
			}
			r = i + 1
		}
	}
	if l == r {
		fmt.Println("Yes")
		iSSPrint(b)
	} else {
		idx := 0
		for i := l; i < r; i++ {
			for idx < n {
				if b[i] != a[idx] && a[i] != b[idx] {
					b[i], b[idx] = b[idx], b[i]
					idx++
					break
				} else {
					idx++
				}
			}
		}
		f := true
		for i := 0; i < n; i++ {
			if a[i] == b[i] {
				f = false
			}
		}
		if f {
			fmt.Println("Yes")
			iSSPrint(b)
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 13896
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int n;
  cin>>n;
  int a[2][n];
  int i,sum[n]={},usum[n]={},ans[n]={};
  for(i=0;i<n;i++){
    cin>>a[0][i];
    if(i==0) sum[i]=a[0][i];
    else sum[i]=sum[i-1]+a[0][i];
  }
  for(i=0;i<n;i++){
    cin>>a[1][i];
  }
  for(i=0;i<n;i++){
    if(i==0) usum[i]=a[1][n-1-i];
    else usum[i]=usum[i-1]+a[1][n-1-i];
  }
  for(i=0;i<n;i++){
    ans[i]=sum[i]+usum[n-1-i];
  }
  sort(ans,ans+n);
  cout<<ans[n-1];
  
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	ll ans = 0;
	ll n;
	cin >> n;

	cout << ((n % 2 == 0) ? n : n * 2) << endl;
}

Measured memory_bytes: 3568
import java.math.*;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    List<Integer>[] lists = new ArrayList[n];
    int cnt = 0;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        for (int i=0; i<n; i++) lists[i] = new ArrayList<>();

        for (int i=0; i<m; i++) {
            int s = sc.nextInt() - 1;
            int t = sc.nextInt() - 1;
            lists[s].add(t);
            lists[t].add(s);
        }

        String str = "0";
        for (int i=1; i<n; i++) str += i;
//        System.out.print(str);

        permutation(str, "");

        System.out.print(cnt);

    }

    void permutation(String s, String res) {
        if (s.length() <= 1) {
//            System.out.println(res + s);
            String tmp = res + s;
            if (tmp.charAt(0) == '0') {
                boolean f = true;
                for (int i=0; i<n-1; i++) {
                    int now = Integer.parseInt(tmp.substring(i, i+1));
                    int next = Integer.parseInt(tmp.substring(i+1, i+2));
//                    System.out.print(now);
                    if (!lists[now].contains(next)) {
                        f = false;
                        break;
                    }
                }
                if (f) cnt++;
            }
        } else {
            for (int i=0; i<s.length(); i++) {
                permutation(s.substring(0, i) + s.substring(i+1), res + s.charAt(i));
            }
        }
    }

}



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

int main()
{
    int N;
    cin >> N;
    int res = 0;
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        res += r-l+1;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
using namespace std;
int n,m;
void work (void)
{
	int i,t;
	t=1;
	for (i=1;i<=n;i++)
	if (t<=m)
	t*=2;
else t+=m;
    cout<<t;
}
int main (void)
{
	cin>>n;
	cin>>m;
	work ();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;


template<int Modulus> 
struct ModInt {
    long long x;
    ModInt(long long x = 0) :x((x%Modulus + Modulus)%Modulus) {}
    constexpr ModInt &operator+=(const ModInt a) {if ((x += a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator-=(const ModInt a) {if ((x += Modulus - a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator*=(const ModInt a) {(x *= a.x) %= Modulus; return *this;}
    constexpr ModInt &operator/=(const ModInt a) {return *this *= a.inverse();}

    constexpr ModInt operator+(const ModInt a) const {return ModInt(*this) += a.x;}
    constexpr ModInt operator-(const ModInt a) const {return ModInt(*this) -= a.x;}
    constexpr ModInt operator*(const ModInt a) const {return ModInt(*this) *= a.x;}
    constexpr ModInt operator/(const ModInt a) const {return ModInt(*this) /= a.x;}
    
    friend constexpr ostream& operator<<(ostream& os,const ModInt<Modulus>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<Modulus>& a) {return is >> a.x;}
    
    ModInt inverse() const {// x ^ (-1) 
        long long a = x,b = Modulus,p = 1,q = 0;
        while (b) {long long d = a/b; a -= d*b; swap(a,b); p -= d*q; swap(p,q);}
        return ModInt(p);
    }
    ModInt pow(long long N) {// x ^ N 
        ModInt a = 1;
        while (N) {
            if (N&1) a *= *this;
            *this *= *this;
            N >>= 1;
        }
        return a;
    }
};

using mint = ModInt<1000000007>;

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

    int s; cin >> s;
    int M = s/3 + 10;
    vector<vector<mint>> dp(M + 1,vector<mint>(s + 1,0));
    rep(i,s + 1) dp[0][i] = 1;
    mint ans = 0;
    rep(i,M) {
        rep(j,s + 1) {
            if (j > 0) dp[i + 1][j] = dp[i + 1][j - 1];
            if (j >= 3) dp[i + 1][j] += dp[i][j - 3];
        }
        ans += dp[i + 1][s] - dp[i + 1][s - 1];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 13660
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x = a+b;
    ll y = c+d;
    if(x>y)
    {
        cout<<"Left";
    }
    else if(x<y)
    {
        cout<<"Right";
    }
    else
    {
        cout<<"Balanced";
    }
}



Measured memory_bytes: 256
#N本のりんごの木、D人の監視
N,D = map(int,input().split())

#監視員の目の範囲(自分がいるマスと左右D分)
me = 2 * D + 1

#答え
ans = 0

while True:
    ans += 1
    N = N - me
    if N <= 0:
        break

print(ans)


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<functional>

int main(){

    std::string s, p;
    std::cin >> s >> p;

    s += s;

    if(s.find(p) != std::string::npos){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }

lli dp[100];

int main(){
    // cout << fixed << setprecision(5);

    dp[0]=1000;
    lli n;
    cin>>n;
    vector<lli> a(n);
    REP(i,0,n)cin>>a[i];

    REP(i,0,n){
        REP(j,i+1,n){
            dp[j]=dp[i];
            lli money = dp[i];
            lli kabu = money/a[i];
            lli nowMoney = money%a[i]+kabu*a[j];
            chmax(dp[j],nowMoney);
        }
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9+7);
const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

const int MAX_N = 112345;
int r[MAX_N];
int a[MAX_N];

int main2() {
  CLR(a, 0);
  CLR(r, 0);

  int N = nextInt() + 1;
  int A = 0, B = 0, C = 0;
  REP(i, N) { 
    a[i] = nextInt();
    if (r[a[i]] != 0) {
      A = r[a[i]] - 1;
      C = N - 1 - i;
      B = N - 2 - A - C;
    }
    r[a[i]] = i+1;
  }
  // pv(a, a+N);
  // pv(r, r+N);
  // cout << A << " " << B << " " << C << endl;

  vector<ll> ans;
  for (int k = 1; k <= N; k++) {
    if (k == 1) {
      ans.push_back(N-1);
    } else {
      ll res = choose(N, k);
      res -= choose(A+C, k-1);
      res = (res % MOD + MOD) % MOD;
      ans.push_back(res);
    }

  }

  REP(i, ans.size()) printf("%d\n", (int)ans[i]);
  return 0;
}

int main() {
  
  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main()
{
	int ar[110];
	int n;
	std:: cin >> n;
	for (int i = 0; i < n; i++)std::cin >> ar[i];
	std::sort(ar, ar + n);
	cout << abs(ar[0] - ar[n - 1]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll sum[510][510];
int main(){
	ll n,m,q;
	cin>>n>>m>>q;
	while(m--){
		ll l,r;
		cin>>l>>r;
		sum[l][r]++;
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)sum[i][j]+=sum[i][j-1];
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)sum[i][j]+=sum[i-1][j];
	
	while(q--){
		ll a,b;
		cin>>a>>b;
		cout<<sum[b][b]+sum[a-1][a-1]-sum[a-1][b]-sum[b][a-1]<<endl;
	}
	return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[10],b[10];
    for(int i=0;i<10;i++){
        cin >> a[i];
    }
    for(int i=0;i<10;i++){
        cin >> b[i];
    }
    sort(a,a+10,greater<int>());
    sort(b,b+10,greater<int>());
    cout << a[0]+a[1]+a[2] << " " << b[0]+b[1]+b[2] << endl;

    return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>
int main(){
	int a,b,c,count,x;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++){
		if(c-(x*(c/x))==0){
			count++;
		}
	}	
	printf("%d\n",count);	
	return 0;
}	

Measured memory_bytes: 596
S = gets.chomp.split('')

count = 0
i = 0

S.length.times do |i|
    if i.even? then
        if S[i].eql?('0') then
            count = count + 1
        end
    else
        if S[i].eql?('1') then
            count = count + 1
        end
    end
end

count2 = 0
i = 0

S.length.times do |i|
    if i.odd? then
        if S[i].eql?('0') then
            count2 = count2 + 1
        end
    else
        if S[i].eql?('1') then
            count2 = count2 + 1
        end
    end
end

if count < count2 then
    print count
else
    print count2
end

Measured memory_bytes: 11516
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  int a,b;
  cin>>a;
  double v=(double)((a+1)/2)/a;
  ansf(v,10);
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int c1,c2,c3;
  int i,card;
  while(scanf("%d %d %d",&c1,&c2,&c3)!=EOF){
    card=0;
    for(i=1;i<=10;i++){
      if(i!=c1&&i!=c2&&i!=c3){
	if(c1+c2+i<=20)  card++;
	else break;
      }
    }
    if(card>=4) printf("YES\n");
    else        printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 580
using System;
using System.Linq;

class Problem {
    public class Dice {
        public int Top    { get; private set; }
        public int South  { get; private set; }
        public int East   { get; private set; }
        public int West   { get; private set; }
        public int North  { get; private set; }
        public int Bottom { get; private set; }
        
        private int[] init;
        
        public void Init() {
            Top    = init[0];
            South  = init[1];
            East   = init[2];
            West   = init[3];
            North  = init[4];
            Bottom = init[5];
        }
        public Dice(int[] nums) {
            init = nums;
            Init();
        }
        public void Roll(string coms) {
            foreach (var com in coms) {
                var tmp = Top;
                switch (com) {
                    case 'E': Top = West;  West  = Bottom; Bottom = East;  East  = tmp; break;
                    case 'N': Top = South; South = Bottom; Bottom = North; North = tmp; break;
                    case 'S': Top = North; North = Bottom; Bottom = South; South = tmp; break;
                    case 'W': Top = East;  East  = Bottom; Bottom = West;  West  = tmp; break;
                }
            }
        }
        public void RollY(string coms) {
            foreach (var com in coms) {
                var tmp = South;
                switch (com) {
                    case 'R': South = West; West = North; North = East; East = tmp; break;
                    case 'L': South = East; East = North; North = West; West = tmp; break;
                }
            }
        }
        public char Position(int num) {
            return num == Top   ? 'T' :
                   num == South ? 'S' :
                   num == East  ? 'E' :
                   num == West  ? 'W' :
                   num == North ? 'N' : 'B';
        }
        public bool Equal(Dice d) {
            return Top    == d.Top   &&
                   South  == d.South &&
                   East   == d.East  &&
                   West   == d.West  &&
                   North  == d.North &&
                   Bottom == d.Bottom;
        }
    }
    
    public static bool Check(Dice d1, Dice d2) {
        var checkComs = new[] {"", "N", "W", "E", "S", "NN"};
        foreach (var com in checkComs) {
            d1.Roll(com);
            if (d1.Equal(d2)) return true;
            d1.RollY("R");
            if (d1.Equal(d2)) return true;
            d1.RollY("R");
            if (d1.Equal(d2)) return true;
            d1.RollY("R");
            if (d1.Equal(d2)) return true;
            d1.Init();
        }
        return false;
    }
    
    public static void Main() {
        var d1 = new Dice(Console.ReadLine().Split().Select(int.Parse).ToArray());
        var d2 = new Dice(Console.ReadLine().Split().Select(int.Parse).ToArray());
        Console.WriteLine(Check(d1, d2) ? "Yes" : "No");
    }
}


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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    int brr[3][3];
    set<int>st;
    frepi(0,2,1)
    {
    	frepj(0,2,1)
    	{
    		cin>>brr[i][j];
    		st.insert(brr[i][j]);
    	}
    }
    int arr[3][3];
    mset(arr,0);
    int n;cin>>n;
    frepi(1,n,1)
    {
    	int x;cin>>x;
    	if(st.find(x)!=st.end())
    	{
    		for(int i=0;i<3;++i)
    		{
    			for(int j=0;j<3;++j)
    			{
    				if(brr[i][j]==x)
    					arr[i][j] = 1;
    			}
    		}
    	}
    }

    for(int i=0;i<3;++i)
    {
    	if(arr[i][0]==arr[i][1] && arr[i][1]==arr[i][2] && arr[i][0]==1)
    	{
    		cout<<"Yes";
    		return;
    	}
    	if(arr[0][i]==arr[1][i] && arr[2][i]==arr[1][i] && arr[0][i]==1)
    	{
    		cout<<"Yes";
    		return;
    	}
    }

    if(arr[0][0]==arr[1][1] && arr[1][1]==arr[2][2] && arr[0][0]==1)
    {
    	cout<<"Yes";
    	return;
    }
    if(arr[1][1]==arr[0][2] && arr[2][0]==arr[0][2] && arr[1][1]==1)
    {
    	cout<<"Yes";
    	return ;
    }
    cout<<"No";

}

int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("/home/suryakant/input.txt","r",stdin);
        freopen("/home/suryakant/output.txt","w",stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

vector<int> edge[100010];

int main() {
	int n, m; cin >> n >> m;
	int h[n]; rep(i,n) cin >> h[i];
	rep(i,m) {
		int a, b; cin >> a >> b;
		--a, --b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	int ans = 0;
	rep(i,n) {
		bool flg = true;
		for(int to : edge[i]) {
			if(h[i] <= h[to]) flg = false;
		}
		if(flg) ans++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 9108
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,a,b = LI()
    ans = 0
    if n == 1:
        if a == b:
            ans = 1
        else:
            ans = 0
    elif n == 2:
        if a <= b:
            ans = 1
        else:
            ans = 0
    else:
        if a <= b:
            summin = a*(n-1) + b
            summax = a + b*(n-1)
            ans = summax - summin + 1
        else:
            ans = 0

    print(ans)
        
main()            


Measured memory_bytes: 74524