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

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
char grid[52][52];

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

    bool ok = true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(grid[i][j]=='#'){
                bool flg = false;
                for(int k=0;k<4;k++){
                    int ni = i + dx[k], nj = j + dy[k];
                    if(0<=ni && ni<h && 0<=nj && nj<w && grid[ni][nj]=='#') flg = true;
                }

                if(!flg) ok = false;
            }
        }
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

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

    int L[200];
    for (int i = 0; i < 2 * N; i++)
        scanf("%d", &L[i]);

    sort(L, L + 2 * N);

    int ans = 0;
    for (int i = 0; i < N; i++)
        ans += L[2 * i];

    cout << ans << endl;

    return 0;
}

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

int solve(int N) 
{ 
	int count_pairs = 0; 

	for (int i = 1; i * i <= N - 1 ; ++i) { 
		for (int j = i; j * i < N; ++j) 
			++count_pairs; 
	} 

	count_pairs *= 2; 

	count_pairs -= int(sqrt(N - 1)); 

	return count_pairs; 
} 

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

	cout << solve(N); 

	return 0; 
} 


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> x(n);
	rep(i,n) cin >> x.at(i);
	int ans=0;
	rep(i,n){
		ans+=2*min(x.at(i),abs(k-x.at(i)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int h;
    int w;
    bool bLoop = true;
    
    while (bLoop)
    {
        cin >> h >> w;
        
        if ((h == 0) && (w == 0))
        {
            bLoop = false;
        }
        else
        {
            for(int i = 0; i < h; ++i)
            {
                for (int j = 0; j < w; ++j)
                {
                    cout << "#";
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;++i)
#define loop(i,a,b)         for (int i=a ; i<b ;++i)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    int n,k;
    cin>>n>>k;
    int mod=1000000007;
    vi a(n);
    f(i,n)cin>>a[i];
    int ans=0;
    f(i,n)
    {
        f(j,n)
        {
            if(a[i]>a[j])
            {
                if(j>i)
                {
                    ans+=(k*(k+1))/2;
                    ans%=mod;
                }
                if(i>j)
                {
                    ans+=(k*(k-1))/2;
                    ans%=mod;
                }
            }
        }
    }
    print(ans)
    
    return 0;
    
    
}

Measured memory_bytes: 3568
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = [rr() for _ in range(n)]
if len(set(li)) != n:
  print('No')
  exit()
else:
  for i in range(n-1):
    if li[i][-1] != li[i+1][0]:
      print('No')
      exit()
  else:
    print('Yes')







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

int level(vector<int> v) {
    const int N = v.size();
    vector<int> base;
    rep(i, N)base.push_back(i + 1);

    int res = 0;
    do {
        if (base == v)break;
        res++;
    } while (next_permutation(base.begin(), base.end()));
    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i, N)cin >> P[i];
    rep(i, N)cin >> Q[i];
    cout << abs(level(P) - level(Q)) << endl;
    return 0;
}


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

long long N, K;
vector<long long> sumV(100001);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int A, B;
  cin >> A >> B;
  cout << max(max(A + A-1, B + B-1), A + B);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
#include <typeinfo>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell   	    1000000007
#define PI 			3.14159265358979323844
#define rep(i,a,b)  for (long long int i=a;i<b;i++)
#define repr(i,a,b) for (long long int i=a-1;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
using namespace std;
ll arr[1001][1001];
ll dp[1001][1001];
 
ll num(int x,int y){
	if (x<0 || y<0 || arr[x][y]==0){
		return 0;
	}
	if (dp[x][y]!=-1)return dp[x][y];
	if (x==0 && y==0){
		return 1;
	}
	return dp[x][y]=(num(x-1,y)+num(x,y-1))%hell;
}
 	
void solve() {
	int n,w;
	cin>>n>>w;
	char c;
	memset(dp,-1,sizeof dp);
	rep(i,0,n){
		rep(j,0,w){
			cin>>c;
			if (c=='#'){
				arr[i][j]=0;
			}
			else{
				arr[i][j]=1;
			}
		}
	}
	cout<<num(n-1,w-1)<<endl;
}
 
signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

int main() {
  int n; cin>>n;
  vector<int> vec(n), dp(n,0);
  for (int i = 0; i < n; i++) {
    cin>>vec.at(i);
  }
  dp[1] = abs(vec[1]-vec[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i-1] + abs(vec[i]-vec[i-1]),dp[i-2] + abs(vec[i]-vec[i-2]));
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int g[1000],top=1,cnt=0,n;
void add(){
    while(g[top]*3+1<n){  
        top++;
        g[top]=g[top-1]*3+1;
    }
}
void sort(int a[],int g){//挿入ソート
    int v,i,j;
    for(i=g+1;i<=n;i++){
        v=a[i];
        j=i-g;
        while(j>=1&&a[j]>v){
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }
}
int main(){
    int i;
    scanf("%d",&n);
	int a[n];
    g[1]=1;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);//入力で与えらえるAの数列
    add();//飛ばし飛ばしでA[]の数列の要素をとってきてg配列を作成
    for(i=top;i>=1;i--)//A配列をソートする
        sort(a,g[i]);
    printf("%d\n",top);//g配列の要素数を出力
    for(i=top;i>=1;i--)//g配列の全要素を出力
        printf("%d ",g[i]);
    printf("\n");
    printf("%d\n",cnt);//入れ替え回数を表示
    for(i=1;i<=n;i++)
        printf("%d\n",a[i]);
    return 0;
}




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

int main(int argc, const char * argv[]) {
    int A, B, C;
    
    cin >> A >> B >> C;
    if ((A + B + 1) >= C) {
        cout << (B + C) << endl;
    } else {
        cout << (B + (A + B + 1)) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    int in[n] = {};
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        in[y]++;
    }

    int dist[n] = {};
    queue<int> que;
    rep(i, 0, n) {
        if (in[i] == 0) que.push(i);
    }
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (auto nv : g[v]) {
            in[nv]--;
            if (in[nv] == 0) {
                que.push(nv);
            }
            dist[nv] = max(dist[nv], dist[v] + 1);
        }
    }
    int ans = -1;
    rep(i, 0, n) ans = max(ans, dist[i]);
    cout << ans << endl;
    return 0;
}


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

int main() {
  
  int N,M;
  cin >> N >> M;
  
  if (M == 0 && N == 1) {
    	cout << 0 << endl;
    	return 0;
  }
  
  int a[N],flg[N];
  for (int i=0 ; i<N ; i++){
    a[i] = 0;
    flg[i] = 0;
  }
  
  int b,c;
  for (int i=0 ; i<M ; i++) {
    cin >> b >> c;
    if (flg[b-1] == 1 && a[b-1] != c) {
		cout << -1 << endl;
    	return 0;
    }
    a[b-1] = c;
    flg[b-1] = 1;
  }
  
  if (a[0] == 0 && flg[0] == 0) {
    a[0] = 1;
  }
  
  int result = 0;
  for (int i= (N - 1) ; i >= 0 ; i--) {
    result += (a[i] * pow(10, (N-i-1)));
  }
  
  if (result == 0 && N == 1 && flg[0] == 1) {
		cout << 0 << endl;
    	return 0;
  }
  
  int zeroflg=0;
  for (int i=0; i<N ; i++){
    if (a[N-i-1] == 0) {
      zeroflg = 1;
    } else {
      zeroflg = 0;
    }
  }
  if (zeroflg == 1) {
    cout << -1 << endl;
    return 0;
  }

  


    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <complex>
#include <algorithm>
using namespace std;

typedef long double Real;
typedef complex<Real> Point;
#define PCR Point const &
#define X real()
#define Y imag()

const Real EPS = 1e-10;
const Real INF = 1e100;
const Real PI = acos(-1);

struct Segment {
    Point p[2];
    Segment (PCR a = Point(), PCR b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
typedef vector<Point> Polygon;
struct Circle { Real radius; Point center; };

Real dot(PCR a, PCR b){
    return a.X*b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}

Point pSP(Segment const & s, PCR p){
    Point base = s[1] - s[0];
    Real r = dot(p - s[0], base) / norm(base);
    return s[0] + base * r;
}

Point rSP(Segment const & s, PCR p){
    Point v = pSP(s,p) - p;
    return p + v * Real(2);
}

enum { LEFT = 1, RIGHT = -1, BACK = 2, FRONT = -2, ON = 0 };
// Includes end-points. Comment in to exclude.
int ccw(PCR x, PCR p, PCR q){
    Point a = p - x, b = q - x;
    if(cross(a,b) > EPS) return LEFT;
    if(cross(a,b) < -EPS) return RIGHT;
    if(/* abs(a) < EPS || */ dot(a,b) < -EPS) return BACK;
    if(/* abs(b) < EPS || */ norm(a) < norm(b)) return FRONT;
    return ON;
}

bool isParallel(Segment const & s, Segment const & t){
    return abs(cross(s[1]-s[0],t[1]-t[0])) < EPS;
}

bool isOrthogonal(Segment const & s, Segment const & t){
    return abs(dot(s[1]-s[0],t[1]-t[0])) < EPS;
}

// Includes end-points. Modify CCW to exclude
bool iSS(Segment const & s, Segment const & t){
    bool f1 = ccw(s[0],s[1],t[0]) * ccw(s[0],s[1],t[1]) <= 0;
    bool f2 = ccw(t[0],t[1],s[0]) * ccw(t[0],t[1],s[1]) <= 0;
    return f1 && f2;
}

#include <iostream>
#include <cstdio>

int main(){
    Segment s,t;
    Real x,y;
    int n; cin >> n;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        s[0] = Point(x,y);
        cin >> x >> y;
        s[1] = Point(x,y);
        cin >> x >> y;
        t[0] = Point(x,y);
        cin >> x >> y;
        t[1] = Point(x,y);
        cout << iSS(s,t) << endl;
    }
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  deque<char> deq;
  for(auto&& e: s) {
    deq.push_back(e);
  }

  int cnt=0;
  while(!deq.empty()){
    if(deq.front()==deq.back()){
      deq.pop_front();
      if(deq.empty()) break;
      deq.pop_back();
    }

    else if(deq.front()!='x' && deq.back()!='x'){
      cout<<-1;
      return 0;
    }

    else if(deq.front()=='x'){
      deq.push_back('x');
      cnt++;
    }
    else{
      deq.push_front('x');
      cnt++;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n, t;
    cin >> n >> t;
    
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    
    vector<ll> mx(n);
    mx[n - 1] = a[n - 1];
    for(ll i = n - 2; i > 0; i--){
        mx[i] = max(mx[i + 1], a[i]);
    }
    
    ll maxx = -INF, c = 0;
    REP(i, n - 1){
        if(a[i] < mx[i + 1]){
            if(maxx == mx[i + 1] - a[i]){
                c++;
            }
            else if(maxx < mx[i + 1] - a[i]){
                maxx = mx[i + 1] - a[i];
                c = 1;
            }
        }
    }
    
    cout << c << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, N;
  cin >> H >> W >> N;
  V<int> A(N);
  REP(i, N) cin >> A[i];
  V<V<int>> grid(H, V<int>(W, -1));
  int i = 0;
  REP(r, H) {
    REP(c, W) {
      int j = (r % 2 == 0) ? c : (W - 1 - c);
      while (A[i] == 0) ++i;
      grid[r][j] = i;
      A[i]--;
    }
  }
  REP(r, H) {
    REP(c, W) { cout << grid[r][c] + 1 << ' '; }
    cout << '\n';
  }
}


Measured memory_bytes: 3736
import sys
S = input()

if S[0] is 'A' and S[2:-1].count('C') == 1:
    if S[-1] != 'C' and S[:2].count('C') == 0:
        S = S.replace('C', '')
        S = S[1:]
        for i in S:
            if i.islower():
                continue
            else:
                print('WA')
                sys.exit()
        print('AC')
else:
    print('WA')    


Measured memory_bytes: 9116
n, m = map(int, input().split())
a = []

for i in range(n):
    a.append(list(map(int, input().split())))

b = []
for j in range(m):
    b.append(int(input()))

for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)


Measured memory_bytes: 6008
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {

		int N,A,B;
		cin >> N;
		vi a(N);
		vi b(N);
		vi c(N);
		for (int i = 0; i < N; i++) {
			cin >> a[i] >> b[i] >> c[i];
			A = min(a[i], b[i]);
			B = max(a[i], b[i]);
			if(B>c[i]){
				if (pow(B, 2) == pow(A, 2) + pow(c[i], 2)) {
					cout << "YES" << endl;
				}
				else {
					cout << "NO" << endl;
				}
		}
			else {
				if (pow(c[i], 2) == pow(B, 2) + pow(A, 2)) {
					cout << "YES" << endl;
				}
				else {
					cout << "NO" << endl;
				}
			}

	}

}

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

typedef long long ll;



int main(){


 string s;
  cin>>s;

  int i=0;

  while(i<s.size()-1){

   if(s[i] == s[i+1]){
    cout<<i+1<<" "<<i+2<<endl;
    return 0; }

   if(i+2 < s.size() && s[i] == s[i+2]){
     cout<<i+1<<" "<<i+3<<endl;
     return 0; }

     i++;
   }

  cout<<-1<<" "<<-1<<endl;

return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    sum += L[i];
  }
  sort(L.begin(), L.end());
  if (2*L[N-1] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 2;
const int INF = 2e18;

bool check(string S) {
    bool temp = true;
    for (int i = 0; i <= S.size() / 2; i++) {
        if (S[i] != S[S.size() - 1 - i]) temp = false;
    }
    return temp;
}

signed main() {
    string S;
    cin >> S;
    int N = S.length();
    if (check(S) && check(S.substr(0, (N - 1) / 2)) && check(S.substr((N + 3) / 2 - 1, N - ((N + 3) / 2) + 1))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
S = np.array([input() for _ in range(N)], dtype=str)
keys, values = np.unique(S, return_counts=True)
cnt = []
for k, v in zip(keys, values):
    cnt.append([k, v])
cnt.sort(reverse=True, key=lambda x: x[1])
a = cnt[0][1]
ans = []
for k, v in cnt:
    if v < a:
        break
    ans.append(k)
ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 97100
using System;
using System.Collections.Generic;
using System.Text;

namespace test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			List<List<int>> resultList = new List<List<int>> ();
			string input;
			while ((input = Console.ReadLine()) != null) {
				int a = int.Parse (input);

				List<int> WeightList = new List<int> ();
				int i = 0;
				while (true) {
					if(a%2==1){
						WeightList.Add ((int)Math.Pow (2, i));
					}
					a /= 2;
					i++;
					if (a == 0){
						break;
					}
				}

				resultList.Add (WeightList);
			}

			foreach (List<int> list in resultList) {
				for (int i=0; i<list.Count; i++) {
					Console.Write (list [i]);
					if (i == list.Count - 1) {
						Console.WriteLine ();
					} else {
						Console.Write (" ");
					}
				}
			}

		}


	}
	
}

Measured memory_bytes: 5716
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    val b = a.map {
        var count = 0
        var x = it
        while (true) {
            if (x%2==0) {
                count++
                x /= 2
            }
            else break
        }
        count
    }
    println(b.sum())
}

Measured memory_bytes: 39936
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    ll n;cin >> n;
    ll p=1;
    for(int i=1;i<=n;i++){
        p=(p*i)%mod;
        
    }
    cout << p << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> v(n+1);
    rep(i,n){
        int x;
        cin >> x;
        v[x]++;
    }
    sort(v.begin(),v.end());
    int res = 0;
    rep(i,n-k+1){
        res+=v[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string n;
  cin >> n;
  cout << (n[0] == '9' || n[1] == '9' ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	s := sc.ReadString()
	t := sc.ReadString()

	for i := 0; i < len(s); i++ {
		if t[i] != s[i] {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1756
#!/usr/bin/env python3
import copy
N, K = map(int, input().split())
A = list(map(int, input().split()))

before = 0
for i in range(K, 0, -1):
    before += A[K-i]
for i in range(K, N):
    after = (before-A[i-K])+A[i]
    if before < after:
        print('Yes')
    else:
        print('No')
    before = copy.deepcopy(after)




Measured memory_bytes: 94212
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n, k;
    cin >> n >> k;
    bool ok[1000]{};
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            ok[a - 1] = true;
        }
    }
    cout << n - count(ALL(ok), true) << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int n; cin>>n;
    cout<<"ai1333";
    rep(i,n/100)cout<<"3";
    cout<<endl;
}



Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int h = tmp[0], w = tmp[1];
	int n = int.Parse(ReadLine());

	int[] d = new int[h*w];
	int idx = 0;

	int[] a = ReadIntArray();
	for (int i = 0; i < n; i++)
	{
	    for (int j = 0; j < a[i]; j++)
	    {
		d[idx++] = i+1;
	    }
	}

	for (int i = 0; i < h; i++)
	{
	    string s = "";
	    int baseIdx = i * w;

	    if ((i&1) == 0)
	    {
		for (int j = 0; j < w; j++)
		{
		    if (j != 0){ s += " "; }
		    s += d[baseIdx + j].ToString();
		}
	    }
	    else
	    {
		for (int j = w-1; j >= 0; j--)
		{
		    s += d[baseIdx + j].ToString();
		    if (j != 0){ s += " "; }
		}
	    }

	    WriteLine(s);
	}
    }
}


Measured memory_bytes: 19936
#include<bits/stdc++.h>
using namespace std;
int T,x,y,t,t1,flag,x1,y2;
int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d",&t,&x,&y);
		if(abs(x-x1)+abs(y-y2)>(t-t1)) flag=1;
		if((abs(x-x1)+abs(y-y2))%2!=(t-t1)%2) flag=1;
		x1=x;y2=y;t1=t; 
	}
	if(flag) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		// スペース区切りの整数の入力
		int a = sc.nextInt();
		int MOD = 1000000007;
		long b = 1;
		long c = 0;
		int MAX = 2000 + 1;
		long e;


long[] fac = new long[MAX];
long[] finv = new long[MAX];
long[] inv = new long[MAX];;


  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;
  }
		for(int i = 0;a > 2; i++){
			b = 1;
			a += -3;
		

// 二項係数計算
    e = fac[a + i] * (finv[a] * finv[i] % MOD) % MOD;


			c += e;
			c = c % MOD;
		} 
		System.out.println(c);
		
		
	}
}

Measured memory_bytes: 35740
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	while(true){
		int M=in(),F=in(),R=in();
		if(M<0 && F<0 && R<0) break;

		if(M<0 || F<0){
			out('F');
		}
		else if(M+F>=80){
			out('A');
		}
		else if(M+F>=65){
			out('B');
		}
		else if(M+F>=50){
			out('C');
		}
		else if(M+F>=30){
			if(R>=50) out('C');
			else out('D');
		}
		else{
			out('F');
		}
	}

	return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,K;
string S;

string solve(string &s,int rest,int malen){
    if(rest==1){
        string t="";
        for(int i=0;i<min(N,2*malen);i++) t+=s.back();
        if(t.size()==N) return t;

        string p=s;
        reverse(p.begin(),p.end());

        string r=t;
        r+=p.substr(malen,N-2*malen);
        return r;
    }


    string t="";
    for(int i=0;i<min(N,2*malen);i++) t+=s.back();
    if(t.size()==N) return t;

    string r=s.substr(malen,N-(2*malen));
    r+=t;
    return solve(r,rest-1,2*malen);
}

int main(){
  cin>>N>>K;
  cin>>S;

  vector<string> cand;
  if(K==1){
      string T=S;
      reverse(T.begin(),T.end());
      T=S+T;
      for(int i=0;i<=N;i++) cand.push_back(T.substr(i,N));
  }else{
      vector<string> v;
      int mi=30;
      for(int i=0;i<N;i++){
          mi=min(mi,S[i]-'a');
      }

      string T=S;
      reverse(T.begin(),T.end());
      T=S+T;
      int malen=1;
      int len=0;
      for(int i=0;i<T.size();i++){
          if(mi==T[i]-'a') len++;
          else{
              malen=max(malen,len);
              len=0;
          }
      }
      malen=max(malen,len);

      len=0;
      for(int i=0;i<T.size();i++){
          if(mi==T[i]-'a') len++;
          else len=0;

          if(len==malen&&i-N+1>=0){
              string s=T.substr(i-N+1,N);
              v.push_back(s);
          }
      }

      for(int i=0;i<v.size();i++){
          string s=solve(v[i],min(K-1,31),malen);
          cand.push_back(s);
      }
  }

  sort(cand.begin(),cand.end());
  cout<<cand[0]<<endl;

  return 0;
}


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

#define ll long long 
using namespace std;



void solve(){
    ll n,d;
    cin>>n>>d;
    ll x,y;
    int ans=0;
    for (ll i = 0; i < n; i++)
    {
        cin>>x>>y;
        if((x*x)+(y*y) <=(d*d)){
            ans++;
        }
    }
    cout<<ans;
    return;
    

   /*ll k;
   cin>>k;
   ll x =7;
   int count =1;
   if(k%2==0){
       cout<<"-1";
       return;
   }
   while(x<k){
       x*=10;
       x+=7;
       count++;
   }
   if(x==k){
       cout<<count;
   }
   else{
       cout<< "-1";
   }
   return;
    */
}

int main(){
    ll t;
   // cin>>t;
    t=1;

    while(t--){
        solve();
    }
    
    return 0;
}

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


#define en "\n"
#define sqrt(n) sqrt((long double) n)
#define all(c) (c).begin() , (c).end()
#define MOD 1000000007
#define mem(a) memset(a,0,sizeof(a))
#define flash() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file_input(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))


using namespace std;

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



const double EPS=0.000000001;
const double INFD32=1000000000;
const ll INF64=1000000000000000000;
const int INF32=1000000000;

#define maxN 30000000
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
  return (a.second>=b.second && a.first>=b.first);
}

signed main(void){
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0){
      cout<<1LL*((a+b)/2);
    }
    else cout<<"IMPOSSIBLE\n";
    return 0;
  }


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

