akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    corner(N%1000==0,0);
    cout << 1000 - (N%1000) << endl;    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <algorithm>
using namespace std;

int main() {
	int H, W, count = 0;
	cin >> H >> W;
	vector<vector<int> >S(H + 2, vector<int>(W + 2)); //左右に1列ずつ余裕を持たせる
	for (int i = 0; i < H + 2; i++) {
		for (int j = 0; j < W + 2; j++) {
			int tmpb = i * j*(i - (H + 1))*(j - (W + 1));
			if (tmpb) {
				char tmp;
				cin >> tmp;
				S[i][j] = (tmp == '.' ? 1 : 0); //白なら1, 黒なら0
				if (S[i][j])count++;
			}
			else {
				S[i][j] = 0;
			}
		}
	}

	vector<vector<int> >isNotChecked(H + 2, vector<int>(W + 2, 1));
	vector<vector<int> >Sd(H + 2, vector<int>(W + 2, -10000)); //-距離
	Sd[1][1] = 0;
	bool trig = true;
	while (trig) {
		priority_queue<tuple<int, int, int> >Q; //-距離、i座標、j座標
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if (S[i][j] && isNotChecked[i][j])Q.push(make_tuple(Sd[i][j], i, j));
			}
		}
		tuple<int, int, int>mintuple = Q.top();
		int mind = get<0>(mintuple), i = get<1>(mintuple), j = get<2>(mintuple);
		isNotChecked[i][j] = 0;
		Sd[i - 1][j] = max(Sd[i - 1][j], Sd[i][j] - 1);
		Sd[i + 1][j] = max(Sd[i + 1][j], Sd[i][j] - 1);
		Sd[i][j - 1] = max(Sd[i][j - 1], Sd[i][j] - 1);
		Sd[i][j + 1] = max(Sd[i][j + 1], Sd[i][j] - 1);
		trig = false;
		for (int m = 1; m <= H; m++) {
			for (int n = 1; n <= W; n++) {
				if (S[m][n] && isNotChecked[m][n])trig = true;
			}
		}
	}
	if (-Sd[H][W] >= 10000)cout << -1;
	else cout << count + Sd[H][W] - 1;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    long long int arr[n+5];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    long long int x=0;
    int idx=0;
    for(int i=0; i<n; i++){
        if(i+1<n && arr[i]>arr[i+1]){
            x+=(arr[i]-arr[i+1]);
            arr[i+1]=arr[i];
        }
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 5104
d = 10**9 + 7

N = int(input())
list_co = list(map(int, input().split()))

ans = 1
def mod_factorial(N, d):
    ans = 1
    for i in range(1,N+1):
        ans = (ans * i) % d
    return ans
        
for i, x in enumerate(list_co):
    if x < 2*(i+1) -1:
        ans *= (i+1)
        list_co.pop(i-1)
ans = (ans * mod_factorial(len(list_co),d)) % d
print(ans)


Measured memory_bytes: 14056
#include <iostream>

#include <fstream>

#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#include <algorithm>
#include <iomanip>
#include <cmath>
#include <random>
#include <cstdlib>
#include <ctime>
#include <utility>

using namespace std;

ifstream in("input.txt");
ofstream out("output.txt");

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

#define F first
#define S second
#define forcin(n, a) for(int i = 0; i < n; ++i) {cin >> a[i];}
#define forcout(n, a) for(int i = 0; i < n; ++i) {cout << a[i] << " ";}
#define PI acos(-1)
#define forup(st, fin) for(int i = st; i < fin; ++i)
#define fordown(st, fin) for(int i = st; i >= fin; --i)
#define reverse_all(v) reverse(v.begin(), v.end())
#define sort_all(v) sort(v.begin(), v.end())
#define sort_allr(v) sort(v.rbegin(), v.rend())

///#define cin in
///#define cout out
///#define int long long

const ll MAXL = 1e18;
const int N = 10005000;
const int MAXN = 1e9 + 7;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    ll a, b;
    cin >> a >> b;
    ll h1 = 1, h2 = 3, add = 3;
    while (abs(h1 - h2) != abs(a - b)) {
        h1 = h2;
        h2 += add;
        add++;
    }
    cout << min(h1, h2) - min(a, b) << "\n";

    return 0;
}

/*

 */

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

