akhauriyash/Code-Regression huggingface dataset:
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;

typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(t,c) for(typeof((c).begin()) t=(c).begin(); t!=(c).end(); ++t)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(t,a,b) for(int t=(a);t<(b);++t)
#define REP(t,n)  FOR(t,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;



const LL mod = 1000000007;

LL gcd(LL a, LL b) { if (a%b == 0) { return b; } else return gcd(b, a%b); }
LL lcm(LL a, LL b) { return a / gcd(a, b)*b; }

#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;


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

	REP(i, N) { cin >> A[i]; }

	int m = 999;
	REP(i, N) {
		int n = 0;
		while (A[i] % 2 == 0) {
			A[i] /= 2;
			n++;
		}
		m = min(m, n);
	}
	cout << m << endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n;
    string s[11000];
    cin >> n;
    rep(i, n) cin >> s[i];
    
    ll a = 0, b = 0, ab = 0, br = 0;
    rep(i, n){
        rep(j, s[i].size()-1){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') ab++;
        }
        if(s[i][0] == 'B') b++;
        if(s[i][s[i].size()-1] == 'A') a++;
        if(s[i][s[i].size()-1] != 'A' && s[i][0] != 'B') br++;
    }
    if(a == n-br) a--;
    if(b == n-br) b--;
    cout << max(0LL, min(a, b)) + ab << endl;

    return 0;
}

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

int main(){
  int a,b;
  int x;
  
  cin >> a >> b;
  x= (a + b) % 2;
  
  if(x == 0)
  {
    cout << (a + b) / 2 << endl;
  }else
  {
  	cout << (a + b + 1) / 2 << endl;
  }
}

Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	int a[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	sort(a,a+10);
	reverse(a,a+10);
	cout<<a[0]<<endl;
	cout<<a[1]<<endl;
	cout<<a[2]<<endl;
}

Measured memory_bytes: 3136
def main():
    N, X = map(int, input().split())
    p = [1]
    for i in range(N+1):
        p.append(p[-1] * 2 + 1)
    a = [1]
    for i in range(N+1):
        a.append(a[-1]*2 + 3)

    return helper(N, X, a, p)

def helper(N, X, a, p):
    if N == 0:
        return 1
    if X == 1:
        return 0
    elif X <= a[N-1] + 1:
        return helper(N-1, X-1, a, p)
    elif X == a[N-1] + 2:
        return p[N-1] + 1
    elif X <= 2*a[N-1] + 2:
        return p[N-1] + 1 + helper(N-1, X-a[N-1]-2, a, p)
    else:
        return 2*p[N-1] + 1

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
//32
#include<iostream>
#include<algorithm>
#include<numeric>
#include<functional>

using namespace std;