template<typename T> void print(vector<T> &x){
	For(i, (int)x.size()){
		cout << x[i] << " ";
	}
	cout << endl;
}

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

unsigned ll func(unsigned ll n, unsigned ll i){

	n++;
	if(n >> i == 0){
		return 0;
	}
	unsigned ll num_one = (n / (2 << i)) * (1 << i);

	if((n % (2 << i)) != 0 && (n % (2 << i)) - (1 << i) > 0){
		num_one += (n % (2 << i)) - (1 << i);
	}

	return num_one;

}

int main(){

	int a, b, k;
	cin >> a >> b >> k;

	int count = 0;

	int max_num = min(a, b);

	for(int i = max_num;; i--){
		if(a % i == 0 && b % i == 0){
			count++;
			if(count == k){
				out(i);
				break;
			}
		}
	}

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100005

typedef struct NT
{
  char name[10];
  int time;
}nt;

void enqueue(nt x);
nt dequeue(void);

nt Q[N];
int head,tail,n;

int main()
{
  nt A;
  int i,c,q,TIME=0;
  scanf("%d%d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].time);
  }
  head=1;
  tail=n+1;
  while(head!=tail){
    A=dequeue();
    if(q>A.time) c=A.time;
    else c=q;
    A.time-=c;
    TIME+=c;
    if(A.time>0) enqueue(A);
    else {
      printf("%s %d\n",A.name,TIME);
    }
  }

  return 0;
}

void enqueue(nt x)
{
  Q[tail]=x;
  if (tail+1==N) tail=0;
  else tail++;
}

nt dequeue(void)
{
  nt x=Q[head];
  if(head+1==N) head=0;
  else head++;
  return x;
}

Measured memory_bytes: 2156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b =Integer.parseInt(sc.next());
		//int[][] c = new int[h][w];

		StringBuilder sb = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();
		for(int j = 0; j < a; j++) {
			sb.append("0");
			sb2.append("1");
		}
		for(int j = a; j < w; j++) {
			sb.append("1");
			sb2.append("0");
		}
		for(int i = 0; i < b; i++) {
			System.out.println(new String(sb));
		}
		for(int i = b; i < h; i++) {
			System.out.println(new String(sb2));
		}

		/*for(int i = 0; i < b; i++) {
			for(int j = 0; j < a; j++) {
				System.out.print(0);
			}
			for(int j = a; j < w; j++) {
				System.out.print(1);
			}
			System.out.printf("%n");
		}
		for(int i = b; i < h; i++) {
			for(int j = 0; j < a; j++) {
				System.out.print(1);
			}
			for(int j = a; j < w; j++) {
				System.out.print(0);
			}
			System.out.printf("%n");
		}*/

		/*for(int i = 0; i < b; i++) {
			for(int j = 0; j < a; j++) {
				c[i][j] = 0;
			}
			for(int j = a; j < w; j++) {
				c[i][j] = 1;
			}
		}
		for(int i = b; i < h; i++) {
			for(int j = 0; j < a; j++) {
				c[i][j] = 1;
			}
			for(int j = a; j < w; j++) {
				c[i][j] = 0;
			}
		}

		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				System.out.print(c[i][j]);
			}
			System.out.printf("%n");
		}*/

		sc.close();
	}

}

