akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  string ans;

  cin >> N >> M;

  if(N==M)ans = "Yes";
  else ans = "No";
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    String result = (a * b) % 2 == 0 ? "Even" : "Odd";
    System.out.println(result);

  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

ll n;
string s;
ll q;
ll a[1000006];
ll b[1000006];

int main()
{
	SPEED;	
	cin>>n;
	cin>>s;
	cin>>q;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='D')
			a[i+1]++;
		if(s[i]=='M')
			b[i+1]++;
		a[i+1]+=a[i];
		b[i+1]+=b[i];
	}
	for(int i=1;i<=q;i++)
	{
		ll x;
		cin>>x;
		x--;
		ll cur=0;
		ll ans=0;
		for(int i=n-x;i<=n;i++)
			if(s[i-1]=='M')
				cur+=a[i]-a[n-x-1];
		for(int i=n;i>=1;i--)
		{
			if(s[i-1]=='C')
				ans+=cur;
			if(i-x-1>0&&s[i-x-2]=='D')
				cur+=b[i-1]-b[max(0ll,i-x-1)];
			if(s[i-1]=='M')
				cur-=a[i]-a[max(0ll,i-x-1)];
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

      int a = sc.nextInt();
      int b = sc.nextInt();


      if(a<=b){
        System.out.println(a);
      }

      if(a>b){
        System.out.println(a-1);
      }
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>

int operate(int a, int b, char op)
{
    switch(op) {
        case '+' : return a + b;
        case '-' : return a - b;
        case '*' : return a * b;
        case '/' : return a / b;
        default: return INT_MIN;
    }
}

int main()
{
    int a, b;
    char op;

    while (1)
    {
        std::cin >> a >> op >> b;
        if (op == '?')
            return 0;
        std::cout << operate(a, b, op) << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3104
def main():
  n, mods = 0, [1]+[0]*2019
  d = 1
  for i in reversed(input()):
    n = (n+int(i)*d)%2019
    d = d*10%2019
    mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()

Measured memory_bytes: 9280
# coding : utf-8
 
import numpy as np
 
N = int(input())
 
A = [int(i) for i in input().split()]

S = [0 for i in range(N+1)]

for i in range(N):
	S[i+1] = S[i] + A[i]

S = sorted(S)
cnt = 0
block = 1
s = S[0]
for i in range(1,N+1):
	if s == S[i]:
		cnt += block
		block += 1
	else:
		s = S[i]
		block = 1

#print(S)
print(cnt)

Measured memory_bytes: 34568
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
bool sortinrev(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
    int n;
    cin>>n;
    double p[n+1];
    for(int i=1;i<=n;i++)
        cin>>p[i];
    double dp[n+1][n+1];
    memset(dp,0.0,sizeof(dp));
    dp[0][0] = 1.0;
    double ans=0.0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
            {
                dp[i][j] = dp[i-1][j]*(1.0-p[i]);
            }
            else
                dp[i][j] = dp[i-1][j]*(1.0-p[i]) + p[i]*dp[i-1][j-1];
        }

    }
    for(int i=(n+1)/2;i<=n;i++)
        ans+=(dp[n][i]);
    cout<<fixed;
    cout<<setprecision(11)<<ans<<endl;
    // cout<<ans<<endl;
    
    

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

Measured memory_bytes: 70528
#include <iostream>
#include <string>
#include <regex>

using namespace std;

int main()
{
	string input;
	cin >> input;

	regex pat{ R"(C+.*F+)" };
	if (regex_search(input.cbegin(), input.cend(), pat)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

int n, m, c, b[20], ans=0;

int main() {
	cin >> n >> m >> c;
	for(int i=0; i<m; i++){
		cin >> b[i];
	}

	for(int i=0, total; i<n; i++){
		total = 0;
		for(int j=0, a; j<m; j++){
			cin >> a;
			total += a*b[j];
		}

		total += c;
		ans += total>0? 1:0;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int f[100001];
int fx(int x){
	return f[x]==x?x:f[x]=fx(f[x]);
}
void hb(int x,int y){
	f[fx(x)]=fx(y);
}
int main(){
	int i,a,b;
	cin>>n>>m;
	for(i=1;i<=n;++i)f[i]=i;
	for(i=1;i<=m;++i){
		cin>>a>>b;
		hb(a,b);
	}
	int s=0;
	for(i=1;i<=n;++i){
		if(f[i]==i)++s;
	}
	cout<<s-1;
}

Measured memory_bytes: 4024
#include<iostream>
using namespace std;
#define lli long long int
#include<math.h>
#include<iomanip>
int main(){
  lli w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<fixed<<setprecision(9)<<(double)(w*h)/2;
  if((2*x==w)&&(2*y==h))
    cout<<" "<<"1\n";
  else
    cout<<" "<<"0\n";
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#define MAXN 2005
using namespace std;
vector<int> G[MAXN];
int n,k,tot;
void dfs(int u,int f,int dep)
{
	if(dep>k)
		return ;
	tot++;
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==f) continue;
		dfs(v,u,dep+1);
	}
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int ans=n;
	int t=k;
	k/=2;
	if(t%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			tot=0;
			dfs(i,-1,0);
			ans=min(ans,n-tot);
		}
	}
	else if(t%2)
	{
		for(int i=1;i<=n;i++)
			for(int j=0;j<G[i].size();j++)
			{
				int v=G[i][j];
				tot=0;
				dfs(v,i,0);
				dfs(i,v,0);
				ans=min(ans,n-tot);
			}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
f=[int(i) for i in input().split()]
lo=0 
from math import ceil 
a.sort()
f.sort(reverse=1)
def check(mi):
    cost=0 
    for i in range(n): 
        curr=a[i]*f[i]
        if curr<mi:
            pass 
        else: 
            cost+=ceil((curr-mi)/(f[i]))
            if cost>k:
                return 0 
    return cost<=k 
hi=10**13
while lo<=hi: 
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1 
    else:
        lo=mi+1 
print(ans)

Measured memory_bytes: 119628
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;

void solve(){
    string s,t;cin>>s>>t;
    ll l=s.length(),n=t.length();
    ll prev=-1,cur;
    vi ch[26];
    rep(i,l) ch[s[i]-'a'].pb(i);
    ll ans=0;
    rep(i,n){
        ll val=t[i]-'a';
        if(ch[val].size()==0) {cout<<-1;return;}
        ll pos=lower_bound(ch[val].begin(),ch[val].end(),prev+1)-ch[val].begin();
        ll tmp=ch[val][pos];
        if(pos==ch[val].size()) {ans+=l-(prev-ch[val][0]);prev=ch[val][0];}
        else {ans+=tmp-prev;prev=tmp;}
        //cout<<t[i]<<" "<<pos<<" "<<ch[val][pos]<<"\n";
        //cout<<ans<<" ";
    }
    cout<<ans;
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 1228
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> n >> a;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(A, A + n);
	for (int i = n-1; i > max(n-1-a,(ll)-1); i--) {
		A[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		sum += A[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define ld double
#define pb push_back
#define EPS 1e-9
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    cin >> n;
    FOR(i,0,n)
        if (n - 4*i < 0) break;
        else {
            int h = n - 4*i;
            if (h%7 == 0) {
                cout << "Yes";
                return 0;
            }
        }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
/*
改善点としては、まずこの入力を3次元配列では受け取らないこと！！


*/
int data1[15][15];
int main()
{
    rep(i, 15)
    {
        rep(j, 15)
        {
            data1[i][j] = -1;
        }
    }
    int N;
    cin >> N;
    rep(i, N)
    {
        int a;
        cin >> a;
        rep(j, a)
        {
            int x, y;

            cin >> x >> y;
            x--;
            data1[i][x] = y;
        }
    }
    //ビット全探索
    int max1 = 0;
    rep(i, 1 << N)
    {
        int flag = 1;
        vector<ll> d(N);
        rep(j, N)
        {
            if (i >> j & 1)
            {
                d[j] = 1;
            }
        }
        rep(k, N)
        {
            if (d[k] == 1)
            {
                //k番目(index)が正直者だという事。
                //data[k]の人の中で正直者と不親切の人の点にいく。

                for (int h = 0; h < N; h++)
                {
                    if (data1[k][h] == -1)
                    {
                        continue;
                    }

                    else if (data1[k][h] != d[h])
                    {
                        flag = 0;
                        break; //この時は矛盾が発生しているので違うbit列に行く必要あり
                    }
                }
            }
            if (flag == 0)
            {
                break;
            }
            //知りたいのはindexじゃない？
        }
        if (flag == 1)
        {
            //ここに入力するのは
            max1 = max(max1, __builtin_popcount(i));
        }
    }
    cout << max1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; ll k; cin >> n >> k;
    VL a(n + 1);
    eFOR(i, 1, n) {
        cin >> a[i];
        (--a[i] += a[i - 1]) %= k;
    }

    unordered_map<ll, ll> cnt;
    ll ans = 0;
    int itr = 0;
    eFOR(i, 0, n) {
        --cnt[a[i]];
        while (itr <= n && itr < i + k)++cnt[a[itr++]];
        ans += cnt[a[i]];
    }

    cout << ans << "\n";

}


Measured memory_bytes: 10056
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#include<bits/stdc++.h>
#include<unordered_map>
#define M 1000000007
#define T 998244353
#define pi 3.14159265
#define N 100003
#define inf 1000000002
#define ll long long
#define fo(i, a, b) for(i=a; i<=b; i++)
#define ro(i, b, a) for(i=b; i>=a; i--)
#define foe(it, x) for(auto it=x.begin(); it!=x.end(); it++)
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fil(x, y) memset(x, y, sizeof(x))
#define deb(x) cout << #x << " " << x << "\n"

using namespace std;

int gcd(int a, int b){
    if(a==0)return b;
    return gcd(b%a,a);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
void solve()
{
    int x;cin>>x;
    cout << lcm(360,x)/x << "\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL 
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    //int _t;cin >> _t; while(_t--)
    solve();
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String strs = sc.next();
		String mid = String.valueOf(strs.length()-2);
		String ans=strs.charAt(0)+mid+strs.charAt(strs.length()-1)	;

		
		
		System.out.println(ans);	
		}
	}


Measured memory_bytes: 22100
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline int read(){
	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')    f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x>=10)     print(x/10);
	putchar(x%10+'0');
}
int main(){
	int a=read(),b=read();
	if (a<=b)	printf("%d\n",a);
	else	printf("%d\n",a-1);
	return 0;
}

Measured memory_bytes: 256
/**
 * @Author : Gaurang_Kothiya
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;
const int MOD2= 998244353;


void Solve()
{
	int n,x,t;
	cin>>n>>x>>t;
	int sum=0,time=0;
	while(sum<n)
	{
		sum += x;
		time +=t;
	}
	cout<<time;
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);	

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  int n;
  cin >> n;
  vector<int> xs(n + 1);
  for (int i = 0; i < n + 1; i++) {
    cin >> xs[i];
  }

  vector<int> cs(n + 1);
  for (int x : xs) cs[x]++;

  vector<int> indexes;
  for (int i = 0; i < n + 1; i++) {
    if(cs[xs[i]] == 2) {
      indexes.push_back(i);
    }
  }
  int i1 = indexes[0];
  int i2 = indexes[1];
  int m = n + 1 - (i2 - i1) - 1;
  // cout << "m: " << m << endl;

  vector<FiniteField> factorials(n + 1);
  vector<FiniteField> inverse_factorials(n + 1);
  factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    factorials[i] = factorials[i - 1] * i;
  }
  inverse_factorials[n] = FiniteField(1) / factorials[n];
  for (int i = n; i >= 1; i--) {
    inverse_factorials[i - 1] = inverse_factorials[i] * i;
  }

  auto c_fn = [&](int a, int b) -> FiniteField {
    if (a < b) return 0;
    auto v = factorials[a] * inverse_factorials[b] * inverse_factorials[a - b];
    // cout << "a: " << a << " b: " << b << " v: " << v.Value() << endl;
    return v;
  };

  for (int k = 1; k <= n + 1; k++) {
    if (k == 1) {
      cout << FiniteField(n).Value() << endl;
    } else {
      FiniteField ans = 0;
      if (k <= n - 1) ans += c_fn(n - 1, k);
      if (k <= n) ans += c_fn(n - 1, k - 1) * 2 - c_fn(m, k - 1);
      ans += c_fn(n - 1, k - 2);
      cout << ans.Value() << endl;
    }
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	int n;cin>>n;
	string s;cin>>s;
	
	int a[26]={};
	for(int i=0;i<s.length();i++){
		a[s[i]-'a']++;
	}
	
	for(int i=0;i<26;i++){
		if(a[i]%2){
			cout<<0<<endl;return 0;
		}
	}
	
	map<pair<string,string>,ll>m;

	for(ll i=0;i<(1<<n);i++){
		
		string k1="",k2="";
		ll i1=i;
		for(int j=0;j<n;j++){
			if(i1%2){
				k1+=s[j];
			}
			else{
				k2+=s[j];
			}
			i1/=2;
		}
		
		m[{k1,k2}]++;
	}
	
	ll ans=0;
	
	for(ll i=0;i<(1<<n);i++){
		string k1="",k2="";
		ll i1=i;
		
		for(int j=2*n-1;j>=n;j--){
			if(i1%2){
				k1+=s[j];
			}
			else{
				k2+=s[j];
			}
			i1/=2;
		}
		//cout<<k1<<" "<<k2<<" ";
		if(m[{k1,k2}]){
			ans+=m[{k1,k2}];
			//cout<<1;
		}
		//cout<<endl;
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int D;
	cin >> D;
	switch(D) {
		case 25:
			cout << "Christmas";
			break;
		case 24:
			cout << "Christmas Eve";
			break;
		case 23:
			cout << "Christmas Eve Eve";
			break;
		case 22:
			cout << "Christmas Eve Eve Eve";
			break;
	}	
	return 0;
}

Measured memory_bytes: 256
x = input()
x = int(x)
list = []
sum = 0

for i in range(x):
	list.append(i+1)

for i in range(x):
    num = list[i]
    if num % 3 == 0 and num % 5 == 0:
        num
    elif num % 3 == 0:
        num
    elif num % 5 == 0:
        num
    else:
        sum = sum + list[i]

print(sum)

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll a; cin >> a;
    string op; cin >> op;
    ll b; cin >> b;

    if (op == "+") {
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }
}

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

int main(void){
    ll n, t;
    cin >> n >> t;

    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll time = 0;
    ll count = 0;
    rep(i, n){
        if(a[i] < time){
            count += t - (time - a[i]);
        }else{
            count += t;
        }
        time = a[i] + t;
    }

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


Measured memory_bytes: 1792
# frozen_string_literal: true

n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
cnt = 0

a.each do |i|
  break if x < i

  x -= i
  cnt += 1
end

if x == 0
  puts cnt
else
  puts cnt == n ? cnt - 1 : cnt
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S,a,b;
  cin >> S;
  a=S/100;
  b=S%100;
  int sum;
  if(0<a && a<13)sum+=1;
  if(0<b && b<13)sum+=2;
  if(sum==0)cout << "NA" <<endl;
  if(sum==1)cout << "MMYY" <<endl;
  if(sum==2)cout << "YYMM" <<endl;
  if(sum==3)cout << "AMBIGUOUS" <<endl;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(random_device{}());
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;++i) cin>>a[i];
    vector<vector<ll>> dp(n+1,vector<ll>(3,-1e18));
    dp[1]={0,0,0};
    for(int i=2;i<=n;++i){
        if(i&1){
            dp[i][0]=max({dp[i-2][0],dp[i-2][1],dp[i-2][2]})+a[i];
            dp[i][1]=dp[i-1][0];
            dp[i][2]=dp[i-1][1];
        }else{
            dp[i][0]=max({dp[i-1][1]+a[i],dp[i-1][2]+a[i]});
            dp[i][1]=dp[i-1][2]+a[i-1];
        }
    }
    cout<<*max_element(all(dp[n]));
    return 0;
}



Measured memory_bytes: 15068
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;

    void solve() {
    	ll n, cnt = 1, m = 998244353;
    	cin >> n;
    	ll a[n];
    	map<ll, ll> mp;
    	rep(i, n) cin >> a[i], mp[a[i]]++;
    	if(a[0]){
    		cout << 0 << endl;
    		return;
    	}
    	repA(i, 1, n-1) if(!mp[a[i] - 1]) {
    		cout << 0 << endl;
    		return;
    	}
    	ll ma = *max_element(a, a+n);
    	repA(i, 2, ma) {
    		repA(j, 1, mp[i])	cnt = (cnt*mp[i-1])%m;
    	}
    	cout << cnt << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


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

typedef long long ll;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()

int main(void)
{
  ll N,size;
  string ans = "Yes";

  cin >> N;
  
  vector<ll> H(N);
  rep(i,N) cin >> H[i];
  
  for(int i=N-2;i>=0;i--){
    if(H[i]>H[i+1]){
      H[i]--;
      if(H[i]!=H[i+1]){
        ans = "No";
        break;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
import bisect
def main():
    N, R = MI()
    if N >= 10:
        print(R)
    else:
        print(R + 1000 - 100 * N)

if __name__ == "__main__":
    main()


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

ll dp[50 + 1][2500 + 1];

int main() {
  int n, a;
  cin >> n >> a;
  dp[0][0] = 1;
  rep(i, n) {
    int x;
    cin >> x;
    for (int j = n; j >= 0; j--) {
      rep(k, 2500) if (dp[j][k] > 0) dp[j + 1][k + x] += dp[j][k];
    }
  }
  ll ans = 0;
  REP(i, 1, n + 1) REP(j, 1, 2501) {
    if (j % i == 0 && j / i == a) ans += dp[i][j];
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, X;
  cin >> N >> X;
  vll x(N);
  rep(i, N) {
    cin >> x[i];
  }

  if (N == 1) {
    COUT(abs(x[0] - X));
    return 0;
  }

  x.pb(X);
  SORT(x);

  ll ans = 0;
  rep(i, x.size()) {
    if (i == 0) {
      ans = x[1] - x[0];
      continue;
    }
    ll num = x[i] - x[i - 1];
    if (num != 0) {
      ans = gcd(ans, num);
    }
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**8)
N,M = map(int,input().split())
XY = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for _ in range(N)]
for i,(x,y) in enumerate(XY):
    x,y = x-1,y-1
    es[x].append((y,i))
    es[y].append((x,i))
if N==1:
    print(1)
    exit()

dpdn = [-1]*(N-1)
parent = [-1]*N
def dfs(v,p=-1):
    ret = 1
    for to,i in es[v]:
        if to==p: continue
        parent[to] = v
        r = dfs(to,v)
        dpdn[i] = r
        ret *= r
    ret += 1
    ret %= M
    return ret
dfs(0)

dpup = [-1]*(N-1)
from collections import deque
q = deque([(0,-1)])
while q:
    v,e = q.popleft()
    lc = [1]
    for _,i in es[v]:
        if i==e: continue
        lc.append((lc[-1] * dpdn[i]) % M)
    rc = [1]
    for _,i in reversed(es[v]):
        if i==e: continue
        rc.append((rc[-1] * dpdn[i]) % M)
    rc.reverse()
    p = 1 if e==-1 else dpup[e]
    j = 0
    for to,i in es[v]:
        if i==e: continue
        dpup[i] = (p * lc[j] * rc[j+1] + 1) % M
        j += 1
        q.append((to,i))

ans = []
for v in range(N):
    r = 1
    for to,i in es[v]:
        if to==parent[v]:
            r *= dpup[i]
        else:
            r *= dpdn[i]
    r %= M
    ans.append(r)
print(*ans, sep='\n')

Measured memory_bytes: 133056
S = gets.chomp
S.length.times do |i|
  if (i % 2 == 0) 
    if S[i] == 'L'
      puts 'No'
      exit
    end
  else
    if S[i] == 'R'
      puts 'No'
      exit
    end
  end
end
puts 'Yes'


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

ll gcd(ll a, ll b, ll c) { return gcd(gcd(a, b), c); }

int main() {
  int k;
  cin >> k;
  ll sum = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      for (int l = 1; l <= k; ++l) {
        sum += gcd(i, j, l);
      }
    }
  }
  cout << sum << endl;
}


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

const int N = 5010;

int dp[N][N], a[N], pre[N][N];
int n, k;

int main(){
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i){
		scanf("%d", &a[i]);
	}
	dp[0][0] = 1;
	for (int i = 1; i <= k; ++ i){
		pre[0][i] = 1;
	}
	for (int i = 1; i <= n; ++ i){
		for (int j = 0; j < k; ++ j){
			dp[i][j] = std::max(dp[i][j], dp[i - 1][j]);
			if (!dp[i - 1][j] || j + a[i] >= k){
				continue;
			}
			dp[i][j + a[i]] = 1;
		}
		for (int j = 0; j < k; ++ j){
			pre[i][j + 1] = pre[i][j] + dp[i][j];
		}
	}
	memset(dp, 0, sizeof(dp));
	dp[n + 1][0] = 1;
	for (int i = n; i >= 1; -- i){
		for (int j = 0; j < k; ++ j){
			dp[i][j] = std::max(dp[i][j], dp[i + 1][j]);
			if (!dp[i + 1][j] || j + a[i] >= k){
				continue;
			}
			dp[i][j + a[i]] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++ i){
		if (a[i] >= k){
			++ ans;
			continue;
		}
		for (int j = 0; j < k; ++ j){
			if (!dp[i + 1][j]){
				continue;
			}
			int left = std::max(0, k - a[i] - j), right = k - j;
			if (pre[i - 1][right] - pre[i - 1][left]){
				++ ans;
				break;
			}
		}
	}
	return printf("%d\n", n - ans), 0;
}

Measured memory_bytes: 196352
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
#define PI 3.1415926
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int N, T, t[200000];
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> t[i];
	}

	int ans = 0;
	for (int i = 1; i < N; i++) {
		int ti = t[i-1] + T;
		ans += min(ti, t[i]) - t[i-1];
	}

	cout << ans + T << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int w[100][100],p[50][50];
int n,m;
void r()
{
	int t,i,j;
	for(i=0;i<m/2;++i)
	{
		for(j=0;j<(m+1)/2;++j)
		{
			t=p[i][j];
			p[i][j]=p[j][m-i-1];
			p[j][m-i-1]=p[m-i-1][m-j-1];
			p[m-i-1][m-j-1]=p[m-j-1][i];
			p[m-j-1][i]=t;
		}
	}
}
bool f(int dx,int dy)
{
	int i,j;
	for(i=0;i<m;++i)
	{
		for(j=0;j<m;++j)
		{
			if(p[i][j]>=0 && w[dy+i][dx+j]!=p[i][j]) return false;
		}
	}
	return true;
}
int main()
{
	int i,j,k;
	while(scanf("%d%d",&n,&m),n)
	{
		for(i=0;i<n;++i)for(j=0;j<n;++j)scanf("%d",&w[i][j]);
		for(i=0;i<m;++i)for(j=0;j<m;++j)scanf("%d",&p[i][j]);
		for(i=0;i<n-m+1;++i)for(j=0;j<n-m+1;++j)
		{
			for(k=0;k<4;++k)
			{
				r();
				if(f(j,i))
				{
					for(k=0;k<m;++k)
						if(p[0][k]>=0)
						{
							printf("%d %d\n",j+k+1,i+1);
							break;
						}
					goto END;
				}
			}
		}
		puts("NA");
END:
		;
	}
	return 0;
}

Measured memory_bytes: 816
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    bool flag = false;
    for(int i=1; i<=9; ++i){
        for (int j=1; j<=9; ++j){
            if(i * j == n){
                flag = true;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
        
    return 0;
}

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

int main() {
    int x,a,b;
    cin>>x>>a>>b;

    if(a-b>=0){
        cout<<"delicious"<<endl;
    }else if((a+x)-b>=0){
        cout<<"safe"<<endl;
    }else{
        cout<<"dangerous"<<endl;
    }

}

Measured memory_bytes: 256
import numpy as np
from operator import mul
from functools import reduce

N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
#A = np.array([[0]*M,N])
A = np.empty((N,M))

result = np.array([])
count = 0

for n in range(N):
    A[n] = [int(m) for m in input().split()]
    result = A[n] * B
    #print(result)
    if sum(result)+C > 0:
        count +=1
print(count)


Measured memory_bytes: 12432
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> h(n),good(n);
    rep(i,0,n-1)cin >> h[i];
    rep(i,1,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        if(h[a] >= h[b])good[b]++;
        if(h[a] <= h[b])good[a]++;
    }
    int ans = 0;
    rep(i,0,n-1)if(good[i] == 0)ans++;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,ans=0,a,b;
    vector<lli> array,brray;
    lli i,j;
    cin>>n;
    rep(i,0,n){
        cin>>a>>b;
        array.push_back(a);
        brray.push_back(b);
    }
    rep(i,0,n){
        j=n-i-1;
        array[j]+=ans;
        if(array[j]%brray[j]!=0){
            ans+=brray[j]-array[j]%brray[j];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2036
def main():
    S = input()
    K = int(input())
    one_seq = sum([int(c) for c in S[:min([K, len(S)])]])
    if one_seq == min([K, len(S)]):
        print(1)
    else:
        for c in S:
            if c != '1':
                print(c)
                return


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<cstdio>
 
using namespace std;
 
double p[5000];
 
double dp[5000][5000];
 
int main()
{
  int n=0;scanf("%d",&n);
  for(int i=1;i<=n;i++)scanf("%lf",&p[i]);
  dp[0][0]=1;
  for(int i=1;i<=n;i++)
  {
    dp[i][0]=dp[i-1][0]*(1-p[i]);
    for(int j=1;j<=i;j++)
    {
      dp[i][j]=p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j];
    }
  }
  double ans=0;for(int i=(n/2)+1;i<=n;i++)ans+=dp[n][i];
  printf("%.15lf",ans);
  return 0;
}

Measured memory_bytes: 117120
N = int(input())
a = [0 for i in range(N)]

# a = map(int, input().split())
a = input().split()

for i in range(N):
    a[i] = int(a[i])

count = 0
for i in range(N):
    while a[i] % 2 == 0:
        count = count + 1
        a[i] = a[i] / 2

print(count)

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

const int DIM = 10;

bool oki[DIM];
vector<int> edg[DIM];

void back( int x, int cnt, int n, int &ans ) {
    oki[x] = true;
    
    if( cnt == n )
        ans ++;
    else {
        for( int y : edg[x] )
            if( oki[y] == false )
                back( y, cnt + 1, n, ans );
    }
        
    oki[x] = false;
    return;
}

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= m; i ++ ) {
        int a, b;
        cin >> a >> b;
        
        edg[a].push_back( b );
        edg[b].push_back( a );
    }
    
    int ans = 0;
    back( 1, 1, n, ans );
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int a[200000];
int cnt[200000];

long long int INF = 1000000007;

long long int pow10_9_5(long long int num){
	long long int pow_num = 1000000005;
	long long int mod_num = 1000000007;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main(){
	
	int n;
	
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		cnt[i] = 0;
	}
	
	for(int i = 0; i <= n; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	int p;
	for(int i = 1; i <= n; i++){
		if(cnt[i] == 2){
			p = i;
		}
	}
	
	vector<int> v;
	
	for(int i = 0; i <= n; i++){
		if(a[i] == p){
			v.push_back(i);
		}
	}
	
	n++;
	int m = n - (v[1] - v[0] + 1);
	
	long long int nCk = 1;
	long long int mCk = 1;
	
	for(int i = 0; i < n; i++){
		nCk *= n - i;
		nCk %= INF;
		nCk *= pow10_9_5(i + 1);
		nCk %= INF;
		
		if(i != 0){
			mCk *= m - (i - 1);
			mCk %= INF;
			mCk *= pow10_9_5(i);
			mCk %= INF;
		}
		
		if(m >= i){
			cout << (nCk - mCk + INF) % INF << endl;
		}else{
			cout << nCk << endl;
		}
		
	}
	
	return 0;
}


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

int main() {
    int N, Y;

    cin >> N >> Y;
    Y /= 1000;
    
    for (int man=0; man<=N; man++) {
        for (int go=0; go<=N-man; go++) {
            int sen = N - man - go;
            int total = 10*man + 5*go + sen;
            if (total == Y) {
                cout << man << " " << go << " " << sen << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import math

def sumEachDigit(num):
    list = []
    for i in range(1,6):
        list.append(num % 10)
        num = math.floor(num / 10)

    return sum(list)


N,A,B = map(int, input().split())

ret = 0
for i in range(1,N+1):
    sumOfEach = sumEachDigit(i)

    if A <= sumOfEach <= B:
        ret += i

print(ret)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[100001];
int mod=1000000007;
int p[5];
int ans=1;
signed main(){
cin>>n;
for(int i=1;i<=n;i++){
	scanf("%lld",&a[i]);
}
for(int i=1;i<=n;i++){
	int temp=0;
	if(p[1]==a[i])temp++;
	if(p[2]==a[i])temp++;
	if(p[3]==a[i])temp++;
	if(p[1]==a[i])p[1]=a[i]+1;
	else if(p[2]==a[i])p[2]=a[i]+1;
	else if(p[3]==a[i])p[3]=a[i]+1;
	else{
		printf("0");
		return 0;
	}
	ans*=temp;
	ans%=mod;
}
cout<<ans;

return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
# 
import math
import sys
import bisect

# いっこ入力
n =int(input())

# n行の数をリストへ
a = [int(input()) for i in range(n)] 

# color
c = [-999]*n

for i in range(0,n):
#    if c[0] >= a[i]:
#        c.insert(0,a[i])
#    else:
    p = bisect.bisect_left(c, a[i])
    c[p-1]=a[i]
#        print(c)
#        print(p)

print(len(c) - bisect.bisect_left(c, -1))


Measured memory_bytes: 52440
MOD = 10**9+7
N = gets.chomp.to_i
str = gets.split
a = Array.new(N)
for i in 0...N do
    a[i] = str[i].to_i
end
a.sort!

answer = 1
for i in 1...N do
    answer = answer * 2 % MOD
end
x = 0
for i in 1..N do
    x += a[-i] * (i+1)
    x %= MOD
end
answer *= x
answer %= MOD
for i in 1...N do
    answer = answer * 2 % MOD
end
puts answer

Measured memory_bytes: 17656
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [String] -> String
solve n ss =
  concat $
  zipWith replicate (foldr1 (zipWith min) (map countEach ss)) alphabet

alphabet = ['a'..'z']

countEach s0 = snd $ mapAccumL op (sort s0) alphabet where
  op s c = (newS, length cs) where
    (cs, newS) = span (== c) s

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> String
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      ss = map (\[x] -> B.unpack x) remLines1
  in solve n ss

outAnswer :: String -> IO ()
outAnswer = putStrLn

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "3\ncbaa\ndaacc\nacacac\n"
inp2 = "3\na\naa\nb\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
test1 = tv1 == "aac"
test2 = tv2 == ""
alltest = test1 && test2



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

int main(){
  int a,b,c;
  
  cin>>a>>b>>c;
  
  if(a==b && b==c) cout<<"No\n";
  else if(a!=b && b!=c && c!=a) cout<<"No\n";
  
  else cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 256