akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int main() {
	int i, j, k;
	int N, M, K;

	cin >> i;
	cout << ((i == 3 || i == 5 || i == 7) ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		int S = new Scanner(System.in).nextInt();
		if(S < 0 || S > 86400) {
			throw new IllegalArgumentException("引数が誤っている。");
		}
		int h = S / 3600;
		int m = (S - (h * 3600)) / 60;
		int s = (S- (h * 3600) - (m * 60));
		System.out.println(h + ":" + m + ":"+ s);
	}
}


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

int64_t MOD = 1000000007;

int main() {
  int64_t n;
  cin >> n;
  int64_t power = 1;
  for (int64_t i = 1; i <= n; ++i) {
    power = power * i % MOD;
  }
  cout << power << endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
  int a,b;
  cin>>a>>b;
  cout<<max({a+b,a*b,a-b})<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int m[10],i,j,temp;
  for(i=0;i<10;i++)scanf("%d",&m[i]);
  for(i=0;i<9;i++){
    for(j=0;j<9-i;j++){
      if(m[j]<m[j+1]){
	int temp=m[j];
	m[j]=m[j+1];
	m[j+1]=temp;
      }
    }
  }
  for(i=0;i<3;i++)printf("%d\n",m[i]);
  return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n;
LL a[200005];
LL l[200005], r[200005], ans = 10000000000;
int main()
{
	scanf("%lld",&n);
	for(LL i = 1; i <= n; i++){
		scanf("%lld",&a[i]);
		l[i] = l[i - 1] + a[i];
	}
	for(LL i = n; i >= 1; i--){
		r[i] = r[i + 1] + a[i];
	}
	for(LL i = 1; i < n; i++){
		ans = min(ans,abs(l[i] - r[i + 1]));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
import random

def main():
    D = int(input())
    c_list = list(map(int, input().split()))
    s_list = [list(map(int, input().split())) for _ in range(D)]
    
    basic_bad = sum(c_list)

    # 初期解生成は必要っぽい
    res = 0
    bad = 0
    last_open = [0] * 26
    t_list = [0] * D
    for i in range(D):
        # find t
        t = 0
        max_val = s_list[i][0] - (basic_bad - (i+1 - last_open[0]) * c_list[0])
        
        for d in range(1,26):
            val = s_list[i][d] - (basic_bad - (i+1 - last_open[d]) * c_list[d])
            if val >= max_val:
                t = d
                max_val = val

        t_list[i] = t 
        
        res += max_val
        last_open[t] = i+1

        res -= bad

    init_res = res

    # loop
    for m in range(10**4):
        d = random.randint(1,D)
        q = random.randint(0,25)

        pre_t = t_list[d-1]
        pre_res = init_res

        t_list[d-1] = q
        res = 0
        
        bad = 0
        last_open = [0] * 26
        for i in range(D):
            t = t_list[i]
            
            res += s_list[i][t]
            bad += basic_bad - (i+1 - last_open[t]) * c_list[t]
            last_open[t] = i+1

            res -= bad
            
        if pre_res > res:
            res = pre_res
            t_list[d-1] = pre_t

    # tが0-index
    for t in t_list:
        print(t+1)

    # with open("out.txt", "w")as of:
    #    for t in t_list:
    #         of.write(f"{str(t+1)}\n")

    # print(res)
if __name__ == "__main__":
    main()

Measured memory_bytes: 85076
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x);
#define rl(x) scanf("%I64d",&x);
#define pi(x) printf("%d",x);
#define pl(x) printf("%I64d",x);
#define lfd() printf("\n");
#define sp() printf(" ");
int a,b,c,d;
string s;
map<int,char> mp;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
	mp[0]='+';
	mp[1]='-';
	for(int i=0;i<8;i++){
		int tmp=a;
		if(i%2==0)
			tmp+=b;
		else
			tmp-=b;
		if((i/2)%2==0)
			tmp+=c;
		else
			tmp-=c;
		if((i/4)%2==0)
			tmp+=d;
		else
			tmp-=d;
		if(tmp==7){
			cout<<a<<mp[i%2]<<b<<mp[(i/2)%2]<<c<<mp[(i/4)%2]<<d<<"=7"<<endl;
			return 0;
		}
	}
	return 0;
}



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

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

    int ans = 0;
    for (int i = 1; i <= n; i+=2) {
        int count = 0;
        for (int j = 1; j <= i; j++) {
            if (i%j == 0)
                count ++;
        }
        if (count == 8)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;


int main() {
	
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()) if(s[i] == '1') ans++;
	cout << ans << endl;
	
	return 0;
}

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

int main(){
    long long N;
    cin >> N;
    long long l[N],r[N];
    long long i;
    long long c=0;
    for(i=0;i<N;i++){
        scanf("%lld %lld",&l[i],&r[i]);
        c+=(r[i]-l[i]+1);
    }
    cout << c <<endl;
    
    return 0;
}

Measured memory_bytes: 256
n, a, b = gets.split.map(&:to_i)

M = 10 ** 9 + 7

def pow(n, a)
  ans = 1
  while(a > 0)
    ans = ans * n % M if a & 1 == 1
    n = n * n % M
    a >>= 1
  end
  ans
end

def combination(n, r)
  mul = lambda {|r, e| r * e % M}
  n.downto(n - r + 1).reduce(1, &mul) * pow(r.downto(1).reduce(1, &mul), M - 2) % M
end

p (pow(2, n) - 1 - combination(n, a) - combination(n, b)) % M

Measured memory_bytes: 1788
from collections import Counter

N = int(input())
a = Counter(list(map(lambda x: x//400, map(int, input().split()))))

c = n = 0
for key in [0,1,2,3,4,5,6,7]:
    if a[key]:
        c += 1
        
for key in [8,9,10,11,12]:
    n += a[key]
        
max_n = c+n
if c:
    min_n = c
else:
    min_n = 1
print(min_n, max_n)

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

namespace atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			//var n = Console.ReadLine();
			int N = int.Parse(Console.ReadLine());
			int sum = 0;
			for (int i = 0; i < N; i++)
			{
				var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				sum += input[1] - input[0] + 1;
			}
			Console.WriteLine(sum);
			//Console.ReadLine();
		}
	}
}

Measured memory_bytes: 11348
import java.util.*;
public class Main {
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int d=sc.nextInt();
      System.out.println(Math.min(a,b)+Math.min(c,d));
	}
}


Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10**9)
n,q=map(int,input().split())
G=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