using namespace std;

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main() {
    int N, M;
    cin >> N >> M;
    vector<PP> city(M);
    for (int i = 0; i < M; i++) {
        int p, y;
        cin >> p >> y;
        city[i] = PP(P(p, y), i);
    }
    sort(city.begin(), city.end());

    vector<P> res(M);
    int pre = 0, cnt = 1;
    for (int i = 0; i < M; i++) {
        if (city[i].first.first != pre) {
            pre = city[i].first.first;
            cnt = 1;
        } else {
            cnt++;
        }
        res[city[i].second] = P(city[i].first.first, cnt);
    }

    for (int i = 0; i < M; i++) {
        printf("%.6d%.6d", res[i].first, res[i].second);
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	int k,a,b;
	bool ok = false;
	cin >> k >> a >> b;
	for(int i = a; i <= b; i++){
		ok |= (i%k==0);
	}
	if(ok){
		cout << "OK\n";
	}else{
		cout <<"NG\n";
	}
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    while(cin>>n>>k){
        vector<int> v(n+5),dp(n+5,0);
        for(int i=0;i<n;i++){
            cin>>v[i];
        }dp[0]=0;
        dp[1]=abs(v[0]-v[1]);
        for(int i=2;i<min(n,k);i++){
            dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
            for(int j=1;j<=i;j++){
                dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
            }
        }
        for(int i=k;i<n;i++){
            if(k!=1)dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
            else dp[i]=dp[i-1]+abs(v[i]-v[i-1]);
            for(int j=1;j<=k;j++){
                dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
            }

        }//for(int i=0;i<n;i++)cout<<dp[i]<<" \n"[i==n-1];
        cout<<dp[n-1]<<"\n";
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

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

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

    int n;
    cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    for(int i = 0; i < n - 1; ++i)  cin >> c[i] >> s[i] >> f[i];
    for(int i = 0; i < n - 1; ++i){
        int cur = s[i] + c[i];
        for(int j = i + 1; j < n - 1; ++j){
            if(cur <= s[j]){
                cur = s[j] + c[j];
            }
            else{
                if(cur % f[j] == 0) cur += c[j];
                else{
                    int foo = (cur - s[j] + f[j] - 1) / f[j];
                    cur = s[j] + foo * f[j] + c[j];
                }
            }
        }
        cout << cur << '\n';
    }
    cout << 0 << '\n';
}

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

int main(){
	int m[13], mm, dd, i;
	m[0] = 0;
	m[1] = m[0];
	m[2] = m[1] + 31;
	m[3] = m[2] + 29;
	m[4] = m[3] + 31;
	m[5] = m[4] + 30;
	m[6] = m[5] + 31;
	m[7] = m[6] + 30;
	m[8] = m[7] + 31;
	m[9] = m[8] + 31;
	m[10] = m[9] + 30;
	m[11] = m[10] + 31;
	m[12] = m[11] + 30;

	string day[7];
	day[0] = "Wednesday";
	day[1] = "Thursday";
	day[2] = "Friday";
	day[3] = "Saturday";
	day[4] = "Sunday";
	day[5] = "Monday";
	day[6] = "Tuesday";

	while (true)
	{
		cin >> mm >> dd;
		if (mm == 0) { break; }
		i = (m[mm] + dd) % 7;
		cout << day[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int h,n;
  cin>>h>>n;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    h-=x;
  }
  if(h<=0) cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

string padit(int index){
    int digits=0;
    stack<int>st;
    while(index!=0){
        st.push(index%10);
        index/=10;
        digits++;
    }
    digits=6-digits;
    string result="";
    while(digits){
        result+='0';
        digits--;
    }
    while(!st.empty()){
        result+=st.top()+'0';
        st.pop();
    }
    return result;
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>v;
    unordered_map<int,vector<int>>ump;
    for(int i=0;i<m;i++)
    {
        int p,y;
        cin>>p>>y;
        v.push_back({p,y});
        ump[p].push_back(y);
    }
    for(auto it=ump.begin();it!=ump.end();it++)
    {
        sort(ump[it->first].begin(),ump[it->first].end());
    }
    for(int i=0;i<v.size();i++)
    {
        int f=v[i].first;
        int s=v[i].second;
        auto it=lower_bound(ump[f].begin(),ump[f].end(),s);
        int index=it-ump[f].begin();
        string result="";
        result+=padit(f);
        result+=padit(index+1);
        cout<<result<<endl;
    }
}

Measured memory_bytes: 12948
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    long m, k;
    cin >> m >> k;
    
    long max = pow(2, m);

    if (m == 1) {
        if (k == 0)
            cout << "0 0 1 1" << endl;
        else
            cout << -1 << endl;
        return 0;
    }

    if (k >= max) {
        cout << -1 << endl;
        return 0;
    }
    
    cout << k;
    for (long i=0; i<max; i++) {
        if (i == k) continue;
        cout << " " << i;
    }
    cout << " " << k;
    for (long i=max-1; i>=0; i--) {
        if (i == k) continue;
        cout << " " << i;
    }
    cout << endl;
}

Measured memory_bytes: 1792
// Problem : D - Chat in a Circle
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n];
		for(int i=0;i<n;++i)
		cin>>arr[i];
		sort(arr,arr+n);
		int sum = arr[n-1];
		int xxx = n-2;
		int ct = 0;
	    if(xxx&1)
	    ++ct;
	    xxx/=2;
	    int i = n-2;
	    while(xxx--)
	    {
	    	sum+=2*arr[i];
	    	--i;
	    }
	    if(ct)
	    sum+=arr[i];
	    cout<<sum<<"\n";
	    	
    }
    return 0;
}