Measured memory_bytes: 25556
l=input()
lis=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(lis)-1):
    if l==lis[i]:
        print(lis[i+1])
        

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
}


Measured memory_bytes: 38148
#include <stdio.h>

struct card {
    int num;
    int flag;
};

int main(void) {
    struct card card[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            scanf(" %d", &card[i][j].num);
            card[i][j].flag = 0;
        }
    }

    int num_count;
    scanf(" %d", &num_count);
    int num;
    for (int i = 0; i < num_count; i++) {
        scanf(" %d", &num);
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (card[j][k].num == num) {
                    card[j][k].flag = 1;
                }
            }
        }
    }

    int result = 0, i, j;
    if (!result) {
        for (i = 0; i < 3; i++) {
            for (j = 0; j < 3; j++) {
                if (card[i][j].flag) {
                    result = 1;
                    continue;
                } else {
                    result = 0;
                    break;
                }
            }
            if (result)
                break;
        }
    }

    if (!result) {
        for (i = 0; i < 3; i++) {
            for (j = 0; j < 3; j++) {
            if (card[j][i].flag) {
                    result = 1;
                    continue;
                } else {
                    result = 0;
                    break;
                } 
            }
            if (result)
                break;
        }
    }

    if (!result) {
        for (i = 0; i < 3; i++) {
            if (card[i][i].flag) {
                result = 1;
                continue;
            } else {
                result = 0;
                break;
            }
        }
    }

    if (!result) {
        for (i = 0; i < 3; i++) {
            if (card[i][2 - i].flag) {
                result = 1;
                continue;
            } else {
                result = 0;
                break;
            }
        }
    }

    if (result) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#define X 1000000007