subtree_size=[0]*n
cnt=[0]*n

for _ in range(q):
    p,x=map(int,input().split())
    p-=1
    cnt[p]+=x
ans=[0]*n

def dfs(G,v,p):
    ans[v]+=cnt[v]
    for nv in G[v]:
        if nv==p:
            continue
        cnt[nv]+=cnt[v]
        dfs(G,nv,v)
    
    subtree_size[v]=1
    for c in G[v]:
        if c==p:
            continue
        subtree_size[v]+=subtree_size[c]

root=0
dfs(G,root,-1)

for i in range(n):
    print(ans[i],end=' ')





Measured memory_bytes: 244216
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 200010;

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

    vector<int> c(MAX_N);
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
    }

    vector<ll> dp(MAX_N);  // dp[i] : 最初からi個(iは1-index)の石の条件を満たす塗り方の個数
    vector<int> last(MAX_N);
    vector<int> pos(MAX_N);

    for(int i = 1; i <= n; i++) {
        last[i] = pos[c[i]];
        pos[c[i]] = i;
    }

    dp[0] = 1;
    for(int i = 1; i <= n; i++) {
        dp[i] = dp[i-1];
        if(last[i] != 0 && last[i] != i-1) {
            dp[i] += dp[last[i]];
            dp[i] %= mod;
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4224
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func count(s string, N int) int {
	if is, _ := strconv.Atoi(s); is > N {
		return 0
	}

	ans := 0
	if strings.Count(s, "7")*strings.Count(s, "5")*strings.Count(s, "3") > 0 {
		ans = 1
	}
	for _, c := range "753" {
		ans += count(s+string(c), N)
	}
	return ans
}

func main() {
	var N int
	fmt.Scan(&N)

	fmt.Println(count("", N))
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int v[8];
    for (int i = 0; i < 8; i++) {
        cin >> v[i];
    }
    int p1 = v[0] * v[4] + v[1] * v[5] + v[0] / 10 * v[6] + v[1] / 20 * v[7];
    int p2 = v[2] * v[4] + v[3] * v[5] + v[2] / 10 * v[6] + v[3] / 20 * v[7];
    if (p1 == p2) {
        cout << "even\n";
    } else if (p1 < p2) {
        cout << "kenjiro\n";
    } else {
        cout << "hiroshi\n";
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;


int main(){
   int t=1 ;
   //cin>>t ;
   while(t--){
     long long n ;
     cin>>n ;
     long long mx=0 ;
     long long ans=0 ;
     long long temp ;
     for(int i=0 ;i<n ;i++){
        cin>>temp ;
        mx=max(temp,mx);
        ans+=mx-temp ;
     }
     cout<<ans<<endl ;
    }


}




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl

const ll INF=1e9+7;
const ll N = 302;
string s;
ll num[]={0,1,2,3,4,5,6,7,8,9};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	ll ans=0;
	ll k=1;
	FOR(i,0,s.size()-1)k*=2;
	FOR(i,0,k){
		ll w=num[s[0]-'0'],p=i;
		FOR(j,1,s.size()){
			if(p%2==0){
				w=w*10+num[s[j]-'0'];
			}else{
				ans+=w;
				w=num[s[j]-'0'];
			}
			p/=2;
		}
		ans+=w;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int x[100];
    int cnt;
    /*
    for(int i=0; i<101; i++){
        cin >> x[i];
        cnt = i + 1;
    }
    */
    
    string s;
    cin >> s;
    
    
    //cout << s[0] <<  " " << s[7] << endl;
    
    int ans = 0;

    for (int i=0; i<=(s.size()-1)/2; i++){
        if(s[i] != s[s.size()-1-i]){
            s[s.size()-1-i] = s[i];
            ans++;
        }
    }
    
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define in insert
#define ff first
#define ss second
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
int main()
{
    int x1,x2;
    int y1,y2;
    cin>>x1>>y1>>x2>>y2;
   int x=x2-x1;
   int y=y2-y1;
   cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int w, h, x, y, r, wpx, wmx, hpy,hmy;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	wmx = x - r;
	wpx = x + r;
	hmy = y - r;
	hpy = y + r;

	if (wmx >= 0 && hmy >= 0) {
		if (wpx <= w && hpy <= h) {
			printf("Yes\n");
		}
		else
			printf("No\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2668
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
    	public void solve(int testNumber, InputReader in, PrintWriter out) {
    		String a = in.next();
    		String b = in.next();
    		String str = a + b;
    		int tmp = Integer.parseInt(str); 
    		int sqrt = (int)Math.sqrt(tmp);
    		if(Math.pow(sqrt, 2) == tmp ) {
        		out.println("Yes");
    		}else {
        		out.println("No");
    		}
    	}
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int h,w,c;
int dy[4]={-1,1,0,0},dx[4]={0,0,-1,1};
vector<vector<int>> tile(10,vector<int>(10));

int BFS(vector<vector<int>> &T, int color){
	queue< pair<int,int> > Q;
	Q.push({0,0});

	vector<vector<bool>> visited(10,vector<bool>(10));
	visited[0][0]=1;

	int cnt=1;
	while(Q.empty()==false){
		int y=Q.front().first, x=Q.front().second;
		//cout<<x<<":"<<y<<endl;
		Q.pop();

		for(int i=0;i<4;i++){
			int nY=y+dy[i], nX=x+dx[i];

			if(nX<0 || nX>=w || nY<0 || nY>=h)continue;
			else if(visited[nY][nX])continue;
			visited[nY][nX]=true;

			if(T[nY][nX]==T[0][0]){
				cnt++;
				T[nY][nX]=color;
				Q.push({nY,nX});
			}
		}
	}
	T[0][0]=color;
	//cout<<endl;
	return cnt;
}

int Solve(int cnt, vector<vector<int>>T){
	vector<vector<int>> tmp(T);
	if(cnt==4){
		tmp=T;
		BFS(tmp,c);
		int ret=BFS(tmp,c);

		return ret;
	}

	int ret=0;
	for(int i=1; i<=6; i++){
		if(T[0][0]==i)continue;

		tmp=T;
		BFS(tmp,i);
		ret=max(ret,Solve(cnt+1,tmp));
	}
	return ret;
}

int main(){
	while(cin>>h>>w>>c, h&&w&&c){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>tile[i][j];
			}
		}
		cout<<Solve(0,tile)<<endl;
	}

	return 0;
}



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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD   = 1e9 + 7;
const double PI = acos(-1.0);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int INF   = 1e18;

#define fastio            ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define f first
#define s second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define spc " "
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    vi pos, neg;
    bool is_zero = false;
    if( a <= 0 && 0 <= b){
        is_zero = true;
    }
    if(c <= 0 && 0 <= d){
        is_zero = true;
    }

    int ans = -INF;

    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    if(is_zero) ans = max(ans, 0LL);

    cout << ans << endl;



}

signed main(){
    fastio;

    solve();

    return 0;
}


Measured memory_bytes: 3644
unittest
{
	assert( [ "3 8 5" ].parse.expand.solve == "Yes" );
	assert( [ "7 3 1" ].parse.expand.solve == "No" );
	assert( [ "10 2 4" ].parse.expand.solve == "Yes" );
	assert( [ "31 41 59" ].parse.expand.solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc );
}

auto solve( long[] abc )
{
	auto s = abc.dup.sort();
	return ( abc[ 2 ] == s[ 1 ] ) ? "Yes" : "No";
}


Measured memory_bytes: 256
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 200001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	cin >> n >> t;
	int t_ar[SIZE];
	rep(i,n) cin >> t_ar[i];

	int sa = 0;
	ll ans = n*t;
	for(int i =1; i<n; i++){
		int time_a = t_ar[i]-t_ar[i-1];
		if(time_a <= t){
			sa += t - time_a;
		}
	}

	ans = n*t - sa;


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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll inf=1000000007;
const ll maxinput=10005;
const ll mod=998244353;
#define mp make_pair
int a[maxinput];int d;
int dp[maxinput][105][2];
int countnumdivbyd(int pos,int rem,int issmall)
{
    if(pos==maxinput)
    {
        if(rem%d==0)
            return(1);
        else
            return(0);
    }
    if(dp[pos][rem][issmall]!=-1)
        return(dp[pos][rem][issmall]);
    int temp=0;
    if(issmall)
    {
        for(int i=0;i<=9;i++)
            temp+=countnumdivbyd(pos+1,(rem+i)%d,issmall)%inf,temp%=inf;

    }
    else
    {
        for(int i=0;i<a[pos];i++)
            temp+=countnumdivbyd(pos+1,(rem+i)%d,1)%inf,temp%=inf;

        temp+=countnumdivbyd(pos+1,(rem+a[pos])%d,0)%inf,temp%=inf;
    }

    return(dp[pos][rem][issmall]=temp%inf);
}
int main()
{
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<maxinput;i++)
        a[i]=0;

    string k;cin>>k;
    int l1=k.length();
    for(int i=0;i<l1;i++)
        a[maxinput-l1+i]=k[i]-'0';

    cin>>d;
    
    cout<<((countnumdivbyd(0,0,0)-1)+inf)%inf<<"\n";    

}

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

using namespace std;
#define inf 1e16
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

struct person{
	int h,p;
	void read() {
		scanf("%d %d",&h,&p);
	}
};

bool cmp(person a, person b){
	return a.h + a.p < b.h + b.p;
}

const int maxn = 5e3 + 3;

ll dp[maxn][maxn]; //dp[i][j] menyatakan banyaknya minimal sum of p sampe idx i dengan banyaknya peserta yg ikut adalah j

void minim(ll &a, ll b){
	a = min(a, b);
}

int main(){
	int n,i,j;
	scanf("%d",&n);
	vector<person> a(n+1);
	for(i=1;i<=n;i++){
		a[i].read();
	}
	sort(a.begin(), a.end(), cmp);

	for(i=1;i<=n;i++){
		if(i > 1){
			for(j=1;j<i;j++){
				dp[i][j] = dp[i-1][j];
			}
			dp[i][j] = inf;
		}else{
			for(j=1;j<=i;j++){
				dp[i][j] = inf;
			}
		}
		
		int h = a[i].h, p = a[i].p;
		// printf("h: %d p: %d\n",h,p);
		for(j=i;j>=1;j--){
			if(h >= dp[i-1][j-1]){
				minim(dp[i][j], dp[i-1][j-1] + p);
				// printf("masuk sini dp[%d][%d]: %lld\n",i,j+1, dp[i][j+1]);
			}
		}
	}
	int ans = 0;
	for(i=1;i<=n;i++){
		for(j=0;j<=i;j++){
			// printf("dp[%d][%d]: %lld\n",i,j,dp[i][j]);
			if(dp[i][j] != inf){
				ans = max(ans, j);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
};

Measured memory_bytes: 193920
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    a = int(input())

    print(a + a**2 + a**3)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10400
/*    
 *  eat_code    
 *  IIIT Allahabad
 */
#include <bits/stdc++.h>
//#include "pretty_print.h"
using namespace std;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define CONTAINS(a, x) (a.find(x) != a.end())
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define nl cout << endl
#define F first
#define S second

#define what_is(x) cout << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define CASET int ___T, case_n = 1; scanf("%d", &___T); while (___T-- > 0) 

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef vector<vi> vvi;

ll INF = 1E9;
ll M = 1E9 + 7;

inline ll power (ll a,ll p){
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}

int main() {
    boost;
    if(fopen("input.txt", "r")){
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    }
    int h, w;
    cin >> h >> w;
    vvi c(10, vi(10)), a(h, vi(w));
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            cin >> c[i][j];
        }
    }
    for(int k = 0;k < 10;k++){
        for(int i = 0;i < 10;i++){
            for(int j = 0;j < 10;j++){
                c[i][j] = min(c[i][k] + c[k][j], c[i][j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cin >> a[i][j];
            if(a[i][j] != -1){
                ans += c[a[i][j]][1]; 
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
//  Train Insane or Remain the same
 

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(void){
  char ss[101];
  int i,n,a=0;
  scanf("%s",ss);
  n=strlen(ss);
  for(i=0;i<n;i++){
    if(ss[i]!=ss[n-1-i]){
      a++;
    }
  }
  printf("%d\n",a/2);
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(A: int, B: int, C: int, K: int):
    print(A + B + C + max(A, B, C) * (2 ** K - 1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)


if __name__ == '__main__':
    main()


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

const string YES = "Yes";
const string NO = "No";


int main(){
    string s;
    cin >> s;
    if(s.at(0)=='9' || s.at(1)=='9') cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int n, x, t; cin >> n >> x >> t;
  int ans;
  if(n % x == 0) ans = n / x * t;
  else ans = (n / x + 1) * t;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int> l(m);
    vector<int> r(m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&l[i],&r[i]);
    }
    int max_l=l[0];
    int min_r=r[0];
    for(int i=1;i<m;i++){
        max_l=max(max_l,l[i]);
        min_r=min(min_r,r[i]);
    }
    if(max_l<=min_r){
        cout<<min_r-max_l+1<<"\n";
    }
    else{
        cout<<"0\n";
    }
    return 0;
}


Measured memory_bytes: 4024
N = int(input())
A = [int(a) for a in input().strip().split()]
B = [int(b) for b in input().strip().split()]
C = [int(c) for c in input().strip().split()]


prev = A[0]
total = B[prev-1]
for a in A[1:]:
  total += B[a-1]
  if a - prev == 1:
    total += C[prev-1]
  prev = a

print(total)

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

public class Main { 
	public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		scr.close();
	}
	
	
	private static int SearchTrio(int n, int x){
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	}
	
	// min??\???max??\??????2??°????????§x???????????????
	private static int SearchPair(int min, int max, int x){
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max(((x-min*2+1)/2),0);
	}
}

Measured memory_bytes: 26068
#include <stdio.h>
 
 int main(void){
         int a,b,c,d,gcd,lcm;
         while( scanf("%d %d",&a,&b) !=EOF){
             c=a; d=b;
             while(1){
                if(a>b){
                  a=a-b;
                }else if(a<b){
                  b=b-a;
                }if( a==b){
                  break;
                }
              }
                 gcd =a;
                 lcm =c/a*d;
              printf("%d %d\n",gcd,lcm);
}
             return 0;
} 
                  

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int k; cin>>k;
	queue<ll> q;
	for(int i = 1; i <= 9; i++) q.push(i);
	while(k){
		k--;
		ll tmp = q.front();
		q.pop();
		if(k == 0){
			cout<<tmp;
			break;
		}
		if(tmp % 10) q.push(10*tmp + tmp%10 - 1);
		q.push(10*tmp + tmp%10);
		if(tmp % 10 != 9) q.push(10*tmp + tmp%10 + 1);
	}
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,i;
  cin>>n>>i;
  cout<<(n+1-i)<<endl;
  return 0;
}


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

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    if(isPalindrome(s) && isPalindrome(s.substr(0, (n - 1) / 2)) && isPalindrome(s.substr((n + 1) / 2))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
int main(void) {
    string s;
    cin >> s;
    REP(i,s.size()) {
        if(s[i] == ',') cout << " ";                                                                                               
        else cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://atcoder.jp/contests/abc117/tasks/abc117_d>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


// dp[桁数][K以下か]
ll dp[55][2];
template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    string bitK;
    while(K){
        bitK += to_string(K%2);
        K/=2;
    }
    while(bitK.length() < 55) bitK += "0";
    reverse(bitK.begin(),bitK.end());
    int len = (int)bitK.length();
    fill(*dp,*dp+55*2,-1);
    
    ll Sum = 0;
    bool ok = false;
    for(int i = 0; i < len;i++){
        ll Add = 1LL<<(len-1-i);
        for(int j = 0; j < 2;j++){
            if(dp[i][j]==-1) continue;
            int lim = j==1?1:(bitK[i]-'0');
            for(int k = 0; k <= lim;k++){
                ll T = 0;
                for(int l = 0; l < N;l++){
                    ll b = (A[l]>>(len-1-i))&1;
                    if(b^k){
                        T += Add;
                    }
                }
                dp[i+1][j|(k<lim)] = max(dp[i+1][j|(k<lim)],dp[i][j]+T);
            }
        }
        
        // 最上位 1
        ll T = Sum;
        for(int l = 0; l < N;l++){
            ll b = (A[l]>>(len-1-i))&1;
            if(b^1){
                T += Add;
            }else{
                Sum += Add;
            }
        }
        if(ok){
            dp[i+1][1] = max(dp[i+1][1],T);
            continue;
        }
        if(bitK[i]=='1') ok = true;
        if(ok){
            dp[i+1][0] = max(dp[i+1][0],T);
        }
    }
    res = max({Sum,dp[len][0],dp[len][1]});
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n,m; cin >> n >> m;
    vector<int> x(m);
    rep(i, m) cin >> x[i];

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

    priority_queue<int> xx;
    rep(i, m-1) xx.push(x[i+1] - x[i]);

    rep(i, n-1) {
        if(xx.empty()) break;
        xx.pop();
    }

    int ans = 0;
    while(!xx.empty()) {
        ans += xx.top();
        xx.pop();
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >>A >>B;
  if(A>12){
    cout << B << endl;}
  else if(A<6){
    cout << "0" << endl;}
  else{
    cout << B/2 << endl;}
  return 0;
}

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


int main() {
  while (true) {
    int N;
    
    cin >> N;
    if (N == 0)
      break;

    int gems_pos[21][2];
    for (int i=0; i<N; i++) {
      cin >> gems_pos[i][0];
      cin >> gems_pos[i][1];
    }

    int M;
    cin >> M;
    int count = 0;
    int x = 10;
    int y = 10;
    
    for (int i=0; i<M; i++) {
      char c;
      int diff;

      cin >> c;
      cin >> diff;

      int des_x = x;
      int des_y = y; 
      
      switch (c) {
      case 'N':
	des_y += diff;
	break;
      case 'S':
	des_y -= diff;
	break;
      case 'E':
	des_x += diff;
	break;
      case 'W':
	des_x -= diff;
	break;
      }

      // debug
      // printf("x:%d y:%d\n", des_x, des_y);
      
      for (int i=0; i<N; i++) {
	if (((x <= gems_pos[i][0] && gems_pos[i][0] <= des_x) ||
	    (des_x <= gems_pos[i][0] && gems_pos[i][0] <= x))
	    &&
	    ((y <= gems_pos[i][1] && gems_pos[i][1] <= des_y) ||
	    (des_y <= gems_pos[i][1] && gems_pos[i][1] <= y)))  {
	  count++;
	  // printf("found\n");
	  gems_pos[i][0] = -1;
	}
      }

      x = des_x;
      y = des_y;
    }

    if (count == N) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  
}

Measured memory_bytes: 3028
/*
                IftekharMd.Shishir
                Dept. of Information and Communication Engineering
                University of Rajshahi
*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

#define ll  long long
#define ull  unsigned long long
#define ld  long double
#define f(i,n)  for(i=0;i<n;i++)
#define F(i,n)  for(i=n-1;i>=0;i--)
#define fa(i,a,b)  for(i=a;i<=b;i++)
#define Fa(i,a,b)  for(i=a;i>=b;i--)
#define printArray(i,a,n)  f(i,n)cout<<a[i]<<" "; cout<<endl;
#define printSet(a)  for(auto setData:a) cout<<setData<<" ";cout<<endl;
#define printMap(a)  for(auto mapData:a) cout<<mapData.first<<" "<<mapData.second<<endl;
#define printVector(a)  for(auto vectorData:a)cout<<vectorData<<" ";cout<<endl;
#define printLinkedList()  temp=head;while(temp){cout<<temp->data<<" ";temp=temp->post;} cout<<endl;

#define pb(x)  push_back(x)
#define all(a)  a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()

#define bs  binary_search
#define lb  lower_bound
#define ub  upper_bound
#define mp  make_pair
#define TxtIO  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define TxtTest freopen("C:/Users/Iftekhar/Documents/what/input.txt", "r", stdin);
#define FastIO  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
#define TestCase  ll t;cin>>t;while(t--)
#define points(x)  fixed<<setprecision(x)
#define scd(a,x,y)  a/__gcd(x,y);
#define nl  cout<<endl;
#define done  return 0

const ld PI= 3.14159265358979323846264338327950288;  //2*acos(0.0);
const long long MOD= 1000000007;
const long long MAX = 32000;

// stringstream demo(str);  demo >> x;
// stringstream demo;  demo << x;  name=demo.str();

using namespace __gnu_pbds;
using namespace std;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main()
{
        FastIO;
        //TxtTest;
        ll n,k,i,x,sum=0,alice=0,bob=0;
        cin>>n;
        vector<ll> a(n);
        f(i,n) cin>>a[i];
        sort(rall(a));
        f(i,n){
                if(i%2==0) alice+=a[i];
                else bob+=a[i];
        }
        sum=alice-bob;
        cout<< sum <<endl;
        done;
}


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int main() {

	int N;
	vector<int> a;

	scanf("%d", &N);
	rep(i, N) {
		int t;
		scanf("%d", &t);
		a.push_back(t);
	}

	sort(a.begin(), a.end(), greater<int>());

	int A = 0, B = 0;
	rep(i, N) {
		if (i % 2) B += a[i];
		else A += a[i];
	}

	printf("%d\n", A - B);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int m,f,r;
	int i,sum;
	
	for(i=0;;i++){
		cin >> m >> f >> r;
		sum=m+f;
		if(m==-1 && f==-1 && r==-1){
			break;
		}
		else if(m==-1 || f==-1){
			cout << "F" << endl;
		}
		else{
			if(sum>=80){
				cout << "A" << endl;
			}
			else if(65<=sum && sum<80){
				cout << "B" << endl;
			}
			else if(50<=sum && sum<65){
				cout << "C" << endl;
			}
			else if(30<=sum && sum<50){
				if(r>=50){
					cout << "C" << endl;
				}
				else{
					cout << "D" << endl;
				}
			}
			else if(sum<30){
				cout << "F" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1152
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nNodes := scanInt(sc)
	nOps := scanInt(sc)

	neighbors := make([][]int, nNodes+1)
	for i := 0; i < nNodes-1; i++ {
		a, b := scanInt(sc), scanInt(sc)
		neighbors[a] = append(neighbors[a], b)
		neighbors[b] = append(neighbors[b], a)
	}

	counts := make([]int64, nNodes+1)
	for i := 0; i < nOps; i++ {
		p, addition := scanInt(sc), scanInt(sc)
		counts[p] += int64(addition)
	}

	var dfs func(i, parent int)
	dfs = func(i, parent int) {
		for _, nb := range neighbors[i] {
			if nb == parent {
				continue
			}
			counts[nb] += counts[i]
			dfs(nb, i)
		}
	}
	dfs(1, 0)

	w := bufio.NewWriter(os.Stdout)
	fmt.Fprint(w, counts[1])
	for i := 2; i <= nNodes; i++ {
		fmt.Fprintf(w, " %d", counts[i])
	}
	fmt.Fprintln(w)
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 75904
n = int(input())
a = list(map(int, input().split()))
up = 100001
l = [0 for i in range(up)]
for i in range(n):
    l[a[i]] += 1
ma = -1
for i in range(1, up-1):
    if ma < l[i-1] + l[i] + l[i+1]:
        ma = l[i-1] + l[i] + l[i+1]
print(ma)

Measured memory_bytes: 56132
#include<iostream>

using namespace std;

int main(){

  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int A=0,B=0;
    //??????????????°??????????????¨???
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;    
      if(a>b)A+=a+b;
      if(a<b)B+=a+b;
      if(a==b){
	A+=a;
	B+=b;
      }
    }
    cout<<A<<" "<<B<<endl;
  }




  return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<map>
#include<queue>
std::map<std::string,int> mp;
std::queue< std::string > q;
int n,m,ans=0; 
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		std::string st;
		std::cin>>st;
		mp[st]++;
		q.push(st); 
	}
	scanf("%d",&m);
	for (int i=1;i<=m;i++)
	{
		std::string st;
		std::cin>>st;
		mp[st]--;
		q.push(st); 
	}
	while (!q.empty())
	{
		std::string st=q.front();q.pop();
		ans=std::max(ans,mp[st]);
	}
	printf("%d\n",ans);
	return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n;
    cin>>n;
    vector<pair<ll,ll>> p(n);
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        p[i]=make_pair(a,b);
    }

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

    ll ans=0, num=0;
    rep(i,0,n){
        ans+=p[i].first - num;
        num=p[i].first;
    }
    ans+=p[n-1].second;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4844
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M; ll L;

ll Dist[305][305], cnt[305][305];

int main(){
  scanf("%d%d%lld", &N, &M, &L);
  fill((ll*)Dist, (ll*)(Dist + N + 1), 1e18);

  for (int i = 1; i <= N; i++) Dist[i][i] = 0;
  for (int i = 0; i < M; i++){
    int A, B; ll C; scanf("%d%d%lld", &A, &B, &C);
    Dist[A][B] = C;
    Dist[B][A] = C;
  }

  for (int k = 1; k <= N; k++){
    for (int i = 1; i <= N; i++){
      for (int j = 1; j <= N; j++){
        Dist[i][j] = min(Dist[i][j], Dist[i][k] + Dist[k][j]);
      }
    }
  }

  fill((ll*)cnt, (ll*)(cnt + N + 1), 1e9);
  for (int i = 1; i <= N; i++){
    for (int j = 1; j <= N; j++){
      if (Dist[i][j] <= L) cnt[i][j] = 1;
    }
    cnt[i][i] = 0;
  }

  for (int k = 1; k <= N; k++){
    for (int i = 1; i <= N; i++){
      for (int j = 1; j <= N; j++){
        cnt[i][j] = min(cnt[i][j], cnt[i][k] + cnt[k][j]);
      }
    }
  }

  int Q; scanf("%d", &Q);
  for (int i = 0; i < Q; i++){
    int S, T; scanf("%d%d", &S, &T);
    if (cnt[S][T] == 1e9) printf("-1\n");
    else printf("%d\n", cnt[S][T] - 1);
  }

  return 0;
}


Measured memory_bytes: 5176
def examB():
    N, X =LI()
    M = [I() for _ in range(N)]
    sumM = sum(M)
    ans = N
    cur = X-sumM
    ans += cur//min(M)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Measured memory_bytes: 3560
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int n;
	cin >> n;
	vector<int> a(n);

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

	vector<int> l(n + 1);

	int total = 0;
	for(int i = 0; i < n + 1; i++){
		if(i == 0){
			l[i] = abs(a[0]);
		} else if(i == n){
			l[i] = abs(a[n - 1]);
		} else {
			l[i] = abs(a[i] - a[i - 1]);
		}
		total += l[i];
	}

	for(int i = 0; i < n; i++){
		int ans;

		if(i == 0){
			ans = total + abs(a[i + 1]) - (l[i] + l[i + 1]);
		} else if(i == n - 1){
			ans = total + abs(a[i - 1]) - (l[i] + l[i + 1]);
		} else {
			ans = total + abs(a[i - 1] - a[i + 1]) - (l[i] + l[i + 1]);
		}

		cout << ans << endl;
	}


}



Measured memory_bytes: 2048