int main(){
  int p[2][10];
  for(int i=0;i<2;i++){
    for(int j=0;j<10;j++){
      cin>>p[i][j];
    }
  }
  for(int i=0;i<2;i++){
    sort(p[i],p[i+1],greater<int>());
    cout<<accumulate(p[i],p[i]+3,0)<<((i==0)?' ':'\n');
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

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

    cout << 700 + 100 * count(all(inp), 'o') << endl;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N,M;
    cin >> N >> M;
    vector<int> cnt(M+1);

    for (int i = 0; i < N; i++) {
        int k;
        cin >> k;
        for (int p = 0; p < k; p++) {
            int x;
            cin >> x;
            cnt[x]++;
        }
    }

    int ans = 0;
    for (int i = 0; i <= M; i++) {
        if (cnt[i] == N) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
h,w,k=map(int,input().split())
l=[list(input()) for i in range(h)]

count=[]
for i in range(h):
  L=[0]
  for j in range(w):
    L.append(int(l[i][j])+L[-1])
  count.append(L)

b=[]
for i in range(2**(h-1)):
  b.append(format(i,'0'+str(h-1)+'b'))

ans=[]
cut=0
for i in range(len(b)):
  cutct=0
  cut=0
  f=0
  for j in range(1,w+1):
    ct=[]
    for j2 in range(h):
      ct.append(count[j2][j]-count[j2][cut])
    check=[]
    x=ct[0]
    for j3 in range(h-1):
      if b[i][j3]=='0':
        x+=ct[j3+1]
      else:
        check.append(x)
        x=ct[j3+1]
    check.append(x)
    if max(check)>k:
      if cut-j<=1:
        ctcheck=[]
        for j2 in range(h):
          ctcheck.append(count[j2][j-1]-count[j2][cut])
        check=[]
        x=ctcheck[0]
        for j3 in range(h-1):
          if b[i][j3]=='0':
            x+=ctcheck[j3+1]
          else:
            check.append(x)
            x=ctcheck[j3+1]
        check.append(x)
        if max(check)>k:
          f=1
      cut=j-1
      cutct+=1
    if cut==w-1:
      ctcheck=[]
      for j2 in range(h):
        ctcheck.append(count[j2][w]-count[j2][cut])
      check=[]
      x=ctcheck[0]
      for j3 in range(h-1):
        if b[i][j3]=='0':
          x+=ctcheck[j3+1]
        else:
          check.append(x)
          x=ctcheck[j3+1]
      check.append(x)
      if max(check)>k:
        f=1
  ct1=0
  for j4 in range(h-1):
    if b[i][j4]=='1':
      ct1+=1
  if f==0:
    ans.append(cutct+ct1)
print(min(ans))

Measured memory_bytes: 62172
#include<cstdio>
using namespace std;
int main()
{
	int a[11],tot=0;
	char c=getchar();
	while(c>='0'&&c<='9')
	{
		a[++tot]=c-'0';
		c=getchar();
	}
	int n=1<<(tot-1);
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		long long t=0;
		for(int j=1;j<=tot;j++)
		{
			t=t*10+a[j];
			if(1<<(j-1)&i) ans+=t,t=0;
		}
		ans+=t;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll a[n],S=0,eS=0;
    rep(0,i,n){
        cin>>a[i];
        S+=a[i];
        if(i%2==1 && i<n-1)eS+=a[i];
    }
    ll x[n];
    x[0]=S-2*eS;
    rep(0,i,n-1){
        x[i+1]=2*a[i]-x[i];
    }
    rep(0,i,n){
        cout<<x[i];
        if(n-1!=i)cout<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long

void lol(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif	
}

void solve(){
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for(int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i];
	vector<vector<int> > dp(3, vector<int>(n, 0));
	dp[0][0] = a[0], dp[1][0] = b[0]; dp[2][0] = c[0];
	for(int i=1; i<n; i++){
		dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
		dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
		dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
	}
	cout << max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1]));
}

int main(){
	FAST(); 
	// lol();
	int t; t = 1; while(t--) solve();
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  string str;
  cin >> str;
  ll n = str.size();
  vector <ll> v(n);
  rep(i, n) v.at(i) = ctoi(str.at(i));
  ll ans = 0;
  for (ll tmp = 0; tmp < (1 << n-1); tmp++) {
    bitset <10> s(tmp);
    ans += v.at(n-1);
    ll count = 0;
    rep(i, n-1) {
      if (s.test(n-2-i)) {
        count = 0;
        ans += v.at(n-2-i)*(ll)pow(10, count);
      } else {
        count++;
        ans += v.at(n-2-i)*(ll)pow(10, count);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Integer[] lengths = new Integer[n];
        for (int j = 0; j < n; j++) {
            lengths[j] = in.nextInt();
        }
        Arrays.sort(lengths);
        long answer = 0;
        for (int j = 0; j < n; j++) {
            for (int k = j + 1, l = j + 2; k < n; k++) {
                while (l < n && lengths[j] + lengths[k] > lengths[l]) {
                    l++;
                }
                answer += (long) (l - k - 1);
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 29036
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;

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

    ll M=max(a,b);
    ll m=min(a,b);
    return gcd(m,M%m);
}

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

int main(){
    int N;cin>>N;
    ll T[110],ans=1;
    for(int i=0;i<N;i++){
        cin>>T[i];
        ans=lcm(ans,T[i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define LL long long
#define ALL(x) x.begin(),x.end()


const LL INF = 1000000000000005;
vector<LL> sum;
vector<LL> A;
vector<LL> C;

struct P{
    int inde;
    LL val;
    LL self;
    P(int inde,LL val,LL self):inde(inde),val(val),self(self){;}
};

struct Cmp{
    bool operator()(const P &p1,const P &p2){
        return p1.val < p2.val;
    }
};

int main()
{
    LL K;
    int x,y,z;
    scanf("%d %d %d %lld",&x,&y,&z,&K);

    _for(i,0,x){
        LL num;
        scanf("%lld",&num);
        A.push_back(num);
    }

    _for(i,0,y){
        LL num;
        scanf("%lld",&num);
        _for(j,0,A.size()){
            sum.push_back(A[j] + num);
        }
    }

    sort(ALL(sum),greater<LL>());

    priority_queue<P,vector<P>,Cmp> pq;

    _for(i,0,z){
        LL num;
        scanf("%lld",&num);
        pq.push(P(0,num+sum[0],num));
    }

    int sz = sum.size();

    for(LL i = 0;i < K;i++){
        P now = pq.top();
        pq.pop();
        printf("%lld\n",now.val);
        now.inde++;
        if(now.inde < sz){
            now.val = now.self+sum[now.inde];
            pq.push(now);
        }
    }


    return 0;
}

Measured memory_bytes: 10616
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    while(cin >> n && n != 0)
    {
        double s[n],ave = 0;
        for(int i = 0;i < n;i++)
        {
            cin >> s[i];
            ave += s[i];
        }
        ave /= n;
        double disp = 0;
        for(int i = 0;i < n;i++)
        {
            disp += (s[i] - ave) * (s[i] - ave);
        }
        cout << fixed << setprecision(20) << sqrt(disp / n) << "\n";
    }

    return 0;
}


Measured memory_bytes: 3288
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 998244353;
const int N_MAX = 300;
const int A_MAX = 300;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

vector<vector<ll>> dp(N_MAX+1, vector<ll>(N_MAX*A_MAX+1, 0)), dp2(N_MAX+1, vector<ll>(N_MAX*A_MAX+1, 0));

ll modpow(ll a, ll t) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= MOD;
        }
        a *= a;
        a %= MOD;
        t >>= 1;
    }
    return ret;
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    ll s = accumulate(a.begin(), a.end(), 0LL);

    dp[0][0] = 1;
    dp2[0][0] = 1;
    for(int i=0;i<n;++i) {
        for(int r=0;r<=s;++r) {
            if(!dp[i][r]) continue;
            dp[i+1][r] += 2 * dp[i][r];
            dp[i+1][r] %= MOD;
            dp[i+1][r+a[i]] += dp[i][r];
            dp[i+1][r] %= MOD;
            dp2[i+1][r+a[i]] += dp2[i][r];
            dp2[i+1][r+a[i]] %= MOD;
            dp2[i+1][r] += dp2[i][r];
            dp2[i+1][r] %= MOD;
        }
    }

    ll ans = 0LL;
    for(int r=(s+1)/2;r<=s;++r) {
        ans += dp[n][r];
        ans %= MOD;
    }
    if(s % 2 == 0) ans += MOD - dp2[n][s/2];
    ans = (3 * ans) % MOD;
    ans = (modpow(3LL, n) + MOD - ans) % MOD;

    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    string s, t;

    cin >> s;
    cin >> t;

    t.pop_back();
    if(s == t)
        cout << "Yes";
    else
        cout << "No";    
}

Measured memory_bytes: 3620
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	char a[20000];
	scanf("%[^\n]",a);
	int len=strlen(a);
	for(int i=0 ; i<len ; i++)
	{
		if(a[i]>='a' && a[i]<='z')
		{
			a[i]-=32;
		}
		else if(a[i]>='A' && a[i]<='Z')
		{
			a[i]+=32;
		}
	}
	printf("%s\n",a);
	return 0;
}

Measured memory_bytes: 3148
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

int p[24][6]=
{
    {0,1,2,3,4,5},
    {0,2,3,4,1,5},
    {0,3,4,1,2,5},
    {0,4,1,2,3,5},
    {1,4,5,2,0,3},
    {1,5,2,0,4,3},
    {1,2,0,4,5,3},
    {1,0,4,5,2,3},
    {2,3,0,1,5,4},
    {2,0,1,5,3,4},
    {2,1,5,3,0,4},
    {2,5,3,0,1,4},
    {3,4,0,2,5,1},
    {3,0,2,5,4,1},
    {3,2,5,4,0,1},
    {3,5,4,0,2,1},
    {4,1,0,3,5,2},
    {4,0,3,5,1,2},
    {4,3,5,1,0,2},
    {4,5,1,0,3,2},
    {5,4,3,2,1,0},
    {5,3,2,1,4,0},
    {5,2,1,4,3,0},
    {5,1,4,3,2,0}
};

int t[4];
int mat[4][6];
int n;
int ans;

void getans()
{
    int ret=0;
    for (int i=0;i<6;i++)
    {
        int tmp[4];
        for (int j=0;j<n;j++)
            tmp[j]=mat[j][p[t[j]][i]];
        int mymax=0;
        for (int j=0;j<n;j++)
        {
            int count=0;
            for (int k=0;k<n;k++)
            {
                if (tmp[j]==tmp[k])
                    count++;
            }
            if (count>mymax)
                mymax=count;
        }
        ret+=(n-mymax);
    }
    if (ret<ans)
        ans=ret;
}
void dfs(int now)
{
    if (now==n)
        getans();
    else
    {
        for (int i=0;i<24;i++)
        {
            t[now]=i;
            dfs(now+1);
        }
    }

}

map<string,int> hash;

int main()
{

    while(scanf("%d",&n),n)
    {
        hash.clear();
        int tot=0;
        for (int i=0;i<n;i++)
        {
            string s;
            for (int j=0;j<6;j++)
            {
                int tc=j;
                if (j==3)   tc=4;
                else if (j==4)  tc=3;
                cin>>s;
                if (hash.find(s)==hash.end())
                {
                    mat[i][tc]=hash[s]=tot++;
                }
                else mat[i][tc]=hash[s];
            }
        }
        if (n==1)
        {
            puts("0");
            continue;
        }
        ans=10000000;
        dfs(0);
        printf("%d\n",ans);
    }
    return 0;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    ll a[n]; f(i,0,n-1) cin >> a[i];
    ll xo = a[0];
    f(i,1,n-1) xo ^= a[i];
    f(i,0,n-1) a[i] ^= xo;
    f(i,0,n-1) cout << a[i] << spc;
    return 0;
}

Measured memory_bytes: 5144
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in asz=26;
const in mx=500009;
in fst[mx][asz+1];
string s;
in n;
in nxte[mx][22];
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>s;
  n=sz(s);
  forn(i,asz+1)
    fst[n][i]=n;
  for(in i=n-1;i>=0;--i){
    forn(j,asz+1)
      fst[i][j]=n;
    fst[i][s[i]-'a']=i;
    in u=i+1;
    in cr=s[i]-'a';
    while(u<n && cr<asz){
      fst[i][cr+1]=fst[u][cr];
      u=fst[i][cr+1]+1;
      ++cr;
    }
    if(fst[i][asz]<n){
      for(in j=0;fst[i][j]==n;++j)
	fst[i][j]=fst[fst[i][asz]+1][j];
    }
  }
  forn(i,n)
    nxte[i][0]=fst[i][asz];
  forn(j,22)
    nxte[n][j]=nxte[n+1][j]=n;
  for(in i=n-1;i>=0;--i){
    for(in j=1;j<22;++j)
      nxte[i][j]=nxte[nxte[i][j-1]+1][j-1];
  }
  in q;
  cin>>q;
  in l,r;
  forn(zz,q){
    cin>>l>>r;
    --l;
    --r;
    in cu=21;
    while(cu>=0){
      if(nxte[l][cu]<=r)
	l=nxte[l][cu]+1;
      --cu;
    }
    if(nxte[l][0]<=r)
      l=nxte[l][0]+1;
    if(l==r+1)
      cout<<"Yes\n";
    else
      cout<<"No\n";
  }
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
    cout << (x / 500) * 1000l + ((x % 500) / 5l) * 5l << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define TEST(t) int inox,t;cin>>t; for(inox=1;inox<=t;inox++)
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,n) for(i=n-1;i>=0;i--)
using namespace std;


int main(){
	int n; int f=0; cin>>n;
	while(n){
		if(n%10==7){f=1;break;}
		n/=10;
	}
	if(f)cout<<"Yes";
	else cout<<"No";
}

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

int dat[400000], lazy[400000], N;
inline void push(int k) {
	if (lazy[k] == -1)return;
	dat[k] = lazy[k];
	if (k < N - 1) {
		lazy[2 * k + 1] = lazy[k];
		lazy[2 * k + 2] = lazy[k];
	}
	lazy[k] = -1;
}
inline void update_node(int k) {
	dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
}
inline void update(int a, int b, int x, int k, int l, int r) {
	push(k);
	if (r <= a || b <= l)return;
	if (a <= l&&r <= b) {
		lazy[k] = x; push(k); return;
	}
	update(a, b, x, k * 2 + 1, l, (l + r) / 2); update(a, b, x, k * 2 + 2, (l + r) / 2, r);
	update_node(k);
}
inline int query(int a, int b, int k, int l, int r) {
	push(k);
	if (r <= a || b <= l)return INT_MAX;
	if (a <= l&&r <= b)return dat[k];
	int lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
	int rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
	update_node(k);
	return min(lb, rb);
}
int main() {
	int n, q; scanf("%d%d", &n, &q);
	N = 1; while (N < n)N <<= 1;
	rep(i, 2 * N - 1)dat[i] = INT_MAX, lazy[i] = -1;
	rep(i, q) {
		int t; scanf("%d", &t);
		if (t == 0) {
			int a, b, x; scanf("%d%d%d", &a, &b, &x);
			update(a, b + 1, x, 0, 0, N);
		}
		else {
			int a; scanf("%d", &a);
			printf("%d\n", query(a, a + 1, 0, 0, N));
		}
	}
}

Measured memory_bytes: 5296
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
	if p[i] < p[i+1] and p[i+1] < p[i+2] or p[i] > p[i+1] and p[i+1] > p[i+2]:
		cnt += 1
print(cnt)

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

using namespace std;

template <unsigned long long mod> class modint {
public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) {
				ret *= a;
			}
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint& u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

const int MOD = 998244353;
using mint = modint<MOD>;

const int MAX = 500005;
mint fact[MAX], invfact[MAX], inv[MAX];

void facinit() {
	fact[0] = fact[1] = 1;
	invfact[0] = invfact[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fact[i] = fact[i - 1] * i;
		inv[i] = -inv[MOD % i] * (MOD / i);
		invfact[i] = invfact[i - 1] * inv[i];
	}
}

mint nPr(int n, int r) {
	return fact[n] * invfact[n - r];
}

mint nCr(int n, int r) {
	if (n < 0 || r < 0 || n < r) return mint{0};
	return fact[n] * invfact[r] * invfact[n - r];
}

mint nHr(int n, int r) {
	if (n == 0 && r == 0) return mint{1};
	return nCr(n + r - 1, r);
}

template <class T> T fastpow(T a, long long p) {
	T tmp = a;
	T ret = 1;
	while (p) {
		if (p & 1) ret *= tmp;
		p >>= 1;
		tmp = tmp * tmp;
	}
	return ret;
}

class Solution {
public:
	void solve() {
		int n, m, k;
		cin >> n >> m >> k;
		facinit();
		mint ans = 0;
		for (int i = 0; i <= k; i++) {
			ans += nCr(n - 1, n - 1 - i) * m * fastpow(mint{m - 1}, n - 1 - i);
		}
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 15408
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
vector<int> to[maxn], tree[maxn];
int dist[maxn], par[maxn];
set<int> now;
void dfs(int u, int r){
	now.insert(u);
	bool bad = false, can = false;;
	for(int j : to[u]){
		if(now.count(j)){
			if(j != r){
				bad = true;
			} else {
				can = true;
			}
		}
	}
	if(bad){
		now.erase(u);
		return;
	}
	if(can){
		cout << now.size() << endl;
		for(int v : now) cout << v << endl;
		exit(0);
	}
	for(int  v: tree[u]) dfs(v, r);
	now.erase(u);
}
int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		to[a].push_back(b);
	}
	for(int i = 1; i <= n; i++){
		memset(dist, -1, sizeof(dist));
		memset(par, -1, sizeof(par));
		for(int j = 0; j <= n; j++) tree[j].clear();
		queue<int> q;
		dist[i] = 0;
		q.push(i);
		while(!q.empty()){
			int u = q.front(); q.pop();
			for(int v : to[u]){
				if(dist[v] == -1){
					dist[v] = dist[u] + 1;
					tree[u].push_back(v);
					q.push(v);
				}
			}
		}
		dfs(i, i);
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
def main():
    n = int(input())
    a = list(map(int, input().split()))

    a.sort()

    ans = 0
    sieve = [False for _ in range(1000001)]
    for i in range(n):
        if sieve[a[i]]:
            continue
        for j in range(a[i], 1000001, a[i]):
            sieve[j] = True
        if i > 0:
            if a[i] == a[i-1]:
                continue
        if i < n-1:
            if a[i] == a[i+1]:
                continue
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 164768
/* Volume2 */
import java.io.*;

class Main
{
  final static int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE };

  public static int stringSize(int x){
    for(int i=0; ; i++){
      if(x <= sizeTable[i]) return i+1;
    }
  }

  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()) != null){
        String[] input = str.split(" ");
        int sum = Integer.parseInt(input[0]) + Integer.parseInt(input[1]);
        sb.append(stringSize(sum)).append("\n");
      }
      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24260
N=int(input())
p=list(map(int,input().split()))
r=[i+1 for i in range(N)]
ans=False
for i in range(0,N-1):
    for j in range(i+1,N):
        p[i],p[j]=p[j],p[i]
        if p==r:
            ans=True
        #print(p)
        p[i], p[j] = p[j], p[i]
if p==r:
    ans = True
print('YES' if ans else 'NO')


Measured memory_bytes: 3064
s = input()
if s[0]!='A':
    if s[0:3] != 'KIH':
        print('NO')
        exit()
    s = s[3:]
elif s[0:4]!='AKIH':
    print('NO')
    exit()
else:
    s = s[4:]
# AKIH......
if s[0]!='A':
    if s[0]!='B':
        print('NO')
        exit()
    s = s[1:]
elif s[0:2]=='AB':
    s = s[2:]
else:
    print('NO')
    exit()
# AKIHAB...
if s[0]!='A':
    if s[0]!='R':
        print('NO')
        exit()
    s = s[1:]
elif s[0:2]=='AR':
    s = s[2:]
else:
    print('NO')
    exit()
# AKIHABAR.
if s=='A' or s=='':
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
char D[1002][1002];
int main() {
	int M,N;
	int R=0;
	char E[2][2];
	char b[4]={'S','J','O','I'};
	cin>>M>>N;
	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			cin>>D[i][j];
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			cin>>E[i][j];
		}
	}
	int a=0;
	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			if(D[i][j]==E[0][0]&&D[i+1][j]==E[1][0]&&D[i][j+1]==E[0][1]&&D[i+1][j+1]==E[1][1]){
				a+=1;
			}
		}
	}
	int c[4];

	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			b[0]=D[i][j];
			for(int k=0;k<4;k++){
				D[i][j]=b[k];
				c[k]=0;
				if(D[i][j]==E[0][0]&&D[i+1][j]==E[1][0]&&D[i][j+1]==E[0][1]&&D[i+1][j+1]==E[1][1])c[k]+=1;
				if(D[i-1][j]==E[0][0]&&D[i][j]==E[1][0]&&D[i-1][j+1]==E[0][1]&&D[i][j+1]==E[1][1])c[k]+=1;
				if(D[i][j-1]==E[0][0]&&D[i+1][j-1]==E[1][0]&&D[i][j]==E[0][1]&&D[i+1][j]==E[1][1])c[k]+=1;
				if(D[i-1][j-1]==E[0][0]&&D[i][j-1]==E[1][0]&&D[i-1][j]==E[0][1]&&D[i][j]==E[1][1])c[k]+=1;
			}
			D[i][j]=b[0];
			R=max(R,a+c[1]-c[0]);
			R=max(R,a+c[2]-c[0]);
			R=max(R,a+c[3]-c[0]);
		}
	}



	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 4056
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int w, h;
	while (cin >> w >> h, w)
	{
		bool wall[32][32][4];
		clear(wall, 0);
		for (int i = 0; i < 2 * h - 1; ++i)
		{
			bool f = i & 1;
			int y = i / 2;
			for (int j = 0; j < w - !f; ++j)
			{
				int t;
				cin >> t;
				if (!f)
					wall[y][j][1] = wall[y][j + 1][3] = t;
				else
					wall[y][j][0] = wall[y + 1][j][2] = t;
			}
		}

		int d[32][32];
		const int INF = 1 << 25;
		rep (y, h) rep (x, w)
			d[y][x] = INF;
		d[0][0] = 1;
		queue<pint> q;
		q.push(pint(0, 0));
		while (!q.empty())
		{
			pint t = q.front(); q.pop();
			int x = t.first, y = t.second;
			int nc = d[y][x] + 1;

			for (int i = 0; i < 4; ++i)
			{
				int nx = x + dx[i], ny = y + dy[i];
				if (0 <= nx && nx < w && 0 <= ny && ny < h
					&& !wall[y][x][i] && nc < d[ny][nx])
				{
					d[ny][nx] = nc;
					q.push(pint(nx, ny));
				}
			}
		}
		int res = d[h - 1][w - 1];
		if (res == INF)
			res = 0;
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n,m;
	cin>>n>>m;

	if(n==m)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}

}

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

