akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int N,M,X,Y;
	cin>>N>>M>>X>>Y;
	vector<int> x(N),y(M);
	for(int i=0;i<N;i++) cin>>x[i];
	for(int i=0;i<M;i++) cin>>y[i];
	
	if(max(X,*max_element(x.begin(),x.end()))>=min(Y,*min_element(y.begin(),y.end()))) cout<<"War"<<endl;
	else cout<<"No War"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n;
string s;
long long num[3];
int get(char x){
    if (x=='R') return 0;
    if (x=='G') return 1;
    return 2;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>s;
    //for (int i=0;i<n;i++){
        //cin>>arr[i];
    //}
    long long tot=0;
    for (int i=1;i<=n;i++){
        num[get(s[i-1])]++;
    }
    tot=num[0]*num[1]*num[2];
    for (int i=0;i<n;i++){
        for (int j=i+1;j<n;j++){
            int k=j+(j-i);
            if (k>=n) continue;
            if (s[i]!=s[j] && s[i]!=s[k]){
                if (s[j]!=s[k]){
                    tot--;
                }
            }
        }
    }
    cout<<tot;
}

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

#define ll long long

signed main(){
   int n;
   cin >> n;
   vector<ll> a(n);
   ll minv = 10000001000;
   ll sum = 0;
   for(int i = 0; i < n; i += 1){
      cin >> a[i];
      minv = min(minv, a[i]);
      sum += a[i];
   }
   if (n % 2 == 1 && sum % 2 == 1){
      cout << "First" << endl;
      return 0;
   }
   if (n % 2 == 1 && sum % 2 == 0){
      cout << "Second" << endl;
      return 0;
   }
   if (n % 2 == 0 && sum % 2 == 1){
      if (minv % 2 == 1){
         cout << "First" << endl;
         return 0;
      }
      if (minv % 2 == 0){
         cout << "First" << endl;
      }
      else {
         cout << "Second" << endl;
      }
      return 0;
   }
   if (n % 2 == 0 && sum % 2 == 0){
      if (minv % 2 == 0){
         cout << "Second" << endl;
      }
      else {
         cout << "First" << endl;
      }
      return 0;
   }  
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n;
    cin >> n;
    pr(n/3);
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val m = sc.nextInt

  val t = m * 1900 + (n - m) * 100
  val p = Math.pow(0.5, m)

  val x = (t / p).toInt

  println(x)
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int element1 = max({A, B, C}) * 9;
    int element2 = A + B + C;
    cout << element1 + element2 << endl;
}

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

int n;
string s;

