akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> d(n + 1);
    int l;
    int ans = 0;
    REP(i, n + 1){
        if (i == 0){
            d[i] = 0;
        }else{
            cin >> l;
            d[i] = d[i - 1] + l;
        }
        
        if (d[i] <= x) ans++;
        else break;
    }
    cout << ans << "\n";
}


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

using namespace std;

int main()
{
	unsigned int n;
	cin >> n;
	unsigned int ts = 0;
	unsigned int hs = 0;

	for (unsigned int i = 0; i < n; ++i) {
	    string t, h;
		cin >> t >> h;
		if (t == h) {
			ts += 1;
			hs += 1;
		} else if (t < h) {
			hs += 3;
		} else {
			ts += 3;
		}
	}
	cout << ts << " " << hs << endl;
	return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x, y; cin >> x >> y;
  vector<int> s = {0, 1, 0, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  cout << ((s[x] == s[y]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[10];
cin >> s;
int num = strlen(s);
int n=0;
int sn=0;
REP(i,num) {
  n+=(s[i]-'0')*pow(10,num-i-1);
  sn+=(s[i]-'0');
}
if(n%sn==0) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


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

using namespace std;
#define int long long
const int p=1e9+7;
int gcd(int x,int y)
{
    if(x==0)
    {
        return y;
    }
    if(y==0)
    {
        return x;
    }
    if(x>=y)
    {
        return gcd(y,x%y);
    }
    return gcd(x,y%x);
}
pair <int,int> rev(pair <int,int> o)
{
    int x=-o.second;
    int y=o.first;
    if(x>0)
    {
        return {x,y};
    }
    else if(x==0 && y>=0)
    {
        return {x,y};
    }
    else
    {
        return {-x,-y};
    }
}
int po(int a,int b)
{
    if(b==0)
    {
        return 1;
    }
    if(b==1)
    {
        return a;
    }
    if(b%2==0)
    {
        int u=po(a,b/2);
        return (u*u)%p;
    }
    int u=po(a,b-1);
    return (a*u)%p;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    int b[n];
    pair <int,int> c[n];
    int ans1=0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i]>>b[i];
        if(a[i]==0 && b[i]==0)
        {
            ans1++;
            c[i]={0,0};
            continue;
        }
        int x=abs(gcd(abs(a[i]),abs(b[i])));
        c[i]={a[i]/x,b[i]/x};
        if(c[i].first<0)
        {
            c[i].first*=(-1);
            c[i].second*=(-1);
        }
        if(c[i].first==0)
        {
            c[i].second=abs(c[i].second);
        }
    }
    vector <pair<int,int> > keys;
    map <pair<int,int>,int> u;
    for(int i=0;i<n;++i)
    {
        if(c[i]!=make_pair(0LL,0LL))
        {
            if(!u.count(c[i]))
            {
                keys.push_back(c[i]);
                u[c[i]]=1;
            }
            else
            {
                u[c[i]]++;
            }
        }
    }
    set <pair<int,int> > o;
    int ans=1;
    for(int i=0;i<keys.size();++i)
    {
        pair <int,int> o1=keys[i];
        if(o.count(o1))
        {
            continue;
        }
        pair <int,int> o2=rev(keys[i]);
        o.insert(o1);o.insert(o2);
        int x1=u[o1];int x2;
        if(!u.count(o2))
        {
            x2=0;
        }
        else
        {
            x2=u[o2];
        }
        ans*=(po(2,x1)+po(2,x2)-1);
        ans%=p;
    }
    cout<<(ans+ans1-1+p)%p;
    return 0;
}


Measured memory_bytes: 50108
/*  CREATED BY
    STREAM_CIPHER
    7-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout << fixed << setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int n,m;
vector<int>g[mx];
vector<int>topo_order;
bool vis[mx];
void dfs(int start)
{
    vis[start]=1;
    for(auto i:g[start])
        if(!vis[i])
            dfs(i);
    topo_order.push_back(start);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        cin>>n>>m;
        for(int i=0;i<m;i++)
        {
            int u,v;
            cin>>u>>v;
            u--,v--;
            g[u].push_back(v);
        }
        for(int i=0;i<n;i++)
            if(!vis[i])
                dfs(i);
        reverse(all(topo_order));
        // for(auto i:topo_order)
        //     cout<<i+1<<" ";
        int dp[n+9]={0};
        memset(dp,0,sizeof dp);
        for(auto i:topo_order)
        {
            for(auto j:g[i])
                dp[j]=max(dp[i]+1,dp[j]);
        }
        // for(int i=0;i<n;i++)
        //     cout<<dp[i]<<" ";
        // cout<<endl;
        int ans=0;
        for(int i=0;i<n;i++)
            ans=max(dp[i],ans);
        cout<<ans<<endl;
}

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

while len(a) > 1:
    res=[]
    a.sort()
    a_mn = a[0]
    res.append(a_mn)
    for i in range(1,len(a)):
        hp = a[i] % a_mn
        if hp!=0:
            res.append(hp)
    a=res
print(a[0])

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const string expr[] = {"+", "-", "*", "/"};
string str;

int main()
{
  while(getline(cin, str)){
    stack<double> st;
    string tmp;
    istringstream stream(str);
    while(getline(stream, tmp, ' ')){
      bool flag = false;
      rep(k, 4) if(tmp == expr[k]){
        double a = st.top();  st.pop();
        double b = st.top();  st.pop();
        if(k == 0){ st.push(b + a);  flag = true;  break; }
        if(k == 1){ st.push(b - a);  flag = true;  break; }
        if(k == 2){ st.push(b * a);  flag = true;  break; }
        if(k == 3){ st.push(b / a);  flag = true;  break; }
      }
      if(!flag) st.push((double)strtol(tmp.c_str(), NULL, 10));
    }
    printf("%.15f\n", st.top());
  }

  return 0;
}

Measured memory_bytes: 1268
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

vector<int> nums;

void dfs(string s, int n)
{
    if (n == 0)
    {
        map<char, int> mp;
        rep(i, s.size())
        {
            if (!mp.count(s[i]))
            {
                mp[s[i]] = 1;
            }
        }
        if (mp.count('3') && mp.count('5') && mp.count('7'))
        {
            nums.push_back(stoi(s));
        }
        return;
    }
    dfs(s + '3', n - 1);
    dfs(s + '5', n - 1);
    dfs(s + '7', n - 1);
}

int main()
{
    int N;
    cin >> N;
    rep2(i, 3, 10)
    {
        dfs("", i);
    }

    rep2(i, 1, nums.size())
    {
        if (N < 357)
        {
            cout << 0 << endl;
            return 0;
        }
        if (nums[i - 1] <= N && N < nums[i])
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << nums.size() << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int x1, x2, y1, y2;cin>>x1>>y1>>x2>>y2;

    int dx=x2-x1; int dy = y2-y1;
    int x3 = x2 -dy;
    int y3 = y2 + dx;
    int x4 = x1 -dy;
    int y4= y1 +dx;

    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;

    return 0;
}


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

int main() {
	int n, m, a[50], b[50], c[50], d[50], ans1[50], ans2[50];
	cin >> n >> m;
	for (int i = 0; i < 50; i++) {
		ans2[i] = 9999999999;
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < ans2[i]) {
				ans2[i] = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans1[i] = j+1;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << ans1[i] << endl;
	}
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    
    vector<int> a;
    
    for(int i=0;i<N;i++)
    {
        int Temp;
        cin>>Temp;
        
        a.push_back(Temp);
        
    }
    
    sort(a.begin(),a.end(),greater<int>());
    
    int max,gokei;
    gokei=0;
    
    max=a[0];
    
    for(int i=1;i<N;i++)
    {
        gokei+=a[i];
    }
    
    if(gokei>max)
    {
        cout<<"Yes";
    }
    
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = 10 ** 9 + 7


# 逆元の前計算
factorial = [1, 1]
inverse = [1, 1]
invere_base = [0, 1]
for i in range(2, N + M + 1):
    factorial.append((factorial[-1] * i) % MOD)
    invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD)
    inverse.append((inverse[-1] * invere_base[-1]) % MOD)


def nCr(n, r):
    if not 0 <= r <= n:
        return 0
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


def nPr(n, r):
    if not 0 <= r <= n:
        return 0
    return nCr(n, r) * factorial[r] % MOD


ans = pow(nPr(M, N), 2, MOD)
for k in range(1, N + 1):
    x = nCr(M, k) * nPr(N, k) * pow(nPr(M - k, N - k), 2, MOD) % MOD
    if k % 2 == 1:
        x = -x
    ans += x
    ans %= MOD

print(ans)


Measured memory_bytes: 214592
use std::io::*;
use std::str::FromStr;

fn solve(line: &str, y: &u32, m: &u32, d: &u32) {
    if *y > 31 {
        println!("? {} {} {}", y-30, m, d);
    } else if *y == 31 && *m >= 5 {
        println!("? {} {} {}", y-30, m, d);
    } else {
        println!("HEISEI {} {} {}", y, m, d);
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    loop {
        let line = iter.next().unwrap();
        if line=="#" {
            break;
        }
        let y: u32 = iter.next().unwrap().parse().unwrap();
        let m: u32 = iter.next().unwrap().parse().unwrap();
        let d: u32 = iter.next().unwrap().parse().unwrap();
        solve(line, &y, &m, &d);
    }
}




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

using namespace std;
#define int long long
#undef int
int main(){
	#define int long long
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	int sum=0,pre=0;
	for(int i=1;i<=n;i++){
		int t;cin>>t;
		if(t==i)pre++;
		else if(pre==1){
			sum++;pre=0;
		}
		if(pre==2){
			sum++;pre=0;
		}
		if(pre>2){
			assert(0);
		}
	}
	if(pre>=1)sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define For(i,n,k) for(ll i=(n);i<(k);i++)
    #define ALL(a)  (a).begin(),(a).end()
    ll ans=0;
    ll n,sq=50,x;
    vector<ll> a(2000);
    vector<ll> badget(50,1e9+7);

    ll find(ll x,ll num){//x番目から左にnum個までのmin
        ll left=x-num+1,right=x;
        ll val=1e9+7;
        if(left==right){
            val=a[left];
        }
        else if(left<0){
            val=min(find(x,x+1),find(n-1,num-x-1));
        }
        else{
            while(left%sq!=0&&left<=right){
                val=min(val,a[left]);
                left++;
            }
            while(right%sq!=0&&left<=right){
                val=min(val,a[right]);
                right--;
            }
            val=min(val,a[right]);
            while(left<right){
                val=min(val,badget[left/sq]);
                left+=sq;
            }
        }
        return val;
    }
    ll calc(ll l){
        ll val=l*x;
        For(i,0,n){
            val+=find(i,l+1);
        }
        return val;
    }
    void Main(){
        cin>>n>>x;
        For(i,0,n){
            cin>>a[i];
            ans+=a[i];
        }

        sq=sqrt(n);
        For(i,0,n){
            badget[i/sq]=min(badget[i/sq],a[i]);
        }

        ll left=0,right=n;
        while(left<right-2){
            ll l1=(2*left+right)/3,l2=(left+2*right)/3;
            if(calc(l1)<calc(l2)){
                right=l2;
            }
            else{
                left=l1;
            }
        }
        
        ans=min({ans,calc(left),calc((left+right)/2),calc(right)});
        cout<<ans<<endl;
    }
    int main(){
        Main();
        return 0;
    }   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k; cin >> n >> k;
    vector<double> p(n+1);
    p[0] = 0;
    for (int i = 0; i < n; i++) {
        ll num; cin >> num;
        p[i+1] = p[i] + (double)(num + 1) / 2;
    }
    // for (auto elem : p) cout << elem << " "; cout << endl;

    double max_num = 0;
    for (int i = 0; i < n - k + 1; i++) {
        max_num = max(max_num, p[i+k] - p[i]);
    }
    printf("%.12lf\n", max_num);

    return 0;
}

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

int a, b, c;

int main() {
    cin >> a >> b >> c;
    int M = max({a, b, c});
    int ans;
    if ((3 * M - a - b - c) % 2 == 0) {
        ans = (3 * M - a - b - c) / 2;
    } else {
        ans = (3 * (M + 1) - a - b - c) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ans = 0
N.times do |i|
  ans += B[A[i] - 1]
  if i != 0
    if A[i] - 1 == A[i-1]
      ans += C[A[i-1] - 1]
    end
  end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) cout << "Yes";
  else cout << "No";
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())

p = (c * d) // gcd(c, d)

a_under = a-1

ans = (b - b//c - b//d + b//p) - (a_under - a_under//c - a_under//d + a_under//p)

print(ans)

Measured memory_bytes: 5304
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

ll gcb(ll a, ll b){/// ユークリッドの互除法: O(log)
    
    if(b == 0) return a;
    
    return gcb(b,a%b);
}


ll lcm(ll a, ll b){
    
    return  a/gcb(a,b) * b; ///gcbは約数
}

int getDigit(ll num){
    return log10(abs(num))+1;
}


int main() {
    string n;cin>>n;
    
    if(n[0]-'0' != 9){
        
        for(auto v = 1;v<n.size();v++){
            
            if(n[v]-'0'!=9){
                cout<<n[0]-'0'-1 + (n.size()-1)*9<<endl;
                return 0;
            }
            
        }
        cout<<n[0]-'0'  +(n.size()-1)*9<<endl;
        return 0;
        
    }
    
    int ans = 0;
    int cur = 0;
    while(n[cur]-'0'==9 && cur != n.size()) {ans+=9;cur++;}
    if(cur==n.size()){cout<<n.size()*9<<endl; return 0;}
    
    cout<<(ans-1) + (n.size()-cur)*9<<endl;
    
    return 0;
}








Measured memory_bytes: 256
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()

down=[0]*(n+1)
up=[0]*(n+1)
up[0]=n
ans=0 if k>1 else n+1
for i in range(1,n+1):
    down[i]=down[i-1]+i
    up[i]=up[i-1]+(n-i)
    if i>=k-1:
        ans+=up[i]-down[i]+1
print(ans%(10**9+7))

Measured memory_bytes: 30096
#include<bits/stdc++.h>
using namespace std;    
#define int long long        
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar) for(int pen=0;pen<sizeof(ar)/8;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rt return 0;
#define mod 1000000007
const int N= 8*1e5+ 10;
int st[N]={0};
void update(int ss, int se, int i, int diff, int si)  
{  
    // Base Case: If the input index lies outside the range of  
    // this segment  
    if (i < ss || i > se)  
        return;  
  
    // If the input index is in range of this node, then update  
    // the value of the node and its children  
    st[si] = st[si] + diff;  
    if (se != ss)  
    {  
        int mid = (ss+se)/2;  
        update(ss, mid, i, diff, 2*si);  
        update(mid+1, se, i, diff, 2*si + 1);  
    }  
}  
int get_sum(int ss, int se, int qs, int qe, int si)  
{  
    // If segment of this node is a part of given range, then return  
    // the sum of the segment  
    if (qs <= ss && qe >= se)  
        return st[si];  
  
    // If segment of this node is outside the given range  
    if (se < qs || ss > qe)  
        return 0;  
  
    // If a part of this segment overlaps with the given range  
    int mid = (ss+se)/2;
    return get_sum(ss, mid, qs, qe, 2*si) +  
        get_sum(mid+1, se, qs, qe, 2*si+1);  
}
int dp[3001][3001]; 
int lcs( string X, string Y, int m, int n )  
{  
    if (m == 0 || n == 0)  
        return 0;

    if(dp[m][n]!=0)
    {
        return dp[m][n];
    }  
    if (X[m-1] == Y[n-1])  
    {
        dp[m][n]=1+lcs(X,Y,m-1,n-1);
        // return 1 + lcs(X, Y, m-1, n-1);
        return dp[m][n];
    }  
    else
     {
         dp[m][n]= max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n));
        return dp[m][n];
     }  
} 
signed main()
{
    string s,t;
    cin>>s>>t;
    int m=s.length();
    int n=t.length();
    for(int i=0;i<=m;i++)
    for(int j=0;j<=n;j++)
    dp[i][j]=0;

   // int final=lcs(s,t,m,n);
    int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (s[i-1] == t[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
   // cout<<lcs(s,t,m,n)<<endl;
   int final=L[m][n];
  // cout<<final<<endl;
   char lcs[final+1];
   lcs[final]='\0';
   int i=m;
   int j=n;
   while(i>0 && j>0){
       if(s[i-1]==t[j-1]){
           lcs[final-1]=s[i-1];
           i--;
           j--;
           final--;
       }
       else if(L[i-1][j]>L[i][j-1]){
           i--;
       }
       else
       {
           j--;
       }
   }
   cout<<lcs<<endl;
}

Measured memory_bytes: 142336
from heapq import heappop, heappush 
N, M = map(int, input().split())
score = 0
AB = [[] for i in range(M)]
for i in range(N):
  a, b = map(int, input().split())
  if M - a >= 0:
    AB[M - a].append(b)
  
#print(AB)
queue = []
for i in range(1, M + 1):
  for j in AB[-i]:
    heappush(queue, -j)
  if queue != []:
    score += -1 * heappop(queue)
  
  #print(score, queue)  
print(score)  
  
  




Measured memory_bytes: 24316
K, N = map(int,(input().split()))
A=list(map(int,(input().split())))
D=[]
for i in range(N):
    if i==(N-1):
        D.append(K+A[0]-A[i])
    else:
        D.append(A[i+1]-A[i])

print(str(int(K-max(D))))

Measured memory_bytes: 26444
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define sz size()
#define pi pair <int, int>
#define pii pair <pi, pi>
#define vi vector <int>
#define int long long
int n;
pair <pi, int> g[201];
vector <int> yy;
int ans;

bool s(pair <pi, int> a, pair <pi, int> b){
     return a.x.x<b.x.x;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>g[i].x.x>>g[i].x.y;
        g[i].y=1;
    }
    for(int i=1; i<=n; i++){
        cin>>g[i+n].x.x>>g[i+n].x.y;
        g[i+n].y=2;
    }
    sort(g+1, g+2*n+1, s);
    for(int i=1; i<=2*n; i++){
          //  cout<<g[i].y;
        if(g[i].y==1) yy.pb(g[i].x.y);
        else if(g[i].y==2){
            int j=-1, mx=-1;
            for(int k=0; k<yy.sz; k++){
                if(mx<yy[k] && g[i].x.y>yy[k]){
                    j=k;
                    mx=yy[k];
                }
            }
            if(j!=-1){
                yy.erase(yy.begin()+j);

                ans++;
            }
        }
    }
    cout<<ans;
}

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

using namespace std;
using ll = long long;

ll mul(ll x, ll y) {
  return x * y;
}

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll m = mul(a,c);
  ll n = mul(a,d);
  ll o = mul(b,c);
  ll p = mul(b,d);
  ll ans = max({m,n,o,p});
  cout << ans << '\n';
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<int> bit(60);
    rep(i, N) {
        rep(b, 60) bit[b] += A[i] >> b & 1;
    }

    ll ans = 0;
    rep(b, 60) {
        ll unit = (1LL << b) % MOD;
        ans = (ans + (ll)bit[b] * (N - bit[b]) % MOD * unit) % MOD;
    }
    write(ans);
}

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

using namespace std;

int N, C;
long long K, a, b;
int sol;

long long A[100005];
long long B[100005];

int main()
{
    #ifdef acm
    freopen("a.in", "r", stdin);
    #endif // acm

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

  cin >> N ;

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

  sort( A+1, A+1+N );

  for( int i = 1; i <= N; i ++ )
    B[i] = B[i-1]+A[i];




  int i;
  for( i = N-1; i >= 1; i -- ){
     if( B[i]*2 < A[i+1] )
        break;
  }

  cout << N-i << '\n';

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long

struct line
{
    int m,c;
    int eval(int x)
    {
        return (2*m*x) + c;
    }
    long double intersectX(line l)
    {
        return (c - l.c)/(l.m -m);
    }
};
deque<line> dq;
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,c1;
    cin>>n>>c1;
    int h[n+5];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dq.push_front({-h[1],(h[1]*h[1])});
    int ans=1;
    for(int i=2;i<=n;i++)
    {
        int x=h[i];
        while(dq.size()>=2 && dq.back().eval(x)>dq[dq.size()-2].eval(x)){
          /*  if(i>=4)
            {
                cout<<dq.back().eval(x)<<" "<<dq[dq.size()-2].eval(x)<<"\n";
            }*/
            dq.pop_back();
        }
        int dp=(x*x)+c1+dq.back().eval(x);
        ans=dp;
        //if(i>3)
        //cout<<i<<" "<<ans<<" "<<dq.back().eval(x)<<" "<<dq.size()<<"\n";
        line cur={-x,dp + (x*x)};
        while(dq.size()>=2 && cur.intersectX(dq[0])<= dq[0].intersectX(dq[1]))
            dq.pop_front();
        dq.push_front(cur);
    }
    cout<<ans;
}