const int MAX_N=1001;
const int mod=1000000007;
ll fact[MAX_N+1];
ll inv[MAX_N+1],finv[MAX_N+1];
int fact_init(ll n,ll p){
    if(fact[0]==0){
        fact[0]=1;
        FOR(i,1,n+1) fact[i]=fact[i-1]*i%p;
    }
    return 0;
}
int inv_init(ll n,ll p){
    inv[1]=1;
    fact[0]=fact[1]=finv[0]=finv[1]=1;
    FOR(i,2,n+1){
        inv[i]=p-(p/i)*inv[p%i]%p;
        fact[i]=fact[i-1]*i%p;
        finv[i]=finv[i-1]*inv[i]%p;
    }
    return 0;
}
ll comb_pow(ll n,ll k,ll p){
    if(k<0||n<k) return 0;
    //return finv[k]*finv[n-k]%p*fact[n]%p;
    return finv[n-k]*fact[n]%p;
}

ll dp[1001][1001];
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    inv_init(n,mod);
    dp[a-1][0]=1;
    FOR(i,a,b+1)FOR(j,0,n+1){
        dp[i][j]+=dp[i-1][j];
        dp[i][j]%=mod;
        ll mul=1;
        FOR(k,1,d+1){
            if(j-k*i>=0){
                mul*=finv[i];mul%=mod;
                if(k>=c){
                    dp[i][j]+=dp[i-1][j-k*i]*comb_pow(n-j+k*i,k*i,mod)%mod*mul%mod*finv[k]%mod;
                    dp[i][j]%=mod;
                }
            }
            else break;
        }
    }
    cout<<dp[b][n]<<endl;
    return 0;
}

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



