akhauriyash/Code-Regression huggingface dataset:
S = input()

S = S[::-1]
while len(S):
    if S[0] == "r":
        if S[:7] == "remaerd":
            S = S[7:]
        elif S[:6] == "resare":
            S = S[6:]
        else:
            print("NO")
            break
    elif S[0] == "m":
        if S[:5] == "maerd":
            S = S[5:]
        else:
            print("N0")
            break
    elif S[0] == "e":
        if S[:5] == "esare":
            S = S[5:]
        else:
            print("N0")
            break
    else:
        print("NO")
        break
else:
    print("YES")


Measured memory_bytes: 3188
#include<stdio.h>

int main()
{
	int i, n, tmp, status, preStatus, count;
	char action[200];
	
	while(1)
	{
		status = preStatus = 0x00;
		count = 0;
		
		scanf("%d", &n);
		
		if(n == 0) break;
		
		for(i = 0; i < n; i++)
		{
			scanf("%s", &action[i * 2]);
		}
		
		for(i = 0; i < n; i++)
		{
			if(action[i * 2] == 'l'){
				tmp = 0x10;
			} else {
				tmp = 0x01;
			}
			
			if(action[i * 2 + 1] == 'u'){
				status |= tmp;
			} else {
				status &= ~tmp;
			}
			
			if((preStatus == 0x00 || preStatus == 0x11) && preStatus == (~status & 0x11))
			{
				preStatus = status;
				count++;
			}
		}
		
		printf("%d\n", count);
	}
	
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
vector<string> v;
int main(){
	while(1){
		int n; cin >>n;
		if(n==0)break;
		int max_size=1e5;
		vector<string> s(n);
		v.clear();
		for(int i=0;i<n;i++){
			cin >>s[i];
			string t;
			t.push_back(s[i][0]);
			bool a=false;
			if(s[i][0]=='a'||s[i][0]=='i'||s[i][0]=='u'||s[i][0]=='e'||s[i][0]=='o')a=true;
			for(int j=1;j<s[i].size();j++){
				if(a==true){
					t.push_back(s[i][j]);
					a=false;
				}
				if(s[i][j]=='a'||s[i][j]=='i'||s[i][j]=='u'||s[i][j]=='e'||s[i][j]=='o')a=true;
			}
			v.push_back(t);
		}
		for(int i=0;i<v.size();i++){
			if(max_size<v[i].size())max_size=v[i].size();
		}
		set<string> per;
		bool c=true;
		for(int k=1;k<=max_size;k++){
			bool b=true;
			int copy=1;
			for(int j=0;j<v.size();j++){
			    if(per.count(v[j].substr(0,k))){
					b=false;
				}
				per.insert(v[j].substr(0,k));
				copy=k;
		    }
			if(b){
				cout <<copy << endl;
				c=false;
				break;
			}
			per.clear();
		}
		if(c)cout << -1 << endl; 
	}
}


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (100010)
#define P ()
#define M (N<<1)
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,m,cnt,S,T,fi[N],ne[M],b[M],deg[N],dd[N];
bool vis[N]; int ans,E;
void add(int x,int y){
	ne[++E]=fi[x],fi[x]=E,b[E]=y;
}
void dfs(int u){
//	if(u==T){ans++;return;}
	vis[u]=1;
	for(int i=fi[u];i;i=ne[i]){
		int v=b[i];
		if(v==T)ans++;
		if(v==T||vis[v])continue;
		dfs(v);
	}
}
int main(){
	read(n),read(m);
	for(int i=1;i<=m;i++){
		int x,y;
		read(x),read(y);
		add(x,y),add(y,x);
		deg[x]++,deg[y]++;
	}
	for(int i=1;i<=n;i++)
	if(deg[i]&1)puts("No"),exit(0);
	for(int i=1;i<=n;i++)
	if(deg[i]>=6)puts("Yes"),exit(0);
	for(int i=1;i<=n;i++)
	if(deg[i]==4)dd[++cnt]=i;
	if(cnt>=3)puts("Yes"),exit(0);
	if(cnt<2)puts("No"),exit(0);
	S=dd[1],T=dd[2];
	memset(vis,0,sizeof(vis)),dfs(S);
	if(ans==2)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


// 2整数の最大公約数を求める関数
ll gcd(ll x, ll y) {
  if(y == 0) return x;
  else return gcd(y, x % y);
}

// 3個以上の整数の最大公約数を求める関数
ll gcdary(ll a[], ll n) {
  if(n == 1) return (a[0]);
  else if(n == 2) return (gcd(a[0], a[1]));
  else return (gcd(a[0], gcdary(&a[1], n - 1)));
}

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

  ll n,k;
  cin>>n>>k;
  ll a[n];
  rep(i,n) cin>>a[i];
  string ans = "IMPOSSIBLE";
  sort(a, a + n);
  if(a[n-1] >= k) {
    if((a[n-1] - k) % gcdary(a, n) == 0) {
      ans = "POSSIBLE";
    }
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 2560
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}



int main(){
    ll n,m,sum=0;
    cin>>n>>m;
    vector<ll> x(m),p(m-1);
    rep(i,m) cin>>x[i];
    sort(ALL(x));
    rep(i,m-1) {
        p[i]=x[i+1]-x[i];
        sum+=p[i];
    }
    if(m<=n){
        cout<<0<<endl;
        return 0;
    }
    
    sort(ALL(p));
    rep(i,n) sum-=p[m-1-i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
from collections import deque
N=int(input())
T=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int, input().split())
    T[a-1].append((b-1,c))
    T[b-1].append((a-1,c))

Q,K=map(int, input().split())
que=deque([(K-1,0)])
done=[-1]*N
while que:
    t=que.popleft()
    now,nowd=t
    done[now]=nowd
    for nex in T[now]:
        nexnode,nexd=nex
        if done[nexnode]!=-1:
            continue
        else:
            que.append((nexnode, nowd+nexd))

#print(done)
for i in range(Q):
    x,y=map(int, input().split())
    print(done[x-1]+done[y-1])

Measured memory_bytes: 47120
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

template<int size, class T>
struct Trie{
    T data;
    Trie* parent;
    vector<Trie*> child;
    Trie(Trie *p=nullptr) :data(),parent(p),child(size+1,nullptr){}
    Trie* find(string &s,Trie* now){ //convert charactor to integer in range of [0,size)
        vector<short> res;
        for(int i=0; i<(int)s.size(); ++i)res.push_back(s[i]-'0');
        return find(res,now);
    }
    template<class S>Trie* find(vector<S> &v, Trie* now){ //find/add nodes
        for(S &s : v){
            if(now->child[s]==nullptr)now->child[s]=new Trie(now);
            now=now->child[s];
        }
        now->child[size]=new Trie(now); //termination
        return now;
    }
    bool terminated(Trie *t){return t->child[size]!=nullptr;}
};

struct Problem{
    LL n,l;
    vector<int> ss,len;
    Trie<2,int> t;
    Problem(LL n, LL l):n(n),l(l),ss(n){};

    void dfs(Trie<2,int>* t, int d){
        for(int i=0; i<2; ++i){
            if(t->child[i]==nullptr)len.push_back(d+1);
            else dfs(t->child[i],d+1);
        }
    }
    void solve(){
        for(int i=0; i<n; ++i){
            string tmp;
            cin >> tmp;
            t.find(tmp,&t);
        }
        dfs(&t,0);
        LL grundy =0;
        for(auto && x:len){
            grundy^=(l-x+1)&(x-l-1);
        }
        if(grundy==0)cout << "Bob"<<"\n";
        else cout << "Alice" <<"\n";


    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,l;
    cin >> n >> l;

    Problem p(n,l);
    p.solve();
    return 0;
}



Measured memory_bytes: 11044
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int ans = 1000-n%1000;
  if(ans==1000)ans=0;
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;

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

	if (n == 1) {
		cout << 1.0 << endl;
	}
	else if ((int)n % 2 == 1) {
		cout << fixed << setp(7) << (double)(((int)n / 2) + 1 )/ n << endl;
	}
	else {
		cout << 0.5 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
//#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

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

  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'L' && i % 2 == 0) {
      cout << "No" << endl;
      return 0;
    }
    if (S[i] == 'R' && i % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main ()  {
  int N ;
  cin >> N ;
  vector<int> line(2*N) ;
  for(int i = 0 ; i < 2 * N ; i++) cin >> line[i] ;
  sort(line.begin(),line.end()) ;
  int ans = 0 ;
  for(int i = 0 ; i < 2 * N ; i += 2 ) ans += line[i] ;
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	if(n%2==0)
		printf("%0.6f",(double)1/2);
	else
		printf("%0.6f",((n/2+1)/(double)n));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int M;
int N;
int *H;
int *A;
int *B;
int *T;

int main(void)
{
    int c;
    int ans = 0;
    scanf("%d", &N);
    scanf("%d", &M);
    H = (int *)malloc(sizeof(int) * N);
    A = (int *)malloc(sizeof(int) * M);
    B = (int *)malloc(sizeof(int) * M);
    T = (int *)malloc(sizeof(int) * N);
    for (c = 0; c < N; ++c)
    {
        scanf("%d", H + c);
        T[c] = 1;
    }
    for (c = 0; c < M; ++c)
    {
        scanf("%d", A + c);
        scanf("%d", B + c);
        --A[c];
        --B[c];
    }
    for (c = 0; c < M; ++c)
    {
        if (H[A[c]] > H[B[c]])
        {
            T[B[c]] = -1;
        }
        else if (H[A[c]] < H[B[c]])
        {
            T[A[c]] = -1;
        }
        else
        {
            T[A[c]] = 0;
            T[B[c]] = 0;
        }
    }
    for (c = 0; c < N; ++c)
    {
        if (T[c] > 0)
        {
            ++ans;
        }
    }
    printf("%d", ans);
    free(A);
    free(B);
    free(H);
    free(T);
    return 0;
}

Measured memory_bytes: 2952
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main() {
    string S, T;
    cin >> S; cin >> T;
    map<char, char> m;
    for(int i = 0; i < S.size(); i++){
        if(m.find(S[i]) != m.end() && m[S[i]] != T[i]){
            cout << "No" << endl; return 0;
        }
        else{
            m[S[i]] = T[i];
        }
    }
    
    m.clear();
    for(int i = 0; i < T.size(); i++){
        if(m.find(T[i]) != m.end() && m[T[i]] != S[i]){
            cout << "No" << endl; return 0;
        }
        else{
            m[T[i]] = S[i];
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const int mod = 1e9+7;
int main() {
	int h,w;
	cin>>h>>w;
	char a[h][w];
	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
				cin>>a[i][j];
		}
	}
	vector<vector<long long>> dp(h,vector<long long> (w));
	dp[0][0] = 1;
	for(int i=1;i<w;i++) {
		dp[0][i] = (a[0][i]=='.'?dp[0][i-1]:0);
	}
	for(int i=1;i<h;i++) {
		dp[i][0] = (a[i][0]=='.'?dp[i-1][0]:0);
	}
	for(int i=1;i<h;i++) {
		for(int j=1;j<w;j++) {
			if(a[i][j]=='#') {
				dp[i][j] = 0;
			} else {
				dp[i][j] = (dp[i][j-1]+dp[i-1][j])%mod;
			}
		}
	}
	//for(int i=0;i<h;i++) {
		//for(int j=0;j<w;j++) {
			//cout<<dp[i][j]<<" ";
		//}
		//cout<<"\n";
	//}
	cout<<dp[h-1][w-1];
}



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

int main () {
   int n,m;
   cin>>n>>m;
   int final=0;
   for(int i=0;i<m;i++)
   { int s;
     cin>>s;
     final+=s;

   }
   if(n-final<0)
   {
     cout<<-1<<endl;
   }
   else
   {
     cout<<n-final<<endl;
   }

}


Measured memory_bytes: 3624
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    if N == 0:
        print(0)
        return

    dp = [(0, 0)] * 32
    dp[0] = (0, 1)
    for i in range(1, 32):
        if i % 2 == 0:
            a = 2 ** i
            dp[i] = (dp[i - 1][0], dp[i - 1][1] + a)
        else:
            a = -(2 ** i)
            dp[i] = (dp[i - 1][0] + a, dp[i - 1][1])

    ans = ""
    total = 0
    for i in range(31, 0, -1):

        l, r = dp[i - 1]
        if i % 2 == 0:
            a = 2 ** i
        else:
            a = -(2 ** i)

        rest = N - total

        if l + a <= rest <= r + a:
            total += a
            ans += "1"
        else:
            ans += "0"

    if N - total == 1:
        ans += "1"
    else:
        ans += "0"
    print(ans.lstrip("0"))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val nQ = sc.nextLine()
            .split(" ")
            .map { Integer.parseInt(it) }
    val namesTimes = Queue()
    for (i in 0 until nQ[0]) {
        val nameTime = sc.nextLine().split(" ")
        namesTimes.enqueue(nameTime[0] to Integer.parseInt(nameTime[1]))
    }
    var processedTime = 0
    while (!namesTimes.isEmpty()) {
        var q = nQ[1]
        var nameTime = namesTimes.dequeue()
        if (nameTime!!.second > q) {
            processedTime += q
            nameTime = nameTime.first to nameTime.second.minus(q)
            namesTimes.enqueue(nameTime)
        } else {
            processedTime += nameTime.second
            q -= nameTime.second
            println("${nameTime.first} $processedTime")
        }
    }
}

class Queue {
    private val a = Array<Pair<String, Int>?>(100001) { null }

    private var head = 0

    private var tail = 0

    fun enqueue(v: Pair<String, Int>?) {
        a[tail] = v
        if (tail + 1 == a.size) {
            tail = 0
        } else {
            tail++
        }
    }

    fun dequeue(): Pair<String, Int>? {
        val r = a[head]
        a[head] = null
        if (head + 1 == a.size) {
            head = 0
        } else {
            head++
        }
        return r
    }

    fun isEmpty() = head == tail
}




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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

ll solve(ll N, ll P, string S)
{
    if (P == 2 || P == 5) {
        long long res = 0;
        for (int i = 0; i < N; ++i) if ((S[N-i-1]-'0') % P == 0) res += N-i;
        return res;
    }
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
    return res;
}


int main()
{
    ll N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    ll cnt = 0;
    if(P == 2 || P == 5) {
        REP(i,0,N) {
            if((S[N-i-1] - '0') % P == 0) cnt += N - i;
        }
    }
    else {
        vec C(N+1, 0);
        ll d = 1;
        REP(i,0,N) {
            C[i+1] = (C[i] + (S[N-i-1] - '0') * d) % P;
            d = (d * 10) % P;
        }
        vec V(P, 0);
        REP(i,0,N+1) ++V[C[i]];
        REP(p,0,P) cnt += V[p] * (V[p]-1) / 2;
    }

    PR(cnt);

    return 0;
}

/*


*/

Measured memory_bytes: 5244
#include <bits/stdc++.h>
#define ll long long int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
#define square(x) x*x
using namespace std;
/**
        * @author :: Sawlani
        *
        */
int main()
{
    ll x,y,a,b,c;
    cin >> x >> y >> a >>  b >> c;

    vector <pair <ll,char>> vp;
    f(i,1,a){
        ll x;
        cin >> x;
        vp.push_back({x,'r'});
        }

     f(i,1,b){
        ll x;
        cin >> x;
        vp.push_back({x,'g'});
        } 

    f(i,1,c){
        ll x;
        cin >> x;
        vp.push_back({x,'c'});
        }
     

    sort(all(vp));

    // for(auto i:vp)
    // cout << i.fi << " " <<  i.se <<  endl;
    ll ans=0;ll xa,xb,xc;
    xa=xb=xc=0;
    rf(i,vp.size()-1,0)
    {

        if((xa+xb+xc)==(x+y))
        break;
         if(vp[i].se == 'r' && xa<x )
        {
            xa++;
            ans+=vp[i].fi;
        }   
        else if(vp[i].se == 'g'  &&  xb<y)
        {
            xb++;
            ans+=vp[i].fi;
        }
        else if(vp[i].se == 'c')
        {
            xc++;
            ans+=vp[i].fi;
        }
        
        
    }

    cout << ans;

}

Measured memory_bytes: 9836
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;

int nCrevenoroddfinder(int n,int r)
{
    int a=r;
    int b=n-r;
    for(int i=0;i<30;i++)
    {
        int x=1<<i;
        if((x&a)&&(x&b))
        {
            return 0;//even
        }
    }
    return 1;//odd
}

ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}


int getMaxGCD(vil &arr, int n) {
   // Calculating MAX in array 
    ll high = 0; 
    for (int i = 0; i < n; i++) 
        high = max(high, arr[i]); 
  
    // Maintaining count array 
    int count[high + 1] = {0}; 
    for (int i = 0; i < n; i++) 
        count[arr[i]]++; 
  
    // Variable to store the 
    // multiples of a number 
    int counter = 0; 
  
    // Iterating from MAX to 1 
    // GCD is always between 
    // MAX and 1. The first 
    // GCD found will be the 
    // highest as we are  
    // decrementing the potential 
    // GCD 
    for (int i = high; i >= 1; i--) 
    { 
        int j = i; 
       counter = 0; 
    
        // Iterating from current 
        // potential GCD 
        // till it is less than 
        // MAX 
        while (j <= high) 
        { 
            // A multiple found 
  
            if(count[j] >=2) 
               return j; 
  
           else if (count[j] == 1)          
                counter++;          
  
            // Incrementing potential 
            // GCD by itself 
            // To check i, 2i, 3i.... 
            j += i; 
  
            // 2 multiples found, 
            // max GCD found 
            if (counter == 2)          
                return i; 
        } 
    } 
}
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n;cin>>n;
  vil v(n);
  ll f;
  for(int i=0;i<n;i++){
        cin>>v[i];
        if(i==0) f=v[i];
        else f=gcd(f,v[i]);
  }
  ll dp[n];
  ll cnt=0;
  
  ll flag=1;
   cnt=0;
  ll an=getMaxGCD(v,n);
  
  if(an==1) cout<<"pairwise coprime";
  else if(f==1)  cout<<"setwise coprime";
  else cout<<"not coprime";
}



  

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int RC[10001];

int main()
{
  int popcnt[1 << 10];
  for (int b = 0; b < (1 << 10); b++){
    popcnt[b] = __builtin_popcount(b);
  }

  int R, C;
  while (R = in(), C = in()){
    memset(RC, 0, sizeof(RC));
    for (int r = 0; r < R; r++){
      for (int c = 0; c < C; c++){
        RC[c] |= in() << r;
      }
    }
    int maxi = 0;
    for (int b = 0; b < (1 << R); b++){
      int tot = 0;
      for (int c = 0; c < C; c++){
        int v = popcnt[b ^ RC[c]];
        tot += max(v, R - v);
      }
      maxi = max(maxi, tot);
    }
    printf("%d\n", maxi);
  }

  return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
int main()
{
	int second;
	scanf("%d",&second);
	int h=second/3600;
	int m=(second-(3600*h))/60;
	int s=(second-(3600*h)-(m*60));
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+1;
int n,h[maxn],dp[maxn];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>h[i];
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll dp1[3001][3001];
ll dp2[3001][3001];

int main() {
  int n, t;
  cin >> n >> t;
  vl A(n), B(n);
  rep(i, n) { cin >> A[i] >> B[i]; }

  rep(i, n) {
    rep(j, t) {
      maxs(dp1[i + 1][j], dp1[i][j]);
      if (j + A[i] < t) maxs(dp1[i + 1][j + A[i]], dp1[i][j] + B[i]);
    }
  }
  drep(i, n) {
    rep(j, t) {
      maxs(dp2[i][j], dp2[i + 1][j]);
      if (j + A[i] < t) maxs(dp2[i][j + A[i]], dp2[i + 1][j] + B[i]);
    }
  }

  rep(i, n+1) {
    rep(j, t) {
      maxs(dp1[i][j+1], dp1[i][j]);
      maxs(dp2[i][j+1], dp2[i][j]);
    }
  }
  ll ans = 0;
  rep(i, n) { 
    rep(j,t)
      maxs(ans, dp1[i][j] + dp2[i+1][t-j-1] + B[i]); 
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solveA() {
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) cout << "Yes";
    else cout << "No";
}

void solveB() {
    int n; cin >> n;
    string s; cin >> s;
    int res = 0;
    for (int i = 0; i + 2 < n; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') res++;
    }
    cout << res;
}

void solveC() {
    int n; cin >> n;
    int p[n], q[n];
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < n;i ++) cin >> q[i];
    int arr[n];
    int lim = 1;
    for (int i = 1; i <= n; i++) lim *= i;
    for (int i = 0; i < n; i++) arr[i] = i + 1;
    int a = 0, b = 0;
    for (int i = 0; i < lim; i++) {
        int isA = 1, isB = 1;
        for (int j = 0; j < n; j++) {
            if (arr[j] != q[j]) isB = 0;
            if (arr[j] != p[j]) isA = 0;
        }
        if (isA) a = i;
        if (isB) b = i;
        next_permutation(arr, arr + n);
    }
    cout << abs(a - b);
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

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

void solveD() {
    long long n, m; cin >> n >> m;
    long long arr[n];
    if (n == 1) {
        int x; cin >> x;
        if (x % 2 == 1) cout << 0;
        else {
            x /= 2;
            int res = (m - x) / (2 * x) + 1;
            cout << ((res < 0) ? 0 : res);
        }
        return;
    }
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        arr[i] /= 2;
    }
    int two = find2(arr[0]);
    for (int i = 1; i < n; i++) {
        if (find2(arr[i]) != two) {
            cout << 0;
            return;
        }
    }
    long long arrLcm = 1LL;
    for (int i = 0; i < n; i++) arrLcm = lcm(arrLcm, arr[i]);
    long long res = m / arrLcm - m / (2 * arrLcm); //(m - arrLcm) / (2 * arrLcm) + 1;
    cout << ((res < 0) ? 0 : res);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    ///solveA();
    ///solveB();
    ///solveC();
    solveD();
}


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

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

  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  vector<long long> ans;
  for (int i = 1; i < n; i++)
  {
    if(a[i]==a[i-1]){
      ans.push_back(a[i]);
      i++;
    }
    if(ans.size()==2){
      cout << ans[0]*ans[1] << endl;
      return 0;
    }
  }

  cout << 0 << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
 
public class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        if(Character.isLowerCase(s.charAt(0))){
            System.out.println("a");
        } else{
            System.out.println("A");
        }
    }
}

Measured memory_bytes: 35520
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return (x % MOD) * (m % MOD) % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    int n, a, b;
    cin >> n >> a >> b;

    int ans = 0;
    int tmp = 1;
    ans = mod(modpow(2,n)-1);
    int mx = max(a,b) +1;
    FOR(i,1,mx) {
        tmp = modd(modm(tmp,n-i+1),i);
        if (i == a || i == b) ans = mod(ans-tmp);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
h,w,n = map(int,input().split())
x = []
for i in range(n):
  x.append(list(map(int,input().split())))
d = defaultdict(int)
for i in x:
  a = []
  for j in range(3):
    for k in range(3):
      if (i[0]-j-1>=0 and i[1]-k-1 >= 0 and i[0]-j-1<=h-3 and i[1]-k-1 <= w-3):
        a.append((i[0]-j-1,i[1]-k-1))
  for j in a:
    d[j] += 1
a = list(d.values())
ans = [0]*10
ans[0] = (h-2)*(w-2)-len(a)
for i in a:
  ans[i] += 1
for i in ans:
  print(i)

Measured memory_bytes: 198116
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ld long double
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int h,w;
  cin >> h >> w;
  int v;
  cin >> v;
  int u=(1<<(h-1));
  int k[h][w];
  rep(i,h){
    string s;
    cin >> s;
    rep(j,w){
      k[i][j]=(s[j]-'0');
    }
  }
  int ans=1000000000;
  rep(i,u){
    int cnt[h];
    rep(j,h)cnt[j]=0;
    int an=0;
    rep(j,h-1){
      if(i&(1<<j))an++;
    }
    int o=0;
    int c=0;
    while(o<w){
      //cout << o << an << endl;
      if(an>1010){
        c++;
        break;
      }
      int l=0;
      cnt[0]+=k[0][o];
      rep(j,h-1){
        if(i&(1<<j)){
          l++;
        }
        cnt[l]+=k[j+1][o];
      }
      int ma=0;
      rep(b,h)ma=max(ma,cnt[b]);
      //cout << ma << endl;
      if(ma>v){
        rep(t,h)cnt[t]=0;
        an++;
      }
      else o++;
      
    }
    //cout << ans << " " << an << endl;
    ans=min(ans,an);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N=input()
n=len(N)
n=int(n)
num=0
num1=1
num2=1
for i in range(n-1):
    if(i%2==0):
        if(i>1):
            for k in range(i):
                num1=num1*10
                num2=num1
        num1=1
        num+=9*num2

if(int(N)>9):
    if(n%2==1):
        num+=int(N)-num2*100+1
else:
    if(n%2==1):
        num+=int(N)%(num2*100)

print(num)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  
  if(s=="KIHBR"||s=="AKIHBR"||s=="KIHABR"||s=="KIHBAR"||s=="KIHBRA"||s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||s=="KIHABAR"||s=="KIHABRA"||s=="KIHBARA"||s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="KIHABARA"||s=="AKIHABARA")cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=[i-1 for i in arr]
acum=[0]
for i in range(n):
  acum.append(acum[-1]+arr[i])
acum=[i%k for i in acum]
ans=0
dic={}
for i in range(n+1):
  if acum[i]%k not in dic:
    dic[acum[i]]=1
  else:
    ans+=dic[acum[i]]
    dic[acum[i]]+=1
  if i>=k-1:
    dic[acum[i-k+1]]-=1
print(ans)

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

int main()
{
  
 	int n;
  	cin>>n;
  	int a[n], b[n], c[n];
  	int x, y, z; cin>>x>>y>>z;
  a[0] = x; b[0] = y; c[0]= z;
  for(int i=1; i<n; i++)
  {
  	cin>>x>>y>>z;
    a[i] = x + max(b[i-1], c[i-1]);
    b[i] = y + max(a[i-1], c[i-1]);
    c[i] = z + max(a[i-1], b[i-1]);
  }
  cout<<max( a[n-1], max(b[n-1], c[n-1] ) )<<endl;
}

Measured memory_bytes: 4716
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
char str[1000000];
int main(){
  scanf("%d %s",&n,str);
  for(int i=0;i<n;i++){
    if(str[i]=='<')a++;
    else break;
  }
  reverse(str,str+n);
  for(int i=0;i<n;i++){
    if(str[i]=='>')b++;
    else break;
  }
  printf("%d\n",n-min(a,b));
  return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include<vector>
using namespace std;
vector<long long> p;
vector<long long> d;
long long def;

long long culd(long long a,long long p){
	long long ans=1;
	while(p){
		if(p&1){
			ans*=a;
			ans%=def;
		}
		a*=a;
		a%=def;
		p>>=1;
	}
	return ans;
}

int main() {
	int n;cin>>n;
	p=vector<long long>(n+2);
	d=vector<long long>(n+2);
	vector<int> a(n);
	vector<int> use(n+1,0);
	int num;
	for(int i=0;i<n+1;i++){
		cin>>a[i];
		if(use[a[i]]){
			num=a[i];
		}else{
			use[a[i]]=1;
		}
	}
	int r,l;
	l=-1;
	for(int i=0;i<n+1;i++){
		if(a[i]==num){
			if(l==-1){
				l=i;
			}else{
				r=i;
			}
		}
	}
//	cout<<num<<endl;
//	cout<<l<<' '<<r<<endl;
	long long right=n-r;
	long long left=l;
	long long sum=right+left;
//	cout<<sum<<endl;
	def=1;
	for(int i=0;i<9;i++){
		def*=10;
	}
	def+=7;
	p[0]=1;
	d[0]=1;
	for(long long i=1;i<n+2;i++){
		p[i]=p[i-1]*i;
		p[i]%=def;
		d[i]=culd(p[i],def-2);
	}
	cout<<n<<endl;
//	for(int i=0;i<n+2;i++){
//		cout<<p[i]<<' '<<d[i]<<endl;
//	}
	for(int i=2;i<=n+1;i++){
		long long ansp,ansm;
		ansp=p[n+1]*d[i];
		ansp%=def;
		ansp*=d[n+1-i];
		ansp%=def;
		if(sum>=0){
		ansm=p[sum]*d[i-1];
		ansm%=def;
		}
		if(sum-i+1>=0){
		ansm*=d[sum-i+1];
		ansm%=def;
		}else{
			ansm=0;
		}
		cout<<(ansp-ansm+def)%def<<endl;
	}
	return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <typeinfo>
//#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int &i:h){
    cin >> i;
  }
  sort(h.begin(), h.end());
  int add = k - 1;
  int ans = INT_MAX;
  for (int i = 0; i + add < n;i++){
    ans = min(h.at(i + add) - h.at(i), ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, Ma, Mb;
std::vector<int>a, b, c;
std::vector<std::vector<std::vector<int>>>memo(41, std::vector<std::vector<int>>(412, std::vector<int>(412, -1)));

int dp(int n, int aa, int bb)
{
	if (aa > 0 && bb > 0 && aa*Mb / Ma == bb && bb*Ma / Mb == aa) return 0;
	if (n == N) return 114514;
	if (memo[n][aa][bb] != -1) return memo[n][aa][bb];
	int res1 = dp(n + 1, aa + a[n], bb + b[n]) + c[n];
	int res2 = dp(n + 1, aa, bb);
	return memo[n][aa][bb] = std::min(res1, res2);
}

int main()
{
	std::ios::sync_with_stdio(false);
	scanf("%d %d %d", &N, &Ma, &Mb);
	a.resize(N), b.resize(N), c.resize(N);
	rep(i, N) scanf("%d %d %d", &a[i], &b[i], &c[i]);
	printf("%d\n", dp(0, 0, 0) >= 114514 ? -1 : dp(0, 0, 0));
	return 0;
}

Measured memory_bytes: 28800
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#pragma GCC optimize ("O3")
using namespace std;
int main () {
    ios::sync_with_stdio(false);
    cin.tie (0);    
    ll n, d; cin>>n>>d;
    cout<<ceil((double) n/(2*d+1));
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int work = num;
		int sum=0;
		
		while(work != 0){
			sum +=  (work % 10);
			work /= 10;
		}
		if(num % sum == 0) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
	}
}


Measured memory_bytes: 23764
#include <stdio.h>

int main(void)
{
	long int a, b, k;

	scanf("%ld %ld %ld", &a, &b, &k);

	if (a >= k)
	{
		printf("%ld %ld\n", a - k, b);
		return 0;
	}

	if (a + b >= k)
	{
		printf("0 %ld\n", b + a - k);
		return 0;
	}

	printf("0 0\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;
 
int main() {
  ll n=5;
  vec a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    if(a[i]==0) {
      cout << i+1 << endl;
    }
  }
}

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

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  rep(i,n) cin>>p[i];
  
  int fmin = n+1;
  int ans = 0;
  rep(i,n){
    if(p[i]<fmin){
      ans++;
      fmin = p[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main(){
 int n,m,x,y,i,j,l,o;
 cin >> n >> m >> x >> y;
 int xM = x;
 int ym = y;

 for(i = 0; i < n; i++){
  cin >> l;
  if(l >= xM){
   xM = l;
  }
 } 
 
 for(j = 0; j < n; j++){
  cin >> o;
  if(o <= ym){
   ym = o;
  }
 } 

 if(xM < ym){
cout << "No War";
}else{
cout << "War";
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int64_t N,K,S;
  cin>>N>>K>>S;
  vector<int64_t>a(N);
  for(int i=0;i<N;i++){
    if(i<K){a[i]=S;}
    else{if(S==1){a[i]=S+1;}
         else{a[i]=S-1;}
    }
  }  
  for(int i=0;i<N;i++){
    cout<<a[i];
    if(i<N-1){cout<<" ";}
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 4032
#include <stdio.h>

const int MOD=998244353;
long long powmod(long long b,int e)
{
    if (e==1) return b;
    if (e&1) return (powmod((b*b)%MOD,e/2)*b)%MOD;
    return powmod((b*b)%MOD,e/2);
}
long long inv(int x)
{
    return powmod(x,MOD-2);
}
long long fac[300005];
long long invfac[300005];
long long choose(int a,int b)
{
    if (b<0 || b>a) return 0;
    return (((fac[a]*invfac[b])%MOD)*invfac[a-b])%MOD;
}

int n;
long long a,b,k,t;

long long ans=0;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    fac[0]=invfac[0]=1;
    for (int i=1; i<=300000; i++) {
        fac[i]=(fac[i-1]*i)%MOD;
        invfac[i]=(invfac[i-1]*inv(i))%MOD;
    }
    scanf("%d",&n);
    scanf("%lld%lld%lld",&a,&b,&k);
    for (int i=0; i<=n; i++) {
        t=k-a*i;
        if (t<0 || t%b) continue;
        t/=b;
        if (t>n) continue;
        // get (n choose i)*(n choose t)
        //printf("pick %d %d\n",i,t);
        ans+=(choose(n,i)*choose(n,t))%MOD;
    }
    printf("%lld\n",ans%MOD);
}


Measured memory_bytes: 5496
N = int(input())
T, A = map(int, input().split())
h = list(map(int, input().split()))

d = 10 ** 9
ans = -1
for i in range(N):
    t = abs((1000 * T - 6 * h[i]) - 1000 * A)
    if t < d:
        ans = i + 1
        d = t
print(ans)


Measured memory_bytes: 3060
/* 
	Author: ankrypt
*/

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

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N;
    cout << N + (N * N * N) + (N * N) << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3564
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int tate = scanner.nextInt();
        int yoko = scanner.nextInt();
        System.out.printf("%d %d\n", tate*yoko, (tate+yoko)*2);
        scanner.close();
    }
}


Measured memory_bytes: 26204
import java.util.Scanner;


public class Main 
{

	public static void main(String[] args) 
	{
		// TODO ©®¶¬³ê½\bhEX^u

		Scanner sc = new Scanner(System.in);
			String input = sc.nextLine();
			int Size = input.length();
			String[] n =new String[30];
			///¶ñðO©çÉn[i]ÌzñÉãü
			for(int i=0;i<Size;i++)
			{
				n[i] = input.substring(i,i+1);
			}
			///¶ñðtÅoÍ
			for(int i=(Size-1);i>-1;i--)
			{
				if(i==0)
					System.out.println(n[i]);
				else
					System.out.print(n[i]);
			}
	}
}

Measured memory_bytes: 11000
import java.util.*;

public class Main{

  public static void main (String[] args){
    
    Scanner scanner = new Scanner (System.in);
    
    String name = scanner.nextLine();
    
    String[] nameList = name.split(" ");
    
    char initial1 = nameList[0].charAt(0);
    char initial2 = nameList[1].charAt(0);
    char initial3 = nameList[2].charAt(0);
    
    System.out.print(initial1);
    System.out.print(initial2);
    System.out.println(initial3);
  }
}

Measured memory_bytes: 21844