akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
b = 0
for i in 1..n-1
    if b == 0
        if a[i-1] < a[i]
            b = 1
        elsif a[i-1] > a[i]
            b = -1
        end
    elsif (b == 1 && a[i-1] > a[i]) || (b == -1 && a[i-1] < a[i])
        b = 0
        ans += 1
    end
end
puts ans+1

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

int main()
{
	int h,w;
	string a[100];
	cin>>h>>w;
	for(int i=0;i<h;i++) cin>>a[i];
	
	for(int i=0;i<w+2;i++) cout<<'#';
	cout<<endl;
	for(int i=0;i<h;i++) cout<<'#'<<a[i]<<'#'<<endl;
	for(int i=0;i<w+2;i++) cout<<'#';
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void calc(int n);

int main(void){
  int n;
  while(true){
    cin>>n;
    if(n==0){break;}
    calc(n);
  }
  return 0;
}

void calc(int n){
  int mod[n];
  for(int i=0;i<n;i++){
    mod[i]=0;
  }
  for(int i=1;i<n;i++){
    mod[(i*i)%n]=1;
  }
  int retval[1+n/2];
  for(int i=0;i<=n/2;i++){
    retval[i]=0;
  }
  for(int i=0;i<n;i++){
    if(mod[i]==0){
      continue;
    }
    for(int j=i+1;j<n;j++){
      if(mod[j]==0){
        continue;
      }
      int d=j-i;
      if(d<0){
        d+=n;
      }
      if(d>n/2){
        d=n-d;
      }
      retval[d]++;
    }
  }
  for(int i=1;i<=n/2;i++){
    cout<<retval[i]*2<<endl;
  }
}



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

int main () {
    char c;

    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
const int MOD = 1e9+7;
int sm[10050];
int dp[5050][5050];
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,m,k,q;
  cin>>n>>m>>k>>q;
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(int i=0;i<m;i++){
    memset(sm,0,sizeof(sm));
    for(int j=0;j<n;j++){
      int x=j%(2*k);
      sm[x]+=dp[i][j];
      sm[x]%=MOD;
      sm[2*k+x]+=dp[i][j];
      sm[2*k+x]%=MOD;
    }
    
    for(int j=1;j<4*k;j++) sm[j]=(sm[j]+sm[j-1])%MOD;
      
    for(int j=0;j<n;j++)
      dp[i+1][j]=(sm[2*k+(j%(2*k))]+MOD-sm[k+(j%(2*k))])%MOD;
  }
  
  for(int i=0;i<q;i++){
    int a,b,c;
    cin>>a>>b>>c;
    int d=(c-a+n)%n;
    cout<<dp[b][d]<<endl;
  }
  
  return 0;
}




Measured memory_bytes: 102868
X = int(input())

max_v = 1
b = 2
for i in range(2, X):
  b =i
  for j in range(2,X):
    p = j
    if b**p > max_v and b**p <= X:
      #print(b, p)
      max_v = b**p
    elif b**p > X:
      break
print(max_v)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  int n;
  cin >>n;
  vector<int>w(n);
  for(int i=0;i<n;i++){
    cin>>w.at(i);
  }
  int ans =100100101;
  for(int i=0;i<n-1;i++){
    int s1,s2;
    s1 =0;
    s2 =0;
    for(int j=0;j<i+1;j++){
      s1 += w.at(j);
    }
    for(int k=i+1;k<n;k++){
      s2 += w.at(k);
    }
    if(ans >abs(s1-s2)){
      ans =abs(s1 -s2);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  vector<int> a(3); REP(i, 3) cin >> a[i];
  sort(ALL(a));
  unique(a);
  cout << (a.size() == 2 ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int n, k, ans; cin >> n >> k;
    ans = k;
    For(i, 0, n-1) ans *= k-1;
    cout << ans;
    
    
    
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


int main()
{
  string s,t;
  cin >> s >> t;
  string t1 = t.substr(0,t.size()-1);
  if(s==t1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
{-# LANGUAGE BangPatterns #-}

import Data.Bits
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Control.Applicative
import Data.Maybe
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
-- import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce

-- lines are 1,2.. width

fibs :: V.Vector Int
fibs = V.unfoldrN 12 (\(x,y) -> Just (y, (y,x+y))) (0,1)

amidas :: Int -> Int
amidas width = fibs V.! width


-- 1 <= left < width
amidasWithLine :: Int -> Int -> Int
amidasWithLine width left
  = amidas (left - 1) * amidas (width - left - 1)

amidasWithoutLine :: Int -> Int -> Int
amidasWithoutLine width at
  = amidas (at - 1) * amidas (width - at)

modulus :: Int
modulus = 1000000007

update :: Int -> V.Vector Int -> V.Vector Int
update width vec
  = V.izipWith3
      (\i l c r -> ((if i > 0 then l * amidasWithLine width i else 0)
                   + c * amidasWithoutLine width (i+1)
                   + (if i < width - 1
                     then r * amidasWithLine width (i+1) else 0))
                   `mod` modulus)
      lvec vec rvec
  where
    lvec = V.cons 0 $ V.init vec
    rvec = V.tail vec `V.snoc` 0

query :: Int -> Int -> Int -> Int 
query height width at = loop height $ V.iterateN width (const 0) 1
  where
    loop 0 vec = vec V.! (at - 1)
    loop h !vec = loop (h-1) $ update width vec

main :: IO ()
main = do
  [h,w,a] <- map read . words <$> getLine
  print $ query h w a


Measured memory_bytes: 636
using System;
using System.Linq;

class A6{
  public static int n;
  public static void Main(){
    int k = 0;
    n  = int.Parse(Console.ReadLine());
    int[] A = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int[] B = new int[n];
    k = A.Max();

    Calc.CountingSort(A,ref B,k);

    Console.WriteLine(string.Join(" ",Array.ConvertAll(B, (e)=> e.ToString())));
    }
}


class Calc{
  static public void CountingSort(int[] A,ref int[] B,int k){
    int[] C = new int[k+1];

    for(int j = 0;j < A6.n;j++){
      C[A[j]]++;
    }
    for(int i = 1;i <= k;i++){
      C[i] += C[i - 1];
    }
    for(int j = A6.n - 1;j >= 0;j--){
      B[C[A[j]] - 1] = A[j];
      C[A[j]]--;
    }
  }
}


Measured memory_bytes: 265720
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*n
        self.rank=[-1]*n

    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)

        if x==y:return
        elif self.rank[x]>self.rank[y]:
            self.root[x] +=self.root[y]
            self.root[y]=x
        else:
            self.root[y] +=self.root[x]
            self.root[x]=y
            if self.rank[x]==self.rank[y]:
                self.rank[y] +=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def size(self,x):
        return -self.root[self.Find_Root(x)]

    def members(self,x):
        root=self.Find_Root(x)
        return [i for i in range(self.n) if self.Find_Root(i)==root]

    def roots(self):
        return[i for i,j in enumerate(self.root) if j<0]

    def group_members(self):
        return {i:self.members(i) for i in self.roots()}

    def group_count(self):
        return len(self.roots())


def kruskal():
    D,M=[],[]

    A,B=sorted(XY),sorted(XY,key=lambda x:x[1])
    for i in range(n-1):
        M.append([abs(A[i][0]-A[i+1][0]),A[i][2],A[i+1][2]])
        M.append([abs(B[i][1]-B[i+1][1]),B[i][2],B[i+1][2]])

    M.sort()
    for i,j,k in M:
        if UnionFind.isSameGroup(j,k) is False:
            UnionFind.Unite(j,k)
            D.append(i)

    return D


n=int(input())
XY=[list(map(int,input().split()))+[i+1] for i in range(n)]
UnionFind=UnionFind(n+1)
print(sum(kruskal()))

Measured memory_bytes: 130804
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    ll n,ks;
    cin>>n>>ks;
    string s;
    cin>>s;
    vector<ll> zero;
    vector<ll> iti;
    ll ii=1;
    ll pre=s[0];
    ll k=1;

    while(ii!=s.size()){
        if(s[ii]!=pre){
            if(pre=='0'){
                zero.push_back(k);
            }else{
                iti.push_back(k);
            }
            k=1;
            pre=s[ii];
        }else{
            k++;
        }
        ii++;
    }
    if(pre=='1'){iti.push_back(k);}else{zero.push_back(k);}

    /*rep(i,iti.size()){
         cout<<iti[i];
     }
     cout<<endl;
     rep(i,zero.size()){
             cout<<zero[i];
     }
 */


    if(ks>=zero.size()||zero.size()==0||iti.size()==0){
        cout<<s.size()<<endl;
        return 0;
    }

    ll syu=0;//kまとまりの数
    bool f=0;if(s[0]=='1')f=1;

    rep(i,ks){
        syu+=zero[i];
        //  cout<<syu<<endl;
    }
    rep(i,ks){
        syu+=iti[i];
        //cout<<syu<<endl;
    }

    if(f==1&&ks<iti.size())syu+=iti[ks];
    ll pres=syu;
    //cout<<" "<<syu<<endl;

    for(ll i=ks;i<zero.size();i++){
        syu-=zero[i-ks];
        syu+=zero[i];
        //cout<<'a'<<syu<<endl;

        if(f==0&&i==ks){
            if(iti.size()>ks) {
                syu += iti[ks];
            }

        }else if(f==1) {
            if (iti.size() > ks){
                syu -= iti[i - ks];
        }
            if(i+1<iti.size()){syu+=iti[i+1];}
        }else{
            if(i-ks-1>=0) {
                syu -= iti[i - ks - 1];
            }
            if(i<iti.size()) {
                syu += iti[i];
            }
        }
        //cout<<syu<<endl;
        pres=max(syu,pres);

    }
    cout<<pres<<endl;


    return 0;
}


Measured memory_bytes: 1404
#include <stdio.h>
#define max 30
#define nil -1

typedef struct{
  int parent;
  int lleaf;
  int leaf;
  int next;
  int sibling;
}node;

node t[max];
int n;

int rmax(int l, int r){
  if(l < r) return r;
  else return l;
}

int deg(int id){
  int deg = 0;
  if(t[id].lleaf != nil) deg++;
  if(t[id].leaf != nil) deg++;
  return deg;
}

int dep(int id){
  int depth = 0;
  if(t[id].parent != nil){
    depth = dep(t[id].parent);
    return depth+1;
  }
  else return 0;
}

int hei(int id){
  return rmax(lhei(id), rhei(id));
} 

int lhei(int id){
  int height = 0;

  if(t[id].lleaf == nil) return 0;
  height = hei(t[id].lleaf);
  return height+1;
}

int rhei(int id){
  int height = 0;

  if(t[id].leaf == nil) return 0;
  height = hei(t[id].leaf);
  return height+1;
}



int main(void){
  int i, j, id, left, right, mheight;

  scanf("%d", &n);
  //init
  for(i = 0; i < max; i++)
    t[i].parent = t[i].leaf = t[i].next = t[i].sibling = nil;



  for(i = 0; i < n; i++){
    scanf("%d", &id);
    scanf("%d", &left);
    scanf("%d", &right);
      t[left].parent = id;
      t[left].sibling = right;
      t[left].next = right;
      t[id].lleaf = left;

      t[right].parent = id;
      t[id].leaf = right;
      t[right].sibling = left;
  }

  for(i = 0; i < n; i++){
    printf("node %d: ", i); 
    printf("parent = %d, ", t[i].parent);
    printf("sibling = %d, ", t[i].sibling);
    printf("degree = %d, ", deg(i));
    printf("depth = %d, ", dep(i));
    printf("height = %d, ",hei(i));

  if(t[i].parent == nil)
    printf("root");
  else if(t[i].leaf != nil || t[i].lleaf != nil)
    printf("internal node");
  else
    printf("leaf"); 
  printf("\n");



  }
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
int N;
std::vector<int>ans;
int main() {
	std::cin >> N;
	if (N == 3) {
		std::cout << 2 << " " << 3 << " " << 25 << std::endl;
		return 0;
	}
	ans.emplace_back(3);
	ans.emplace_back(9);
	int M = 0;
	while (ans.size() + 2 <= N && M + 4 <= 30000) {
		ans.emplace_back(M + 2);
		ans.emplace_back(M + 4);
		M += 6;
	}
	M = 12;
	while (ans.size() + 2 <= N && M + 9 <= 30000) {
		ans.emplace_back(M + 3);
		ans.emplace_back(M + 9);
		M += 12;
	}
	M = 1;
	while (ans.size() < N) {
		ans.emplace_back(M * 6);
		M++;
	}
	for (int i = 0; i < N; i++) {
		std::cout << ans[i];
		if (i != N - 1)std::cout << " ";
		else std::cout << std::endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  if (n % 10 == 0) cout << "pon" << endl;
  if (n % 10 == 1) cout << "pon" << endl;
  if (n % 10 == 2) cout << "hon" << endl;
  if (n % 10 == 3) cout << "bon" << endl;
  if (n % 10 == 4) cout << "hon" << endl;
  if (n % 10 == 5) cout << "hon" << endl;
  if (n % 10 == 6) cout << "pon" << endl;
  if (n % 10 == 7) cout << "hon" << endl;
  if (n % 10 == 8) cout << "pon" << endl;
  if (n % 10 == 9) cout << "hon" << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		
		int k = 0;
		int sum = 0;
		
		do {
			sum += x;
			k++;
		}
		while (sum % 360 != 0);
		
		System.out.println(k);
		
		sc.close();
	}
}




Measured memory_bytes: 26992
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

bool isset(ll bit, ll i) { return (bit>>i)&1; }

signed main() {
    ll D,G,ans=1e10;
    cin>>D>>G;
    vector<ll> p(D), c(D);
    rep(i,0,D) cin>>p[i]>>c[i];
    rep(bit,0,1<<D){
        ll t = 0, score = 0;
        // complete bonus & basic score
        rep(i,0,D) {
            if (isset(bit,i)){
                score += c[i] + 100*(i+1)*p[i];
                t += p[i];
            }
        }

        // basic score
        for (ll i=D-1; i>=0; i--) {
            if (!isset(bit,i)){
                if (G-score >= 100*(i+1)*p[i]) { // solve all problems
                    score += 100*(i+1)*p[i];
                    t += p[i];
                } else if (G-score > 0) {
                    ll q = (G-score + 100*(i+1)-1 )/(100*(i+1)); // solve q prombles
                    score += 100*(i+1)*q;
                    t += q;
                }
            }
        }

        if (score>=G && t<ans){
            ans=t;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define SZ(x) ((int) (x).size())

using namespace std;
typedef long long LL;
typedef vector<int> VI;

template <typename T, typename TT> ostream & operator << (ostream &out, pair<T, TT> t) { return out << "(" << t.X << "," << t.Y << ")";}
template <typename T> ostream & operator << (ostream &out,vector<T> t) { out << "["; for (auto x:t) out << x << " "; out << "]"; return out;}
template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
template <typename T> void read(T & x) 
{
	int f = 1; char ch; x = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); x *= f;
}

const int NX = 100010;

int n, q, sN; LL ans[NX], s[NX], a[NX], t[NX];
int main() 
{	
	read(n); read(q); 
	for (int i = 1; i <= q; i++)
		read(a[i]);
	
	s[++sN] = n;	
	for (int i = 1; i <= q; i++)
	{
		while(sN && a[i] <= s[sN])
			--sN;
		s[++sN] = a[i];
	}
	
	t[sN] = 1;
	for (int i = sN; i; i--)
	{
		LL u = s[i];
		LL v = upper_bound(s + 1, s + i, u) - s - 1;
		while (v)
		{
			t[v] += (u / s[v]) * t[i];
			u %= s[v];
			v = upper_bound(s + 1, s + v, u) - s - 1;	
		}
		ans[1] += t[i];
		ans[u + 1] -= t[i];
	}
	
	LL cur = 0;
	for (int i = 1; i <= n; i++)
	{
		printf("%lld\n", cur += ans[i]);
	}
	return 0;
}





Measured memory_bytes: 4864
numbers = gets.chomp
n = numbers.split()[0].to_i
k = numbers.split()[1].to_i
p = 0
i = 1
k_tmp2 = n+1
k_tmp1 = (k.to_f/i).ceil
while k_tmp2 > 1
  if k_tmp1 < k_tmp2
    p += (k_tmp2-k_tmp1).to_f/(i*n)
    k_tmp2 = k_tmp1
  end
  i *= 2
  k_tmp1 = (k.to_f/i).ceil
end
puts p


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
const int MOD = 1000000007;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}


int main() {
    int n; cin >> n;
    multimap<string,ll> m;
    for(int i = 0;i < n;i++){
        string s; cin >> s; sort(s.begin(),s.end());
        auto x = m.find(s);
        if(x == m.end()){
            m.insert(make_pair(s,1));
        }else{
            x->second++;
        }
    }
    ll ans = 0;
    for(auto x:m){
        if(x.second == 1) continue;
        ans += x.second*(x.second-1)/2;
    }
    cout << ans;
}


Measured memory_bytes: 11272
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (h, n) = InputLine.to_ia
  a = InputLine.to_ia

  s = a.reduce(:+)
  
  if h <= s then
    puts 'Yes'
  else
    puts 'No'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 8120
#[allow(dead_code)]
fn main() {
    let mut nn=i::u();
    let mut bb=i::iv(nn);
    let mut len=bb.len();
    let mut maxkabe=0;
    let mut pkabe=0;
    for xx in 0..(len-1){
        if (bb[xx]<bb[xx+1]){
            //kabe
            if (maxkabe<pkabe){
                maxkabe=pkabe;
            }
            pkabe=0;
        }else{
            pkabe+=1;
        }
    }
    if (maxkabe<pkabe){
        maxkabe=pkabe;
    }
    println!("{}",maxkabe);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int long long

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

ll count(vector<ll> &a, int N) {
    vector<ll> cnt(N, 0);
    ll total = 0;

    REP(i, N) {
        cnt[i] = (a[i] >= N) ? a[i] / N : 0;
        total += cnt[i];
    }

    REP(i, N) {
        a[i] -= cnt[i] * N;
        a[i] += total - cnt[i];
    }

    return total;
}

bool is_end(const vector<ll> &a, int N) {
    REP(i, N) {
        if (a[i] >= N) {
            return false;
        }
    }
    return true;
}

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

    vector<ll> a(N);
    REP(i, N) {
        ll _a;
        cin >> _a;
        a[i] = _a;
    }

    ll ans = 0;
    while (is_end(a, N) == false) {
        ans += count(a, N);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int x=0;
    int n=N;
    while (n > 0){
	x+=n%10;
	n/=10;
    }

    if (N%x == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long[][] time = new long[n][2];
      for(int i = 0;i < n;i++){
      	time[i][0]=sc.nextLong();
        time[i][1]=sc.nextLong();
      }
      Arrays.sort(time,(a,b)->Integer.compare((int)a[1],(int)b[1]));
      long sum = 0;
      for(int i = 0;i < n;i++){
      	sum+=time[i][0];
        if(sum>time[i][1]){
        	System.out.println("No");
            return;
        }
      }
      System.out.println("Yes");
    }
}

Measured memory_bytes: 112964
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	long long N, M; cin >> N >> M;
	long long ans;
	if (2*N >= M)ans = M / 2;
	else {
		ans = N;
		M -= 2 * N;
		ans += M / 4;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const int INF = 1000100000;
#define rep(i,n) for(int i=0;i<n;++i)

ll max(ll x,ll y){
  if(x>y)return x;
  else return y;
}


ll min(ll x,ll y){
  if(x>y)return y;
  else return x;
}


int main(){
  ll h,w;
  cin >>h >> w;
  int ans;
  ll smax,smin;
  if((h*w)%3==0)ans=0;
  else ans=min(h,w);

  for(ll i=1;i<h;i++){
    smin=min(i*w,(w/2)*(h-i));
    smax=max(i*w,((w+1)/2)*(h-i));
    ans=min(ans,smax-smin);
    }
  for(ll i=1;i<w;i++){
    smin=min(i*h,h/2*(w-i));
    smax=max(i*h,(h+1)/2*(w-i));
    ans=min(ans,smax-smin);
  }
  cout << ans << endl;
}


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

int main()
{
    long long n, k;

    cin >> n >> k;

    long long sum = 0;

    for (long long i = k; i <= n + 1; i++)
    {
        long long min = (i * (i - 1)) / 2;
        long long max = (i * (2 * n - i + 1)) / 2;
        long long num = 0;

        num += max - min + 1;

        sum += num;
        sum %= 1000000007;
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 3624
N,M=map(int,input().split())
ans=1
if abs(N-M)>=2:
    print(0)
elif abs(N-M)==1:
    for n in range(N):
        ans*=(n+1)
        ans%=1000000007
    for m in range(M):
        ans*=(m+1)
        ans%=1000000007
    print(ans)
else:
    for n in range(N):
        ans*=(n+1)
        ans%=1000000007
    for m in range(M):
        ans*=(m+1)
        ans%=1000000007
    ans*=2
    ans%=1000000007
    print(ans)

Measured memory_bytes: 3064
N,K=map(int,input().split())
mod=10**9+7
#K blue
#N-K red
MAX_N=2019
Fact=[0 for i in range(MAX_N+1)]
Finv=[0 for i in range(MAX_N+1)]
Fact[0]=1;Finv[0]=1
for i in range(MAX_N):
    Fact[i+1]=((i+1)*Fact[i])%mod
    Finv[i+1]=pow(Fact[i+1],mod-2,mod)
def C(a,b):
    return (Fact[a]*(Finv[b]*Finv[a-b])%mod)%mod
for i in range(1,K+1):
    if N-K+1>=i:
        print((C(N-K+1,i)*C(K-1,i-1))%mod)
    else:
        print(0)


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

typedef long long ll;

ll mypow(int n, int a) {
    if (a == 0) {
        return 1;
    } else {    
        ll r = n;
        for (int i = 0; i < a - 1; i++) {
            r *= n;
        }
        return r;
    }
}

int main() {
    int M, K; cin >> M >> K;
    if (K >= mypow(2, M)) {
        cout << -1 << endl;
    } else if (M == 0) {
        cout << "0 0" << endl;
    } else if (M == 1 && K == 0) {
        cout << "1 1 0 0" << endl;
    } else if (M == 1 && K == 1) {
        cout << -1 << endl;
    } else {
        for (int i = 0; i < mypow(2, M); i++) {
            if (i != K) printf("%d ", i);
        }
        printf("%d ", K);
        for (int i = mypow(2, M) - 1; 0 <= i; i--) {
            if (i != K) printf("%d ", i);
        }
        printf("%d", K);
    }
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);


void solve(long long N, long long A, long long B){
  ll res = (N / (A+B)) * A + min(N%(A+B), A);
  cout << res << endl;

}

int main(){
    long long N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    int ret = 0;

    if ((b <= a && a <= b + w) || (a <= b && b <= a + w)) {
        cout << "0" << endl;
    } else {
        if (a + w < b) {
            cout << b - a - w << endl;
        } else if (b + w < a) {
            cout << a - b - w << endl;
        }
    }
    return 0;
}

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

int main()
{
    string t;
    cin >> t;
    for (int i = 0; t[i] != 0; i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

using namespace std;

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

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N, K;cin >> N >> K;
	ll ans = 0;
	for (int i = K-N + 1;i < N + K;i++) cout << i<<" ";
}


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


int main() {
    int n; std::cin >> n;
    std::string buf = "";
    auto func = [&](auto &self, char last = 'a') {
        if (buf.size() >= n) {
            std::cout << buf << std::endl;
            return;
        }
        for (char c = 'a'; c <= last; c++) {
            buf.push_back(c);
            self(self, last + (c == last));
            buf.pop_back();
        }
    };
    func(func);
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N=1100;
const ll inf=1000000000000LL;
vector<int> g[N+5];
ll w[N+5],v[N+5];
int n,x,d,len;
ll dp[1000010];
vector<pair<ll,ll> > a;
void dfs(int k)
{
    v[k]=1;
    int nn = g[k].size();
    rep(i, 0, nn - 1)
    {
        int u = g[k][i];
        dfs(u);
        v[k]+=v[u];
        w[k]+=w[u];
    }
}
struct Node
{
    ll w,v,num;
}b[N + 5];
bool cmp(const Node x,const Node y)
{
	return 1.0 * x.v / x.w >= 1.0 * y.v / y.w;
}
ll work()
{
    ll ans=0;
    rep(i, 0, 125000)
    	if(dp[i] <= x)
        {
            ll res = i;
            ll now = x - dp[i];
            rep(j, 1, len)
                if(b[j].num == inf || 1.0 * b[j].num * b[j].w > 1.0 *now)
                {
                    res += now / b[j].w * b[j].v;
                    break;
                }
                else res += b[j].num * b[j].v, now -= b[j].num * b[j].w;
            ans = max(ans, res);
        }
    return ans;
}
int main()
{
	n = read();
	x = read();
	d = read();
	w[1] = read1();
	rep(i, 2, n)
    {
        w[i] = read1();
        int x = read();
        g[x].pb(i);
    }
    dfs(1);
    rep(i, 1, n)
    {
        int num = min(d, 50);
        if(i == 1) num = 50;
        int pw = 1;
        while(num >= pw)
        {
            a.pb(mp(w[i] * pw, v[i] * pw));
            num -= pw;
            pw <<= 1;
        }
        if(num) a.pb(mp(w[i]*num,v[i]*num));
        if(i == 1 || d > 50) b[++ len] = {w[i], v[i], d - 50LL};
        if(i == 1) b[len].num = inf;
    }
    sort(b + 1, b + len + 1, cmp);
    rep(i, 0, 125000) dp[i] = inf;
    dp[0] = 0;
    for(auto x : a)
    	rrep(j, 125000, x.Y)
            dp[j] = min(dp[j], dp[j - x.Y] + x.X);
    printf("%lld\n", work());
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// g++ -o a a.cpp -Wall -lm -std=c++17
ll oddsolve(ll a){return (a+1)/2 %2;}
ll func(ll a){
    if(a%2==1)return oddsolve(a);
    else return oddsolve(a+1)^(a+1);
}
int main(){
    ll a,b;cin>>a>>b;
    cout<<(func(a-1)^func(b))<<endl;
}

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

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ANS = 1;
        for (int i = 1; i <= N; i++) {
            ANS = i * ANS % ((long) Math.pow(10, 9) + 7);
        }
        System.out.println(ANS);
    }
}

Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int N, ns[100000+9];
int dp[100000+9];
int main(){
    scanf("%d",&N);
    for(int i=0;i<N;i++)scanf("%d",&ns[i]);
    dp[0]=0, dp[1]=abs(ns[0]-ns[1]);
    for(int i=2;i<N;i++){
        dp[i]=min(dp[i-1]+abs(ns[i]-ns[i-1]), dp[i-2]+abs(ns[i]-ns[i-2]));
    }
    cout<<dp[N-1]<<endl;
    return 0;
}


Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
int a[200005],n,i;

int main(){
    cin>>n;
    for(i=1;i<=n;i++)
	cin>>a[i];
    sort(a+1,a+n+1);
    
    for(i=1;i<n;i++)
    if(a[i]==a[i+1]){
        cout<<"NO";
        return 0;
    }
    
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int is_prime1(int);
int is_prime2(int);

int prime[168];

int main()
{
	int input, input_cnt, prime_cnt, cnt;
	int output[30];
	
	/*Make prime table*/
	prime[0] = 2;
	prime_cnt = 1;
	for(cnt = 3; cnt < 1000; cnt += 2)
		if(is_prime1(cnt)){
			prime[prime_cnt] = cnt;
			prime_cnt++;
		}
	
	/*Get, calculate input then save in output[]*/
	input_cnt = 0;
	while(scanf("%d", &input) != EOF){
		prime_cnt = 0;
		if(input >= 2)
			prime_cnt++;
		for(cnt = 3; cnt <= input; cnt += 2)
			if(is_prime2(cnt))
				prime_cnt++;
		output[input_cnt] = prime_cnt;
		input_cnt++;
	}
	
	/*print output[]*/
	for(cnt = 0; cnt < input_cnt; cnt++)
		printf("%d\n", output[cnt]);
	
    return 0;
}

/*Test prime directly*/
int is_prime1(int prime1_input)
{
	int prime1_cnt;
	
	if(prime1_input == 1){
		return 0;
	}
	else if(prime1_input == 2 || prime1_input == 3 || prime1_input == 5 || prime1_input == 7){
		return 1;
	}
	else if((prime1_input % 2) == 0){
		return 0;
	}
	
	for(prime1_cnt = 3 ; prime1_cnt <= (sqrt(prime1_input)); prime1_cnt += 2)
		if(prime1_input % prime1_cnt == 0)
			return 0;
	
	return 1;
}

/*Test prime with prime table*/
int is_prime2(int prime2_input)
{
	int prime2_cnt = 0;
	for( ;prime2_cnt <168; prime2_cnt++){
		if(prime[prime2_cnt] > sqrt(prime2_input))
			break;
		if(prime2_input % prime[prime2_cnt] == 0)
			return 0;
	}
	return 1;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 200005
Int fact[MAX_P],inv[MAX_P];
Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}
Int euler_phi(Int n){
  Int res=n;
  for(Int i=2;i*i<=n;i++){
    if(n%i==0){
      res=res/i*(i-1);
      for(;n%i==0;n/=i);
    }
  }
  if(n!=1) res=res/n*(n-1);
  return res;
}

Int euler[MAX_N];

void euler_phi2(){
  for(Int i=0;i<MAX_N;i++) euler[i]=i;
  for(Int i=2;i<MAX_N;i++){
    if(euler[i]==i){
      for(Int j=i;j<MAX_N;j+=i) euler[j]=euler[j]/i*(i-1);
    }
  }
}

Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n>0){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inverse2(Int a,Int mod){
  return mod_pow(a,mod-2,mod);
}

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
}

Int mod_fact(Int n,Int mod,Int& e){
  e=0;
  if(n==0) return 1;
  Int res=mod_fact(n/mod,mod,e);
  e+=n/mod;
  if(n/mod%2!=0)return res*(mod-fact[n%mod]) %mod;
  return res*fact[n%mod]%mod;
}

Int mod_comb(Int n,Int k,Int mod){
  if(n==k||k==0) return 1;
  Int e1,e2,e3;
  Int a1=mod_fact(n,mod,e1),a2=mod_fact(k,mod,e2),a3=mod_fact(n-k,mod,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%mod,mod)%mod;
}

Int mod_comb2(Int n,Int k,Int mod){
  Int res=1;
  for(Int i=0;i<k;i++){
    res*=(n-i)%mod;
    res%=mod;
    res*=mod_inverse(i+1,mod);
    res%=mod;
  }
  return res;
}

Int montmort(Int n,Int mod){
  Int res=0,inv=1;
  for(Int k=2;k<=n;k++){
    (inv*=mod_inverse(k,mod))%=mod;
    if(k%2) (res+=mod-inv)%=mod;
    else (res+=inv)%=mod;
  }
  for(Int i=1;i<=n;i++)
    (res*=i)%=mod;
  return res;
}
//END CUT HERE

//mod_pow
signed AOJ_NTL1B(){
  int n,m;
  cin>>m>>n;
  cout<<mod_pow(m,n,MOD)<<endl;
  return 0;
}
/*
  verified on 2017/12/31
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B&lang=jp
*/

//montmort
signed ARC009_C(){
  Int n,k;
  cin>>n>>k;
  const Int MMOD=1777777777;
  Int a=montmort(k,MMOD);
  a=a*mod_comb2(n,k,MMOD)%MMOD;
  cout<<a<<endl;
  return 0;
}
/*
  verified on 2017/12/31
  https://arc009.contest.atcoder.jp/tasks/arc009_3
*/


signed main(){
  AOJ_NTL1B();
  
  //ARC009_C();
  return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int N, M; cin >> M >> N;
    vector< vector<char> > S(N, vector<char>(M));
    for (int i = 0; i < M; ++i) {
        string aux; cin >> aux;
        for (int j = 0; j < N; ++j)
            S[j][i] = aux[j];
    }

    vector< vector<int> > cost(2 * M + 1, vector<int>(M));
    vector< vector<int> > dp(M + 1, vector<int>(M + 1, 0));
    int answer = 0;
    for (int i = 0; i + 1 < N; ++i) {
        string A(3 * M, ' '), B(3 * M, ' ');
        copy(S[i + 1].begin(), S[i + 1].end(), B.begin() + M);
        for (int j = 0; j <= 2 * M; ++j) {
            copy(S[i].begin(), S[i].end(), A.begin() + j);
            int start;
            for (start = 0; A[start] == ' ' && B[start] == ' '; ++start);
            for (int k = start, diff = 0; k < start + M; ++k) {
                if (A[k] == B[k])
                    ++diff;
                cost[j][k - start] = diff;
            }
            fill(A.begin() + j, A.begin() + j + M, ' ');
        }

        auto displace = [&](int first, int second) {
            int poz = M + (first - second);
            int count = max(M - first, M - second);
            return cost[poz][count - 1];
        };

        for (int i = 0; i <= M; ++i)
            for (int j = 0; j <= M; ++j)
                dp[i][j] = numeric_limits<int>::max();

        dp[0][0] = 0;
        for (int i = 0; i <= M; ++i)
            for (int j = 0; j <= M; ++j) {
                if (i < M)
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + displace(i, j));
                if (j < M)
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + displace(i, j));
            }
        answer += dp[M][M];
    }

    cout << answer << "\n";
}


Measured memory_bytes: 1408
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;

int n;
vector <int> adj[100005];
int dp[100005][2];

int dfs(int node,int color,int parent) 
{
	if(dp[node][color]!=-1)return dp[node][color];
    int sum=1;
    for(int i = 0;i < adj[node].size();++i)    
    {
         if(adj[node][i]!=parent)
        	{
        		if(color==0)sum*=(dfs(adj[node][i],1-color,node)+dfs(adj[node][i],color,node));
        		else sum*=dfs(adj[node][i],1-color,node);
        		sum%=hell;
        	}
        	
    }
    return dp[node][color]=sum%hell;
}


void solve()
  {
	cin>>n;
	int x,y;
	rep(i,n-1)
	{
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	rep(i,100005)dp[i][0]=-1,dp[i][1]=-1;
	cout<<(dfs(1,1,-1)+dfs(1,0,-1))%hell;


  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}
	

Measured memory_bytes: 18880
#ifndef YK_INCLUDE
#include <bits/stdc++.h>
#endif //! YK_INCLUDE
int main() {
    std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

    uint64_t N;
    std::cin >> N;
    uint64_t min = UINT64_MAX;
    for(int i = 0;i < 5;++i){
    	uint64_t in;
    	std::cin >> in;
    	min = std::min(min, in);
    }
    std::cout << (N / min + (N%min?1:0)+4) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
# define M_PI          3.141592653589793238
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

int getnum(string a)
{
    int i,p=0;
    rep0(i,a.size())
    {
        p*=10;
        p+=a[i]-'0';
    }
    return p;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    double a;
    cin>>a;
    a = 2*M_PI*a;
    printf("%.10f\n",a);
}


Measured memory_bytes: 3804
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;


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

	string a, b, c;
	cin >> a >> b >> c;
	int ans = 30000;

	vector<int>ab(8001);
	for (int i = -4000; i <= 4000; i++) {
		int flag = 1;
		for (int j = 0; j < a.size(); j++) {
			if (j - i >= 0 && j - i < b.size()) {
				if (a[j] != b[j - i] && a[j] != '?'&&b[j - i] != '?') {
					flag = 0;
					break;
				}
			}
		}
		ab[i+4000] = flag;
	}
	vector<int>ac(8001);
	for (int i = -4000; i <= 4000; i++) {
		int flag = 1;
		for (int j = 0; j < a.size(); j++) {
			if (j - i >= 0 && j - i < c.size()) {
				if (a[j] != c[j - i] && a[j] != '?'&&c[j - i] != '?') {
					flag = 0;
					break;
				}
			}
		}
		ac[i+4000] = flag;
	}
	vector<int>bc(8001);
	for (int i = -4000; i <= 4000; i++) {
		int flag = 1;
		for (int j = 0; j < b.size(); j++) {
			if (j - i >= 0 && j - i < c.size()) {
				if (b[j] != c[j - i] && b[j] != '?'&&c[j - i] != '?') {
					flag = 0;
					break;
				}
			}
		}
		bc[i+4000] = flag;
	}
	for (int i = -4000; i <= 4000; i++) {
		for (int j = -4000; j <= 4000; j++) {
			if (i + j <= 4000 && i + j >= -4000) {
				if (ab[i+4000] && bc[j+4000] && ac[i + j+4000]) {
					int l = min({ 0, i, i + j });
					int r = max({ (int)a.size() + 0, (int)b.size() + i, (int)c.size() + i + j });
					ans = min(ans, r - l);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384