akhauriyash/Code-Regression huggingface dataset:
n = int(input())
*h, = map(int, input().split())
cnt = 0
minh = min(h)
# 一番低い木が育つまでは全体に水やりできるので、全体に水やりしたあとの状態
h = [i - minh for i in h]
cnt += minh + h[0]

for i in range(1, n):
  # 左隣が自身以下であるなら、その差分の水やりは自身のみの成長にのみ使われる
  if h[i-1] <= h[i]: cnt += h[i] - h[i-1]
print(cnt)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vi x(n),y(n),s(m),t(m);
    rep(i,n) cin>>x[i]>>y[i];
    rep(i,m) cin>>s[i]>>t[i];
    rep(i,n){
        int mi=abs(s[0]-x[i])+abs(t[0]-y[i]);
        int idx=0;
        rep(j,m){
            int d = abs(s[j]-x[i])+abs(t[j]-y[i]);
            if (d<mi){
                mi = d;
                idx = j;
            }
        }
        cout<<idx+1<<"\n";
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl;
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<P> VP;
const int INF = 1LL<<60;
const int MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
  int a,b;
  cin>>a>>b;
  string ans;
  if(a<0&&b>0)ans="Zero";
  else if(a==0|b==0)ans="Zero";
  else if(a<0&&b<0)ans=((b-a)%2==0?"Negative":"Positive");
  else if(a>0&&b>0)ans="Positive";
  out(ans);
  
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
	if (a < b) swap(a, b);
		while (b != 0) {
			T tmp = b;
			b = a % b;
			a = tmp;
		}
	return a;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int K;
    ll ans = 0;
    cin >> K;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                int m = gcd<int>(i, j);
                int n = gcd<int>(m, k);
                ans += n;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> s(M);
	for (int i=0;i<M;i++) {
		int k;
		cin >> k;
		vector<int> tmp(k);
		for (int j=0;j<k;j++) {
			cin >> tmp[j];
		}
		s[i] = tmp;
	}

	vector<int> p(M);
	for (int i=0;i<M;i++) {
		cin >> p[i];
	}

	int ans = 0;
	for (int i=0;i<(1<<N);i++) {
		vector<int> arr(N);
		int tmp = i;
		for (int j=0;j<N;j++) {
			arr[j] = tmp%2;
			tmp /= 2;
		}

		bool flag = true;
		for (int i=0;i<M;i++) {
			int k = s[i].size();
			int cnt = 0;
			for (int j=0;j<k;j++) {
				cnt += arr[s[i][j]-1];
			}
			if (cnt%2 != p[i]) flag = false;
		}
		if (flag) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int levenshtein_distance(const string& s1, const string& s2) {
    auto m = s1.size();
    auto n = s2.size();

    int dp[m+1][n+1];
    // fill(&dp[0][0], &dp[m][n] + 1, 0);
    for (auto i = 0; i <= m; ++i)
        dp[i][0] = i;
    for (auto j = 0; j <= n; ++j)
        dp[0][j] = j;

    for (auto i = 1; i <= m; ++i) {
        for (auto j = 1; j <= n; ++j) {
            auto cost = s1[i-1] == s2[j-1] ? 0 : 1;
            dp[i][j] = min(dp[i-1][j] + 1, min(dp[i][j-1] + 1, dp[i-1][j-1] + cost));
        }
    }
    return dp[m][n];
}

int main() {
    string s1, s2;
    cin >> s1 >> s2;

    cout << levenshtein_distance(s1, s2) << endl;

    return 0;
}

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

using namespace std;

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

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int add(int x,int y) {
  return x + y >= mod ? x + y - mod : x + y;
}

inline int mul(int x,int y) {
  return (ll) x * y % mod;
}

int ans,n,m,x[N],y[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1 ; i <= n ; i++)
    cin >> x[i];
  for (int i = 1 ; i <= m ; i++)
    cin >> y[i];
  sort(x + 1,x + n + 1);
  sort(y + 1,y + m + 1);
  int temp = 0;
  for (int i = 2 ; i <= m ; i++)
    temp = add(temp,mul(y[i] - y[i - 1],mul(m - i + 1,i - 1)));
  for (int i = 2 ; i <= n ; i++)
    ans = add(ans,mul(mul(temp,mul(n - i + 1,i - 1)),x[i] - x[i - 1]));
  cout << ans << endl;
}

Measured memory_bytes: 1024
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

void solve(){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++){
        int legs = i*4 + (x-i)*2;
        if(legs == y){
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
import heapq
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
l=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(-b)
tmp=[]
heapq.heapify(tmp)
ans=0
for i in range(m):
  for j in l[i]:
    heapq.heappush(tmp,j)
  if len(tmp)>0:
    ans+= heapq.heappop(tmp)
print(-ans)

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


long long d[200005];
int a[200005];
int n;


int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], d[a[i]]++;
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += d[i]*(d[i]-1)/2;
    }
    for (int i = 1; i <= n; i++)
    {
        long long tt = d[a[i]]-1;
        ans -= tt*(tt+1)/2;
        ans += tt*(tt-1)/2;
        cout << ans << "\n";
        ans -= tt*(tt-1)/2;
        ans += tt*(tt+1)/2;
    }
    return 0;
}