int main(){
  cin >> n >> s;
  int bnum[n + 1]; //左側の黒の数
  bnum[0] = 0;
  for(int i = 0; i < n; i++){
    bnum[i + 1] = bnum[i];
    if(s.at(i) == '#'){
      bnum[i + 1]++;
    }
  }
  //rep(i, n + 1) cerr << bnum[i] << " "; cerr << endl;
  int wnum[n + 1]; //右側の白の数
  wnum[n] = 0;
  for(int i = n - 1; i >= 0; i--){
    wnum[i] = wnum[i + 1];
    if(s.at(i) == '.'){
      wnum[i]++;
    }
  }
  //rep(i, n + 1) cerr << wnum[i] << " "; cerr << endl;
  int res = 1e9;
  for(int i = 0; i <= n; i++){
    res = min(bnum[i] + wnum[i], res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2180
N = int(input())
ps = [int(pi) for pi in input().split(' ')]
trues = list(range(1, N+1))

bools = [pi != ti for pi, ti in zip(ps, trues)]
S = sum(bools)
if S == 0 or S == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

//-------------------------------------------------------------------
ll P, p2;
#define N_MAX 10000000
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}

//-------------------------------------------------------------------
struct segtree{
  ll M=1, INIT;
  vector<ll> dat;
  segtree(ll N, ll num){
    INIT = num;
    while(M<N) M*=2;
    for(int i=0;i<M*2-1;i++)  dat.push_back(num);
  }
  void update(ll x, ll k, ll l=0, int r=-1){
    if(r==-1) r = M;
    k+=M-1;
    dat[k] = x;
    while(k>0) k = (k-1)/2, dat[k] = ((dat[k*2+1]*10)%P + dat[k*2+2])%P;
  }
  ll query(ll a, ll b=-1, ll k=0, ll l=0, ll r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return INIT;
    if(a<=l && r<=b) return dat[k];
    ll A = query(a, b, k*2+1, l, (l+r)/2);
    ll B = query(a, b, k*2+2, (l+r)/2, r);
    return A + B;
  }
};
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n >> P;
  string s;std::cin >> s;
  vll tbl(n, 0);
  init();
  reverse(all(s));
  vll t(n+1, 1);
  rep(i, 1, n+1) t[i] = (t[i-1]*10)%P;

  for(int i=0;i<n;i++){
    ll num = s[i] - '0';
    tbl[i] = ((i==0?0:tbl[i-1]) + (t[i]*num)%P)%P;
  }


  vll cnt(1000000, 0);
  ll ans = 0;

  if(P==2){
    re(i, n) if(s[i]=='2'||s[i]=='4'||s[i]=='6'||s[i]=='8'||s[i]=='0') ans += n-i;
  }else if(P==5){
    re(i, n) if(s[i]=='5'||s[i]=='0') ans += n-i;
  }else{
    re(i, n) {
      if(tbl[i]==0) ans++;
      ans += cnt[tbl[i]];
      cnt[tbl[i]]++;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 245884
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int A, B;
	int counter;
	counter = 0;
	cin >> A >> B;
	int ten_thousand;
	int thousand;
	int hundred;
	int ten;
	int one;
	int num;
	for (int i = A; i <= B; i++) {
		num = i;
		ten_thousand = num / 10000;
		num = num - ten_thousand * 10000;
		thousand = num / 1000;
		num = num - thousand * 1000;
		hundred = num / 100;
		num = num - hundred * 100;
		ten = num / 10;
		num = num - ten * 10;
		one = num;
		if (ten_thousand == one&&thousand == ten) {
			counter++;
		}
	}
	cout << counter << endl;
}


Measured memory_bytes: 256
//Link : https://codeforces.com/contest/1253

#include <bits/stdc++.h>
using namespace std;
#define ll long long
/*
#include <limits.h>
INT_MAX
LLONG_MAX
*/
#define N 2005

char s[N];
vector<int> adj[N];
int depthSum[N],cnt[N];

void dfs(int node,int par) {
  depthSum[node] = cnt[node] = 0;
  if(s[node]=='1') {
    cnt[node] = 1;
  }
  for(int ch : adj[node]) {
    if(ch==par) {
      continue;
    }
    dfs(ch,node);
    depthSum[node] += depthSum[ch] + cnt[ch];
    cnt[node] += cnt[ch];
  }
}

int getMin(int node,int par) {
  int maxChild = 0;
  for(int ch : adj[node]) {
    if(ch!=par) {
      if(depthSum[ch] + cnt[ch]>depthSum[maxChild] + cnt[maxChild]) {
        maxChild = ch;
      }
    }
  }
  if(maxChild==0) {
    return 0;
  }
  int minDepthSum = getMin(maxChild,node) + cnt[maxChild];
  if(minDepthSum <= depthSum[node] - (depthSum[maxChild]+cnt[maxChild])) {
    return depthSum[node]&1;
  }
  return minDepthSum - depthSum[node] + (depthSum[maxChild]+cnt[maxChild]);
}

int solveRoot(int root) {
  dfs(root,0);
  if(getMin(root,0)==0) {
    return depthSum[root]/2;
  } else {
    return 1e9;
  }
}

void solve() {
  int n;
  scanf("%d",&n);
  scanf(" %s",s+1);
  for(int i=0;i<n-1;++i) {
    int a,b;
    scanf("%d %d",&a,&b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int ret = 1e9;
  for(int i=n;i;--i) {
    ret = min(ret, solveRoot(i));
  }
  if(ret==1e9) {
    ret = -1;
  }
  printf("%d\n",ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

int main() {
  string S;
  int ans;

  cin >> S;

  int len = S.size();
  for (int i = len - 1; i > 1; i--){
    if (i % 2 != 1) continue;
    int j = i / 2;

    if (S.substr(0, j) == S.substr(j, j)){
      ans = i - 1;
      break;
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
using int64 = long long;
using vint = vector<int>;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, init, n) for (int i = (init); i < (n); ++i)
#define RepLong(i, n) for (int64 i = 0; i < (n); ++i)
#define InitRepLong(i, init, n) for (int64 i = (init); i < (n); ++i)
#define RepItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)

int main()
{
	int n;
	cin >> n;
	vint x(n), y(n);
	Rep(i, n)
	{
		cin >> x[i] >> y[i];
	}

	double distSum = 0;
	Rep(i, n)
	{
		InitRep(j, i + 1, n)
		{
			distSum += ::sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
		}
	}
	cout << fixed << setprecision(10) << (distSum * 2 / n) << endl;

	return 0;
}

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

int main()
{
  long long int a,b;
  unsigned long long ans=0;
  cin>>a>>b;
  if(b>a)
  swap(a,b);
  long long int tem1=1;
  long long int t;
  for(int t=1;t<=b;t++)
  {
    if((a%t==0)&&(b%t==0))
    {
      tem1=t;
    }
  }
  ans=tem1;
  cout<<a/ans*b;
}


Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    md = 10**9+7

    S = list(reversed(A))

    for i in range(1,N):
        S[i] = (S[i-1]+S[i])%md
    
    S.reverse()

    ans = 0
    for i in range(N-1):
        ans += (A[i]*S[i+1])%md
        ans %= md
    print(ans)
resolve()

Measured memory_bytes: 105292
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <assert.h>
#define N 1000010
using namespace std;

int n, k;
const int INF[2] = {20000000, 20000001};
vector<int> edge[N];

bool vis[N];
int val[N];

int up[N], down[N];
bool dfs(int u, int fa, bool odd) {
	up[u] = INF[odd]; down[u] = -INF[odd];
	for (int i = 0; i < edge[u].size(); ++i) {
		int v = edge[u][i];
		if (v != fa) {
			if (!dfs(v, u, odd ^ 1)) return false;
			up[u] = min(up[v] + 1, up[u]);
			down[u] = max(down[v] - 1, down[u]);
		}
	}

	if (down[u] > up[u]) return false;
	if (vis[u]) {
		if (down[u] > val[u] || up[u] < val[u]) return false;
		down[u] = up[u] = val[u];
	}
	if ((abs(down[u]) & 1) != odd || (abs(up[u]) & 1) != odd) return false;
	return true;
}

void getAns(int u, int fa, bool odd) {
	for (int i = 0; i < edge[u].size(); ++i) {
		int v = edge[u][i];
		if (v != fa) {
			if (!vis[v]) {
				if (val[u] + 1 <= up[v] && val[u] + 1 >= down[v]) val[v] = val[u] + 1;
				else val[v] = val[u] - 1;
			}
			getAns(v, u, odd ^ 1);
		}
	}
}

bool check(int u, int fa) {
	for (int i = 0; i < edge[u].size(); ++i) {
		int v = edge[u][i];
		if (v == fa) continue;
		if (abs(val[u] - val[v]) != 1) return false;
		if (!check(v, u)) return false;
	}
	return true;
}

int a[N], b[N];
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	
	scanf("%d", &k);
	for (int i = 1; i <= k; ++i) {
		scanf("%d%d", &a[i], &b[i]);
		val[a[i]] = b[i];
		vis[a[i]] = 1;
	}
	if (!dfs(a[1], 0, (b[1] & 1))) {
		puts("No");
	}
	else {
		val[a[1]] = b[1];
		getAns(a[1], 0, b[1] & 1);
		assert(check(1, 0));
		puts("Yes");
		for (int i = 1; i <= n; ++i) printf("%d\n", val[i]);
	}
}

Measured memory_bytes: 47744
from collections import deque
n = int(input())
q = deque(maxlen=n-1)

for i in range(n - 1):
    a, b, c = map(int, input().split())
    q.append([a-1, b-1, c % 2])

cllist = [-1] * n
a, b, c = q.popleft()
cllist[a] = 0
cllist[b] = c
while q:
    a, b, c = q.popleft()
    if cllist[a] != -1:
        cllist[b] = (cllist[a] + c) % 2
    elif cllist[b] != -1:
        cllist[a] = (cllist[b] + c) % 2
    else:
        q.append([a, b, c])
print(*cllist)


Measured memory_bytes: 146708
#include <stdio.h>

int pow_func(int base, int exponent) {
	int answer = 1;
	while (exponent != 0){
		answer = answer * base;
		exponent--;
	}
	return answer;
}

int main(void)
{
	int a[200], b[200];
	int n = 0;
	int i,j = 0;

	while((scanf("%d%d", &a[n], &b[n]) != EOF) && (n <= 200)) {
		if (((a[n] >= 0) && (a[n] <= 1000000)) && ((b[n] >= 0) && (b[n] <= 1000000))) {
			n++;
		}
	}
	
	for (i = 0; i < n; i++) {
	  j=0;
	  if((a[i]==0) && (b[i]==0)){
	    printf("0\n");
	  }else{
		while (j <= 7) {
		  int result = pow_func(10,j);
			if (((a[i] + b[i]) / 10) < result) {
				printf("%d\n", j + 1);
				break;
			}
			else {
				j++;
		    }
		}
	  }
	}

	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>

int main (int ac, char **av ) {
  int a, b =0;

  fscanf(stdin, "%d %d\n", &a, &b);
  if (a < b) {
      fprintf(stdout, "a < b\n");
  } else if (a == b) {
    fprintf(stdout, "a == b\n");
  } else {
    fprintf(stdout, "a > b\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s;
    cin>>t;
  int l=s.size(),c=0;
  int p=t.size();
  for(int i=0;i<l;i++)
  {
    if(s[i]!=t[i])
      c++;
      
  }
  if(c==0)
    cout<<"Yes";
  else
    cout<<"No";
  
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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

int main() {
	init();

	ll a, b, x; cin >> a >> b >> x;
	--a;
	if (a < 0)a = -1;
	else a /= x;
	b /= x;
	cout << b - a << "\n";

	return 0;
}

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

s = A[0]
s_ = sum(A[1:])
gap = abs(s-s_)
for i in range(1, n-1):
    s += A[i]
    s_ -= A[i]
    if gap > abs(s-s_):
        gap = abs(s-s_)
print(gap)

Measured memory_bytes: 30440
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    for (ll i = N; ; i++) {
        string s = to_string(i);
        char f = s.front();
        bool same = true;
        for (char c : s) {
            if (c != f) {
                same = false;
                break;
            }
        }
        if (same) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int e[300010], w[300010];
int main(void)
{
    int N;
    cin >> N;
    string s;
    cin >> s;

    int ans = 1000000;

    //1-indexed
    for (int i = 0; i < N; ++i)
    {
        if (s[i] == 'E')
        {
            e[i + 1] = e[i] + 1;
            w[i + 1] = w[i];
        }
        else
        {
            w[i + 1] = w[i] + 1;
            e[i + 1] = e[i];
        }
    }

    for (int i = 1; i <= N; ++i)
    {
        if (i == 1)
        {
            if (s[i - 1] == 'E')
            {
                ans = min(ans, e[N] - 1);
            }
            else
            {
                ans = min(ans, e[N]);
            }
        }
        else if (i == N)
        {
            if (s[i - 1] == 'E')
            {
                ans = min(ans, w[N]);
            }
            else
            {
                ans = min(ans, w[N] - 1);
            }
        }
        else
        {
            if (s[i - 1] == 'E')
            {
                ans = min(ans, w[i] + e[N] - e[i]);
            }
            else
            {
                ans = min(ans, w[i] - 1 + e[N] - e[i]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
 int main(void)
{
 int a, b, c, x;
 scanf("%d %d %d", &a, &b, &c);
 if(a>b)
{
 x=a;
 a=b;
 b=x;
 }
 if(b>c)
{
 x=b;
 b=c;
 c=x;
 }
 if(a>b)
{
 x=a;
 a=b;
 b=x;
 }
 printf("%d %d %d\n", a, b, c);
 return 0;
 } 


Measured memory_bytes: 2104
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)2e6 + 123;

int n, k;
set <int> s;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif	
	Fast_Read_Out();
	Random();
	string a, b;
	cin >> a >> b;
	int what1, what2;
	cin >> what1 >> what2;
	string v;
	cin >> v;
	if(a == v) what1--;
	if(b == v) what2--;
	cout << what1 << ' ' << what2;
}

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

int main() {
	int N, X;
	cin >> N >> X;
	vector<int>D(N+1);
	D[0] = 0;

	for (int i = 0;i < N;++i) {
		int x;
		cin >> x;
		D[i + 1] = D[i] + x;
	}
	int ans = 0;
	for (int i = 0;i <= N;++i) {
		if (X >= D[i]) { ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0]);

  let answer;
  if (N % 1000 === 0) {
    answer = 0;
  } else {
    answer = 1000 - N % 1000;
  }

  console.log(answer);

}
// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


int main(){
  
  string N;
  cin >> N;
  bool a = true;
  
  for(int i = 0; i < N.size() - 2; i++){
    if(N.at(i) == N.at(i + 1) && N.at(i + 1) == N.at(i + 2)){
      cout << "Yes" << endl;
      a = false;
      break;
    }
  }
  
  if(a){
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int S,h,m,s;
	scanf("%d",&S);

		m = S/60;
		s= S%60;
		h= m/60;
		m = m%60;
		printf("%d:%d:%d\n",h,m,s);
	return 0;
    }



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

string func(int s, int l){
	double h = s*30.0 + l/2.0, m = l*6;
     
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      return "alert";
    }
    else if(90 <= ang && ang <= 180) {
      return "safe";
    }
    else return "warning";
}
 
int main() {
	int n, s, l; cin >> n;
	char c;
	while(n--) {
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
  	return 0;
}

Measured memory_bytes: 3128
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn solve(
    i: usize,
    l: usize,
    r: usize,
    a: &Vec<(usize, usize)>,
    memo: &mut Vec<Vec<Option<usize>>>,
) -> usize {
    if let Some(x) = memo[l][r] {
        return x;
    }
    if l == r {
        return 0;
    }
    let x1 =
        a[i].1 * (a[i].0 as isize - l as isize).abs() as usize + solve(i + 1, l + 1, r, a, memo);
    let x2 = a[i].1 * (r as isize - a[i].0 as isize - 1).abs() as usize
        + solve(i + 1, l, r - 1, a, memo);

    let x = max(x1, x2);
    memo[l][r] = Some(x);
    x
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut a = a.into_iter().enumerate().collect::<Vec<(usize, usize)>>();
    a.sort_by_key(|&x| x.1);
    a.reverse();
    let mut dp = vec![vec![None; n + 1]; n + 1];
    println!("{}", solve(0, 0, n, &a, &mut dp));
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,ans=0;
  cin>>n;
  vector<long long int> a(n+1),b(n);
  rep(i,n+1) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n){
    if(a[i]+a[i+1]>=b[i]){
      ans+=b[i];
      if(b[i]>=a[i]){
        a[i+1]+=a[i]-b[i];
      }
      
    }else{
      ans+=a[i]+a[i+1];
      a[i]=0;
      a[i+1]=0;
    }
  }
  cout<<ans<<endl;
  
  
  
}
///////////////////////////




Measured memory_bytes: 1792
///Atcoder
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000

#define ll long long
#define sc scanf
#define pf printf
//#define pi 2*acos(0.0)

#define ft first
#define se second
#define Max 10001000
#define st(s) s.size();
#define r(input) freopen("input.txt","r",stdin)
#define w(output) freopen("output.txt","w",stdout)
#define maxall(v) *max_element(v.begin(),v.end())
#define minall(v) *min_element(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define un(v) Sort(v), v.erase(unique(v.begin(),v.end()),v.end())
#define cover(a,d) memset(a,d,sizeof(a))

using namespace std;


int main()
{
    ll a,b,n;
    cin>>a>>b;
    ll k;
    if(b==100)
        b++;
    if(a==0)
        k=1;
    else if(a==1)
        k=100;
    else if(a==2)
        k=10000;
//    cout<<k<<endl;
    n=k*b;
    cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double c_w = w/2., c_h = h/2.;
    if ((double)x == c_w && (double)y == c_h) printf("%.9f 1", w*h/2.);
    else printf("%.9f 0", w*h/2.);
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n",(x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)

// const long long INF = 1LL<<60;

#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)998244353;

const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
  if(a<0)a=-a;
  if(b<0)b=-b;
    ll g;g=gcd(a,b);
    return b/g*a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll RS(ll N,ll P,ll m){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,m);
            return t*t%m;
        }else{
            return N*RS(N,P-1,m)%m;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}
int main() {
  ios::sync_with_stdio(false);
  int x=in();
  int ans;
    ans=1;
    while((ans*x)%360!=0){
      ans++;
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3640
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
void cal(ll n,vector<ll>&fact)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll a=i;
            ll b=n/i;
            fact.pb(a);
            if(b!=a)
            {
                fact.pb(b);
            }
        }
    }
    fact.pb(n);
}
int main()
{
fast;
ll n;
cin>>n;
if(n==2)
{
    cout<<1<<endl;
    return 0;
}
set<ll>ans;
for(ll i=2;i*i<=n;i++)
{
    ll x=n;
    while(x%i==0)
    {
        x=x/i;
    }
    ll y=x%i;
    if(y==1ll)
    {
        ans.insert(i);
    }
}
vector<ll>fact;
cal(n-1,fact);
for(ll i=0;i<fact.size();i++)
{
    ll j=fact[i];
    ll x=n;
    while(x%j==0)
    {
        x=x/j;
    }
    ll y=x%j;
    if(y==1ll)
    {
        ans.insert(j);
    }
}
ans.insert(n);

cout<<ans.size()<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> B;
void input(){
    fast_io();
    cin >> N;
    B = fetch_vec<int>(N);
}

bool solve(){
    for (int i = 0; i < N; i++)
    {
        if(B[i]>i+1) return false;
    }
    vector<int> ans;
    while(!B.empty()){
        for (int i = B.size()-1; i >= 0; i--)
        {
            if(B[i]==i+1){
                ans.push_back(i+1);
                B.erase(B.begin()+i);
                break;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    for(auto a:ans) cout << a << endl;
    
    return true;
}   

int main()
{
    input();
    if(!solve()) cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

char mat[70][70];
string dp[72][72];

string cmp(string a, string b)
{
    if(a.size() > b.size()) {
        return a;
    } else if(a.size() < b.size()) {
        return b;
    } else {
        if(a == b) 
            return a;
        for(int i = 0; i < a.size(); i++) 
            if(a[i] > b[i])
                return a;
            else if(a[i] < b[i])
                return b;
    }
}

int main()
{
    int w, h;
    while(cin >> w >> h && w && h) {
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                cin >> mat[i][j];
            }
        }

        for(int i = 0; i < 72; i++) 
            for(int j = 0; j < 72; j++)
                dp[i][j] = "";

        string ret = "";
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(isdigit(mat[i][j])) {
                    string more = cmp(dp[i + 1][j], dp[i][j + 1]);
                    if(more == "" && mat[i][j] == '0')
                        dp[i + 1][j + 1] = "";
                    else 
                        dp[i + 1][j + 1] = more + string(1, mat[i][j]);

                } else {
                    dp[i + 1][j + 1] = "";
                }
                ret = cmp(ret, dp[i + 1][j + 1]);
            }
        }
        cout << ret << endl;
    }
}

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

int main(){
  int n;
  cin >> n;
  double t,a;
  cin >> t >> a;
  int ans;
  double min=10000000;
  double com;
  double h[n+1];

  for(int i=1;i<=n;i++){
    cin >> h[i];
    com = t-(h[i]*0.006);
    if(abs(com-a)<min){
      ans = i;
      min = abs(com-a);
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
n = gets.chomp.to_i
x_arr = gets.chomp.split(" ").map(&:to_i)

min = 9999999999999
(1..100).each do |p|
  sum = 0
  x_arr.each do |x|
    sum += (p - x) ** 2
  end
  min = sum if sum < min
end
puts min


Measured memory_bytes: 1788
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

m1, d1 = li()
m2, d2 = li()

print(1 if m1 != m2 else 0)

Measured memory_bytes: 3064
n,m = tuple([int(x) for x in raw_input().split(" ")])

A = []
for i in range(n):
    A.append([int(x) for x in raw_input().split(" ")])

v=[]
for i in range(m):
    v.append(int(raw_input()))

for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j]*v[j]
    print s

Measured memory_bytes: 4544
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 200010;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

int C[MAXN][33];

int main()
{
	
	int n, m;
	cin >> n >> m;
	for (int i = 0; i <= 200000; ++ i)
	{
		C[i][0] = 1;
		for (int j = 1; j <= i && j <= 30; ++ j)
			C[i][j] = (C[i-1][j-1]+C[i-1][j])%MOD;
	}
	ll ans = 1;
	for (int i = 2; i*i <= m; ++ i)
		if (m%i == 0)
		{
			int cnt = 0;
			while (m%i == 0)
			{
				m /= i;
				cnt ++;
			}
			ans = ans*C[n+cnt-1][cnt]%MOD;
		}
	if (m > 1)
		ans = ans*C[n+1-1][1]%MOD;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin>>H>>W;
    vector<ll> cnt(26,0);
    string a;
    char aj;
    FOR(i,0,H){
        cin>>a;
        FOR(j,0,W){
            aj=a[j];
            cnt[aj-'a']++;
        }
    }
    

    bool ok=true;
    ll A=0;
    ll B=0;
    ll Z=0;
    if(H%2==0 && W%2==0){
        FOR(i,0,26){
            if(cnt[i]%4!=0)ok=false;
        }
    }else if(H%2!=0 && W%2!=0){
        FOR(i,0,26){
            if(cnt[i]==0)continue;
            if(cnt[i]>=4)A+=cnt[i]/4;
            if(cnt[i]%2==0)B++;
            else Z++;
        }
        if(A<(H-1)*(W-1)/4 || Z!=1)ok=false;
    }else{
        FOR(i,0,26){
            if(cnt[i]==0)continue;
            if(cnt[i]>=4)A+=cnt[i]/4;
            if(cnt[i]%2==0)B++;
            else Z++;
        }
        if(A<(H/2)*(W/2) || Z!=0)ok=false;
    }
    


    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    /*FOR(i,0,26){
        cout<<cnt[i]<<' ';
    }*/
    
    

    return 0;
}

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

using namespace std;
  
int main() {
    int n, a;
    int count = 0;
    
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ++count;
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)

using namespace std;

const int MAXN = 100;
long long ax[MAXN], ay[MAXN], bx[MAXN], by[MAXN];
long long c[MAXN][MAXN];

int main() {
  int n, m;
  ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    FOR(i, 0, n-1) cin >> ax[i] >> ay[i]; 
    FOR(i, 0, m-1) cin >> bx[i] >> by[i];
    FOR(i, 0, n-1) FOR(j, 0, m-1) c[i][j] = abs(ax[i] - bx[j]) + abs(ay[i] - by[j]);
    FOR(i, 0, n-1) {
      int res = 0;
      FOR(j, 1, m-1) {
        if (c[i][j] < c[i][res] || 
            (c[i][j] == c[i][res] && 
             (bx[j] < bx[res] || 
              ( bx[j] == bx[res] && by[j] < by[res]))))
        res = j;
      }
      cout << res + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    
    
 
return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			if(Math.abs(sc.nextLong() - sc.nextLong()) <= 1) {
				System.out.println("Brown");
			}else{
				System.out.println("Alice");
			}
		}
	}
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;

ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll table[5005][5005];

int main(){
    cin >> n >> m;
    num = (1ll << n);
    for(int i=0;i<num;i++){
        x[i] = INF;
    }
    x[0] = 0;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        ll bit = 0;
        for(int j=0;j<b;j++){
            cin >> c;
            c--;
            bit += (1ll << c);
        }
        for(int j=0;j<num;j++){
            x[j | bit] = min(x[j | bit] , x[j] + a);
        }
        for(int j=0;j<num;j++){
            //pe(j);p(x[j]);
        }
    }
    ll ans = x[num - 1];
    if(ans == INF){
        p(-1);
    }else{
        p(ans);
    }
    return 0;
}

















Measured memory_bytes: 15872
function main(input) {
  input = input.split('');
  let max = 0;
  let currentMax = 0;
  let current = 'R';
  for (let i = 0;i < input.length;i++) {
    if (input[i] == 'R' && current == 'R') {
      max++;
    } else if (input[i] == 'R') {
      max = 1;
    }
    if (input[i] == 'S' && current == 'R') {
      currentMax = max;
      max = 0;
    }
    current = input[i];
  }
  console.log(Math.max(max, currentMax));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29652
#include"bits/stdc++.h"
#include<regex>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
#define rrep(i,n) for(ll i=n-1;i>=0;--i)
#define pp pair<ll,ll>
#define ppp pair<ll,pp>
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define fi first
#define se second
const ll mod=1e9+9,INF=1e16;
vector<ll>node[200010];
int ans[200010];
void dfs(int pos=1,int from=0,int val=0){
    ans[pos]+=val;
    rep(i,node[pos].size()){
        if(node[pos][i]!=from)dfs(node[pos][i],pos,ans[pos]);
    }
}
ll n,q;
int main(){
    cin>>n>>q;
    int a,b;
    rep(i,n-1){
        cin>>a>>b;
        node[a].push_back(b);
        node[b].push_back(a);
    }
    rep(i,q){
        cin>>a>>b;
        ans[a]+=b;
    }
    dfs();
    rep(i,n)cout<<ans[i+1]<<" \n"[i==n-1];
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll t1,t2,a1,a2,b1,b2;cin>>t1>>t2>>a1>>a2>>b1>>b2;

  if(t1*a1+t2*a2==t1*b1+t2*b2) { cout<<"infinity"<<endl; return 0; }

  // A always runs long
  if(t1*a1+t2*a2<t1*b1+t2*b2) {
    swap(a1,b1);
    swap(a2, b2);
  }

  if(a1>b1) { cout<<0<<endl; return 0; }

  ll diff = (t1*a1+t2*a2) - (t1*b1+t2*b2);

  ll t1_diff = b1*t1-a1*t1;
  if(t1_diff==diff) { cout<<2<<endl; return 0; }

  ll result=(t1_diff/diff)*2;
  if(t1_diff%diff!=0)result++;//これ追加したらAC
  cout<<result<<endl;

//cout<<t1_diff<<' '<<diff<<endl;

  return 0;
}

Measured memory_bytes: 3636