akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());

        var flags = new List<uint>();

        var array = Console.ReadLine().Split(' ');

        foreach(var item in array)
        {
            flags.Add(uint.Parse(item));
        }

        var all = (uint)0;

        foreach(var item in flags)
        {
            all = all ^ item;
        }

        var ans = new List<uint>();

        foreach (var item in flags)
        {
            ans.Add(all^item);
        }

        foreach(var item in ans)
        {
            Console.WriteLine((int)item);
        }




        Console.ReadLine();

    }
}

Measured memory_bytes: 43572
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll> s(n);
  rep(i,n)cin>>s[i];
  s.erase(unique(all(s)),s.end());
  //rep(i,s.size())cout<<s[i];
  ll l=(ll)s.size();
  vector<ll>dp(l+1);
  dp[0]=1;
  vector<ll>stock(200001);
  ll mod=1e9+7;
  rep(i,l)
  {
    dp[i+1]=dp[i];
    if(i==0||s[i]!=s[i-1])
    {
      dp[i+1]+=stock[s[i]];
      dp[i+1]%=mod;

      stock[s[i]]+=dp[i];
      stock[s[i]]%=mod;
    }
  }
  cout<<dp[l]<<endl;

  return 0;

}


Measured memory_bytes: 4992
import fractions
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

def ABC(x,y,z):
    return z-(z//x+z//y-z//lcm(x,y))

a,b,c,d=map(int,input().split())
print(ABC(c,d,b)-ABC(c,d,a-1))

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int x, y, a;

  int w[] = {0,W};
  int h[] = {0,H};

  for (int i = 0; i < N; i++) {
    cin >> x >> y >> a;
    if(a == 1){
      w[0] = max(w[0], x);
    }else if(a == 2){
      w[1] = min(w[1], x);
    }else if(a == 3){
      h[0] = max(h[0], y);
    }else if(a == 4){
      h[1] = min(h[1], y);
    }
  }

  if(w[1] - w[0] > 0 && h[1] - h[0]){
    cout << (w[1] - w[0]) * (h[1] - h[0]) << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d %d\n%s\n" @@ fun n q s ->
  let acc = Array.make (n + 1) 0 in
  for i = 1 to n - 1 do
    acc.(i + 1) <- acc.(i) + (if s.[i - 1] = 'A' && s.[i] = 'C' then 1 else 0)
  done;
  for i = 0 to q - 1 do
    Scanf.scanf "%d %d\n" @@ fun l r ->
      Printf.printf "%d\n" @@ acc.(r) - acc.(l)
  done


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	map<string,int> m;
	while(n--)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<m.size()<<endl;
	return 0;
}

Measured memory_bytes: 19196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
static const ll mod = 1000000007;
# define INF (1 << 29)
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    string s;
    cin >> s;
    string year = "";
    string month = "";
    string day = "";
    for(int i=0; i<4; i++){
        year += s[i];
    }
    for(int i=5; i<7; i++){
        month += s[i];
        day += s[i+3];
    }
    int y = atoi(year.c_str());
    int m = atoi(month.c_str());
    int d = atoi(day.c_str());


    if(m <= 4) cout << "Heisei";
    else cout << "TBD";

    return 0;
}

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