int main(){
    vector <int> arr(4);
		int a = 0;
		for(int i = 0; i < 4; i++){
			cin >> arr[i];
		}
		sort(arr.begin(),arr.end());
		if(arr[0] == 1){
			if(arr[1] == 4){
				if(arr[2] == 7){
					if(arr[3] == 9){
						a = 1;
					}
				}
			}
		}
    if(a == 1){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

Measured memory_bytes: 256
N,K = map(int,input().split())
sum = 0
for b in range(1,N+1):
    q = N % b
    p = (N - q) //  b
    sum += p * max(0,b-K)
    sum += max(0,q-K+1)

if(K == 0):
    sum -= N
print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n;
    vector<int> t;
    int total {0};
    for (int i = 0; i < n; i++) {
        int T;
        cin >> T;
        t.push_back(T);
        total += t.at(i);
    }
    
    cin >> m;
    int p[m];
    int x[m];
    for (int j = 0; j < m; j++) {
        cin >> p[j] >> x[j];
    }
    
    for (int l = 0; l < m; l++) {
        cout << total - (t.at(p[l] - 1) - x[l]) << endl;
    } 
    return 0;
}

Measured memory_bytes: 384
// Aizu Vol0 0094: Calculation of Area
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b;

	while (scanf("%d%d", &a, &b) == 2) {
		printf("%lf\n", (double)a * (double)b / 3.305785);
	}
	return 0;
}

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