Measured memory_bytes: 3968
function Main(input) {
  input=input.split(/\n/)
    var n= parseInt(input[0]);
	var ip = input[1].split(" ");
	ip.sort(compareFunc);
	var c = parseInt(ip[0]);
	for(var i=1;i<n;i++){
	   c = (c+parseInt(ip[i]))/2;
	}
	console.log(c);
}
 
function compareFunc(a, b) {
    return parseFloat(a) - parseFloat(b);
}
     
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
// #define mp make_pair
#define nt _int128 
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define inf 0x3f3f3f3f
 
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 5;
const ll mxi = 2e3 + 5;

int main()
{
    fast_as_levi;
    ll i,n,k;
    cin>>n>>k;
    ll ar[n];
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    ll dp[n+1]={0};
    dp[1] = abs(ar[1]-ar[0]);
    for(i=2;i<n;i++)
    {
        ll mi = INT_MAX; 
        for(ll j=1;j<=k;j++)
        {
            if(i>=j)
            mi = min(mi,dp[i-j] + abs(ar[i]-ar[i-j]));
        }
        dp[i] = mi;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val arr = Iterator.continually(io.StdIn.readLine.split(" "))
    .take(n)
    .toBuffer
  val ans = (Array(Array("0","0","0")).toBuffer++arr)
    .zip(arr)
    .forall{case (cur, nex) => {
      val dt =nex(0).toInt - cur(0).toInt
      val dist = (nex(1).toInt - cur(1).toInt).abs +
                 (nex(2).toInt - cur(2).toInt).abs
      dt >= dist && (dist&1) == (dt&1)
    }}

  println(if(ans) "Yes" else "No")
}

Measured memory_bytes: 77512
n = int(input())
a = list(map(int, input().split()))

ans = 0
same = 1
front = a[0]
for i in range(1, n):
    temp = a[i]
    if temp == front:
        same += 1
    else:
        ans += same // 2
        front = temp
        same = 1
else:
    ans += same // 2

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int cnt[26];

int main(){
  string s;
  cin>>s;
  string t="abcdefghijklmnopqrstuvwxyz";
  for(int i=0;i<s.size();i++){
     for(int j=0;j<26;j++){
        if(s[i]==t[j])cnt[j]++;
     }
  }
  for(int i=0;i<26;i++){
     if(cnt[i]==0){
        cout<<t[i]<<endl;
        return 0;
     }
  }
  cout<<"None"<<endl;
   
   
}

Measured memory_bytes: 512
//#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
//#include<cmath>
//#include<string>
//#include<cctype>
//#include <vector>
using namespace std;
int main() {
	int n;
	while (cin >>n, n) {
		int a[25] = {};
		int i=0, s = 32;
		while(i<n) cin >> a[i++];
		i = 0;
		while (s>0) {
			s -= (s - 1) % 5;
			cout << s << endl;
			s -= a[i++%n];
			cout << max(0,s) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";
int x[10];
int ans = 0;

int SetAns() {

	rep(i, 5) {
		cin >> x[i];
		if (x[i] == 0) return i;
	}
}

int main() {
	
	cout << SetAns() + 1<< endl;
	return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int max = 0;
		for (int i = 1; i < N - 1; i++) {
			String X = S.substring(0, i);
			String Y = S.substring(i);
			int result = 0;
			for (int j = 0; j < 26 && result < N; j++) {
				char alphbet = (char) ((char)'a' + j);
				if (X.contains(String.valueOf(alphbet)) && Y.contains(String.valueOf(alphbet))) {
					result++;
				}
			}
			max = Math.max(max, result);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 27524
#pragma GCC optimize("O3", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int k, t; cin >> k >> t;
	vector<int> a(t);
	for (int i = 0; i < t; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	int prv = a[t - 1] - 1;
	priority_queue<int> q;
	for (int i = 0; i < t - 1; ++i) q.push(a[i]);
	while (!q.empty()) {
		int nx = q.top(); q.pop();
		if (prv) q.push(prv);
		prv = --nx;
	}
	cout << prv << endl;
	return 0;
}

Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

const double PI = acos(-1);

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};
string Psb[2] = {"Impossible", "Possible"};
string psb[2] = {"impossible", "possible"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, y;
    cin >> n >> y;
    y /= 1000;
    forn(a, n + 1)
    {
        forn(b, n + 1)
        {
            if (a + b <= n && y - 10 * a - 5 * b == n - a - b) cout << a << " " << b << " " << n - a - b, exit(0);
        }
    }
    cout << "-1 -1 -1";
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var maxHonest = 0;
            var testimony = new Tuple<int, int>[n][];
            for (var i = 0; i < n; i++)
            {
                var a = int.Parse(Console.ReadLine());
                testimony[i] = new Tuple<int, int>[a];
                for (var j = 0; j < a; j++)
                {
                    var xy = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                    testimony[i][j] = new Tuple<int, int>(xy[0] - 1, xy[1]);
                }
            }

            foreach (var bit in BitFullSearchEnumerable(n))
            {
                var honest = bit.Count(x => x);
                var valid = true;
                for (var i = 0; i < n; i++)
                {
                    if (bit[i])
                    {
                        for (var j = 0; j < testimony[i].Length; j++)
                        {
                            var target = testimony[i][j].Item1;
                            var isHonest = testimony[i][j].Item2 == 1;
                            if (bit[target] != isHonest)
                            {
                                valid = false;
                                break;
                            }
                        }
                    }
                }
                if (valid) maxHonest = Math.Max(maxHonest, honest);
            }
            Console.WriteLine(maxHonest);
        }

        static IEnumerable<bool[]> BitFullSearchEnumerable(int n)
        {
            if (n < 0) yield return new bool[0];
            for (var i = 0; i < Math.Pow(2, n); i++)
            {
                var array = new bool[n];
                for (var j = 0; j < n; j++)
                {
                    var right = (i >> j) & 1;
                    array[j] = right == 1;
                }
                yield return array;
            }
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace _gnu_pbds;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i = a ; i < b ; i++)
#define stoink stack<ll>
#define quu queue<ll>
#define quee queue<pair<ll,ll>>
#define vec vector <ll>
#define vecd vector<ld>
#define vg vector<vector<ll> >
#define eg vector<pair<ll,ll>>
#define vgw vector<vector<pair<ll,ll> > >
#define pa pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
// #define pre 0.00000000000000000001
#define inf 100000000
#define endl '\n'
vg graph(100005);
ll mod;
vec in(100005),out(100005);
void inDfs(ll ver,ll par) {
    in[ver] = 1;
    for(auto i : graph[ver]) {
        if(i == par)
            continue;
        inDfs(i,ver);
        in[ver] = ((in[i] + 1) % mod * in[ver]) % mod;
    }
}
void outDfs(ll ver,ll par,ll up) {
 	in[ver] = (in[ver] * (up + 1)) % mod;
 	vec arr(graph[ver].size() + 1);
 	ll  n = 0;
 	for(auto i : graph[ver]){
 		if(i == par)
 			continue;
 		arr[++n] = i;
 	}
 	vec suff(n+2,1),pre(n+2,1);
 	fr(i,1,n + 1) {
 		pre[i] = (pre[i - 1] * (in[arr[i]] + 1)) % mod;
 	}
 	for(int i = n; i >= 1 ; i--) {
 		suff[i] = (suff[i + 1] * (in[arr[i]] + 1)) % mod;
 	}
 	fr(i,1,n + 1) {
 		ll val = (((pre[i - 1] * suff[i + 1]) % mod) * (up + 1)) % mod;
 		outDfs(arr[i],ver,val);
 	}
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin >> n >> m;
    mod = m;
    fr(i,1,n) {
        ll u,v;
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    inDfs(1,0);
    outDfs(1,0,0);
    fr(i,1,n+1) cout << in[i] % mod << endl;
    return 0;
}	

Measured memory_bytes: 23156
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n,m,a,b,c,d,ans;
    ll l;
    cin>>a>>b>>c;
    while(b<a){
        b++;c--;
    }
    cout<<max(c,0)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
r,c = gets.split(" ").map do |i| i.to_i end
spreadsheet = Array.new(r+1)
(0..r).each do |r|
    input = gets.to_s
    spreadsheet[r] = input.split(" ").map do |i| i.to_i end
    spreadsheet[r].push(spreadsheet[r].inject(:+))
end

spreadsheet[-1] = Array.new(c+1)
spreadsheet[-1].fill(0)

(0..c).each do |c|
    (0..r-1).each do |r|
        spreadsheet[-1][c] += spreadsheet[r][c]
    end
end

(0..r).each do |r|
    puts "#{spreadsheet[r].join(" ")}"
end

Measured memory_bytes: 9000
#include<iostream>
#include<string>
using namespace std;
	
int main(){
  	string S;
  	string ans;
	cin >> S;
  	for(int i = 0 ; i < 12; i++){
    	if(i!= 4){
          	ans +=S[i];
        }else{
          	ans +=" ";
        	ans +=S[i];
        }
    }
  	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int ans = 0;
    rep(i,n){
        int a; cin >> a;
        ans += a;
    }
    cout << ans - n << endl;


    return 0;
}

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

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> vec(N);

    for(int i = 0; i < N; i++){
	int a;
	cin >> a;
	vec.at(i) = a;
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    
    int alice = 0;
    int bob = 0;
    bool turn = true;
    for(int a: vec){
	if(turn){
	    alice += a;
	}else{
	    bob += a;
	}
	turn = !turn;
    }

    cout << (alice-bob) << endl;
}


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

int main() {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 累積和と連想配列
    vector<long long> s(N+1, 0);
    map<long long, long long> nums;
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
    for (int i = 0; i < N+1; ++i) nums[s[i]]++;

    // 集計処理
    long long res = 0;
    for (auto it : nums) {
        long long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
}   

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

#define ll long long
#define pb push_back
#define for(i,a,b) for(ll i=a;i<b;i++)

using namespace std;


int main(void)
{
    string s;
    getline(cin,s);
    if(s[2]==s[3] && s[4]==s[5]) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
const int maxn=3011,maxm=1e5+1;
string s,t;
vector<char> ret;
int f[maxn][maxn];
pii pre[maxn][maxn];
main()
{
    cin>>s>>t;
    int m=s.size(),n=t.size();
    s=' '+s;
    t=' '+t;
    forinc(i,1,m)
    forinc(j,1,n)
    {
        ///f[i][j]=max(f[i-1][j],f[i][j-1]);
        if(s[i]==t[j])
        {
             f[i][j]=f[i-1][j-1]+1;
            pre[i][j]={i-1,j-1};
            //cout<<i<<" "<<j<<"\n";
        }
        else{
            if(f[i-1][j]>f[i][j-1])
        {
            pre[i][j]={i-1,j};
            f[i][j]=f[i-1][j];
        }
        else{
            pre[i][j]={i,j-1};
            f[i][j]=f[i][j-1];
        }
        }
    }
    while(m>0&&n>0)
    {
        if(s[m]==t[n]) ret.push_back(s[m]);
        int u=m,v=n;
        m=pre[u][v].first;
        n=pre[u][v].second;
    }
    reverse(ret.begin(),ret.end());
    for(auto &v:ret) cout<<v;
}


Measured memory_bytes: 106368
def get_array():
    l=list(map(int, input().split()))
    return l
def ab(a,b,c):
	if((a+b>c) and (a+c>b) and (b+c>a)):
		return 1
	else:
		return 0
n=input()
n=int(n)
l=get_array()
c=0
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if(l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]):
				if(ab(l[i],l[j],l[k])):
					#print(i,j,k)
					c+=1
print(c)	

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

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

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

  string s; cin >> s;
  ll ans = 0;
  rep(i, 1<<(s.size()-1)) {
    ll tmp = s[0]-'0';
    rep(j, s.size()-1) {
      if(i & 1<<j) {
        ans += tmp;
        tmp = s[j+1]-'0';
      } else {
        tmp = tmp*10+s[j+1]-'0';
      }
    }
    ans += tmp;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
while True:
	try:
		n=int(input())
		cnt=0
		for a in range(10):
			if a<=n:
				for b in range(10):
					if b<=n:
						for c in range(10):
							if c<=n:
								d = n-(a+b+c)
								if 0<=d<=9:
									cnt+=1
							else:
								break
					else:
						break
			else:
				break
		print(cnt)
	except EOFError:
		break

Measured memory_bytes: 7628
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
	int N;
	int A[210] = { 0 };
	int target = 0;

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

	for (int i = 1;; i++) {
		target = std::pow(2, i);

		for (int idx = 0; idx < N; idx++) {
			if ((A[idx] % target) != 0) {
				cout << i - 1 <<endl;
				return 0;
			}
		}

	}
	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int ,int> pi;
typedef pair<ll ,ll> pl;
typedef map<ll ,ll> ml;
#define modulo 1000000007
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N=1e6+1;

void solve()
{ 
    string s1,s2;
    cin >> s1;
    cin >> s2;
    int count=0;
    for(int i=0;s1[i];i++)if(s1[i]!=s2[i])count++;
    cout << count << endl;
}

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

Measured memory_bytes: 3836
A, B, C, D, E, F = map(int, input().split())

noudo = 0
satou = 0
sato_mizu = 100 * A

for x in range(F//(100*A)+1):
    for y in range(F//(100*B)+1):
        if 100 * (A*x+B*y) > F:
            break

        for z in range(F // C + 1):
            if C * z > (A * x + B * y) * E:
                break

            if 100 * (A * x + B * y) + C * z > F:
                break

            for w in range(F // C + 1):
                if (C*z + D*w + 100 * (A*x+B*y)) == 0:
                    break

                if C*z + D*w > (A * x + B * y)*E:
                    break

                if 100 * (A*x+B*y)+C*z + D*w > F:
                    break

                if noudo < 100* (C*z + D*w)/(C*z + D*w + 100 * (A*x+B*y)):
                    noudo = 100* (C*z + D*w)/(C*z + D*w + 100 * (A*x+B*y))
                    sato_mizu = (C*z + D*w + 100 * (A*x+B*y))
                    satou = C*z + D*w
print(sato_mizu, satou)

Measured memory_bytes: 80336
#include <stdio.h>
#include <stdlib.h>
int main(void) {
  void* m=malloc(8);
  if(! scanf("%d%d", (int*)m, (int*)(m+4)) ) exit(0);
  *(double*)m= (double) *(int*)m / *(int*)(m+4);
  printf("%f\n", *(double*)m);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;
    cin >> n;
    double x;
    string u;
    double sum = 0;
    for(int i = 0; i < n; i++){
        cin >> x >> u;
        if(u == "JPY") sum += x;
        else sum += x * 380000.0;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef struct{
    long weight;
    long no;
} wn;

bool wncw(const wn& a, const wn& b){
    if(a.weight != b.weight){
        return a.weight < b.weight;
    }else{
        return a.no < b.no;
    }
}
bool wncn(const wn& a, const wn& b){
    if(a.no != b.no){
        return a.no < b.no;
    }else{
        return a.weight < b.weight;
    }
}

using node = vector<long>;
void connect_check(long from, const vector<node>& graph, vector<wn>& a){
    long s=graph[from].size();
    for(long j=0; j<s; j++){
        long to = graph[from][j];
        if(a[from].no!=a[to].no){
            a[to].no=a[from].no;
            connect_check(to, graph, a);
        }
    }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long n, m;
    cin >> n >> m;
    //最初から木
    if(m==n-1){
        cout << "0" << endl;
        return 0;
    }
    if(2*(n-m-1)>n){
        cout << "Impossible" << endl;
        return 0;
    }
    vector<wn> a(n);
    for(long i=0; i<n; i++){
        cin >> a[i].weight;
        a[i].no = -1;
    }
    vector<node> graph(n);
    for(long i=0; i<m; i++){
        long x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    long no=0;
    for(long i=0; i<n; i++){
        if(a[i].no==-1){
            a[i].no=no;
            connect_check(i, graph, a);
            no++;
        }
    }
    long cost_sum=0;
    sort(a.begin(), a.end(), wncn);
    for(long k=0, i=0; k<n-m; k++){
        while(a[i].no!=k) i++;
        cost_sum += a[i].weight;
        a[i].weight = 1e10;
    }
    sort(a.begin(), a.end(), wncw);
    for(long k=0; k<n-m-2; k++){
        cost_sum += a[k].weight;
    }
    cout << cost_sum << endl;
    /*
    for(long i=0; i<n; i++){
        long s=graph[i].size();
        cout << i << " : ";
        cout << a[i].weight << " : ";
        cout << a[i].no << " : ";
        for(long j=0; j<s; j++){
            cout << graph[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int a[3];
int res[4] = {0};

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a + 3);
    ++res[0];
    if(a[0] <= 0 || a[1] <= 0 || a[2] <= 0 || a[2] >= a[1] + a[0])break;
    else if(a[2] * a[2] == a[0] * a[0] + a[1] * a[1])++res[1];
    else if(a[2] * a[2] > a[0] * a[0] + a[1] * a[1])++res[3];
    else ++res[2];


//*/

//*/ break;
  }
  printf("%d %d %d %d\n", res[0] - 1, res[1], res[2], res[3]);
  return 0;
}

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

int main() {
	int a;
	scanf("%d",&a);
	int b;
	scanf("%d",&b);
	int c;
	scanf("%d",&c);
	int k;int gg=0;
	scanf("%d",&k);
	int s=0;
	if(k<a)
	{printf("%d",k);gg=9;}
	else if(k>=a)
	{
	    k=k-a;
	    s=s+a;
	    if(b<=k)
	    {
	        k=k-b;
	    }
	    else if(b>k && gg==0)
	    {printf("%d",s);gg=9;}
	    if(c<=k)
	    {
	        k=k-c;
	        s=s-c;
	    }
	    else if(c>k)
	    s=s-k;
	    if(gg==0)
	    printf("%d",s);
	}
	return 0;
}


Measured memory_bytes: 3704
import collections
import math

def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

def nCr(n,r):
  #print(n,r)
  return (FAC[n]*INV[n-r]*INV[r])%MOD

n,m = map(int,input().split())

MOD = 10**9 + 7
FAC = [1]
INV = [1]
N = int(math.log(m,2))+n+1
for i in range(1,N+1):
  FAC.append((FAC[i-1]*i) % MOD)
  INV.append(pow(FAC[-1],MOD-2,MOD))

c = collections.Counter(prime_factorize(m))
#print(c)
ans = 1
for k,v in c.items():
  #print(k,v)
  ans *= nCr(v+n-1,v)
  ans %= MOD
print(ans)

Measured memory_bytes: 83640
<?php
$n = fscanf(STDIN, str_repeat("%d ", 3));

$cnt5 = 0;
$cnt7 = 0;

foreach($n as $k => $v){
    if($v === 5){
        $cnt5++;
    } else {
        $cnt7++;
    }
}

if( $cnt5 === 2 && $cnt7 === 1 ) {
    echo 'YES';
} else {
    echo 'NO';
}
?>


Measured memory_bytes: 4728
fun main(args: Array<String>) {
    val (k, x) = readLine()!!.split(" ").map { it.toInt() }
    val ans = mutableListOf<Int>()
    for (i in x-k+1..x) ans.add(i)
    for (i in x+1 until x+k) ans.add(i)
    println(ans.joinToString(" "))
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	string s;

	cin >> s;

	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t a, b, c, d;

    std::cin >> a >> b >> c >> d;

    int64_t max = -INT64_MAX;

    max = std::max(max, a*c);
    max = std::max(max, a*d);
    max = std::max(max, b*c);
    max = std::max(max, b*d);

    std::cout << max << std::endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;

int main() {
	string s;
	deque<char> tmp;
	cin >> s;
	for (auto i : s) {
		tmp.pb(i);
	}
	int q;
	bool rev = 0;
	scanf("%d", &q);
	while (q--) {
		int t;
		scanf("%d", &t);
		if (t == 1) {
			rev ^= 1;
		} else {
			int f; char c;
			cin >> f >> c;
			if (f == 1) {
				if (rev) {
					tmp.pb(c);
				} else {
					tmp.push_front(c);
				}
			} else {
				if (!rev) {
					tmp.pb(c);
				} else {
					tmp.push_front(c);
				}
			}
		}
	}
	if (rev) {
		while (!tmp.empty()) {
			cout << tmp.back();
			tmp.pop_back();
		}
		printf("\n");
	} else {
		while (!tmp.empty()) {
			cout << tmp.front();
			tmp.pop_front();
		}
		printf("\n");
	}
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

inline int S(int x) {
  int r = 0;
  while (x) {
    r += x % 10, x /= 10;
  }
  return r;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  int n;
  Read(n);
  int ans = INT_MAX;
  for (int i = 1; i < n; ++i) {
    CheckMin(ans, S(i) + S(n - i));
  }
  printf("%d\n", ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 764
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.awt.geom.*;
import static java.util.Arrays.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int W;
		int N;
		int[] v = new int[1010];
		int[] w = new int[1010];
		int[][] u = new int[1010][1010];
		int count = 1;
		while(true){
			W = Integer.parseInt(sc.next());
			if(W==0){
				break;
			}
			N = Integer.parseInt(sc.next());
			for(int i=0;i<N;i++){
				String str = sc.next();
				String[] num = str.split(",",0);
				v[i+1] = Integer.parseInt(num[0]);
				w[i+1] = Integer.parseInt(num[1]);
			}

			for(int i=1;i<=N;i++){
				for(int j=0;j<=W;j++){
					if(j<w[i]){
						u[i][j] = u[i-1][j];
					}
					else{
						if(u[i-1][j]>u[i-1][j-w[i]]+v[i]){
							u[i][j] = u[i-1][j];
						}
						else{
							u[i][j] = u[i-1][j-w[i]]+v[i];
						}
					}
				}
			}
			int max = u[N][W];
			out.println("Case "+count+":");
			out.println(max);
			out.flush();
			for(int i=1;i<=W;i++){
				if(u[N][i]==max){
					out.println(i);
					out.flush();
					break;
				}
			}
			count++;
		}
	}
}

Measured memory_bytes: 29688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = Integer.parseInt(in.next());
		int b = Integer.parseInt(in.next());
		
		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}
	}
}	


Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	ll n,k;
	cin>>n>>k;
    COMinit();	
	ll ans=0;
	for(ll i=0;i<=min(k,n-1);i++){
		ll cnt=COM(n,i);
		ll cnt2=COM(n-1,i);
		ll sum=cnt*cnt2;
		sum%=inf;
		ans+=sum;
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 15532
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
	int n; cin >> n;
	ll ans = 0, c = -1, d;
	for (int i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		if (a <= b)ans += b;
		else {
			if (c == -1) { c = a; d = b; }
			else if (b < d) {
				ans += d; c = a; d = b;
			}
			else ans += b;
		}
	}
	if (c == -1)cout << "0\n";
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N,M,Q = map(int,input().split())

Section = [[0]*N for _ in range(N)]
for _ in range(M):
    L,R = map(int,input().split())
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for _ in range(Q):
    p,q = map(int,input().split())
    print(Ans[p-1][q-1])

Measured memory_bytes: 21076
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

void dfs(int u, int p, int d, vector<int> &depth, vector<int> &sub_max, vector<vector<int>> &graph){
	depth[u] = d;
	int s = 0;
	for(int v: graph[u]){
		if(v==p) continue;
		dfs(v, u, d+1, depth, sub_max, graph);
		s = max(sub_max[v]+1, s);
	}
	sub_max[u] = s;
}

int main(){
	int N, U, V;
	cin >> N >> U >> V;
	U--; V--;
	vector<vector<int>> graph(N);
	for(int i=0; i<N-1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	vector<int> depth(N), sub_max(N);
	dfs(V, -1, 0, depth, sub_max, graph);

	int ans = 0;
	int x = U;
	while(x != V) {
		int a = depth[x];
		int b = depth[U]-depth[x];
		if(a <= b) break;
		ans = max(ans, b + sub_max[x] + a - b - 1);

		for(int y: graph[x]){
			if(depth[x]==depth[y]+1){
				x = y;
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
    int N, R_sum=0, B_sum=0;
    string s;
    cin >> N;
    cin >> s;
    for (int i = 0; i < N; ++i) {
        if (s[i] == 'R') R_sum++;
        else if (s[i] == 'B') B_sum++;
    }
    if (R_sum > B_sum) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

string str;
int q;

int main(){
	cin >> str >> q;
	string od, rp;
	int a, b;
	for (int I = 0; I < q; I++) {
		cin >> od >> a >> b;
		if (od == "print") {
			for (int i = a; i <= b; i++) {
				cout << str[i];
			}
			cout << endl;
		}
		else if (od == "reverse") {
			int c = (b - a + 1) / 2;
			for (int i = 0; i < c; i++) {
				char r = str[a + i];
				str[a + i] = str[b - i];
				str[b - i] = r;
			}
		}
		else if (od == "replace") {
			cin >> rp;
			for (int i = a; i <= b; i++) {
				str[i] = rp[i- a];
			}
		}
	}

	return 0;
}

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

int main() {
  int  H , M , h, m , K;
  cin >> H >> M >> h >> m >> K;
  int sa;
  sa=(h*60+m)-(H*60+M)-K;
  cout << sa << endl;
}

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

int main(void){
  int n, m;
  vector<int> t(100), p(100), x(100);

  cin >> n;

  for(int i = 0; i < n; i ++)
    cin >> t.at(i);

  cin >> m;

  for(int i = 0; i < m; i ++)
    cin >> p.at(i) >> x.at(i);

  for(int i = 0; i < m; i ++){
    int sum = 0;
    for(int j = 0; j < n; j ++){
      if(j == (p.at(i)-1)) sum += x.at(i);
      else sum += t.at(j);
    }
    cout << sum << 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;

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

    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    char hand[t.length()];

    int res = 0;
    rep(i, t.length()){
        if(i<k){
            if(t[i] == 's') {
                res += r;
                hand[i] = 'r';
            }
            if(t[i] == 'p') {
                res += s;
                hand[i] = 's';
            }
            if(t[i] == 'r') {
                res += p;
                hand[i] = 'p';
            }
        }
        else{
            if(t[i] == 's') {
                if(hand[i-k] != 'r'){
                    res += r;
                    hand[i] = 'r';
                }
                else hand[i] = '?';
            }
            if(t[i] == 'p') {
                if(hand[i-k] != 's'){
                    res += s;
                    hand[i] = 's';
                }
                else hand[i] = '?';
            }
            if(t[i] == 'r') {
                if(hand[i-k] != 'p'){
                    res += p;
                    hand[i] = 'p';
                }
                else hand[i] = '?';
            }            
        }
    }
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 592
def pushBack(lists, x):
    return lists.insert(len(lists), x)

def randomAccess(lists, p):
    print(lists[p])

def popBack(lists):
    return lists.pop(len(lists) - 1)

if __name__ == '__main__':
    l = list()
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            pushBack(l, int(j[1]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            popBack(l)


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

int main () {
  if (fopen ("test.inp", "r")) {
    freopen ("test.inp", "r", stdin);
  }
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  string s;
  int a;
  cin >> a >> s;
  if (a >= 3200) {
    cout << s;
  }
  else {
    cout << "red";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

int main() {

int H,W,x,y;

do{
cin >> H >> W;
for(x=1;x<=H;++x){
for(y=1;y<=W;++y){
if(H==0 && W==0){break;}
cout << "#";
}
if(H==0 && W==0){break;}
cout << endl;
}
if(H==0 && W==0){break;}
cout << endl;
}while(H>0 && W>0);

}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int m; cin>>m;
    cout<<48-m<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner sc = new Scanner(System.in);

    private long pow(long x) {
        long r = 1;
        for (int i = 0; i < 5; ++i) {
            r *= x;
        }
        return r;
    }

    private void run() {
        long t = sc.nextLong();
        for (long x = 0; x <= 1000; ++x) {
            for (long y = -1000; y <= 1000; ++y) {
                long v = pow(x) - pow(y);
                if (v == t) {
                    System.out.println(String.format("%d %d", x, y));
                    return;
                }
            }
        }
    }

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


Measured memory_bytes: 35824