int main(){
  int n,y;
  cin >> n >> y;
  long long aa=-1,bb=-1,cc=-1;
  
  for(long long a=0;a<=n;a++){
    for(long long b=0;a+b<=n;b++){
      if(y-10000*a-5000*b >= 0){
        int c = (y-10000*a-5000*b) / 1000;
        if(a+b+c == n){
          aa = a;
          bb = b;
          cc = c;
        }
      }
    }
  }
  
  cout << aa << " " << bb << " " << cc << endl;
  
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n, k = list(map(int, input().strip().split()))
    i = 0
    while n > 0:
        n //= k
        i += 1
    print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> pii;


bool pairCmp(const pii& lhs, const pii& rhs){
    return lhs.second < rhs.second;
} 
 
int main() {
    int N, M;
    cin >> N >> M;
    vector<pii> ab(M);
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(ab.begin(), ab.end(), pairCmp);

    int ans = 0;
    int prevCut = 0;
    for (int i = 0; i < M; i++) {
        if (ab[i].first > prevCut) {
            prevCut = ab[i].second - 1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int K;
    cin >> K;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            if((i % 2 == 0 && j % 2 == 1)|| (i % 2 == 1 && j % 2 == 0)){
                ans++;
            }
        }
    }
    cout << ans / 2 << endl;
    return 0;
    
}

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

int main() {
    int a, b;

    while( 1 ) {
        cin >> a >> b;
        if ( a == 0 && b == 0 ) break;

        for (int i = 0; i < a; i++) {
            for ( int n = 0; n < b; n++) {
                int s = i + n;
                if ( s % 2 == 1 ) {
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
s = gets.to_i
mod = 10**9 + 7
ans = 0

def combination(n, r)
  r = [r, n - r].min
  return 1 if r == 0

  (n - r + 1).upto(n).inject(:*) / 1.upto(r).inject(:*)
end

def repeated_combination(n, r)
  combination(n + r - 1, r)
end

1.upto(s / 3) { |i| ans += repeated_combination(i, s - i * 3) % mod }

puts ans % mod


Measured memory_bytes: 14968
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int n,k,a[N],ans;
vector<int> p,neg;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ans = OO;

    cin >> n >> k;

    for(int i=0;i<n;++i) {
        cin >> a[i];
        if(a[i]<0) neg.pb(-a[i]);
        else p.pb(a[i]);
    }

    sort(neg.begin(),neg.end());
    sort(p.begin(),p.end());

    for(int j=0;j<=p.size();++j) {

        int rem = k-j;
        int a=0,b=0;

        if(rem>neg.size()) continue;

        if(rem>0) {
            a = neg[rem-1];
        }

        if(j>0) {
            b = p[j-1];
        }

        if(a>b) swap(a,b);

        ans = min(ans,2*a+b);

    }

    cout << ans << '\n';

    return 0;

}

Measured memory_bytes: 1404
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;


const int MAX = 101;
const int SIZE = 1e5;

int main(){
  
    int n;
    cin >> n;
    vector <int> v(SIZE,0);
    for (int i = 1; i <= MAX; ++i){
        for (int j = 1; j <= MAX; ++j){
            for (int k = 1; k <= MAX; ++k){
                if (i*i + k*k + j*j + i*j + i*k + j*k <= 10000)
                v[i*i + k*k + j*j + i*j + i*k + j*k]++;
                
            }
        }
    }
    for (int i = 1; i <= n; ++i) cout << v[i] << endl;


}

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


public class B
{
	public static void Main()	
	{
		int N = Int32.Parse(Console.ReadLine());
		int K = Int32.Parse(Console.ReadLine());
		int ans = 1;
		for(int i = 0; i < N; i++)
		{
			if(ans < K)
			{
				ans *= 2;
			}
			else
			{
				ans += K;
			}
		}
		Console.WriteLine(ans);
	}
}





Measured memory_bytes: 13140
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;



int dp[100100];
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int x;
    cin >> x;
    dp[0] = 1;
    rep(i, x){
        if(!dp[i + 100]) dp[i + 100] = dp[i];
        if(!dp[i + 101]) dp[i + 101] = dp[i];
        if(!dp[i + 102]) dp[i + 102] = dp[i];
        if(!dp[i + 103]) dp[i + 103] = dp[i];
        if(!dp[i + 104]) dp[i + 104] = dp[i];
        if(!dp[i + 105]) dp[i + 105] = dp[i];
    }
    print(dp[x]);
    
}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    vector<int> v(4);
    for(int i=0; i<4; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    vector<int> x = {1, 4, 7, 9};
    if(v == x) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int r;
  cin >> r;

  cout << r*r << endl;

  return 0;
}


Measured memory_bytes: 888
from sys import stdin

if __name__ == '__main__':
    W, H, x, y = [int(x) for x in stdin.readline().rstrip().split()]

    max = (W * H) / 2

    if W / 2 == x and H / 2 == y:
        print(str(max) + " 1")
    else:
        print(str(max) + " 0")

Measured memory_bytes: 2940
while True:
    inp = raw_input().split()
    a = int(inp[0])
    b = int(inp[2])
    op = inp[1]
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a / b)
    elif op == '?':
        break

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

using namespace std;

inline void quit(){ exit(0); }

typedef long long ll;

ll mpow(ll _x, ll _y, ll _mod){
    if(_y==0) return 1;
    if(_y==1) return _x%_mod;
    if(_y&1) return (mpow(_x, _y-1, _mod)*_x)%_mod;
    ll _tmp = mpow(_x, _y>>1, _mod);
    return (_tmp*_tmp)%_mod;
}

int n, k;
vector<int> link[1002];
int parent[1002];
bool visited[1002];
vector<int> ans;
vector<int> rans;

struct data{
    int x, d;
    data(){}
    data(int x, int d): x(x), d(d){}
};
queue<data> que;

void getAns(int x){
    if(!x) return;
    ans.push_back(x);
    int tmp = parent[x];
    parent[x] = 0;
    getAns(tmp);
}

void bfs(int x){
    memset(parent, 0, sizeof(parent));
    memset(visited, 0, sizeof(visited));

    while(!que.empty()) que.pop();

    que.push(data(x, 0));
    while(!que.empty()){
        data tmp = que.front();
        que.pop();
        int tx = tmp.x, td = tmp.d;
        if(tx == x && td){
            ans.clear();
            getAns(x);
            reverse(ans.begin(), ans.end());
            ans.pop_back();

            if(rans.empty() || rans.size() > ans.size()) rans = ans;
            return;
        }

        for(auto &y: link[tx]){
            if(visited[y]) continue;
            visited[y] = 1;
            parent[y] = tx;
            que.push(data(y, td+1));
        }
    }
}

int main(){
    scanf("%d %d", &n, &k);
    for(int i=1; i<=k; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        link[x].push_back(y);
    }

    for(int i=1; i<=n; i++){
        bfs(i);
    }

    if(rans.empty()){
        printf("-1");
    }
    else{
        printf("%d\n", rans.size());
        for(int i=0; i<rans.size(); i++){
            printf("%d\n", rans[i]);
        }
    }
}


Measured memory_bytes: 384
def f(list,num):
    if list=="E":
        num[0],num[2],num[5],num[3] =num[3],num[0],num[2],num[5]
    elif list=="W":
        num[0],num[2],num[5],num[3] =num[2],num[5],num[3],num[0]
    elif list=="N":
        num[0],num[1],num[5],num[4]=num[1],num[5],num[4],num[0]
    else:
        num[0],num[1],num[5],num[4]=num[4],num[0],num[1],num[5]
L=list(map(int,input().split()))
A=list(str(input()))
for i in range(len(A)):
  f(A[i],L)
print(L[0])


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    ll k;cin>>k;
    vector<ll> v(n+1),dist(n);
    for(int i=0;i<n;i++)cin>>v[i];
    v[n]=k;
    //if(n==1){cout<<v[0];return 0;}
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)dist[i]=v[i+1]-v[i];
    ll ans=dist[0];
    for(int i=1;i<n;i++)ans=__gcd(ans,dist[i]);
    cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int n, k, m, c, x;
int d[11]={};
int ans, wei;
int main()
{
	cin >> n >> k;
	rep(i, k)
	{
		cin >> m;
		d[m]=1;
	}
	while(1)
	{
		c=n;
		ans=0;
		while(c!=0)
		{
			x=c%10;
			if(d[x]==1)
			{
				ans=1;
				break;
			}
			c=c/10;
		}
		if(ans==0)
		{
			cout << n << endl;
			break;
		}
		else
		{
			n++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
string str, str2;
int main() {
	int N, K, tmp;
	int ans = 0;
	cin >> N >> K;
	for (int i = 0;i < N;i++) {
		cin >> tmp;
		if (tmp >= K) {
			ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
import sys
A = int(input())
B = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
if(A>B):
    print("GREATER")
    sys.exit()
elif(A==B):
    print("EQUAL")
    sys.exit()
else:
    print("LESS")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll fac[500007], finv[500007], inv[500007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<500007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll p(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n]*finv[n-k]%mod;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n, m;
    cin >> n >> m;
    mint ans = 0;
    for(ll i = 0;i <= n;i++){
    	mint num = mint(com(n, i)) * mint(p(m - i, n - i));
    	if(i & 1) num = -num;
    	ans += num;
    }
    ans *= mint(p(m, n));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15356
from collections import defaultdict
n = int(input())
name_d = dict()
name_d["M"] = 0
name_d["A"] = 0
name_d["R"] = 0
name_d["C"] = 0
name_d["H"] = 0

for _ in range(n):
    s = input()
    if s[0] in "MARCH":
        name_d[s[0]] += 1
#print(name_d)
name_patturn = ["MAR", "MRC", "MCH", "MAH", "MAC", "MRH", "ARC", "ARH", "ACH", "RCH"]
ans = 0
for patturn in name_patturn:
    ans += name_d[patturn[0]]*name_d[patturn[1]]*name_d[patturn[2]]

print(ans)


Measured memory_bytes: 74792
import java.util.Scanner;
import java.util.Arrays;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
 
    long K = sc.nextLong();
    long P = 0L;
    long Dif = 1L;
 
    for(int i = 1; i <= K; i++){
      P += Dif;
      if(helper(P + Dif) > helper(P + 2 * Dif))
      Dif *= 10L;
      System.out.println(P);
    }
  }
  public static double helper(long n){
    double S = (double) n;
    double sum = 0.0;
    while(n != 0){
      sum += (double) n%10;
      n = n/10;
    }
    return S/sum;
  }
}

Measured memory_bytes: 21716
fun main(args: Array<String>?): Unit {
    while(true){
        val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && m == 0) return
        val computers = BooleanArray(n){false}
        computers[0] = true
        val record = Array(m){
            val (t, s, d) = readLine()!!.trim().split(' ').map{it.toInt() - 1}
            Triple(t, s, d)
        }.sortedBy(Triple<Int, *, *>::first)
        for ((_, s, d) in record) {
            computers[d] = computers[s] || computers[d]
        }
        println(computers.count{it})
    }
}


Measured memory_bytes: 117532
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    long long int lis[100001]={0};
    long long int ansa=0,ansb=0;
    for(int i=1;i<=N;i++){
        cin>>lis[i];
        lis[i]+=lis[i-1];
    }
    long long int a=0,b=0;
    for(int i=1;i<=N;i++){
        if(i==1){
            if(lis[i]<=0){
                a=1-lis[i];
                ansa+=1-lis[i];
            }
            if(0<=lis[i]){
                b=-1*(1+lis[i]);
                ansb+=1+lis[i];
            }
        }
        else if(i%2==0){
            if(0<=lis[i]+a){
                ansa+=1+lis[i]+a;
                a+=-1*(1+lis[i]+a);
            }
            if(lis[i]+b<=0){
                ansb+=1-(lis[i]+b);
                b+=1-(lis[i]+b);
            }
        }
        else{
            if(lis[i]+a<=0){
                ansa+=1-(lis[i]+a);
                a+=1-(lis[i]+a);
            }
            if(0<=lis[i]+b){
                ansb+=1+lis[i]+b;
                b+=-1*(1+lis[i]+b);
            }
        }
    }
    cout<<min(ansa,ansb)<<endl;
    return 0;
}


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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (YES) << endl;}else{cout << NO << endl;}
#define YES "YES"
#define NO "NO"

vector<int> v;

int main()
{
	long long i = 1;
	long long n;
	cin >> n;
	while (n) {
		long long nt = abs(n);
		int res = (nt & abs(i)) != 0 ? 1 : 0;
		v.pb(res);
		n -= res * i;
		i *= -2;
	}
	if (v.size() == 0) v.pb(0);
	reverse(all(v));
	for(int x : v) cout << x;
	cout << endl;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    long long int x;
    priority_queue<long long int> a;
    for(int i=0;i<n;i++){
        cin>>x;
        a.push(x);
    }
    while(m--){
        x=a.top()/2;
        a.pop();
        a.push(x);
    }
    long long int sum=0;
    while(!a.empty()){
        sum+=a.top();
        a.pop();
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1400
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS
struct qq{
    int a,b,c,d;
};
int n,m,q;
vector<qq> query;
map<vector<int>,int> mp;
void dfs(vector<int> &v,int last) {
    // debug(v.size());
    if(v.size() == n+1) {
        // debug(v.size(),n+1,q);
        int ans = 0;
        for(int i=0;i<q;i++) {
            int ai = query[i].a,bi = query[i].b,ci = query[i].c,di = query[i].d;
            if(v[bi]-v[ai] == ci) ans+=di;
        }
        // for(int i=0;i<100;i++) ans++;
        mp[v] = ans;
        return ;
    }
    for(int i=max(last,(int)1);i<=m;i++) {
        v.push_back(i);
        dfs(v,i);
        v.pop_back();
    }
}
vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
cin>>n>>m>>q;
FOR(i,0,q) {
    int  a,b,c,d;
    cin>>a>>b>>c>>d;
    query.push_back({a,b,c,d});
}
vector<int> v;
dfs(v,0);
int mx = 0;
for(auto it = mp.begin();it!=mp.end();it++) mx = max(mx,it->second);
cout<<mx;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 32492
import qualified Data.ByteString.Char8 as B
import qualified Data.Map              as M

main :: IO ()
main = do
  _ <- getLine
  s <- B.getLine
  print $ solve s

solve :: B.ByteString -> Integer
solve = pred . M.foldr (%*%) 1 . M.map succ . B.foldr (\c mp -> M.insertWith (+) c 1 mp) M.empty
  where
    x %*% y = ((x `mod` 1000000007) * (y `mod` 1000000007)) `mod` 1000000007

Measured memory_bytes: 10620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException{ 
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int i = 0, x;
            while (0 != (x = Integer.parseInt(br.readLine()))) {
                System.out.printf("Case %d: %d%n", ++i, x);
            }
        }
    }
}



Measured memory_bytes: 60388
s = raw_input()
if s[0] != 'A':
	print 'WA'
else:
	if s[-1] != 'A' and s[-1] != 'C' and not s[-1].islower():
		print 'WA'
	elif s[1] != 'A' and s[1] != 'C' and not s[1].islower():
		print 'WA'
	else:
		ss = s[2:-1]
		c = 0
		flag = True
		for sss in ss:
			if sss == 'C':
				c += 1
			else:
				if sss != 'A' and not sss.islower():
					flag = False
					break
		if c != 1:
			flag = False
		if flag:
			print 'AC'
		else:
			print 'WA'

Measured memory_bytes: 2692
int N,A[2<<17];
void sort_impl(int l,int r)
{
	if(r-l<=1);
	else if(r-l==2)
	{
		if(A[l+1]<A[l])
		{
			int tmp=A[l];
			A[l]=A[l+1];
			A[l+1]=tmp;
		}
	}
	else
	{
		int a=A[l];
		int b=A[(l+r)/2];
		int c=A[r-1];
		if((b<a)!=(b<c))
		{
			A[l]=b;
			A[(l+r)/2]=a;
		}
		else if((c<a)!=(c<b))
		{
			A[l]=c;
			A[r-1]=a;
		}
		int mid=l;
		int L=l,R=r-1;
		do{
			while(A[L]<A[mid])L++;
			while(A[mid]<A[R])R--;
			if(L<R)
			{
				int tmp=A[L];A[L]=A[R];A[R]=tmp;
				if(mid==L)mid=R;
				else if(mid==R)mid=L;
				L++;
				R--;
			}
			else if(L==R)L++,R--;
		}while(L<=R);
		sort_impl(l,L);
		sort_impl(L,r);
	}
}
void sort(int N)
{
	sort_impl(0,N);
}
main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",&A[i]),A[i]-=i;
	sort(N);
	long ans=0,mid=A[N/2];
	for(int i=0;i<N;i++)ans+=A[i]<mid?mid-A[i]:A[i]-mid;
	printf("%lld\n",ans);
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_77B(){
    int n;
    cin >> n;
    int max = 0;
    for(int i = 0; i*i <= n; i++){
        max = i*i;
    }
    cout << max << endl;
}

int main(void){
    solve_77B();
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll A[200010], B[200010];

int main(void){
    int N;
    cin >> N;
    for(int i=0; i<N; ++i) cin >> A[i] >> B[i];
    sort(A, A+N);
    sort(B, B+N);
    if(N&1) cout << B[N>>1]-A[N>>1]+1 << endl;
    else cout << (B[N>>1]+B[(N>>1)-1])-(A[N>>1]+A[(N>>1)-1])+1 << endl;
    return 0;
}


Measured memory_bytes: 6712
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] charArr = new char[H][W];
		String str;

		for (int i = 0; i < H; i++) {
			str = sc.next();
			for (int j = 0; j < W; j++) {
				charArr[i][j] = str.charAt(j);
			}
		}

		List<Integer> mRowPos = new ArrayList<>();
		List<Integer> mColPos = new ArrayList<>();
		boolean match;

		for (int i = 0; i < H; i++) {
			match = false;
			for (int j = 0; j < W; j++) {
				if (charArr[i][j] == '.') {
					match = true;
				} else {
					match = false;
					break;
				}
			}
			if (match == true) {
				mRowPos.add(i);
			}
		}

		for (int j = 0; j < W; j++) {
			match = false;
			for (int i = 0; i < H; i++) {
				if (charArr[i][j] == '.') {
					match = true;
				} else {
					match = false;
					break;
				}
			}
			if (match == true) {
				mColPos.add(j);
			}
		}
		
		for (int i = 0; i < H; i++) {
			if (mRowPos.contains(i)) {
				continue;
			}
			for (int j = 0; j < W; j++) {
				if (!mColPos.contains(j)) {
					System.out.print(charArr[i][j]);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 23636
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n, m;
	cin >> n >> m;
	int a[55] = {};
	int t = 0;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int r;
			cin >> r;
			a[r]++;
			if (a[r] == n)t++;
		}
	}
	cout << t << endl;
	return 0;

}

Measured memory_bytes: 256
# ABC145 D Knight
def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a

def comb_mod(n, k, mod):
    if k > n or k < 0:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod

x, y = map(int, input().split())
MOD = 10**9 + 7
if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
    print(0)
    exit()
i = (2 * x - y) // 3
j = (2 * y - x) // 3
print(comb_mod(i + j, i, MOD))


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#define MAXN 1000010
#define LL long long

const LL P=1000000007;

int n;
LL g[MAXN],sg[MAXN];

inline void update(LL &x,LL y){ x=(x+y)%P; }

int main(){
	scanf("%d",&n);
	g[0]=1;
	sg[0]=1;
	for(int i=1;i<=n;i++){
		g[i]=g[i-1];
		if(i>=3) g[i]=(g[i]+sg[i-3])%P;
		sg[i]=(sg[i-1]+g[i])%P;
	}
	LL ans=0;
	//a[n]=1
	update(ans,g[n-1]);
	for(int i=2;i<=n;i++){
		int j=n-i-1;
		if(j<0) j=0;
		update(ans,sg[n-2]-(j?sg[j-1]:0));
	}
	//a[n-1]=1
	update(ans,g[n-1]*(n-1));
	//else
	for(int i=0;i<=n-2;i++)
		update(ans,g[i]*(n-1)%P*(n-1));
	ans=(ans+P)%P;
	printf("%lld\n",ans);
}


Measured memory_bytes: 15744
gets
l=gets.split.map &:to_i
s=l.sort
c=0
l.size.times{|i|
  a=l.index t=s[i]
  n=0
  (n+=1;b=l.index s[a];c+=l[b];l[a],l[b]=l[b],l[a];a=b)while a>i
  c+=[t*n,t*2+s[0]*(n+2)].min
}
p c

Measured memory_bytes: 6124
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
int lcm(int x, int y) { return x/gcd(x, y)*y; }
int mod_pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) { res = res * x % MOD; } x = x * x % MOD; y >>= 1; } return res; }
int comb(int n, int k) { k = min(k, n - k); int nnn = 1; for (int i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } int kkk = 1; for (int i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
int to_int(string s) { int n = s.size(); int ans = 0; for (int i = 0; i < n; i++) { ans = ((ans * 10) + (s[i] - '0')) % MOD; } return ans; }
int DisitSum(int x){ int ret=0; while(x){ ret++;x/=10;} return ret; }
bool is_prime(int n) { for(int i = 2; i*i <= n; i++) { if (n % i == 0) return false; } return n != 1; }
int extgcd(int a, int b, int& x, int& y) { // ax+by = gcd(a,b) >> gcd(a,b)
    int d = a;
    if(d != 0) { d = extgcd(b, a%b, y, x); y -= (a/b)*x; }
    else { x = 1, y = 0; }
    return 0;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    int k=b/c+b/d-b/(lcm(c,d));
    // cout<<k<<endl;

    int l=(a-1)/c+(a-1)/d-(a-1)/(lcm(c,d));
    // cout<<l<<endl;

    cout<<(b-a+1)-(k-l)<<endl;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, a[101], b[101], c[101], d[101];

struct edge{ int to, cap, rev; };
vector<edge> G[210];
bool used[210];

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, 0, G[from].size()-1});
}

int dfs(int v, int t, int f){
	if(v==t) return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap>0){
			int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	while(1){
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if(!f) return flow;
		flow += f;
	}
} 

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0;i<n;i++){
		cin >> c[i] >> d[i];
	}
	int s = 2*n;
	int t = s+1;
	for(int i=0;i<n;i++){
		add_edge(s, i, 1);
	}
	for(int i=0;i<n;i++){
		add_edge(i+n, t, 1);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]<c[j]&&b[i]<d[j]){
				add_edge(i, n+j, 1);
			}
		}
	}

	cout << max_flow(s, t) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