Measured memory_bytes: 5216
import math


# 素数判定
def is_prime(n):
    for i in range(2, int(math.sqrt(n) + 1)):
        if n % i == 0:
            return False
    return True


# 約数列挙
def get_divisor(n, is_sort=False):
    divisors = [1]
    for i in range(2, int(math.sqrt(n) + 1)):
        if n % i == 0:
            divisors.append(i)
            other_div = n // i
            if i != other_div:
                divisors.append(other_div)
    divisors.append(n)
    if is_sort:
        divisors.sort()
    return divisors


# 素因数分解
def prime_factor(n):
    factors = {}
    for i in range(2, int(math.sqrt(n) + 1)):
        if n % i == 0:
            factors[i] = 0
        while n % i == 0:
            n = n // i
            factors[i] += 1
        if n == 1:
            break
    if n != 1:
        factors[n] = 1
    return factors


if __name__ == '__main__':
    n = int(input())
    prime_dict = {}
    for i in range(2, n + 1):
        prime_dict[i] = 1
        for key, value in prime_factor(i).items():
            prime_dict[key] += value

    ans = 1
    for i in prime_dict.values():
        ans = ans * i
    print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n, k, p; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int l; cin >> l;
		if (l == 1)p = i;
	}
	k--; n--;
	cout << (n+k-1)/k << endl;
}

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

using namespace std;

const long long mod = 1e9 + 7;

