akhauriyash/Code-Regression huggingface dataset:
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 120000;

vector<int> eds[MAXN];
int n;

pair<int, int> dfs1(int v, int p) {
	pair<int, int> ans = {0, v};
	for (int u: eds[v]) {
		if (u == p)
			continue;
		pair<int, int> tmp = dfs1(u, v);
		++tmp.first;
		ans = max(ans, tmp);
	}
	return ans;
}
vector<int> st;

int get(int a, int p, int b) {
	st.push_back(a);
	if (a == b)
		return 1;
	for (int u: eds[a]) {
		if (u == p)
			continue;
		if (get(u, a, b))
			return 1;
	}
	st.pop_back();
	return 0;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
	}
	int a = dfs1(0, -1).second;
	int b = dfs1(a, -1).second;
	st.clear();
	get(a, -1, b);
	vector<int> vv;
	int sum = st.size();
	for (int i = 1; i < st.size() - 1; ++i) {
		sum += eds[st[i]].size() - 2;
		vv.push_back(eds[st[i]].size() - 2);
	}
	if (sum != n) {
		cout << -1 << "\n";
		return 0;
	}
	vector<int> vv2 = vv;
	reverse(ALL(vv2));
	if (vv > vv2)
		vv = vv2, reverse(ALL(st));
	vv.insert(vv.begin(), 0);
	vv.push_back(0);
	int cur = 0;
	vector<int> ans;
	for (int i = 0; i < st.size(); ++i) {
		int start = cur;
		++cur;
		for (int j = 0; j < vv[i]; ++j)
			ans.push_back(cur++);
		ans.push_back(start);
	}
	for (int i: ans)
		cout << i + 1 << " ";
	cout << "\n";
	return 0;
}




Measured memory_bytes: 12664
#include <stdio.h>
#include<math.h>
using namespace std;

int Zeller(int month,int day){
	int year = 2004;
	if(month == 1 || month==2){
		year--;
		month += 12;
	}
	return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7;
}

int main(){

	int month,day;
	while(true){
		scanf("%d %d",&month,&day);
		if(month == 0)break;

		switch(Zeller(month,day)){
		case 0:
			printf("Sunday\n");
			break;
		case 1:
			printf("Monday\n");
			break;
		case 2:
			printf("Tuesday\n");
			break;
		case 3:
			printf("Wednesday\n");
			break;
		case 4:
			printf("Thursday\n");
			break;
		case 5:
			printf("Friday\n");
			break;
		case 6:
			printf("Saturday\n");
			break;
		}

	}

    return 0;
}

Measured memory_bytes: 2484
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
int arr[3005];
int dp[3005][3005][2];
const int def = LLONG_MAX;
int maximumdiff(int arr[], int i, int j, int turn){
    if(i>j){
        return 0;
    }
    if(dp[i][j][turn]!=-1){
        return dp[i][j][turn];
    }
    if(turn==1){
        return dp[i][j][turn]= max(arr[i]+ maximumdiff(arr,i+1,j,0), arr[j]+maximumdiff(arr,i,j-1, 0));
    }
    else{
        return dp[i][j][turn]=min(maximumdiff(arr,i+1,j, 1),  maximumdiff(arr,i, j-1,1)) ;
    }
}
 
signed main () {
    clock_t beg = clock();
    // cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int a;
    cin>>a;
    int sum=0;
    int arr[a];
    for(int i=0;i<a;i++){
        cin >>arr[i];
        sum+=arr[i];
    }
    for(int i=0;i<a;++i){
        for(int j=0;j<a;++j){
            for(int turn=0;turn<=1;turn++){
                dp[i][j][turn]=-1;
            }
        }
    }

    int x= maximumdiff(arr,0,a-1,1);
    // cout<<x<<" ";
    int y = sum-x;
    cout<<x-y<<endl;
    // int mod = 1000000000 +7;
    // at any state we have no ofheads
    // int s =     
    return 0;
}