int main() {
	string a, b; cin >> a >> b;
	sort(all(a));
	sort(rall(b));
	if (a < b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
h,w,a,b = map(int, input().split())

s = [['0' for j in range(w)] for i in range(h)]

for i in range(b):
  for j in range(a,w):
    s[i][j] = '1'

for i in range(b,h):
  for j in range(a):
    s[i][j] = '1'

for i in range(h):
  print (''.join(s[i]))


Measured memory_bytes: 17800
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      
      if(a == 1) a = 14;
      if(b == 1) b = 14;
      
      if(a == b) System.out.println("Draw");
      else if(a < b) System.out.println("Bob");
      else System.out.println("Alice");
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> p(n+1, vector<int>(3));
  rep(i,n) rep(j,3) cin >> p[i][j];
  vector<vector<ll>> dp(n+1, vector<ll>(3));
  rep(i,n) rep(j,3) rep(k,3) {
    if(j == k) continue;
    dp[i+1][j] = max(dp[i+1][j], dp[i][k] + p[i][j]);
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
  return 0;
}


Measured memory_bytes: 13996
// ALDS1_8_A.cpp
// Binary search trees - Binary Search Tree I

#include <iostream>
#include <vector>
using namespace std;
const int NIL = -1;
struct TreeNode {
    int val;
    TreeNode* lchild;
    TreeNode* rchild;
    //TreeNode* parent;
    TreeNode(int x): val(x), lchild(NULL), rchild(NULL) {}
};

void insert(TreeNode *&tree, TreeNode *node)
{
    if (tree) {
        TreeNode *tmp = tree;
        TreeNode *tmp2 = tmp;
        while (tmp != NULL) {
            tmp2 = tmp;
            if (node->val < tmp->val) {
                tmp = tmp->lchild;
            }
            else {
                tmp = tmp->rchild;
            }
        }
        if (node->val < tmp2->val) {
            tmp2->lchild = node;
        }
        else {
            tmp2->rchild = node;
        }
    }
    else {
        tree = node;
}
}

void inorder(TreeNode *tree) {
    if (!tree) return;
    inorder(tree->lchild);
    cout << " " << tree->val;
    inorder(tree->rchild);
}

void preorder(TreeNode *tree) {
    if (!tree) return;
    cout << " " << tree->val;
    preorder(tree->lchild);
    preorder(tree->rchild);
}

void print(TreeNode *tree) {
    inorder(tree);
    cout << endl;
    preorder(tree);
    cout << endl;
}

int main()
{
    int n;
    cin >> n;
    string cmd;
    int num;
    TreeNode *tree = NULL;
    while(n--) {
        cin >> cmd;
        if (cmd == "insert") {
            cin >> num;
            TreeNode *node = new TreeNode(num);
            insert(tree, node);
        }
        if (cmd == "print")
            print(tree);
    }
    return 0;
}

Measured memory_bytes: 18824
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());

		int X = parseInt(st.nextToken());

		if(X == 7 || X==5|| X==3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
int n, matrix[100001][3];
int dp[100001][3];

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> matrix[i][0] >> matrix[i][1] >> matrix[i][2];
	}
	dp[1][0] = matrix[1][0];
	dp[1][1] = matrix[1][1];
	dp[1][2] = matrix[1][2];
	for(int i = 2; i <= n; ++i){
		dp[i][0] = matrix[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = matrix[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = matrix[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
	return 0;
}

Measured memory_bytes: 5888
import java.util.Scanner

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

  val n = sc.nextInt

  val al = Seq.fill(n)(sc.nextInt)

  val div2 = al.filter(_ % 2 == 0)
  val (divOnly2, divOver4) = div2.partition(_ % 4 != 0)

  val oddCon      = n - div2.size
  val divOnly2Con = divOnly2.size
  val divOver4Con = divOver4.size

  val res =
    if(divOnly2Con >= 1) if( divOver4Con >= oddCon ) "Yes" else "No"
    else if(  divOver4Con + 1 >= oddCon ) "Yes" else "No"

  println(res)
}

/*
*
*
*
*
* */

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

int main (){
    string S;
    cin>>S;
    bool Check=true;
    if(!(S.at(0)=='A')){//Aチェック
        Check=false;
    }

    if(S.at(1)<91){
        Check=false;
    }
    int CCheck=0;

    for(int i=2; i<S.size()-1; i++){
        if(S.at(i)=='C'){
            CCheck ++;
        }
        else if(S.at(i)<91){
            Check=false;
            break;
        }

    }
    
    if(!(CCheck==1)){
        Check=false;
    }

    if(S.at(S.size()-1)<91){
        Check=false;
    }

    if(Check){
      	cout<<"AC"<<endl;
    }
  	else{
		cout<<"WA"<<endl;
    }
  
    

    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
llint p[100005];
void solve(){
  cin >> n;
  for(int i=1;i<=n;i++)cin >> p[i];
  int cnt=0;
  for(int i=1;i<=n;i++){
    if(i==p[i]){
      swap(p[i],p[i+1]);
      cnt++;
    }
  }
  cout << cnt << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n,m,alla=0;
    cin>>n>>m;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        alla+=a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    if(a[m-1]*(4*m)<alla) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 3632
import heapq


def pad(p):
    n = 1
    q = p
    while True:
        q = q // 10
        if q == 0:
            break
        n += 1
    return "0" * (6 - n) + str(p)


n, m = list(map(int, input().split(' ')))
ps = []
ys = []
year_ids = {}
heaps = {}
for i in range(m):
    p, y = list(map(int, input().split(' ')))
    ps.append(p)
    ys.append(y)
    if p not in heaps:
        heaps[p] = []
        year_ids[p] = {}
    heapq.heappush(heaps[p], y)



for p in heaps:
    yid = 1
    while True:
        if len(heaps[p]) == 0:
            break
        y = heapq.heappop(heaps[p])
        year_ids[p][y] = yid
        yid += 1


for i in range(m):
    p = ps[i]
    y = ys[i]
    x = year_ids[p][y]
    print(pad(p) + pad(x))

Measured memory_bytes: 71660