Measured memory_bytes: 7352
import java.util.Scanner;

public class Main {
	private static int[] l;
	private static int A, B, C;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();

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

		System.out.println(solve(0, 0, 0, 0));
	}

	private static long solve(int p, int a, int b, int c) {
		if (p == l.length) {
			if (a == 0 || b == 0 || c == 0) return 1000000000000L;
			return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;
		}

		long answer = solve(p + 1, a, b, c);
		answer = Math.min(answer, solve(p + 1, a + l[p], b, c) + 10);
		answer = Math.min(answer, solve(p + 1, a, b + l[p], c) + 10);
		answer = Math.min(answer, solve(p + 1, a, b, c + l[p]) + 10);

		return answer;
	}
}


Measured memory_bytes: 24504
//https://atcoder.jp/contests/abc061/tasks/abc061_d
//D - Score Attack
//bellman_ford, costを負値でいれて最短経路を探索
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
	edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {}
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T>
struct node {
	vector<edge<T>> edges;
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< node< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
//s start node
//return 各nodeへの最短の距離, numeric_limits< T >::max() と等しい場合INF(=到達できない)
template< typename T >
vector< T > bellman_ford(const Edges< T > &edges, int V, int s, vector<bool>& negative) {
    const auto INF = numeric_limits< T >::max();
    vector< T > dist(V, INF);
    dist[s] = 0;
    //辺の緩和を反復
    for(int i = 0; i < V - 1; i++) {
        for(auto &e : edges) {
            if(dist[e.src] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }
    //負の重みの閉路がないかチェック
    //vector<bool> negative(V,false);
    negative.assign(V,false);
    for (ll n=0;n<V;n++){
        for(auto &e : edges) {
            if(dist[e.src] == INF) continue;
            if(dist[e.src] + e.cost < dist[e.to]) negative.at(e.to)=true;
            if(negative.at(e.src)) negative.at(e.to)=true;
        }
    }
    return dist;
}

int main() {
#if LOCAL&01
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,M; cin>>N>>M;
    Edges<ll> edges;
    FOR(e,1,M+1){
        ll a,b,c; cin>>a>>b>>c;
        edges.emplace_back(a,b,-c);
    }
    vector<bool> negative;
    auto result = bellman_ford(edges,N+1,1,negative);
    if (negative.at(N)) {
        cout<<"inf"<<endl;
    } else {
        cout<<-result.at(N)<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}

int main() {
	fast();
	/*
From 
400
 through 
599
: 
8
-kyu
From 
600
 through 
799
: 
7
-kyu
From 
800
 through 
999
: 
6
-kyu
From 
1000
 through 
1199
: 
5
-kyu
From 
1200
 through 
1399
: 
4
-kyu
From 
1400
 through 
1599
: 
3
-kyu
From 
1600
 through 
1799
: 
2
-kyu
From 
1800
 through 
1999
: 
1
-kyu
	*/
	int n;
	cin >> n;
	if (n >= 1800) {
		cout << 1 << nl;
	} else if (n >= 1600) {
		cout << 2 << nl;
	} else if (n >= 1400) {
		cout << 3 << nl;
	} else if (n >= 1200) {
		cout << 4 << nl;
	} else if (n >= 1000) {
		cout << 5 << nl;
	} else if (n >= 800) {
		cout << 6 << nl;
	} else if (n >= 600) {
		cout << 7 << nl;
	} else if (n >= 400) {
		cout << 8 << nl;
	}
}

Measured memory_bytes: 3636
macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}
     
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};
//#[proconio::fastout]
fn main() {
    input!{
        n: usize,
        t: [i32; n],
        m: usize,
        drinks: [(usize, i32); m],
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    for (p, x) in drinks {
        writeln!(out, "{}", t.iter().sum::<i32>() - t[p - 1] + x).unwrap();
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll N, C, K;
  cin >> N >> C >> K;
  vector<ll> T(N);
  for (int i = 0; i < N; i++) cin >> T[i];
  sort(T.begin(), T.end());

  ll ans = 0;
  for (int i = 0; i < N;) {
    ans++;
    if (i >= N) break;
    ll start = i;
    while (i < N && T[i] - T[start] <= K && i - start < C) i++;
  }

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

Measured memory_bytes: 1152
def prime_factor(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


MOD = 10**9+7
lim = 200000
inv_t = [-1 for i in range(lim+1)]
factrial = [-1 for i in range(lim+1)]
factrial_inv = [-1 for i in range(lim+1)]


def set_inv(max=lim):
    inv_t[0] = 0
    for i in range(1, max):
        inv_t[i] == mod_inv(i)


def mod_inv(x, mod=MOD):
    y, u, v, _x = mod, 1, 0, x
    while y:
        t = _x//y
        _x -= t*y
        _x, y = y, _x
        u -= t*v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u


def mod_pow(a, n, mod=MOD):
    res = 1
    while n:
        if n & 1:
            res = res*a % mod
        a = a*a % mod
        n >>= 1
    return res


def set_factrial(max=lim, mod=MOD):
    c = 1
    factrial[0] = factrial_inv[0] = 1
    for i in range(1, max):
        c *= i
        c %= mod
        factrial[i] = c
        factrial_inv[i] = mod_inv(c, mod)


def comb(a, b, mod=MOD):
    if factrial[0] == -1:
        set_factrial()
    return (factrial[a]*factrial_inv[b]*factrial_inv[a-b]) % mod


n, m = [int(_) for _ in input().split()]
ans = 1
for p, e in prime_factor(m):
    ans *= comb(n-1+e, e)
    ans %= MOD
if m==1:
    ans=1
print(ans)


Measured memory_bytes: 20580
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    int n;cin>>n;
    cout <<(10000-n)%1000<<endl;
}

Measured memory_bytes: 3592
num_str = []
while True:
	inputValue = input()
	if inputValue == "0 0":
		break
	num_str.append(inputValue)
for i in range(0, len(num_str)):
	a, b = [int(j) for j in num_str[i].split(" ")]
	if a > b:
		print(b, a)
	else:
		print(a, b)


Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
using s64 = int64_t;
using u64 = uint64_t;

int main() {
	u64 K, N;
	cin >> K >> N;
	
	vector<u64> A(N);
	for(u64 i=0; i<N; i++) {
		cin >> A[i];
	}

	u64 fA = A[0];
	for(u64 i=0; i<N-1; i++) {
		A[i] = A[i+1] - A[i];
	}
	
	A[N-1] = fA + K - A[N-1];
	
	
	cout << K - *max_element(A.begin(), A.end());
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {

	int n, l;
	std::cin >> n >> l;

	std::vector<int> vec;

	for (int i = 0; i < n; ++i) {
		int a = 0;
		a = i+1 + l - 1;
		vec.push_back(a);
	}

	std::sort(vec.begin(), vec.end());

	int temp = -10000000;

	for (int i = 0; i < n; ++i) {
		if (temp < 0 - std::abs(vec[i])) {
			temp = vec[i];
		}
	}

	int ans = 0;

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

	std::cout << ans -temp << std::endl;

}

Measured memory_bytes: 256
#include <iostream>
using ll=long long;
using namespace std;
int main(){
  ll N;
  ll mod=1000000007;
  cin >> N;
  ll ten=1;
  ll eight=1;
  ll nine=1;
  for(ll i=0;i<N;i++){
    ten*=10;
    eight*=8;
    nine*=9;
    ten%=mod;
    eight%=mod;
    nine%=mod;
  }
  ll res=ten+eight-nine-nine;
  res%=mod;
  if(res<0){
    cout << res+mod <<  endl;
  }else{
    cout << res << endl;
    }
}


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

int main()
{
  int n;
  cin >> n;
  vector<int64_t> a(n);
  for (auto&& e : a) cin >> e;
  int64_t sum = accumulate(begin(a), end(a), 0LL);
  int64_t x = 0;
  for (int i = 1; i < n - 1; i += 2) {
    x += a[i];
  }
  x = sum - x * 2;
  cout << x;
  for (int i = 0; i < n - 1; i++) {
    x = a[i] * 2 - x;
    cout << ' ' << x;
  }
  cout << endl;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int X, t;
   cin >> X >> t;
   cout << max(0, X -t) << endl;
   return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    count = 0
    for i in range(len(S)):
        if S[i] != T[i]: count += 1
    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9388
N, K = map(int, input().split())
S = input()

l = [0]
curr = '1'
for c in S:
    if c != curr:
        l.append(1)
        curr = c
    else:
        l[-1] += 1
if curr == '0':
    l.append(0)

n_group = (len(l) - 1) // 2
sum_ = 0
k = min(K, n_group)
sum_ = sum(l[0:2*k+1])
max_ = sum_
for i in range(k, n_group):
    sum_ -= l[2*i-2*K] + l[2*i+1-2*K]
    sum_ += l[2*i+1] + l[2*i+2]
    max_ = max(max_, sum_)
print(max_)

Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
#define int ll

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a) distance((v).begin(),upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a) distance((v).begin(),lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};

struct D21{
  int is,js;
  D21(int isize,int jsize){
    is = isize;
    js = jsize;
  }
  int operator()(int i,int j){
    return i*js+j;
  }
};

void Main(){
  int n;
  cin>>n;
  ll w;
  cin>>w;
  v(pll) a(n);
  cin>>a;

  vv(ll) dp(n+1,vl(1e5+1,INF));
  dp[0][0] = 0;
  rep(i,n) rep(j,1e5+1){
    if(a[i].se<=j) dp[i+1][j] = min(dp[i][j], dp[i][j-a[i].se]+a[i].fi);
    else dp[i+1][j] = dp[i][j];
  }
  ll ans = 0;
  rep(i,1e5+1){
    if(dp[n][i]<=w){
      ans = i;
    }
  }
  cout<<ans<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 80256
N = int(input()) 
dp = [0]*(N+1)
for i in range(N+1):
  if i==0:
    dp[i] = 2
  elif i == 1:
    dp[1] = 1
  else:
    dp[i] = dp[i-1]+dp[i-2]

print(dp[N])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  vector<int>x(5);
  rep(i,5) cin >> x[i];
  rep(i,5){
    if(x[i]==0){
      cout <<i+1<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    list.sort(p)
    print(sum(p[0:K]))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9144