int main(void){
    int n;
    cin >> n;
    vector<pair<int, int> > a;
    for (int i = 0; i < n; ++i){
        int p;
        cin >> p;
        a.push_back(make_pair(p, 0));
    }
    for (int i = 0; i < n; ++i){
        int p;
        cin >> p;
        a.push_back(make_pair(p, 1));
    }
    sort(a.begin(), a.end());
    long long ans = 1, x = 0, y = 0;
    for (int i = 0; i < 2 * n; ++i){
        if (a[i].second == 0){
            if (y){
                ans = (ans * y) % mod;
                y--;
            }else{
                x++;
            }
        }else{
            if (x){
                ans = (ans * x) % mod;
                x--;
            }else{
                y++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

int main(void)
{
	ll n, m, k;
	cin >> n >> m >> k;
	Factorial f(n * m);
	ll comb = f.cmb(n * m - 2, k - 2);
	ll x = 0;
	rep(i, n) {
		ll dist = i;
		ll count = n - i;
		ll select = m * m;
		ll num = (dist * count * select) % mod;
		x += (num * comb) % mod;
		x %= mod;
	}
	swap(n, m);
	rep(i, n) {
		ll dist = i;
		ll count = n - i;
		ll select = m * m;
		ll num = (dist * count * select) % mod;
		x += (num * comb) % mod;
		x %= mod;
	}
	cout << x << endl;
	return 0;
}


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

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

    for(int i = 0; i < s.size(); i++) {
        int rep = (int)s[i] + n;
        if(rep > 90) rep -= 26;
        s[i] = (char)rep;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> mp;
int inf =  1e9;
typedef pair<int,mp> mmp;

int main(){
    while(1){
	int n,m;
	cin>>n>>m;
	if(n == 0 ) break;
	vector< vector<mp> > g(n);
	vector<mmp> edge( m );
	for(int i=0;i<m;i++){
	    int a,b,w;
	    cin>>a>>b>>w;
	    a--,b--;
	    g[a].push_back( mp( w , b ) );
	    g[b].push_back( mp( w , a ) );
	    edge[i] = mmp( w , mp( a, b ) );
	}
	sort( edge.begin() , edge.end() );
	int res = 1e9;
	for(int j=0;j<m;j++){
	    vector<bool> used( n , false );
	    int mini = edge[j].first;
	    int maxc = edge[j].first;
	    int a = edge[j].second.first;
	    int b = edge[j].second.second;
	    int rest = n-2;
	    used[a] = used[b] = true;
	    priority_queue<mp , vector<mp> , greater<mp> > q;
	    for(int i=0;i<g[a].size();i++)if( mini <= g[a][i].first && !used[ g[a][i].second ] ) q.push( g[a][i] );
	    for(int i=0;i<g[b].size();i++)if( mini <= g[b][i].first && !used[ g[b][i].second ] ) q.push( g[b][i] );
	    while( !q.empty()  ){
		mp now = q.top();
		q.pop();
		if( used[ now.second ] )continue;
		used[now.second] = true;
		rest--;
		maxc = max( maxc , now.first );
		for(int i=0;i<g[now.second].size();i++){
		    if( mini > g[now.second][i].first || used[ g[now.second][i].second ] )continue;
		    q.push( g[now.second][i] );
		}
	    }
	    if( rest == 0 ) res = min( res , maxc-mini );
	}
	if( res == 1e9 ) cout<<-1<<endl;
	else cout<<res<<endl;
    }

    return 0;
}



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

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

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

  int ans = 0;
  for (auto i : Map) {
    ans += i.second % 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 4864
S = list(input())
T = []
cnt = 0
for i in range(len(S)):
  if S[i]=='R':
    T.append(1)
  else:
    T.append(0)
result = int("".join(str(i) for i in T),2)
if(result==0):
  cnt=0
elif ((result==6) or (result==3)):
  cnt = 2
elif (result==7):
  cnt = 3
else:
  cnt = 1
print(cnt)

Measured memory_bytes: 8944
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
int A , B , C;
cin >> A >> B >> C;
  if (A == B) {
cout << C << endl;
} else if (A == C ) {
  cout << B << endl;
} else {cout << A << endl;}



}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

bool is_uruu(int y){
  return (!(y % 4) && ((y % 100) || !(y % 400)));
}

int main() {
  int A, B;
  bool fir = true;
  while(cin >>A >>B && (A || B)){
    if(!fir) cout <<endl;
    fir = false;
    bool f = false;
    FOR(i, A, B + 1){
      if(is_uruu(i)){ f = true; cout <<i <<endl; }
    }
    if(!f) cout <<"NA" <<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <stdlib.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main()
{
    int N,a,b,c,count;
    count = 0;
    cin >> N;
    int L[N];
    for(int i=0;i<N;i++) cin >> L[i];

    sort(L,L+N);

    for(int i=0;i<N-2;i++){
        a = L[i];
        for(int j=i+1;j<N-1;j++){
            b = L[j];
            for(int k=j+1;k<N;k++){
                c = L[k];
                if( c >= a+b ) break;
                if( abs(a-b) < c && c < a+b ) count++;
            }
        }
    }

    cout << count << "\n";

}

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

int main(){
    int n,k=1e5+10;
    cin>>n;
    int a[n],t[k]={};
    for(int i=0;i<n;i++){
        cin>> a[i];
        t[a[i]]++;
    }
    int sum[k]={},ans=0;
    for(int i=1;i+1<k;i++){
        sum[i]=t[i-1]+t[i]+t[i+1];
        ans=max(ans,sum[i]);
    }

    cout<<ans;


}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define inf 1000000099
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 

 
int32_t main()
{
    int n,m;
    cin>>n>>m;
    vector<int>g[n];
    //watch(n);
    for (int i = 0; i < m; ++i)
    {
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
        
    }
    
    bool visited[n]={0};
    //memset(visited,false,sizeof(visited));
    map<int,int>um;
    queue<int>q;
    q.push(0);

    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        visited[x]=1;
        for(auto it:g[x])
        {
            if(visited[it]==0)
            {
              um[it]=x;
              q.push(it);
              visited[it]=1;
            }
        }

    }
    int flag=0;
    for(int i=0;i<n;i++)
    {
      if(visited[i]==0)
        flag=1;
    }
    if(flag==0)
    {
        cout<<"Yes"<<endl;
        for(auto x:um)
      cout<<x.second+1<<endl;
    }
    else
      cout<<"No"<<endl;
}



Measured memory_bytes: 18304
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 1e5+10;
ll n;
vll a;
ll dp[N];
ll go(ll i)
{
	if(i == 0)
		return 0;
	if(i == 1)
		return abs(a[i] - a[0]);
	ll &ans = dp[i];
	if(ans != -1)
		return ans;
	return ans = min(go(i-1) + abs(a[i] - a[i-1])  , go(i-2) + abs(a[i] - a[i-2]));
}
signed main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("/home/karn/in", "r", stdin);
	//     freopen("/home/karn/out", "w", stdout);
	// #endif
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	cin >> n;
	cres(a , n);
	rep(i,0,n)
	{
		dp[i] = -1;
		cin >> a[i];
	}

	cout<<go(n-1)<<endl;






////////////////////////////////////////////////////////////////////////////////////////////

	// #ifndef ONLINE_JUDGE
 //    	cout<<endl<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec"<<endl;
 //    #endif
	
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using std::cerr;
using std::endl;

struct IO {
  const static int S = 3e7;
  char buc_in[S], *p_in = buc_in;
  IO() {
    // freopen("data", "r", stdin);
    fread(buc_in, 1, S, stdin);
  }
  inline int rd() {
    int b = 0;
    while (!isdigit(*p_in)) ++p_in;
    while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
    return b;
  }
} io;

const int N = 8e5 + 233, P = 924844033, Gp = 5;
inline int fpow(int x, int y) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}
int fac[N], inv[N], ifac[N];

int rev[N], lim, L, inv_lim, w[N];
inline void init(int n) {
  for (lim = 1, L = 0; lim < n; lim <<= 1, ++L);
  for (int i = 0; i < lim; ++i)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (L - 1));
  inv_lim = fpow(lim, P - 2);
  int qwq = lim >> 1, omega = fpow(Gp, (P - 1) / lim);
  w[qwq] = 1;
  for (int i = qwq + 1; i < lim; ++i)
    w[i] = 1ll * w[i - 1] * omega % P;
  for (int i = qwq - 1; i; --i)
    w[i] = w[i << 1];
}

inline void DFT(int f[], int o) {
  unsigned long long tmp[N];
  for (int i = 0; i < lim; ++i)
    tmp[rev[i]] = f[i];
  for (int i = 0; i < lim; i += 2) {
    int nx = tmp[i], ny = tmp[i + 1];
    tmp[i] = nx + ny, tmp[i + 1] = nx + P - ny;
  }
  for (int i = 2; i < lim; i <<= 1) {
    for (int j = 0; j < lim; j += i << 1) {
      auto *a = tmp + j, *b = tmp + i + j;
      auto *p = w + i;
      for (int k = 0; k < i; ++k) {
        int ny = b[k] * p[k] % P;
        b[k] = a[k] + P - ny;
        a[k] += ny;
      }
    }
  }
  for (int i = 0; i < lim; ++i)
    f[i] = tmp[i] % P;
  if (o == -1) {
    std::reverse(f + 1, f + lim);
    for (int i = 0; i < lim; ++i)
      f[i] = 1ll * f[i] * inv_lim % P;
  }
}

int n, size[N], cnt[N];
int A[N], B[N];
std::vector<int> G[N];

void dfs(int x, int fa) {
  size[x] = 1;
  ++cnt[n];
  for (int y : G[x])
    if (y != fa) {
      dfs(y, x);
      size[x] += size[y];
      --cnt[size[y]];
    }
  if (fa) --cnt[n - size[x]];
}

int main() {
  n = io.rd();
  fac[0] = inv[1] = ifac[0] = ifac[1] = 1;
  for (int i = 1; i <= n; ++i)
    fac[i] = 1ll * fac[i - 1] * i % P;
  for (int i = 2; i <= n; ++i) {
    inv[i] = P - 1ll * P / i * inv[P % i] % P;
    ifac[i] = 1ll * ifac[i - 1] * inv[i] % P;
  }
  for (int i = 1; i < n; ++i) {
    int x = io.rd(), y = io.rd();
    G[x].push_back(y), G[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 0; i <= n; ++i) {
    A[i] = 1ll * cnt[i] * fac[i] % P;
    B[i] = ifac[i];
    if (A[i] < 0) A[i] += P;
  }
  std::reverse(A, A + n + 1);
  init((n + 1) << 1), DFT(A, 1), DFT(B, 1);
  for (int i = 0; i < lim; ++i)
    A[i] = 1ll * A[i] * B[i] % P;
  DFT(A, -1);
  for (int i = 1; i <= n; ++i) {
    int ans = A[n - i];
    ans = 1ll * ans * ifac[i] % P;
    printf("%d\n", ans);
  }
  /*
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int j = i; j <= n; ++j)
      ans = (ans + 1ll * cnt[j] * fac[j] % P * ifac[i] % P * ifac[j - i]) % P;
    std::cout << ans << '\n';
  }
  */
  return 0;
}


Measured memory_bytes: 56576
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

vector<vector<int>> g;

pair<int, int> dfs(int v, int p) {
  pair<int, int> res{0, v};
  for (int u : g[v]) {
    if (u == p) continue;
    auto d = dfs(u, v);
    d.first++;
    res = max(res, d);
  }
  return res;
}

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    g = vector<vector<int>>(n);
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      --a, --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }

    int x = dfs(0, -1).second;
    int y = dfs(x, -1).first;
    eprintf("y = %d\n", y);
    if (y % 3 == 1) {
      printf("Second\n");
    } else {
      printf("First\n");
    }
  }

  return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    cin >> n;
    vector<string> ss(n);
    vector<vector<int>> appear(n, vector<int>(26, 0));
    
    auto c2i = [](const char c){return c - 'a';};
    auto i2c = [](const int i) {return (char)((int)'a' + i);};
    
    repeat(i, n) {
        cin >> ss[i];
        repeat(j, (int)ss[i].length()) {
            int idx = c2i(ss[i][j]);
            ++appear[i][idx];
        }
    }
    repeat(i, 26) {
        int mincnt = 1e5;
        repeat(j, n) {
            mincnt = min(mincnt, appear[j][i]);
        }
        char c = i2c(i);
        repeat(j, mincnt) {
            cout << c;
        }
    }
    cout << endl;
    return 0;
    
}

Measured memory_bytes: 256
/*Author SHUBH AGRAWAL  */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
//a power n mod p

#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 

lld l,r,mid,ans;
lld n,m,i,j,k,x;


char c;
void solve()
{
    int a[200000];
    cin>>k>>n;
    for(i=0;i<n;i++) cin>>a[i];
    ans=k;
    lld max=0;
    for(i=1;i<n;i++)
    {
        if(a[i]- a[i-1] >max) max= a[i]-a[i-1]; 
    }
    if(max< k-a[n-1]+a[0]) max=k-a[n-1]+a[0];
    cout<<k-max;
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

string ans = "";
bool f(ll a){
    cout<<"? "<<ans<<a;
    rep(i, 15 - to_string(a).size() - ans.size()) cout<<9;
    cout<<endl;
    char c;
    cin>>c;
    return c == 'Y';
}
bool f2(ll a){
    cout<<"? "<<a<<endl;
    char c;
    cin>>c;
    return c == 'Y';
}

int main() {
    while(ans.size() < 9){
        int lb = -1, ub = 9;
        while(ub - lb > 1){
            int cen = (ub + lb) / 2;
            if(ans.empty() && cen == 0){
                if(f2(1e+16)) {
                    ll temp = 9, re = 1;
                    while (!f2(temp)) {
                        re *= 10;
                        temp *= 10;
                        temp += 9;
                    }
                    cout <<"! "<< re << endl;
                    return 0;
                }else{
                    break;
                }
            }
            (f(cen) ? ub : lb) = cen;
        }
        ans.push_back(char('0' + ub));
    }
    ll temp = 10, re = 1;
    while (f2(temp)) {
        ++re;
        temp *= 10;
    }
    cout<<"! "<<ans.substr(0, re)<<endl;
}

Measured memory_bytes: 596
import java.util.Scanner;
import static java.lang.System.out;

class Watch {
    int second;

    Watch(int second) {
        this.second = second;
    }

    @Override
    public String toString() {
        int h = this.second / 3600;
        int m = this.second % 3600 / 60;
        int s = this.second % 60 % 60;
        return String.format("%d:%d:%d", h, m, s);
    }
}

public class Main {
    public static void main(String... args) {
        int s = new Scanner(System.in).nextInt();
        out.println(new Watch(s));
    }
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

    int n;
    cin >> n;
    vector<int> vec(n);
    rep (i, n)
        cin >> vec[i];

    double ave = 0;
    rep (i, n)
        ave += vec[i];
    ave /= n;

    int idx = 0;
    double min = INF;
    rep (i, n) {
        if (abs(vec[i] - ave) < min) {
            min = abs(vec[i] - ave);
            idx = i;
        }
    }
    print(idx);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
n,k = map(int, input().split())

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

def nHr(n,r):
    return comb(n+r-1,r)

def getR(i):
    split=i+1
    must1=i-1
    balls=n-k-must1
    if balls<0:
        return 0
    return nHr(split,balls)

def getB(i):
    split=i
    must1=i
    balls=k-must1
    if balls<0:
        return 0
    return nHr(split,balls)

for i in range(1,k+1):
    ans = (getR(i)*getB(i)) % (10**9+7)
    print(ans)

Measured memory_bytes: 46300
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    if((n % 100) % 10 == 3)
        cout << "bon" << endl;
    else if((n % 100) % 10 == 0 || (n % 100) % 10 == 1 || (n % 100) % 10 == 6 || (n % 100) % 10 == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;


    //*/
}

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

int main() {

int x[5];
int y[5];
cin >>x[1]>>y[1]>>x[2]>>y[2];

int h=x[2]-x[1];
int v=y[2]-y[1];

x[3]=x[2]-v;
y[3]=y[2]+h;

x[4]=x[3]-h;
y[4]=y[3]-v;

cout <<x[3]<<" "<<y[3]<<" "<<x[4]<<" "<<y[4];


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a;
  cin>>a;
  cout<<a*a*a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	char a, b; cin >> a >>b;
	if(a == 'H') cout << b;
	else {
		if(b == 'H') cout << "D";
		else cout << "H";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;

ll gcd(ll m, ll n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

ll lcm(ll m, ll n) {
  return abs(m*n) / gcd(m, n);
}

int f(int x) {
  int res = 0;
  while(x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if(a[i] % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  int t = f(a[0]);
  rep(i, n) {
    if(f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t;
  }
  m >>= t;

  ll l = 1;
  rep(i, n) {
    l = lcm(l, a[i]);
    if(l > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  m /= l;
  int ans = (m+1)/2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define ull unsigned long long int
#define T int test; scanf("%d",&test); while(test--)
#define pb push_back
#define in insert
#define PI acos(-1)
#define sc(n) scanf("%d",&n)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define lsc(n) scanf("%lld",&n)
#define lsc2(a,b) scanf("%lld%lld",&a,&b)
#define rep(i,n) for(i=0;i<n;i++)
#define fr(i,a,b) for(i=a;i<b;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
using namespace std;



int main()
{
	ll n,m,i;
	lsc2(n,m);
	ll k,s=0;
	rep(i,m)
	{
		lsc(k);
		s+=k;
	}
	n-=s;
	if(n>=0)
	{
		cout << n << endl;
	}
	else
		cout << -1 << endl;
    return 0;
}


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

int main() {

  int n;
  cin >> n;
  string s;
  cin >> s;
  int lol = 0;

  if(n % 2 == 1) {
    cout << "No" << endl;        
    return 0;
  }
  else {
    lol = n / 2;
  }

  int t = n/2;
  int ans = 0;

  for (int i = 0; i < lol; i++) {
    if(s.at(i) == s.at(t)) {
      ans++;
      t++;
    }
  }
  if(ans == n/2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = [[] for i in range(n)]
for i in range(n-1):
    x,y = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)

def dfs(v):
    d = [-1 for i in range(n)]
    q = []
    d[v] = 0
    q.append(v)
    while len(q):
        v = q.pop()
        for i in a[v]:
            if d[i] == -1:
                d[i] = d[v]+1
                q.append(i)
    return d
c1 = dfs(0)
c2 = dfs(n-1)
c = 0
for i in range(n):
    if c1[i]>c2[i]:
        c += 1
if c>= n/2:
    print("Snuke")
else:
    print("Fennec")


Measured memory_bytes: 29164
#include<stdio.h>
int main(void){
    int x[3000], y[3000];
    int i = 0, j, tunc;
    while (1){
        scanf("%d %d", &x[i], &y[i]);
        if (x[i] == 0 && y[i] == 0){
            break;
        }
        else{
            i++;
        }
    }
    for (j = 0; j < i;j++){
        if (y[j] < x[j])
        {
            tunc = x[j];
            x[j] = y[j];
            y[j] = tunc;
        }
        printf("%d %d\n", x[j], y[j]);
    }
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
    rep(i,n+1) dp[i][0]=1;
    rep(i,n)FOR(j,1,k+1){
      dp[i+1][j]=(dp[i][j]+dp[i+1][j-1])%mod;
      if(j>=a[i]+1) (dp[i+1][j]-=-mod+dp[i][j-1-a[i]])%=mod;
    }
    cout<<dp[n][k]<<endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int N;
  string S;
  int state = 0;
  int count = 0;
  cin >> N >> S;
  for (int i = 0; i < N; i++) {
    if (state == 2) {
      if (S[i] == 'C') state = 3;
      else if (S[i] == 'A') state = 1;
      else state = 0;
    } else if(state == 1) {
      if (S[i] == 'B') state = 2;
      else if (S[i] == 'A') state = 1;
      else state = 0;
    } else if (state == 0) {
      if (S[i] == 'A') state = 1;
      else state = 0;
    }
    if (state == 3) {
      count++;
      state = 0;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
k = int(input())
lunlun = [0] * 100
lunlun[1] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
i = 1

for _ in range(9):
    n = len(lunlun[i])
    lunlun[i+1] = []
    for x in lunlun[i]:
        r = x%10
        if r > 0:
            lunlun[i+1].append(10*x + r-1)
        lunlun[i+1].append(10*x + r)
        if r < 9:
            lunlun[i+1].append(10*x + r+1)
    i += 1

for i in range(1, 11):
    for j in range(len(lunlun[i])):
        k -= 1
        if k == 0:
            print(lunlun[i][j])
            exit()


Measured memory_bytes: 11636
import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

H,W,M=nm()
r=[0]*(10**6)
c=[0]*(10**6)
mass=set()
for i in range(M):
    h,w=nm()
    mass.add(H*h+w)
    r[h]+=1
    c[w]+=1

rl=[]
cl=[]

r_max=0
for i in range(1,H+1):
    r_max=max(r[i],r_max)
    
c_max=0
for i in range(1,W+1):
    c_max=max(c[i],c_max)

for i in range(1,H+1):
    if(r[i]==r_max):
        rl.append(i)

for i in range(1,W+1):
    if(c[i]==c_max):
        cl.append(i)



for i in rl:
    for j in cl:
        if(i*H+j not in mass):
            print(r_max+c_max)
            sys.exit(0)


print(r_max+c_max-1)


Measured memory_bytes: 168884
#include <iostream>
using namespace std;
int road[6];
int main() {
  for (int i = 0; i < 6; i++) {
    cin >> road[i];
  }
  int c[4] = {0, 0, 0, 0};
  for (int i = 0; i < 6; i++) {
    c[road[i] - 1]++;
  }
  for (int i = 0; i < 4; i++) {
    if (c[i] > 2) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}

Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll x;
    cin>>x;
    cout<<(1-x)<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main() {
  string s;
  while (true) {
    cin >> s;
    if (s == "0") break;
    int sum{};
    for (const auto &c : s) {
      sum += c & 0xF;
    }
    cout << sum << endl;
  }

  return 0;
}



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

int main()
{
    int64_t nof, d;
    cin>>nof>>d;
    int64_t tot = 0;
    int64_t p1, p2;
    for(size_t i{0}; i!=nof; ++i)
    {
        cin>>p1>>p2;
        if(sqrt(p1*p1+p2*p2) <= d)
            ++tot;
    }
    cout<<tot;
}


Measured memory_bytes: 3192