akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const ll maxn = 100;

int main(){
    
    int n,k;
    cin >> n>>k;
    
    if((n-1)*(n-2)/2<k){
        cout << -1<<endl;
    }else{
        
        int rest = (n-2)*(n-1)/2-k;
        cout << n-1+rest<<endl;
        
        for(int i=2;i<=n;i++){
            cout << 1 <<' '<<i<<endl;
        }
        bool key=false;
        
        for(int i=2;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                
                if(rest>0){
                    cout << i<<' '<<j<<endl;
                    rest--;
                }else{
                    key=true;
                    break;
                }
                
            }
            if(key)break;
        }
        
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
//const ll big=1000000007LL;
const ll big=1777777777LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

  int n,m;cin >> n >> m;
  vector<ll> a(n),b(m);
  rep(i,n)cin >> a[i];
  rep(i,m)cin >> b[i];
  
  vector<ll> ans=convolution(a,b);
  rep(i,ans.size())cout << ans[i] << " \n"[i+1==ans.size()];
}

Measured memory_bytes: 27252
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int m,N;cin>>N;
  vector<long long int>A(N);
  cin>>A.at(0);
  for(int i=1;i<N;i++){
    cin>>m;A.at(i)=A.at(i-1)+m;
  }
  m=fabs(A.at(N-1)-2*A.at(0));
  for(int i=1;i<N;i++){
    long long int f=A.at(i-1),x=A.at(i)-A.at(i-1),b=A.at(N-1)-A.at(i);
    x=fabs(fabs(f-b)-x);
    m=min(m,x);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 1792
N=int(input())
H=list(map(int,input().split()))
cnt=0
left=0
ans=0

while left<N-1:
  #print(cnt,H[left],H[left+1])
  if H[left+1]<=H[left]:
    cnt+=1
    left+=1
  else:
    ans=max(ans,cnt) 
    cnt=0
    left+=1

ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

int dp[10], nxt[10];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, kk;
    cin >> h >> w >> kk;
    dp[0] = 1;
    rep(i, 0, h){
        rep(j, 0, 10) nxt[j] = 0;
        for(int j = 0; j < (1 << (w - 1)); j++){
            bool valid = true;
            for(int k = 0; k < w - 2; k++){
                if(j & (1 << k)){
                    if(j & (1 << (k + 1))){
                        valid = false;
                    }
                }
            }
            if(!valid) continue;
            rep(k, 0, w){
                if(j & (1 << k)){
                    (nxt[k + 1] += dp[k]) %= mod;
                    continue;
                }
                if(k > 0 && j & (1 << (k - 1))){
                    (nxt[k - 1] += dp[k]) %= mod;
                    continue;
                }
                (nxt[k] += dp[k]) %= mod;
            }
        }
        swap(dp, nxt);
    }
    cout << dp[kk - 1] << endl;
}

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

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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  ll ans = pow(10,9);
  rep(i, n-k+1) {
    ans = min(ans, h[i+k-1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}

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

long long a,b,c,d,e,f,x,y;

int main()
{
	scanf("%lld %lld %lld %lld %lld %lld",&a,&b,&c,&d,&e,&f);
	a=a*100;b=b*100;
	for(int i=0;i<=f;i+=a){
		for(int j=0;i+j<=f;j+=b){
			for(int k=0;i+j+k<=f;k+=c){
				for(int l=0;i+j+k+l<=f;l+=d){
					long long w=i+j;
					long long s=k+l;
					if(s*100>w*e)continue;
					if(w+s==0)continue;
					if(y==0){
						x=w+s;y=s;
					}else if(y*(w+s)<s*x){
						x=w+s;y=s;
					}
				}
			}
		}
	}
	printf("%lld %lld\n",x,y);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr char sp = ' ';

ll N, res;

ll f(ll x, ll p) {
	while (x%p == 0)x /= p;
	return x%p;
}

int main() {
	cin >> N;
	vector<ll>v;
	for (ll i = 1; i*i <= N; i++) {
		if (N%i == 0) {
			v.push_back(i);
			v.push_back(N / i);
		}
		if ((N - 1) % i == 0) {
			v.push_back(i);
			v.push_back((N - 1) / i);
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for (ll l : v) {
		if (l == 1)continue;
		if (f(N, l) == 1)res++;
	}
	cout << res << endl;
}

Measured memory_bytes: 384
//PDF解説に倣ってDP
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,m,a,b,c;
  cin>> n >> m;
  vector<pair<int,bitset<12>>> key(m);
  for (int i=0; i<m; i++){
    cin>> a >> b;
    key[i]=make_pair(a,0);
    for (int j=0; j<b; j++){
      cin>> c;
      key[i].second.set(c-1);
    }
  }
  
  n=pow(2,n); //箱の数->箱の状態数
  vector<int> dp(n,100000001); //dp[i] iの状態にできる最小費用,不可能な時 100000001
  dp[0]=0;
  for (int i=0; i<m; i++){ //鍵を一本ずつ増やす
    bitset<12> s;
    tie(a,s)=key[i];
    for (int j=0; j<n; j++){
      if (dp[j]==100000001) continue;
      bitset<12> t(j);
      c=(t|s).to_ullong();
      dp[c]=min(dp[c],dp[j]+a);
    }
  }
  
  int ans=dp[n-1];
  if (ans==100000001) ans=-1;
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;


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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j,h;
    ll Q,N,K,M;
    
    long double a, b;
    long double x;

    vector<ll> aa;
    string S;

    ll flag=0;
    ll temp=0;

    cin  >>N>>M;

    for(i=0;i<M;i++){
        cin>>Q;
        count=count+Q;
    }
    if (N<count){
        cout<<-1<<endl;
    }else{
    cout<<N-count<<endl;
    }


    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<math.h>
using namespace std;
typedef long long ll;
ll INF = 100000000000;
const int maxn = 1005;
ll a[305][305];
ll zuizhongtu[305][305];
struct Edge {
	ll from, to, dist;

	Edge(ll u, ll v, ll d) : from(u), to(v), dist(d) {}
};

struct HeapNode {
	ll d, u;

	bool operator<(const HeapNode &rhs) const {
		return d > rhs.d;
	}
};

struct Dijkstra {
	ll n, m;
	vector <Edge> edges;
	vector<ll> G[maxn];
	bool done[maxn];
	ll d[maxn];
	ll lushu[maxn];
	ll p[maxn];
	vector<ll> path;

	void init(ll n) {
		this->n = n;
		for (ll i = 0; i < n; i++) G[i].clear();
		edges.clear();
		path.clear();
	}

	void addEdge(ll from, ll to, ll dist) {
		edges.push_back(Edge(from, to, dist));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	void dijkstra(ll s) {
		priority_queue <HeapNode> Q;
		for (ll i = 0; i <= n; i++) d[i] = INF;
		for (ll i = 0; i <= n; i++) lushu[i] = 0;
		d[s] = 0;
		memset(done, 0, sizeof(done));
		Q.push((HeapNode) {
			0, s
		});
		while (!Q.empty()) {
			HeapNode x = Q.top();
			Q.pop();
			ll u = x.u;
			if (done[u]) continue;
			done[u] = true;
			for (ll i = 0; i < G[u].size(); i++) {
				Edge &e = edges[G[u][i]];
				if (d[e.to] > d[u] + e.dist) {
					d[e.to] = d[u] + e.dist;
					lushu[e.to] = lushu[u] + 1;
					p[e.to] = G[u][i];
					Q.push((HeapNode) {
						d[e.to], e.to
					});
				} else {
					if(d[e.to] == d[u] + e.dist) {
						lushu[e.to] = max(lushu[e.to],lushu[u] + 1);
					}
				}
			}
		}
	}

	void findpath(ll x, ll end) {
		path.clear();
		path.push_back(x);
		findd(x, end);
	}

	void findd(ll x, ll end) {
		if (x == end)
			return;
		else {
			path.push_back(this->edges[this->p[x]].from);
			findd(this->edges[this->p[x]].from, end);
		}
	}
};

int main() {
	ll n;
	scanf("%lld",&n);
	Dijkstra dj;
	dj.init(n);
	for(ll i=0; i<n; i++) {
		for(ll j=0; j<n; j++) {
			scanf("%lld",&a[i][j]);
			zuizhongtu[i][j] = a[i][j];
			if(i != j)
				dj.addEdge(i,j,a[i][j]);
		}
	}
	bool flag = true;
	for(ll i=0; i<n; i++) {
		dj.dijkstra(i);
		for(ll j=0; j<n; j++) {
			if(a[i][j] > dj.d[j])	flag = false;
			if(dj.lushu[j] > 1) {
				zuizhongtu[i][j] = 0;
				zuizhongtu[j][i] = 0;
			}
		}

	}
	if(!flag)	printf("-1\n");
	else {
		ll daan = 0;
		for(ll i=0; i<n; i++) {
			for(ll j=0; j<n; j++) {
				daan += zuizhongtu[i][j];
			}
		}
		printf("%lld\n",daan / 2);
	}
	return 0;
}


Measured memory_bytes: 6700
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            WriteLine(string.Join("", ReadLine().Select(c => c == '9' ? '1' : '9')));
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

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

using namespace std;
string enumerate(int,int,int,int);
bool consistent_order(string);

char datas[50][50];
int data;
char moji;
int min_x[256];
int max_x[256];
int min_y[256];
int max_y[256];
string include_moji[256];

int main(){
  int h,w,tmp;
  while(cin >> tmp){
    for(int kaisu=0;kaisu<tmp;kaisu++){
      cin >> h >> w;
      
      for(int i=0;i<256;i++){
	min_x[i] = max_x[i] = min_y[i] = max_y[i] = -1;
      }
      
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  cin >> datas[i][j];
	  data=int(datas[i][j]);
	  if(min_x[data]==-1){
	    min_x[data] = max_x[data] = i;
	    min_y[data] = max_y[data] = j;
	  }
	  if(max_x[data] < i){
	    max_x[data] = i;
	  }else if(min_x[data] > i){
	    min_x[data]  = i;
	  }
	  if(max_y[data] < j){
	    max_y[data] = j;
	  }else if(min_y[data] > j){
	    min_y[data]  = j;
	  }
	}
      }

      
      string enume = enumerate(0,0,w-1,h-1);
      sort(enume.begin(), enume.end());

      if(enume == "."){
	cout << "SAFE" << endl;
      }else{

	if(enume[0]=='.'){
	  enume.erase(0,1);

	}

	string all =" ";
	
	for(unsigned int k=0;k<enume.size();k++){
	  moji = enume[k];
	  all+=enumerate(min_y[moji],min_x[moji],max_y[moji],max_x[moji]);
	}
	
	if(all.find('.') != string::npos){ //àµ·û`àÉ.ª Á½çAâßé
	  cout << "SUSPICIOUS" << endl;
	}else{
	  for(unsigned int k=0;k<enume.size();k++){
	    moji = enume[k];
	    include_moji[moji] = enumerate(min_y[moji],
					   min_x[moji],max_y[moji],max_x[moji]);
	  }
	  if(!consistent_order(enume)){
	    cout << "SUSPICIOUS" << endl;
	  }	
	}
      }
    }    
  }
}


string enumerate(int left, int top, int right, int bottom){
  string all="";
  for(int i=top;i <= bottom; i++){
    for(int j=left;j <= right;j++){
      //±ÌªÌL@ªöµ¢ ±±©ç
      if(all.find(datas[i][j])==string::npos){
	all += datas[i][j];
	//±±ÜÅ
      }
    }
  }
  return all;	
}

bool consistent_order(string order){
  int i;
  int order_size = order.size();
  do{
    for(i=0 ; i<order_size;i++){
      string wa = "";
      
      for(int j=i+1;j<order_size;j++){
	wa += include_moji[order[j]];	
      }
      
      if(wa.find(order[i])!= string::npos){
	break;
      }
    }
    if(i==order_size){
      cout <<"SAFE" << endl;
      return true;
    }
  }while(next_permutation(order.begin(),order.end()));
  return false;
}

Measured memory_bytes: 924
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        int d = inp.nextInt();
        System.out.println((a - c) * (b - d));
        inp.close();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
  int p[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << p[K - 1] << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static final int mod = 1000000007;
  public static final int fmax = 1000007;
  public static long fac[] = new long[fmax];
  public static long inv[] = new long[fmax];
  public static long finv[] = new long[fmax];
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = Integer.parseInt(sc.next());
    int y = Integer.parseInt(sc.next());
    
    int u = 0;
    int v = 0;
    int ai = 0;
    int aj = 0;
    boolean flg = false;
    int k = 0;
    
    NCRinit();
    
    if((x+y)%3 == 0){
      k = (x+y)/3;
    } else {
      System.out.println("0");
      return;
    }
    
    for(int i=-x; i<=x; i++){
      u = 2*i;
      v = i;
      if(u==x-(k-i) && v==y-2*(k-i)){
        flg = true;
        ai = i;
        aj = k-i;
      }
      if(flg) break;
    }
    
    if(ai < 0 || aj < 0 || !flg){
      System.out.println("0");
      return;
    }
    
    long ans = ncr(ai+aj, ai);
    
    System.out.println(ans);
    
  }
  
  // テーブルを作る前処理
  public static void NCRinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < fmax; 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;
    }
  }

  // 二項係数計算
  public static long ncr(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
  
}


Measured memory_bytes: 47828
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


ll kaijo(ll n){
  ll ret = 1;
  rep(i,n+1){
    if(i==0) continue;
    ret *= i;
    ret %= 1000000007;
  }
  return ret;
}


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

  ll M,N ;cin >> M >> N ;

  if(abs(M-N) >1 ) {
    cout <<"0" << endl;
    return 0;
  }
  
  ll ans = 1;
  ans *= kaijo(M); ans %= 1000000007;
  ans *= kaijo(N); ans %= 1000000007;
  if(M==N) ans *= 2; ans %= 1000000007;
  cout  << ans << endl;


  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 105;

int n;
char S[MAXN];

int main() {
    scanf(" %s", S);
    n = strlen(S);

    for (int i = 0; i < n; i++) {
        if (i % 2 == 1 && S[i] == 'R') {
            printf("No\n");
            return 0;
        } else if (i % 2 == 0 && S[i] == 'L') {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
import math

A, B, H, M = map(int, input().split())

def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d
  
x1 = A * math.cos((30*H + M/2)/360*2*math.pi)
y1 = A * math.sin((30*H + M/2)/360*2*math.pi)
  
x2 = B * math.cos(6*M/360*2*math.pi)
y2 = B * math.sin(6*M/360*2*math.pi)
#print(x1, y1, x2, y2)

print(get_distance(x1, y1, x2, y2))

Measured memory_bytes: 9540
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

string S;
signed main(){
	cin >> S;
	rep(i, S.size()) cout << "x";
	cout << endl;
}

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

int N, M;
vector<pair<int, int>> edges[100000];
vector<int64_t> V[100000];
bitset<100000> visited;

vector<int64_t> MODS = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093, 1000000097, 1000000103, 1000000123, 1000000181};

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a, int64_t MOD){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

void dfs(int i, int par, vector<int64_t> v){
    if(visited[i]){
        if(v != V[i]){
            cout << "No" << endl;
            exit(0);
        }else{
            return;
        }
    }
    visited[i] = 1;
    V[i] = v;
    for(auto& p : edges[i]) if(p.first != par){
        int64_t c = p.second;
        vector<int64_t> v2(10);
        for(int j=0; j<10; j++){
            v2[j] = (c > 0 ? c : inv_mod(-c, MODS[j])) * v[j] % MODS[j];
        }
        dfs(p.first, i, v2);
    }
}

int main(){
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a, b, x;
        cin >> a >> b >> x;
        a--; b--;
        edges[a].emplace_back(b, x);
        edges[b].emplace_back(a, -x);
    }
    for(int i=0; i<N; i++) if(!visited[i]){
        vector<int64_t> v(10, 1);
        dfs(i, -1, v);
    }
    cout << "Yes" << endl;
    return 0;
}



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

int charint(char x) {
  string str = "0123456789";
  for (int i=0;i<10;i++) {
    if (x==str[i]) {
      return i;
    }
  }
}

int main() {
  string N;
  cin >> N;
  int X=0;
  for (int i=0;i<N.size(); i++) {
    X+=charint(N[i]);
    X%=9;
  }
  if (X==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define fresh                  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}


int main()
{
    //fresh;
    int n;
    scanf("%d",&n);
    if(n>=1 && n<= 999)puts("ABC");
    else if(n>= 1000 && n<=1998)puts("ABD");

}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    vector<int> ans(300005);
    int maxi = 0;
    for(int i = 1;i<=200;i++){
        for(int j = 1;j<=200;j++){
            for(int k = 1;k<=200;k++){
                int sum = i*i+j*j+k*k+i*j+j*k+k*i;
                maxi = max(maxi,sum);
                ans.at(sum)++;
            }
        }
    }
    //cout << maxi << endl;
    for(int i = 1;i<=N;i++) cout << ans.at(i) << endl;
}


Measured memory_bytes: 4516
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<bool> a_bool(8,false);
  int complement = 0;
  REP(i, N) {
    cin >> a[i];
    if (a[i] / 400 < 8) {
      a_bool[a[i] / 400] = true;
    } else {
      complement++;
    }
  }
  int ans = 0;
  REP(i, 8) {
    if (a_bool[i]) ans++;
  }
  if (ans != 0) {
    cout << ans << " " << ans + complement << endl;
  } else {
    cout << 1 << " " << ans+complement<< endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a[10],i,j,b;
for(i=0;i<10;i++){
	scanf("%d",&a[i]);
}
for(i=0;i<9;i++){
	for(j=0;j<9;j++){
		if(a[j] < a[j+1]){
			b=a[j];a[j]=a[j+1];a[j+1]=b;
		}
	}
}


printf("%d\n%d\n%d\n",a[0],a[1],a[2]);

return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

string a,b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b;
    int n=a.size(),p1=0;
    int m=b.size(),p2=0;
    for(int i=1;i<=n+m;i++)
    {
        if(i%2)
            cout<<a[p1++];
        else
            cout<<b[p2++];
    }
    cout<<"\n";
    return 0;
}
/**

**/


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, c, ans=0;

    scanf("%d%d%d", &a, &b, &c);

    while(b>0){
        if(b<a) break;
        b=b-a;
        ans++;
        if(ans==c) break;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
   int h,w,n;

   int h_a,w_a;

   scanf("%d",&h);
   scanf("%d",&w);
   scanf("%d",&n);

    if(n%h==0)
    {
        h_a=n/h;
    }
    else
    {
        h_a=n/h+1;
    }
    if(n%w==0)
    {
        w_a=n/w;
    }
    else
    {
        w_a=n/w+1;
    }

    if(h_a<w_a)
    {
        printf("%d",h_a);
    }
    else
    {
        printf("%d",w_a);
    }
    


    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
struct Matrix {
	int n,m; ll dp[55][55];
	void init(int x,int y) {
		n=x; m=y;
		memset(dp,0,sizeof(dp));
	}
	friend Matrix operator * (Matrix t1,Matrix t2) {
		Matrix res; res.init(t1.n,t2.m);
		for (int i=1;i<=t1.n;i++)
		for (int j=1;j<=t2.m;j++)
		for (int k=1;k<=t1.m;k++)
			res.dp[i][j]=(res.dp[i][j]+t1.dp[i][k]*t2.dp[k][j])%mod;
		return res;
	}
} A,B;
int n;
ll y,ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	read(y);
	A.init(n,n);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++) read(A.dp[i][j]);
	B.init(n,n);
	for (int i=1;i<=n;i++) B.dp[i][i]=1;
	while (y) {
		if (y&1) B=B*A;
		A=A*A; y/=2;
	}
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++) ans=(ans+B.dp[i][j])%mod;
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define ll long long
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>

int main() {
	int n, m, k, ans;
	char a[110][110];
	char b[110][110];
	mf_graph<int> g(10002);
	rep(i, 110) {
		rep(j, 110) {
			a[i][j] = 0;
			b[i][j] = 0;
		}
	}
	k = 0;
	cin >> n >> m;
	rep(i, n)cin >> a[i];

	rep(i, n) {
		rep(j, m) {
			b[i][j] = a[i][j];
			if (a[i][j] == '.') {
				if ((i + j) & 1) {
					g.add_edge(10000, m*i + j, 1);
					k++;
				}
				else {
					g.add_edge(m*i + j, 10001, 1);
					k++;
				}
			}
		}
	}
	rep(i, n) {
		rep(j, m-1) {
			if ((a[i][j] == '.')&&(a[i][j+1] == '.')) {
				if ((i + j) & 1) {
					g.add_edge(m*i + j, m*i + j + 1, 1);
				}
				else {
					g.add_edge(m*i + j + 1, m*i + j, 1);
				}
			}
		}
	}
	rep(i, n-1) {
		rep(j, m) {
			if ((a[i][j] == '.') && (a[i+1][j] == '.')) {
				if ((i + j) & 1) {
					g.add_edge(m*i + j, m*i + j + m, 1);
				}
				else {
					g.add_edge(m*i + j + m, m*i + j, 1);
				}
			}
		}
	}
	ans = g.flow(10000, 10001);
	rep(i, n) {
		rep(j, m - 1) {
			if ((a[i][j] == '.') && (a[i][j + 1] == '.')) {
				if ((g.get_edge(k)).flow) {
					b[i][j] = '>';
					b[i][j + 1] = '<';
				}
				k++;
				}
			}
		}
	rep(i, n-1) {
		rep(j, m) {
			if ((a[i][j] == '.') && (a[i+1][j] == '.')) {
				if ((g.get_edge(k)).flow) {
					b[i][j] = 'v';
					b[i+1][j] = '^';
				}
				k++;
			}
		}
	}
	cout << ans << endl;
	rep(i, n) {
		cout << b[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> a(1000001, 0);
    for (int i = 0; i < n; ++i) {
        int aa;
        cin >> aa;
        a[aa]++;
    }
    for (lint i = 1000000; i >= 1; --i) {
        if (a[i] != 0) {
            lint j = i * 2;
            while (j <= 1000000) {
                a[j] = 0;
                j += i;
            }
        }
    }
    lint ret = 0;
    for (int i = 1; i <= 1000000; ++i) {
        if (a[i] == 1) {
            ret++;
        }
    }

    cout << ret << "\n";
    return 0;
}

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

int main(){
  int d,t,s;
  cin >> d >> t >> s;
  if(d<=s*t) cout << "Yes";
  else cout << "No";
  
  return 0;
}

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

typedef pair<int,int> P;

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        vector<vector<P> > V(N);
        for (int i = 0; i < M; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            V[a].push_back(P(c, b));
            V[b].push_back(P(c, a));
        }

        priority_queue<P, vector<P>, greater<P> > que;
        vector<int> used(N);
        que.push(P(0, 0));

        int sum = 0;
        while (que.size()) {
            P p = que.top(); que.pop();
            int now = p.second;
            int cost = p.first;

            if (used[now]) continue;
            used[now] = true;
            sum += cost;

            for (auto i : V[now]) {
                que.push(i);
            }
        }

        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3016
n=int(input())
a=['a','b','c','d','e','f','g','h','i','j']

def dfs(s, count):
    if len(s) == n:
        print(s)
        return
 
    for z in range(count + 1):
        dfs(s + a[z], count + 1 if z == count else count)

dfs("",0) 


Measured memory_bytes: 4340
#include <iostream>

using namespace std;
long long a[20][20],sc[1<<16],dp[1<<16];
int main(){
	int i,j,k,n;
	cin >> n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin >> a[i][j];
		}
	}
	for(k=0;k<(1<<n);k++){
		long long x = 0;
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				if((k&(1<<i)) && (k&(1<<j))){
					x += a[i][j];
				}
			}
		}
		sc[k] = x;
		dp[k] = -1000000000000000000;
	}
	dp[0] = 0;
	for(i=0;i<(1<<n);i++){
		k = i^((1<<n)-1);
		for(j=k;j>0;j=(j-1)&k){
			dp[i|j] = max(dp[i|j],dp[i] + sc[j]);
		}
	}
	cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define mn 1000000007
int parent(int u) {
	return u / 2;
}
int left(int u) {
	return u * 2;
}
int right(int u) {
	return u * 2 + 1;
}
void maxHeap(int u,vi& A) {
	int l = left(u);
	int r = right(u);
	int max_ = u;
	if (l < A.size() && A[l]>A[max_]) max_ = l;
	if (r < A.size() && A[r]>A[max_]) max_ = r;
	if (max_!=u) {
		swap(A[u],A[max_]);
		maxHeap(max_,A);
	}
}
void heapInKey(int i,vi& A) {
	while (i>1&&A[i]>A[parent(i)]) {
		swap(A[i],A[parent(i)]);
		i = parent(i);
	}
}
void insert(int key,vi& A) {
	A.push_back(key);
	heapInKey(A.size()-1,A);
}
int extract(vi& A) {
	if (A.size()<=1)return 0;
	int temp = A[1];
	A[1] = A[A.size()-1];
	A.pop_back();
	maxHeap(1,A);
	return temp;
}
int main() {
	vi A(1);
	while (true) {
		string o = "";
		cin >> o;
		if (o == "end")break;
		if (o=="insert") {
			int key;
			cin >> key;
			insert(key,A);
		}
		else {
			cout<<extract(A)<<endl;
		}
	}
};




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

int main() {
    int i,j,c=0;
    char a[3],b[3];
    for(i=0;i<3;i++){
        cin>>a[i];
    }
    for(j=0;j<3;j++){
        cin>>b[j];
    }
    for(i=0;i<3;i++){
        if(a[i]==b[i]){
            c++;
        }
    }
    cout<<c;
	return 0;
}

Measured memory_bytes: 256
(function() {
    'use strict';

    var lines = [];
    require('readline').createInterface({
      input: process.stdin,
      output: process.stdout
    }).on('line', function(line) {
      lines.push(line);
    });
    process.stdin.on('end', function() {
      //lines.forEach(function(line) {
        //var tokens = line.split(' ').map(Number);
        //    console.log(tokens[0] + ' ' + tokens[1]);
      //}
      //)
      ;

    // ToDo start
      var inLines = lines[0].split(" ")

      var keta = (inLines+'').length
      var insum = 0;

      for (var i=0;i<keta;i++){
        insum+=parseInt((inLines+'')[i])
      }

      var amari = inLines % insum;
//      console.log(insum)
      if (amari == 0) {
          console.log("Yes")
      } else {
        console.log("No")
        
      }
      
//      console.log( Math.pow(parseInt(lines[0]),2) - parseInt(lines[1])  )
    // ToDo end

    });


})();



Measured memory_bytes: 21320
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

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

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

int main()
{
    ll a;
    cin >> a;

    cout << (a + a * a + a * a * a) << endl;

    return 0;
}


Measured memory_bytes: 3620
n = int(input())

for _ in range(n):
    day_sum = 0
    year, month, day = map(int, input().split())

    # total days of the first year (including the first day)
    day_sum += 1

    if year % 3 == 0 or month % 2 == 1:
        day_sum += 20 - day
    else:
        day_sum += 19 - day

    for m in range(month+1, 11):
        if year % 3 == 0 or m % 2 == 1:
            day_sum += 20
        else:
            day_sum += 19

    # total days from the second year to the second year from the last
    for y in range(1, 1000-year):
        for m in range(1, 11):
            if (year+y) % 3 == 0 or m % 2 == 1:
                day_sum += 20
            else:
                day_sum += 19

    print(day_sum)

Measured memory_bytes: 6720
#include <stdio.h>

int main(void)
{
	int a, b, c, a2, b2, c2; 
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	a2 = a;
	b2 = b;
	c2 = c;
	
	//a > b?????????a??¨b?????\????????????
	if(a > b){
		a = b;
		b = a2;
	}

	//b > c?????????b??¨c?????\????????????
	if(b > c){
		b2 = b;
		b = c;
		c = b2;
	}	
	
	//a > b?????????a??¨b?????\????????????
	if(a > b){
		a2 = a;
		a = b;
		b = a2;
	}
	
	//a, b, c?????????
	printf("%d ",a);
	printf("%d ",b);
	printf("%d\n",c);
	
	
	return 0;
}

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

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  for(int i=0; i<N; i++){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  int x_white_first=0, x_white_last=W;
  int y_white_first=0, y_white_last=H;
  for(int i=0; i<N; i++){
    switch(a.at(i)){
      case 1:
        x_white_first=max(x_white_first,x.at(i));
        break;
      case 2:
        x_white_last=min(x_white_last,x.at(i));
        break;
      case 3:
        y_white_first=max(y_white_first,y.at(i));
        break;
      case 4:
        y_white_last=min(y_white_last,y.at(i));
    }
  }
  int xlength=max(0,x_white_last-x_white_first);
  int ylength=max(0,y_white_last-y_white_first);
  cout << xlength*ylength;
  return 0;
}

Measured memory_bytes: 3640
N = int(input())
d = {}
s = "MARCH"
for c in s:
    d[c] = 0
for _ in range(N):
    c = input().strip()[0]
    if c in d:
        d[c] += 1

r = 0
for i in range(5):
    a = s[i]
    for j in range(i+1, 5):
        b = s[j]
        for k in range(j+1, 5):
            c = s[k]
            r += d[a]*d[b]*d[c]
print(r)


Measured memory_bytes: 43496
package main

import (
	"fmt"
)

func gcd(a,b int)int{
		if b == 0{
			return a
		}
		return gcd(b, a%b)
}

func main() {
	var n int
	m := []int{}
	fmt.Scan(&n)
	
	for i:=0;i<n;i++{
		var a int
		fmt.Scan(&a)
		m=append(m,a)
	}

	min:=m[0]

	for i:=1;i<n;i++{
		min = gcd(min,m[i])
	}
	
	fmt.Println(min)
}

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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

int main(int, char**) {
	int n, q;
	cin >> n >> q;
	vector<vector<int>> tree(n, vector<int>());
	for (int i=0; i<n-1; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	vector<vector<int>> sons(n, vector<int>());
	vector<bool> visit(n, false);
	queue<int> check;
	check.push(0);

	while(!check.empty()){
		int now = check.front();
		check.pop();
		visit[now] = true;
		if (tree[now].empty()) continue; // no son
		for (int i=0; i<tree[now].size(); i++) {
			int a = tree[now][i];
			if (visit[a]) continue;
			sons[now].push_back(a);
			check.push(a);
		}
	}

	vector<int> score(n, 0);
	for (int i=0; i<q; i++) {
		int p, x;
		scanf("%d %d", &p, &x);
		p--;
		score[p] += x;
	}

	vector<int> ret(n, 0);

	queue<int> que;
	que.push(0);

	while(!que.empty()) {
		int now = que.front();
		que.pop();
		ret[now] = score[now];
		if (sons[now].empty()) continue; // no son
		for (int i=0; i<sons[now].size(); i++) {
			int a = sons[now][i];
			score[a] += score[now];
			que.push(a);
		}
	}

	for (int i=0; i<n; i++) {
		cout << ret[i] << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;

	ll num = __builtin_popcountll(n);
	ll bit = 64 - __builtin_clzll(n);

	vl v(bit + num - 2); REP(i, v.size()) v[i] = v.size() - i;
	vb b(v.size(), false);
	ll use = 0;
	for (ll i = 0; i < bit - 1; ++i) {
		if ((n >> i) & 1) {
			b[i + use] = true;
			v.push_back(i + 1 + use);
			++use;
		}
	}
	REP(i, b.size()) if (!b[b.size() - 1 - i]) v.push_back(b.size() - i);
	cout << v.size() + 2 << endl;
	REP(i, v.size()) cout << v[i] << " ";
	cout << "100 100" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll dp[MAX];


vll fac, inv, invfac;
void comb_set(ll x = MAX) {
  fac.resize(x + 1, 0);
  invfac.resize(x + 1, 0);
  inv.resize(x + 1, 0);
  fac[0] = inv[1] = invfac[0] = 1;
  FOR(i, 1, x + 1) (fac[i] = fac[i - 1] * i) %= mod;
  FOR(i, 2, x + 1) (inv[i] = (mod - mod / i) * inv[mod%i]) %= mod;
  FOR(i, 1, x + 1) (invfac[i] = invfac[i - 1] * inv[i]) %= mod;
}
ll comb(ll x, ll y) {
  if (x < y) return 0;
  return fac[x] * invfac[x - y] % mod * invfac[y] % mod;
}


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



  cin >> n >> m;
  vll v(n);
  rep(i, n) cin >> v[i];
  sort(rall(v));
  comb_set(MAX);
  dp[m] = fac[n];
  rep(i, n) {
    FOR(j, v[i], m + 1) {
      (dp[j%v[i]] += inv[n - i] * dp[j]) %= mod;
      (dp[j] = (((n - i - 1) * inv[n - i]) % mod) * dp[j]) %= mod;
    }
  }
  rep(i, m + 1) (ans += i * dp[i]) %= mod;
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 6272
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

typedef pair<int, int> P;
typedef tuple<int, int, int> triple;
typedef long long ll;

int gcd(int a, int b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    y >>= 1;
  }
  return r;
}

const int COM_MAX = 500010;
ll fac[COM_MAX], facinv[COM_MAX], inv[COM_MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  facinv[0] = facinv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < COM_MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    facinv[i] = facinv[i-1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD) * facinv[n-k] % MOD;
}

ll PERM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD);
}

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;

  map<int, int> factors;
  for (int i = 2; i * i <= M; ++i) {
    while (M % i == 0) {
      ++factors[i];
      M /= i;
    }
  }
  if (M > 1) {
    ++factors[M];
  }

  COMinit();
  ll r = 1;
  for (auto x : factors) {
    r *= COM(x.second + N - 1, N - 1);
    r %= MOD;
  }

  cout << r << endl;
}


Measured memory_bytes: 12032
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::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>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long 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(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool operator==(const mint& a, const mint& b) { return a.x == b.x;}

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

    int n, k;
    cin >> n >> k;
    cout << mint(k).pow(n) << endl;
}



Measured memory_bytes: 3228