int main(){
  int n,x,array[101],ans=0;
  cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  sort(array,array+n);
  for(int i=0;i<n-1;i++){
    if(array[i]>x){
      break;
    }
    x-=array[i];
    ans++;
  }
  cout<<(x==array[n-1]?ans+1:ans)<<endl;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $N);

fscanf(STDIN, "%d %d", $T, $A);
$array = explode(" ", fgets(STDIN));

$result;
$min;
for ($j=0; $j < $N; $j++) {
	if ($min > abs($A - ($T - $array[$j] * 0.006)) || is_null($min)) {
		$result = $j+1;
		$min = abs($A - ($T - $array[$j] * 0.006));
	}	
}
echo $result;

Measured memory_bytes: 4728
a, b, c, x, y = [int(i) for i in input().strip().split(" ")]

z = min(x, y)
total = 0

if (a+b) > c*2:
    total += c * 2 * z
else:
    total += a * z + b * z

if (a < c * 2):
    total += (x-z) * a
else:
    total += (x-z) * c * 2

if (b < c * 2):
    total += (y-z) * b
else:
    total += (y-z) * c * 2

print(total)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>

int main()
{
  int count;
	std::cin >> count; std::cin.ignore();
	for(int i = 0 ; i < count ; i++)
    {
      	int value;
	  	std::cin >> value;

      	if(value % 2 != 0){
          continue;
        }

       	if(value % 3 != 0 && value % 5 != 0 ){
			std::cout << "DENIED" << std::endl;
         	std::exit(0);
        }

    }

	std::cout << "APPROVED" << std::endl;
}