Measured memory_bytes: 144668
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

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

    cin >> N >> M;

    if (N % M == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

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

  int ans = INF, l = 0, r;
  int sum = std::accumulate(w.begin(), w.end(), 0);

  for (int i = 0; i < n - 1; ++i) {
    l += w[i];
    r = sum - l;
    ans = min(ans, abs(l - r));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Measured memory_bytes: 29460
def main():
    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        divs.sort(reverse=True)
        return divs

    N, M = (int(i) for i in input().split())
    divs = trial_division(M)
    for d in divs:
        if N*d <= M:
            return print(d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std; 
  int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
int k=0;
for(int i=0;i<n;i++){
	if(a[i]!=i+1){
		k++;
	}
}
if(k==0 || k==2){
	cout<<"YES"<<endl;
}
else
cout<<"NO"<<endl;


	  return 0;
  }

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e7+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 998244353;

int n,fac[maxn],ifac[maxn],inv[maxn];

int c(int a,int b) {return 1ll*fac[a]*ifac[b]%mod*ifac[a-b]%mod;}

int qpow(int a,int x) {
    int res=1;
    for(;x;x>>=1,a=1ll*a*a%mod) if(x&1) res=1ll*res*a%mod;
    return res;
}

int main() {
    read(n);fac[0]=ifac[0]=inv[0]=inv[1]=1;
    for(int i=2;i<=n;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod,ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
    int ans=qpow(3,n);
    for(int i=n/2+1;i<=n;i++) ans=(ans-2ll*qpow(2,n-i)*c(n,i)%mod+mod)%mod;
    write(ans);
    return 0;
}


Measured memory_bytes: 117376
//package CodeFestival2017QualA;

import java.io.*;
import java.util.*;


public class Main{
	public static void main(String[] args) throws Exception{ new Main(new Reader()); }
	public Main(Reader rr) throws IOException{
		char[] c=rr.ns().toCharArray();
		if(c.length>=4&&c[0]=='Y'&&c[1]=='A'&&c[2]=='K'&&c[3]=='I')
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	class pointer{
		int parent;
		ArrayList<Integer> children;
		pointer(int parent){
			this.parent=parent;
		}
	}
	static class Reader{
		private DataInputStream din;
		private byte[] buffer=new byte[1024];
		private int bufP, bytR;
		public Reader() throws IOException{
			din=new DataInputStream(System.in);
			bufP=bytR=0;
		}
		public Reader(String file) throws IOException{
			din=new DataInputStream(new FileInputStream(file));
			bufP=bytR=0;
		}
		private String rl() throws IOException{
			byte[] buf=new byte[1024];
			int cnt=0, c;
			while((c=read())!=-1){
				if(c=='\n') break;
				buf[cnt++]=(byte)c;
			}
			return new String(buf, 0, cnt);
		}
		private int ni() throws IOException{
			int num=0;
			byte c=read();
			while(c<=' ') c=read();
			boolean neg=(c=='-');
			if(neg) c=read();
			do{
				num=num*10+c-'0';
			} while((c=read())>='0'&&c<='9');
			if(neg) return -num;
			return num;
		}
		private long nl() throws IOException{
			long num=0;
			byte c=read();
			while(c<=' ') c=read();
			boolean neg=(c=='-');
			if(neg) c=read();
			do{
				num=num*10+c-'0';
			} while((c=read())>='0'&&c<='9');
			if(neg) return -num;
			return num;
		}
		private double nd() throws IOException{ return Double.parseDouble(ns()); }
		private char nc() throws IOException{ return (char)next(); }
		private String ns() throws IOException{
			int c=next();
			StringBuilder sb=new StringBuilder();
			while(!(isChar(c))){
				sb.appendCodePoint(c);
				c=read();
			}
			return sb.toString();
		}
		private char[] ns(int n) throws IOException{
			char[] buf=new char[n];
			int c=next(), r=0;
			while(r<n&&!(isChar(c))){
				buf[r++]=(char)c;
				c=next();
			}
			return n==r?buf:Arrays.copyOf(buf, r);
		}
		private char[][] nm(int n, int m) throws IOException{
			char[][] map=new char[n][];
			for(int i=0; i<n; i++) map[i]=ns(m);
			return map;
		}
		private int[] na(int n) throws IOException{
			int[] a=new int[n];
			for(int i=0; i<n; i++) a[i]=ni();
			return a;
		}
		private boolean isChar(int c) throws IOException{ return !(c>=33&&c<=126); }
		private int next() throws IOException{ int c; while((c=read())!=-1&&isChar(c)); return c; }
		private byte read() throws IOException{
			if(bufP==bytR){
				bytR=din.read(buffer, bufP=0, 1024);
				if(bytR==-1) buffer[0]=-1;
			}
			return buffer[bufP++];
		}
		public void close() throws IOException{
			if(din==null) return;
			din.close();
		}
	}
}


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

void solve(int n){
	int x[n] = {};
	for(int i=0; i<n; ++i)
		cin >> x[i];
	double mi = 1e18;
	int ans = -1;
	for(int i=0; i<1<<12; ++i){
		int s = i / 256;
		int a = i / 16 % 16;
		int c = i % 16;
		int r[n] = {};
		int num[256] = {};
		double tmp = 0.0;
		r[0] = s;
		for(int j=1; j<=n; ++j)
			r[j] = (a * r[j-1] + c) % 256;
		for(int j=0; j<n; ++j)
			++num[(x[j]+r[j+1])%256];
		for(int j=0; j<256; ++j)
			if(num[j] != 0)
				tmp -= (double)num[j] / n * log((double)num[j] / n);
//		cout << i/256 << " " << i/16%16 << " " << i%16 << " ";
//		printf("%.10lf\n", tmp);
		if(mi - 1e-10 > tmp){
			mi = tmp;
			ans = i;
		}
	}
	cout << ans / 256 << " " << ans / 16 % 16 << " " << ans % 16 << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		solve(n);
	}
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	string A, B, C;
	cin >> A >> B >> C;
	cout << A[0] << B[1] << C[2] << endl;
}



Measured memory_bytes: 256
import math
K=int(input())
c=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      a=math.gcd(i,j)
      b=math.gcd(a,k)
      if i==j==k:
        c+=b
      elif i==j or j==k:
        c+=3*b
      else:
        c+=6*b
print(c)

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll c[200010] = {};

int main() {

    ll n; cin >> n;

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

        c[a[i]]++;
    }

    ll sum = 0;

    for (ll i = 0; i < 200010; ++i) {
        ll t = c[i];

        sum += t * (t - 1) / 2;
    }

    for (ll i = 0; i < n; ++i) {
        ll t = c[a[i]];

        ll d = t * (t - 1) / 2 - (t - 1) * (t - 2) / 2;

        cout << sum - d << endl;
    }
}

Measured memory_bytes: 4736
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  
  int h[n];
  
  int max = 0 , flag = 0;
  
  for(int i = 0;i < n;i ++){
    scanf("%d",&h[i]);
    if(max < h[i]){
      max = h[i];
    }
    else{
      if(max-1 >h[i]){
        flag = 1;
      }
    }
  }
  
  if(flag == 0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#define MAX 7368791
char flag[MAX+1];
int m;
int n;
int main(void){
    int i,j;
    while(1){
        scanf("%d%d", &m, &n);
        if(m==0 && n==0) break;
        for(i=0; i<=MAX; i++) flag[i] = 0;
        for(i=0; i<n; i++){
            for(j=m; j<=MAX; j += m)
                flag[j] = 1;
            while(flag[m]==1) m++;
        }
        printf("%d\n",m);
    }
    return 0;
}



Measured memory_bytes: 8924
import sys
from math import pi, cos, sqrt
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a, b = geta()

    a = int(a)
    b2 = int(b[0] + b[2:4])

    print(a * b2 // 100)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9568
#include <iostream>
#include <cstdint>
#include <cmath>

using namespace std;

int main(){
    uint64_t a;
    double c;
    cin >> a >> c;
    int64_t b = static_cast<int64_t>(c * 1000);
    cout << (a*b)/1000 << '\n';
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1,class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL H;
	cin >> H;
	LL A;
	cin >> A;
	LL ans = 0;
	while (1) {
		H -= A;
		ans++;
		if (H <= 0)break;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
#define rep(i,n) for(int i=0;i<n;i++)




int main(void)
{
    string s;
    long long k;

    cin>>s>>k;

    double now=0;

    rep(i,s.size())
    {
        int no = s[i]-'0';

        now+= pow(no,5000000000000000);

        if(now>=k)
        {
            cout<<s[i];
            break;
        }
    }
    


}



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

using namespace std;

int main(){
    int N;
    float A,sum=0;
    cin >> N;

    for(int i=0;i<N;i++){
        cin >> A;
        sum += 1.00000/A;
    }

    cout << setprecision(10) << 1.00000/sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    int x;
    cin >> x;
    if(x==1)
        cout << 0 << endl;
    else
        cout << 1 << endl;
}

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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int cnt[5];

int main() {
    cont (i, 6) {
        int a;
        cin >> a;
        ++cnt[a];
    }
    sort(cnt + 1, cnt + 5);
    if (cnt[1] == 1 && cnt[2] == 1 && cnt[3] == 2 && cnt[4] == 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')

const int N_MAX = 5000;
const int K_MAX = 5000;

int N, K;
int a[N_MAX];
int dp[2][K_MAX + 1];

void solve() {
  sort(a, a + N, greater<int>());

  int ans = N;
  int *cur = dp[0], *nxt = dp[1];
  cur[0] = 1;
  REP(i, N) {
    fill(nxt, nxt + K + 1, 0);
    bool need = false;
    REP(j, K + 1) {
      if (cur[j] > 0 && j < K && j + a[i] >= K) need = true;
      nxt[j] |= cur[j];
      nxt[min(j + a[i], K)] |= cur[j];
    }
    if (need) ans = N - 1- i;
    // printf("a: %d, need: %s\n", a[i], need ? "true" : "false");
    // DUMP(nxt, K + 1);
    swap(cur, nxt);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &K);
  REP(i, N) scanf("%d", a + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

#define ll long long
const ll mod = 1e9+7;
const int N = 2e5+10;

ll qpow(ll a,ll x)
{
	ll t = a;
	a = 1;
	while (x)
	{
		if (x & 1) a = a * t % mod;
		t = t * t % mod;
		x = x >> 1;
	}
	return a;
}

ll C(int n,int a)
{
    ll c1 = 1,c2 = 1;
    for (int i = 1;i<=a;i++)
    {
        c1 = (c1 * (n - i + 1)) % mod;
        c2 = c2 * i % mod;
    }
    return c1 * qpow(c2,mod-2) % mod;
}

ll c1[N],c2[N];

ll a[N],b[N];

void init1(int n)
{
    a[0] = 1;
    b[0] = 1;
    for (int i = 1;i<=n;i++)
    {
        a[i] = a[i-1] * i % mod;
        b[i] = qpow(a[i],mod-2);
    }
}

void init(ll *t,int n)
{
    t[0] = 1;
    for (int i = 1;i<=n;i++)
        t[i] = a[n] * b[i] % mod * b[n - i] % mod;
}

int main()
{
    ll n,m;
    cin>>n>>m;
    ll ans = 0;
    m = min(m,200000LL);
    init1(n);
    init(c2,n-1);
    init(c1,n);
    
    for (int i = 0;i<=m;i++) 
    {
        // ans = (ans + C(n-1,i) * C(n,n-i) % mod) % mod;
        ans = (ans + c2[i] * c1[n-i] % mod) % mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 152076289;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<LP> v;
ll a[1 << 17], b[1 << 17];
bool used[1 << 17];
int main(){
	int n; cin >> n;
	ll sa = 0; ll sb = 0;
	rep(i, n) {
		cin >> a[i] >> b[i];
		sa += a[i]; sb += b[i];
	}
	ll out = 0;
	rep(i, n) {
		v.push_back({ a[i],i });
		v.push_back({ b[i],i });
	}
	sort(v.begin(), v.end());
	bool con = false;
	rep(i, n - 1) {
		out += v[i].first; int id = (int)v[i].second;
		if (used[id])con = true;
		used[id] = true;
	}
	if (con) {
		out += v[n - 1].first;
	}
	else {
		Rep(i, n - 1, (int)v.size()) {
			int id = (int)v[i].second;
			if (!used[id])continue;
			out += v[i].first; break;
		}
	    int chk = 0;
		rep(i, n) {
			if (!used[i])chk = i;
		}
		ll csum = a[chk] + b[chk];
		rep(i, n - 2) {
			csum += v[i].first;
		}
		out = min(out, csum);
	}
	out = min({ out,sa,sb });
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 8048
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main() {
  int n;
  readf (" %d", &n);
  auto t = n.text;
  writeln (t.find('7').empty ? "No" : "Yes");
}



Measured memory_bytes: 3204
#include<iostream>
#include<deque>

int main() {
	
	int num, suu;
	std::deque<int> vec;
	int i, j, t;

	scanf("%d", &num);

	

	for (i = 0; i < num; i++) {
		scanf("%d", &suu);
		if (i % 2 == (num - 1) % 2) {
			//一致
			vec.push_front(suu);
		}
		else {
			vec.push_back(suu);
		}
	}
	
	for (i = 0; i < num; i++) {
		printf("%d ", vec[i]);
	}

}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace atcoder.Abc
{
    //https://atcoder.jp/contests/abc177/tasks/abc177_a
    public class QA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            WriteLine(a[0] > a[1] * a[2] ? "No" : "Yes");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 17724
N = int(input())
ans = list()
for j in range((N+1)//2):
  A = list()
  for i in range(2*j + 1):
    if (2*j + 1) % (i+1) ==0:
      A.append(i)
  if len(A) == 8:
    ans.append(j)
print(len(ans))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

ll S[200005];

int main(){
    int n,k;
    cin >> n>> k;
    S[0]=0;
    rep2(i,n+1){
        S[i]=S[i-1]+i;
    }
    ll ans=0;
    for(int i=k;i<=n+1;i++){
        ll temp1=S[n+1]-S[n+1-i];
        ll temp2=S[i]-S[0];
        ans+=temp1-temp2+1;
        //cerr<<ans<<endl;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}



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

void check(char,char,int*);

int main(){
	int n;
	string s;
	cin >> n >> s;
	char mozi = '0';
	int ans = 0;
	int *A = &ans;
	for(int i = 0;i < s.size();i++){
		ans++;
		check(s.at(i),mozi,A);
		mozi = s.at(i);
	}
	cout << ans;
	return 0;
}

void check(char CH,char mo,int *X){
	if(CH == mo)*X -= 1;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
struct Edge{
    int from,to;
};
using Graph=vector<vector<Edge>>;
namespace ProconLib{
    
    //no multiple Edges
    //undirected edges graph
    template<typename edge_t,typename graph_t>
    vector<edge_t> bridgeDetection(graph_t &g){
        int n=g.size();
        vector<int> pre(n,-1),low(n,-1);
        int k=0;
        vector<edge_t> res;
        function<int(int,int)> dfs=[&](int v,int pv){
            pre[v]=k++;
            low[v]=pre[v];
            for(auto &e:g[v]){
                int to=e.to;
                if(to==pv) continue;
                if(pre[to]==-1){
                    low[v]=min(low[v],dfs(to,v));
                    if(low[to]==pre[to]){
                        res.push_back(e);
                    }
                }
                else{
                    low[v]=min(low[v],low[to]);
                }
            }
            return low[v];
        };
        for(int i=0;i<n;i++){
            if(pre[i]==-1){
                dfs(i,-1);
            }
        }
        return res;
    }
}

//verify
using namespace ProconLib;
using Graph=vector<vector<Edge>>;
int main(){
    int v,e;
    cin>>v>>e;
    Graph g(v);
    for(int i=0;i<e;i++){
        int s,t;
        cin>>s>>t;
        g[s].push_back(Edge{s,t});
        g[t].push_back(Edge{t,s});
    }
    vector<Edge> res=bridgeDetection<Edge>(g);
    for(auto &e:res){
        if(e.from>e.to) swap(e.from,e.to);
    }
    sort(res.begin(),res.end(),[](Edge lhs,Edge rhs){return make_pair(lhs.from,lhs.to)<make_pair(rhs.from,rhs.to);});
    for(auto &e:res){
        cout<<min(e.from,e.to)<<" "<<max(e.from,e.to)<<endl;
    }
    return 0;
}


Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll X;
  cin>>X;
  vector<ll> vec(0);
  for(ll i=0;i<=150;i++) {
    ll a=1;
    for(ll j=0;j<5;j++) {
a*=i;
    }
    vec.push_back(a);
  }
  
  
  for(ll i=0;i<=150;i++) {
    ll k=abs(X-vec[i]);
    ll index=lower_bound(all(vec),k)-vec.begin();
    if(vec[index]==k) {
if(X-vec[i]>=0) {
  cout<<i<<" "<<-1*index<<endl;
}
      else {
cout<<i<<" "<<index<<endl;
      }
      return 0;
    }
  }
}


  
  
  
  

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n;
	cin>>n;
	int a[20], b[20];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<n; i++){
		cin>>b[i];
	}
	for(int i=1; i<n; i+=2) swap(a[i], b[i]);
	int dp[18][1<<18];
	const int INF=1e9;
	for(int i=0; i<(1<<n); i++){
		for(int j=0; j<n; j++) dp[j][i]=INF;
	}
	for(int i=0; i<n; i++){
		dp[i][1<<i]=0;
	}
	for(int i=1; i<(1<<n)-1; i++){
		int c=popcount(i);
		int cnt[18]={};
		for(int k=0; k<n; k++){
			if(i&(1<<k)) continue;
			for(int l=k+1; l<n; l++){
				if((i&(1<<l))==0) continue;
				cnt[k]++;
			}
		}
		for(int j=0; j<n; j++){
			if((i&(1<<j))==0 || dp[j][i]==INF) continue;
			for(int k=0; k<n; k++){
				if(i&(1<<k)) continue;
				if(c&1){
					if(a[j]>b[k]) continue;
				}else{
					if(b[j]>a[k]) continue;
				}
				dp[k][i^(1<<k)]=min(dp[j][i]+cnt[k], dp[k][i^(1<<k)]);
			}
		}
	}
	int ans=INF;
	for(int i=0; i<n; i++) ans=min(ans, dp[i][(1<<n)-1]);
	if(ans>=INF/2) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

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

int main(void) {
	int x, y, z; cin >> x >> y >> z;
	int ans = 0;
	x -= z;

	for (int i = 0;; i++) {
		if (x - (z + y) >= 0) {
			x -= z + y;
			ans += 1;
		}
		else { break; }
	}

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



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

int main()
{
	string s;
	cin >> s;
	
	if (s == "Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else if (s == "Rainy")
	{
		cout << "Sunny" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int a;string s;cin>>a>>s;
    if(a>=3200){
        cout<<s<<endl;
        return 0;
    }
    else cout<<"red"<<endl;return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                     \
  ifstream in("atcoder-problems/ddcc2020_qual_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int H, W, K;
void w_dfs(vector<vector<int>> &ans, int i, int j) {
  if (ans[i][j] == 0) return;
  if (j - 1 >= 0 && ans[i][j - 1] == 0) {
    ans[i][j - 1] = ans[i][j];
    w_dfs(ans, i, j - 1);
  }
  if (j + 1 < W && ans[i][j + 1] == 0) {
    ans[i][j + 1] = ans[i][j];
    w_dfs(ans, i, j + 1);
  }
}

void h_dfs(vector<vector<int>> &ans, int i, int j) {
  if (ans[i][j] == 0) return;
  if (i - 1 >= 0 && ans[i - 1][j] == 0) {
    ans[i - 1][j] = ans[i][j];
    h_dfs(ans, i - 1, j);
  }
  if (i + 1 < H && ans[i + 1][j] == 0) {
    ans[i + 1][j] = ans[i][j];
    h_dfs(ans, i + 1, j);
  }
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  cin >> H >> W >> K;

  vector<vector<char>> c(H, vector<char>(W, ' '));
  vector<vector<int>> ans(H, vector<int>(W, 0));
  int cnt = 0;
  rep(i, H) rep(j, W) {
    cin >> c[i][j];
    if (c[i][j] == '#') ans[i][j] = ++cnt;
  }

  rep(i, H) rep(j, W) { w_dfs(ans, i, j); }
  rep(i, H) rep(j, W) { h_dfs(ans, i, j); }

  rep(i, H) {
    rep(j, W) { cout << ans[i][j] << ' '; }
    cout << endl;
  }

  return 0;
}

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

using namespace std;

using int64 = long long;


int main() {
  int N, K;
  string S;


  cin >> N >> K;
  cin >> S;
  deque< int > bit(N);
  for(int i = 0; i < N; i++) {
    bit[i] = S[i] == 'A';
  }

  int last = N;
  bool f = false;
  while(K--) {
    while(last >= 2 && bit[last - 1] ^ f && !(bit[last - 2] ^ f)) {
      last -= 2;
    }
    if(last == 0) break;
    if(last == 1) K %= 2;
    if(bit[0] ^ f) {
      bit[0] = f;
    } else {
      bit.pop_front();
      bit.emplace_back(f);
      f ^= 1;
    }
  }
  for(int i = 0; i < N; i++) cout << "BA"[bit[i] ^ f];
  cout << endl;

}


Measured memory_bytes: 1540
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        // 短針の角度
        double shortradian = (double)h * 30 + (double)m * 0.5;
        double y1 = Math.cos(Math.toRadians(shortradian)) * a;
        double x1 = Math.tan(Math.toRadians(shortradian)) * y1;
        
        // 長針の角度
        double longradian = (double)m * 6;
        double y2 = Math.cos(Math.toRadians(longradian)) * b;
        double x2 = Math.tan(Math.toRadians(longradian)) * y2;
        
        double tmp = Math.sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2));
        
        // System.out.println(y1 + " " + y2);
        // System.out.println(x1 + " " + x2);
        System.out.println(tmp);
    }
}


Measured memory_bytes: 36000
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,cnt=0;
  string s,alph="abcdefghijklmnopqrstuvwxyz",t[1000];
  cin >> s >> n;
  map<string,int> mp;
  for(int i=0;i<alph.size();i++){
    for(int j=0;j<s.size();j++){
      if(s[j]==alph[i]){
        for(int k=1;k<=n;k++){
          if(mp[s.substr(j,k)]==0){
            mp[s.substr(j,k)]++;
            t[cnt]=s.substr(j,k);
            cnt++;
          }
        }
      }
    }
    if(cnt>=n){
      sort(t,t+cnt);
      cout << t[n-1] << endl;
      return 0;
    }
  } 
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

ll a , b , x;
ll f(ll n){
    ll ans = 1;
    for(ll i = 0; i < 5; i++){
        ans *= n;
    }
    return ans;
}

int main()
{
    _FastIO;
    cin >> x;
    for(a = 0; a <= 1000; a++){
        for(b = 0; b <= 1000; b++){
            if(f(a) - f(b) == x){
                cout << a << " " << b << endl;
                return 0;
            }
            if(f(a) + f(b) == x){
                cout << a << " " << (-1) * b << endl;
                return 0;
            }
            if((-1) * f(b) - f(a) == x){
                cout << (-1) * a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>

#define lli long long int
#define ld long double
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    string a, b;
    cin>>a>>b;
    lli c, d;
    cin>>c>>d;
    string s;
    cin>>s;
    if(s == a)
        c --;
    else
        d --;
    cout<<c<<' '<<d;
    cout<<'\n';
    return ;
}



/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int a, b;
string s;

int main() {
	cin >> a >> b >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i < a) {
			if (!('0' <= s[i] && s[i] <= '9')) {
				cout << "No" << endl;
				return 0;
			}
		}
		else if (i == a) {
			if (s[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (!('0' <= s[i] && s[i] <= '9')) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  bool YYMM = false;
  bool MMYY = false;
  if((s[0] == '1' && s[1] <'3' || s[0] == '0') && (s[0] !='0' || s[1] != '0'))MMYY = true;
  if((s[2] == '1' && s[3] <'3' || s[2] == '0') && (s[2] !='0' || s[3] != '0'))YYMM = true;
  if(YYMM && MMYY)cout << "AMBIGUOUS" << endl;
  else if(YYMM)cout << "YYMM" << endl;
  else if(MMYY)cout << "MMYY" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int rt = 0, rx = 0, ry = 0;
  rep(i, n) {
    int d = abs(rx - x[i]) + abs(ry - y[i]);
    rt += d;
    if (t[i] < rt || (t[i] - rt) % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
    rt = t[i], rx = x[i], ry = y[i];
  }
  cout << "Yes" << endl;


  
  return 0;
}

Measured memory_bytes: 1408
MOD = 10 ** 9 + 7
n, m = map(int, input().split())
a = 1
d = [1] * (n + 1)
for i in range(n):
  d[i + 1] = ((m - n + i) * d[i] + i * d[i - 1]) % MOD
  a = a * (m - i) % MOD
print(a * d[n] % MOD)

Measured memory_bytes: 67736
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

   int N, M;
   cin >> N >> M;

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

   int K = 1000000007;
   vector<int> S(N + 1);
   for (int i = N; i >= 0; --i) {
      if (i == N)
         S[i] = 1;
      else if (i == N - 1)
         S[i] = binary_search(a.begin(), a.end(), i) ? 0 : 1;
      else
         S[i] = binary_search(a.begin(), a.end(), i) ? 0 : (S[i + 1] + S[i + 2]) % K;
   }

   cout << S[0] % K << endl;

   return 0;
}

Measured memory_bytes: 1024
from itertools import accumulate

n, k = map(int, input().split())
a = list(map(int, input().split()))

a_plus = [e if e > 0 else 0 for e in a]

acc = [0] + list(accumulate(a))
acc_plus = [0] + list(accumulate(a_plus))
ans = 0
for i in range(1, n - k + 2):
    white = acc_plus[i-1] + acc_plus[n] - acc_plus[i+k-1]
    black = white + acc[i+k-1] - acc[i-1]
    ans = max(ans, white, black)

print(ans)


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

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

	int N;
	cin >> N;
	vector<int> ball_pool(N, 0);
	vector<int> integer_counters(N, 0);
	for (int i = 0; i < N; ++i) {
		int num;
		cin >> num;
		ball_pool[i] = num;
		integer_counters[num - 1]++;
	}

	unsigned long long int combination_sum = 0UL;
	for (int i = 0; i < N; ++i) {
		if (integer_counters[i] > 0) {
			combination_sum += 1UL * integer_counters[i] * (integer_counters[i] - 1) / 2;
		}
	}
	for (int i = 0; i < N; ++i) {
		cout << combination_sum - integer_counters[ball_pool[i] - 1] + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 4224
#if 0
16:09-
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2012

#endif

#include <iostream>
#include <stdint.h>
using namespace std;

#define REP(var, start, count) for(int var=start; var<count; var++)

int main(void) {
	while(true) {
		int e;
		cin >> e;
		
		int ans = 10000000;
		
		if ( e == 0 ) { break; }
		
		REP(z, 0, 101) {
			int z3 = z*z*z;
			if ( z3 > e ) { break; }
			
			REP(y, 0, 1001) {
				if ( y*y > e-z3 ) { break; }
				
				int x = (e-z3-y*y);
				int res = x+y+z;
				if ( res < ans ) { ans = res; }
			}
		}
		
		cout << ans << endl;
	}

}

Measured memory_bytes: 2936
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define int long long
int gcd(int a, int b) {
	if (!b)return a;
	return gcd(b, a%b);
}
signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 3600; i++) {
		for (int j = 1; j <= 3600; j++) {
			int ad = i*j, au = i + j;//(bunbo,bunsi)
			int wd = n*i*j, wu = 4 * i*j - n*(i+j);
			if (wu>0&&wd>0&&wu%gcd(wd, wu) == 0 && wu / gcd(wd, wu) == 1) {
				cout << i << ' ' << j << ' ' << wd / gcd(wd, wu) << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;

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


#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define int long long
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[111100];
vector<pair<int ,int> > ii;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=1,h=1,j;
  string s;
  cin >>s;
  if(s[0]==s[1]&&s[1]==s[2]) d++;
  if(s[1]==s[2]&&s[2]==s[3]) d++;
  if(d>0) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}


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

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

    int check = 1;
    for(int i=0; i<n; i++) {
        if(mao[i]%2==0 && mao[i]%3!=0 && mao[i]%5!=0) check=0;
    }

    if(check==1) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		int r = 0, c = 0;
		int i = 0, j = 0;
		ArrayList<Integer> elements = new ArrayList<Integer>();

		Scanner sc = new Scanner(System.in);
		for (int t = 0; t < 2; ++t) {
			elements.add(sc.nextInt()); // ?????????????´???°?±????
		}
		r = elements.get(0);
		c = elements.get(1);
		if (r >= 1 && r <= 100 && c >= 1 && c <= 100) { // ??¶?´??????¶
			int[][] mat = new int[r + 1][c + 1]; // ?¨?????????????????????????????????????????????¨???????????????[r+1][c+1]
			for (i = 0; i < r; ++i) {
				for (j = 0; j < c; ++j) {
					mat[i][j] = 0; // ??????????????????
				}
			}

			for (i = 0; i < r; ++i) {
				for (j = 0; j < c; ++j) {
					mat[i][j] = sc.nextInt(); // ????´????????????????
					mat[i][c] += mat[i][j]; // ???????????????????????????
					mat[r][j] += mat[i][j]; // ??????????????????
					mat[r][c] += mat[i][j]; // ?????????????¨?
				}
			}
			for (i = 0; i < r + 1; ++i) {
				for (j = 0; j < c + 1; ++j) {
					System.out.print(mat[i][j]);
					if (j != c) { // ?????????????????????????????????AOJ??§?????¬?????????????????§?????¨??????????????????????????????
						System.out.print(" ");
					}
				}
				System.out.println("");
			}
		}
		sc.close();
	}

}

Measured memory_bytes: 41144
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i * 500 + j * 100 + k * 50 == x:
        ans += 1
print(ans)

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    rep(i, N){
        if(i > 0){
            if(A[i-1] < A[i]) A[i]--;
        }
        else A[i]--;
    }
    bool ok = true;
    rep(i, N-1){
        if(A[i] > A[i+1]) ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define maxn 100005

int GLL(LL& x) {
  return scanf("%lld", &x);
}

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


int N;
vector<LL> A;
int main() {
  GI(N);
  A.resize(3*N);

  FORN(i, 3*N) {
    GLL(A[i]);
  }

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

  LL p = 0;
  LL soln = 0;
  for (int i = 3*N-1; i >= N; i--) {
    if (p & 1) soln += A[i];
    p++;
  }

  printf("%lld\n", soln);

    
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll N; cin >> N;
  ll B = N;
  for (ll A = 1; A * A <= N; A++) {
    if (N % A == 0) B = N / A;
  }
  int res = 0;
  while (B) {
    res++;
    B /= 10;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
bool F[500];
int main() {
	vector<int> G[500];
	int n,m;
	while(scanf("%d %d",&n,&m),n|m) {
		for(int i=0;i<500;i++) G[i].clear();
		for(int i=0;i<m;i++) {
			int a,b;
			scanf("%d %d",&a,&b);
			G[a-1].push_back(b-1);
			G[b-1].push_back(a-1);
		}
		memset(F,0,sizeof(F));
		F[0]=true;
		int ans=0;
		for(int i=0;i<G[0].size();i++) {
			if(!F[G[0][i]]) ans++,F[G[0][i]]=true;
			for(int j=0;j<G[G[0][i]].size();j++) {
				if(!F[G[G[0][i]][j]]) ans++, F[G[G[0][i]][j]]=true; 
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1192