long fact[2000001] = {};
long invfact[2000001] = {};

long pow_(long a,long n){
  long ans = 1;
  while(n>0){
    if(n & 1){
      ans = (ans * a) % X;
    }
    a = (a * a) % X;
    n >>= 1;
  }
  return ans ;
}
  
void makefact(){
  long i = 1;
  for(i=1;i<=2000000;i++){
    if(i==1){
      fact[i] = 1;
      invfact[i] = 1;
    }else{
      fact[i] = (fact[i-1] * i) % X;
      invfact[i] = pow_(fact[i],X-2) % X;
    }
  }
}

int main(){
  long x = 0;
  long y = 0;
  long movea = 0;
  long moveb = 0;
  long i = 0;
  long j = 0;
  long oh = 0;
  long flag = 0;
  
  scanf("%ld %ld",&x,&y);
  makefact();
  for(i = 0;i < x/2+1;i++){
    movea = x - 2 * i;
    moveb = i;
    if(2*movea + moveb == y){
      flag = 1;
      break;
    }
  }
  if(!flag){
    oh = 0;
  }else{
    if(movea == 0 || moveb == 0){
      oh = 1;
    }else{
      oh = (((fact[movea+moveb]*invfact[movea])%X)*invfact[moveb]) % X;
    }
  }

  printf("%ld",oh);
  return 0;
}


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

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

    int ans = 0;
    for (int i = 0; i + 1 < (int)S.size(); i++) {
        if (S[i] != S[i + 1]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int a[M],b[M];
vector<int>vec;
int sum=0;
 main()

{
    fast
    int n,m,k;
    cin>>n>>m>>k;
    f(i,1,n)cin>>a[i];
    f(i,1,m)cin>>b[i];
    vec.pb(0);
    f(i,1,m)
    {
        sum+=b[i];
        vec.pb(sum);
    }
    int cnt=0;
    int sum=0;
    f(i,0,n)
    {
        sum+=a[i];
        if(sum>k)break;
        int x=i,y=0;
        int baki=k-sum;
        int idx=upper_bound(vec.begin(),vec.end(),baki)-vec.begin();
        y=idx-1;
        cnt=max(cnt,x+y);
    }
    cout<<cnt<<endl;
    return 0;

}





































Measured memory_bytes: 8432
X=int(input())
N=10**3
L=[[0 for i in range(N)] for i in range(N)]
for i in range(N):
  for j in range(i):
    L[i][j]=i**5-j**5
C=[]
M=[[0 for i in range(N)] for i in range(N)]
for i in range(N):
  for j in range(N):
    M[i][j]=i**5+j**5
for i in range(N):
  for j in range(i):
    if L[i][j]==X:
      C.append([i,j])
for i in range(N):
  for j in range(N):
    if M[i][j]==X:
      C.append([i,-j])
print(C[0][0],C[0][1])

Measured memory_bytes: 90220
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include  <list>
#include  <utility>
#include  <memory>
#include  <cstring>
#include  <fstream>
#include  <numeric>
using namespace std;
vector <int> mod10;
vector <int> unmod10;
int t;
int main(){
  int n,cnt=0;
  cin>>n;
  for (int i=0;i<n;i++){
    cin>>t;
    cnt+=t;
    if (t%10==0) mod10.push_back(t);
    else unmod10.push_back(t);
  }
  if (cnt%10!=0){
  	cout<<cnt;
  	return 0;
  }
  if (unmod10.size()==0){
    cout<<"0";
    return 0;
  }
  int les=1000;
  for (int i=0;i<unmod10.size();i++)
    les=min(unmod10[i],les);
  cout<<cnt-les;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(T))

Measured memory_bytes: 5460
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    double res = 0.0;
    for (Int i = 0; i < n; i++) {
        double x;
        string s;
        cin >> x >> s;
        res += s == "JPY" ? x : x * 380000.0;
    }
    printf("%lf\n", res);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    ll s;
    cin>>s;
    vl dp(s+1,0);
    dp[0]=1;
    for(int i=3;i<=s;i++) {
        for(int j=0;j<=i-3;j++) {
            dp[i]=(dp[i]+dp[j])%mod;
        }
    }

    cout<<dp[s];

}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3636