Measured memory_bytes: 256
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
yymm = False
mmyy = False

if 1 <= s1 <= 12:
  mmyy = True
if 1 <= s2 <= 12:
  yymm = True

if mmyy and yymm:
  print('AMBIGUOUS')
elif mmyy:
  print('MMYY')
elif yymm:
  print('YYMM')
else:
  print('NA')


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

#define ll long long
#define endl "\n"
ll INF = 1e9 + 7;

int main(){
	ll n, w, sum = 0, ans = 0; cin>>n>>w;
	vector<pair<ll, ll>> v(n);
	for(auto &i : v){
		cin>>i.second>>i.first;
		sum += i.first;
	}
	vector<ll> dp(sum+1, INF);
	dp[0] = 0;
	for(ll i = 1; i<=n; i++){
		for(ll j = sum; j >= v[i-1].first; j--){
			dp[j] = min(dp[j], v[i-1].second + dp[j-v[i-1].first]);
			if(dp[j] <= w){
				ans = max(ans, j);
			}
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	int m = sqrt(N);
    cout<<m*m<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
const double eps = 1e-10;//????????????????????????

int main(){
	int N;
	vd a(8);
	cin >> N;
	rep(i,N){
		rep(i,8){
			cin>>a[i];
		}
		if(abs((a[1]-a[3])*(a[4]-a[6])-(a[5]-a[7])*(a[0]-a[2]))< eps){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

}

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

int main(){
  int N;cin>>N;
  int K[100010]={};
  int ans=0;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    if(a>100000)ans++;
    else K[a]++;
  }

  for(int i=1;i<=100000;i++){
    if(K[i]==0){
      continue;
    }else if(K[i]<i){
      ans+=K[i];
    }else if(K[i]>=i){
      ans+=K[i]-i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
// BISMILLAHIR RAHMANIR RAHEEM
// ALLAH IS WATCHING ME
// ALLAH save us from COVID-19.Amin.

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

/// Author : Md Mehraj Hossain 

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

using ll =long long;

int main(){
	int n;
	cin >> n;
	if(n>=1200){
		cout << "ARC\n";
	}
	else{
		cout << "ABC\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <iomanip>

using ll = long long;

int main() {
    int N, K;
    std::cin >> N >> K;

    double ans = 0.0;
    for (int i = 1; i <= N; i++) {
        int n = i;
        int p = 0;
        while (n < K) {
            n *= 2;
            p++;
        }
        double a = 1.0;
        while (p > 0) {
            a *= 0.5;
            p--;
        }
        a /= (double)N;
        ans += a;
    }
    std::cout << std::setprecision(14);
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
fn next_num(n: &String, x: usize) -> (u64, u64) {
    let keta = n.len();

    for i in x..keta {
        let a = n[i..i + 1].parse::<u64>().unwrap();
        if a != 0 {
            return (a, i as u64);
        }
    }
    (0, 0)
}

fn k2(n: &String, n_first: u64) -> u64 {
    let mut ans = 0;
    let (n_second, i2) = next_num(n, 1);
    let keta = n.len() as u64;

    ans += 9 * 9 * ((keta - 2) * (keta - 2 + 1) / 2); // keta-1桁までの数
    ans += (n_first - 1) * 9 * (keta - 1); // keta桁の先頭1つ目の数字より1つ少ないケース
    if n_second > 0 {
        ans += 9 * (keta - i2 - 1); // 先頭1つ目が上限値と同じケース、かつ二桁めが1少ないケース
        ans += n_second;
    }
    ans
}

fn main() {
    let n = read::<String>();
    let k = read::<u64>();
    let keta = n.len() as u64;
    let n_first = n[0..1].parse::<u64>().unwrap();

    let mut ans = 0;
    if k == 1 {
        ans = 9 * (keta - 1) + n_first;
    } else if k == 2 {
        ans += k2(&n, n_first);
    } else if k == 3 {
        let (n_second, i2) = next_num(&n, 1);

        for i in 2..keta - 1 {
            ans += 9 * 9 * 9 * i * (i - 1) / 2;
        }
        ans += (n_first - 1) * 9 * 9 * (keta - 1) * (keta - 2) / 2;

        if n_second > 0 {
            // 先頭1桁が固定(n_first)のケース
            ans += k2(&n[i2 as usize..].to_string(), n_second);
        }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#define MAX 251

int parent(int);
int left(int);
int right(int);
void insert(int);

int n;
int A[MAX];

int main()
{
  int i;
  int p;
  int l, r;

  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    {
      scanf("%d", &A[i]);
    }

  for(i = 1; i <= n; i++)
    {
      p = parent(i);
      l = left(i);
      r = right(i);

      printf("node %d: key = %d, ", i, A[i]);
      if(p >= 1)
	printf("parent key = %d, ", A[p]);
      if(l <= n)
	printf("left key = %d, ", A[l]);
      if(r <= n)
	printf("right key = %d, ", A[r]);
      printf("\n");
    }

  return 0;
}

int parent(int i)
{
  return i / 2;
}

int left(int i)
{
  return 2 * i;
}

int right(int i)
{
  return 2 * i + 1;
}

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

int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(d2 == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

using namespace std;

int main() {
  char co, ce;
  bool easy = true;
  while (cin >> co) {
    if (co == 'L') {
      easy = false;
      break;
    }
    cin >> ce;
    if (ce == 'R') {
      easy = false;
      break;
    }
  }

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


Measured memory_bytes: 256