akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
using namespace std;

const int MAXN = 505;

int N;
int x[MAXN];
int down[MAXN], up[MAXN];
bool bio[MAXN * MAXN];
int sol[MAXN * MAXN];
int occ[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%d", x + i);	
}

void bye() {
	puts("No");
	exit(0);
}

bool check() {
	for (int i = 1; i <= N * N; i++) 
		if (++occ[sol[i]] == sol[i] && i != x[sol[i]])
			return false;
	
	for (int i = 1; i <= N; i++)
		if (occ[i] != N)
			return false;
	
	return true;
}

void solve() {
	for (int i = 1; i <= N; i++) {
		down[i] = i - 1;
		up[i] = N - i;
		bio[x[i]] = true;
		sol[x[i]] = i;
	}
	
	for (int i = 1; i <= N * N; i++) {
		if (bio[i]) 
			continue;
		int mini = MAXN * MAXN, who = 0;
		for (int j = 1; j <= N; j++)
			if (down[j] && x[j] < mini) {
				mini = x[j];
				who = j;
			}
		if (!who)
			break;
		if (i >= x[who])
			bye();
		sol[i] = who;
		bio[i] = true;
		down[who]--;
	}
	
	for (int i = N * N; i; i--) {
		if (bio[i])
			continue;
		int maks = 0, who = 0;
		for (int j = 1; j <= N; j++)	
			if (up[j] && x[j] > maks) {
				maks = x[j];
				who = j;
			}
		if (!who)
			break;
		if (i <= x[who])
			bye();
		sol[i] = who;
		bio[i] = true;
		up[who]--;
	}
	
	if (!check())
		bye();
	
	puts("Yes");
	for (int i = 1; i <= N * N; i++)
		printf("%d ", sol[i]);
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}

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

const int mxN = 17;
int N, a[mxN][mxN];
ll scores[1 << mxN], dp[1 << mxN];
vector<int> v;

void rec(int idx, int mask, int grp, ll score_now)
{
	if (idx == (int)v.size())
	{
		dp[mask] = max(dp[mask], score_now + scores[grp]);
		return;
	}
	rec(idx + 1, mask, grp, score_now);
	rec(idx + 1, mask ^ (1 << v[idx]), grp ^ (1 << v[idx]), score_now);
}

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
			cin >> a[i][j];
	}
	for (int mask = 0; mask < (1 << N); mask++)
	{
		for (int i = 0; i < N; i++)
		{
			for (int j = i + 1; j < N; j++)
			{
				if ((mask & (1 << i)) && (mask & (1 << j)))
					scores[mask] += a[i][j];
			}
		}
	}
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	for (int mask = 0; mask < (1 << N); mask++)
	{
		v.clear();
		for (int i = 0; i < N; i++)
		{
			if (!(mask & (1 << i)))
				v.push_back(i);
		}
		rec(0, mask, 0, dp[mask]);
	}
	cout << dp[(1 << N) - 1];

	return 0;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
	int n;cin>>n;
	ll a[200010];ll sum[200010];
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum[i+1]=sum[i]+a[i];
	}
	sort(sum,sum+n+1);
	ll ans=0;
	ll c=1;
	for(int i=1;i<=n;i++){
		if(sum[i]==sum[i-1]){
			c++;
		}else{
			ans+=c*(c-1)/2;
			c=1;
		}
	}
	ans+=c*(c-1)/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
import Data.List
f x n [] = n
f x n (a:as)
  | a <= x*2 = f (x+a) (n+1) as
  | otherwise = f (x+a) 1 as
main = do
  getLine
  as <- sort . map read . words <$> getLine
  print $ f 0 0 (sort as)

Measured memory_bytes: 39932
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(i, a, b) for(ll i = a; i <= b; i++)
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define rrep(i, b, a) for(ll i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
const ll INF = 1e18L + 5;

void min_self(ll &a, ll b){ a = min(a, b); }

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll n, W;
    cin >> n >> W;
    vector<ll> weight(n), value(n);
    rep(i, 0, n) cin >> weight[i] >> value[i];
    ll sum_value = 0;
    for(auto x : value) sum_value += x;
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(ll item = 0; item < n; ++item) {
        for(ll value_already = sum_value - value[item]; value_already >= 0; --value_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(ll i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W)
            answer = max(answer, (ll)i);
    }
    cout << answer;
}

Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
def factor(n):
    i = 2
    m = n
    while m >= i:
        while m%i == 0:
            m //= i
            d[i] += 1
            d[i] %= mod
            if m < i:break
        i += 1
n = I()
d = defaultdict(int)
for i in range(2,n+1):
    factor(i)
ans = 1
for i in d.values():
    ans *= i+1
    ans %= mod
print(ans)
"""

#D
n,a,b = LI()
x = LI()
ans = 0
for i in range(n-1):
    if a*(x[i+1]-x[i]) > b:
        ans += b
    else:
        ans += a*(x[i+1]-x[i])
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 60016
import java.util.Scanner
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val s = scn.next()
	val n = s.length
	if ((0 until (n-1)/2).any { s[it] != s[n-1-it] }) no()
	if ((0 until (n-1)/4).any { s[it] != s[(n-3)/2-it] || s[(n+1)/2+it] != s[n-1-it] }) no()
	print("Yes")
}

fun no(){
	print("No")
	exitProcess(0)
}


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

#define REP(i,n) for(int i=0;i< (n);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 FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<ll, ll> LP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


char mass[6][6];
ll H,W,K;
int main() {
	cin >> H>>W>>K;

	REP(i, H) {
        string tmp;
        cin >> tmp;
		REP(j, W) {
			mass[i][j] = tmp[j];
		}
	}

    ll result = 0;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bitH = 0; bitH < (1 << H); ++bitH) {
        for (int bitW = 0; bitW < (1 << W); ++bitW) {
            ll count = 0;
            REP(i, H) {
                REP(j, W) {
                    if (bitH & (1 << i) || bitW & (1 <<j)) { // 列挙に含まれるならカウントせず

                    }
                    else {//含まれないなら調べる
                        if (mass[i][j] == '#') count++;
                    }
                }
            }

            if (count == K) result++;

        }
    }


    cout << result << endl;

	return 0;

}

Measured memory_bytes: 3640
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
d = 1
for i in s:    
    p = (int(i) * d + (p)) % 2019
    dp[p] += 1
    d *= 10
    d = d % 2019
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)

Measured memory_bytes: 9312
from collections import deque
import copy
 
def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]
 
 
    # スタート地点をqueueに追加
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])
 
    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))
 
        if nque:
            que = copy.copy(nque)
        else:
            break
 
    print(count - 1)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 115492
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
print(min(n%k, k-n%k))

Measured memory_bytes: 10212
#include<iostream>
#include<string>
using namespace std;
int main(){
  string  a,b;
  cin>>a>>b;
  int x=stoi(a+b);
  for(int i=0;i<=1000;i++){
    if(x==i*i){
      puts("Yes");
      return 0;
    }
  }
    puts("No");
}
  

Measured memory_bytes: 256
def feasible():
    n, m = map(int, raw_input().split())
    g = [ raw_input().strip() for r in range(n) ]
    start = 0
    for row in g:
        in_row = False
        found_row = False
        for c, ch in enumerate(row):
            if ch == '.':
                in_row = False
                continue
            if c < start:
                return False
            if not in_row and found_row:
                return False
            in_row = True
            found_row = True
            start = c
    return True
                
print('Possible' if feasible() else 'Impossible')


Measured memory_bytes: 9328
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  map<int,LL>m;
  REP(i,0,n){
    LL a;
    cin>>a;
    ++m[a];
  }
  LL cnt = 0;
  for(auto v:m){
    if(v.first <v.second)cnt+=v.second-v.first;
    else if(v.second<v.first)cnt+=v.second;
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 6272
n = int(input())
a = [int(input()) for _ in range(n)]
a = sorted(a)
b = abs###
# min, max
p,q = a[0],a[-1]
res = b(p-q)
for i in range(n//2-1):
    # i+1, n-2-i
    res += b(p-a[n-2-i])
    res += b(q-a[i+1])
    p,q = a[i+1],a[n-2-i]
if n%2==1:
    c = a[n//2]
    res += max(b(p-c),b(q-c))
print(res)


Measured memory_bytes: 8284
#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;
}
const int maxn=(3e5)+10;
int n,d[maxn],s[maxn],S;
bool solve(int mid) {
	int mn=0;
	for (int i=1;i<=n;i+=2) {
		if (mn<=s[i]-mid) {
			if (i==n) return 1;
			mn=min(mn,s[i+1]);
		}
	}
	return 0;
}
void solve1() {
	int a=0;
	for (int i=1;i<=n;i++) {
		s[i]=s[i-1];
		if (i&1) s[i]+=d[i];
		else s[i]-=d[i],a+=d[i];
		S+=d[i];
		//printf("%d ",s[i]);
	}
//	printf("\n");
	int l=0,r=S,res,mid;
	while (l<=r) {
		mid=(l+r)/2;
		if (solve(mid)) res=mid,l=mid+1;
		else r=mid-1;
	}
	res+=a;
	printf("%d %d\n",res,S-res);
}
void solve2() {
	int a=0,b=0;
	for (int i=1;i<=n;i++)
		if (i&1) a+=d[i];
		else b+=d[i];
	printf("%d %d\n",max(a,b),min(a,b));
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(d[i]);
	if (n&1) solve1();
	else solve2();
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
  int N,A,B;
  cin>>N>>A>>B;
  int a=0,b=0,c=0;
  for(int i=0;i<N;i++){
    int p;
    cin>>p;
    if(p<=A) a++;
    if(A<p&&p<=B) b++;
    if(p>B) c++;
  }
  cout<< min(a,min(b,c)) <<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, k;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        k = sc.nextInt();
        solve();
    }

    void solve() {
        int current = 1;
        for (int i = 0; i < n; i++) {
            if (current >= k) {
                current += k;
            } else {
                current *= 2;
            }
        }
        System.out.println(current);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#pragma GCC_compile("Ofast")
#define INF 1e9+5
using namespace std;

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int N,K,MIN;

    cin>>N>>K;    

    vector<int>h(N);
    vector<int>dp(N);


    for(int& x:h){
        cin>>x;
    }
 
    dp[0]=0;
    for(int i=1;i<N;i++){
        MIN=INF;
        for(int j=1;j<=min(i,K);j++){
            MIN=min(MIN,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i]=MIN;
    }

   cout<<dp[N-1]<<endl;

   return 0;
}

Measured memory_bytes: 1024
target = input()
first, second = int(target[0:2]), int(target[2:4])
if first == 0:
  first = 100
if second == 0:
  second = 100

def check():
  if first >12 and second >12:
    return 'NA'
  elif first <= 12 and second <= 12:
    return 'AMBIGUOUS'
  elif first >12 and second <= 12:
    return 'YYMM'
  else:
    return 'MMYY'

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

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define rap(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
  int n,a[10000],b[10000]={};
  cin>>n;
  rap(i,n){
    cin>>a[i];
  }
  rap(i,n){
    if(a[i]%2==0){
      if(a[i]%3==0 || a[i]%5==0){
	b[i]=1;
      }
    }else{
      b[i]=1;
    }
  }
  rap(i,n){
    if(b[i]!=1){
      cout<<"DENIED\n";
      return(0);
    }
  }
  cout<<"APPROVED\n";
  return(0);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

int a[301][301] = { {0} };
vector<ll> s[90001];
P m[90001] = { P(0 ,0) };

void solve_abc154() {
	string s, t, u;
	ll a, b;
	ll ans = 0;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (u == s) a--;
	else if (u == t) b--;

	cout << a << " " << b <<"\n";
}

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

	solve_abc154();

	return 0;
}

Measured memory_bytes: 3840
#include <iostream>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = a-b;
  if(k % 2 == 1){
    ans *= -1;
  }
  if(abs(ans) > 1e+18){
    cout << "Unfair" << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int ruijou(int);
int ruijou(int n){
  int i,sum=1;
  for(i=0;i<=n;i++){
    sum*=5;
  }
  return sum;
}

main(){
  int data[20];
  int i,j,sum,n,a;

  for(i=0;i<14;i++){
    data[i]=ruijou(i);
  }

  while(1){
    scanf("%d", &n);
    if(n==0) break;

    sum=0;
    for(i=0;data[i]<=n;i++){
      a=n/data[i];
      sum+=a;
    }

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

Measured memory_bytes: 0
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <set>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;
int m;

vector<set<int>> g;
vi used;

int cur = 0;
int ans = 0;

void input() {
  g.clear();
  used.clear();
  ans = 0;
  cur = 0;

  cin >> n >> m;

  g.resize(n);
  used.resize(n);

  for (int i = 0; i < m; ++i) {
    int u;
    int v;
    cin >> u >> v;

    --u;
    --v;

    g[u].insert(v);
    g[v].insert(u);
  }
}

void dfs(int v, int prev = -1) {
  ++cur;

  used[v] = 1;

  for (auto&& i : g[v]) {
    if (used[i] || i == prev)
      continue;

    dfs(i, v);
  }
}

void solve() {
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      dfs(i);

      ans = max(ans, cur);

      cur = 0;
    }
  }
  
  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 41384
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, X, Y;
	cin >> N >> X >> Y;

	--X; --Y;
	vector<int> ans(N, 0);
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			int idx = j - i;
			idx = min(idx, abs(X - i) + 1 + abs(Y - j));
			idx = min(idx, abs(Y - i) + 1 + abs(X - j));
			++ans[idx];
		}
	}

	for (int i = 1; i < N; ++i) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, a[60], k, ans;
vector<int> v[60][60];
int main()
{
    IO
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++)
        {
            for(int ii=1; ii<=i; ii++)
                v[i][j].push_back(a[ii]);
            for(int ii=n; ii>=n-j+1; ii--)
                v[i][j].push_back(a[ii]);
            sort(v[i][j].begin(),v[i][j].end());
        }
    for(int i=0; i<=k; i++)
        for(int j=0; j<=k; j++)
            for(int r=0; r<=k; r++)
            {
                if(i+j+r>k || i+j>n || r>i+j)
                    continue;
                int sum=0;
                for(auto t : v[i][j])
                    sum+=t;
                for(int t=0; t<r; t++)
                    sum-=v[i][j][t];
                ans=max(ans,sum);
            }
    cout<<ans;

}


Measured memory_bytes: 4488
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int ans = 0;
		int n = scan.nextInt();
		int m = scan.nextInt();
		int h[] = new int[n];
		int a[][]= new int[m][2];
		int non[] = new int[n];
		
		for(int i=0;i<n;i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i=0;i<m;i++) {
			for(int j=0;j<2;j++) {
				a[i][j] = scan.nextInt();
			}
			
			if(h[a[i][0]-1]<h[a[i][1]-1]) {
				non[a[i][0]-1] = 1;
			}else if(h[a[i][0]-1]>h[a[i][1]-1]){
				non[a[i][1]-1] = 1;
			}else if(h[a[i][0]-1]==h[a[i][1]-1]){
				non[a[i][1]-1] = 1;
				non[a[i][0]-1] = 1;
			}
		}
		
		for(int i=0;i<n;i++) {
			if(non[i] == 0) {
				ans += 1;
			}
		}
		
		System.out.println(ans);
	}	
	
	
	//最小公約数
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
}


Measured memory_bytes: 63236
#coding:utf-8
N=input()
P=map(int,raw_input().split())
c=0
R=range(1,N+1)
for i in range(N-1):
    if P[i]==R[i]:
        P[i],P[i+1]=P[i+1],P[i]
        c+=1
if P[N-1]==R[N-1]:
    c+=1
print(c)    

Measured memory_bytes: 42476
import java.util.*;


public class Main {
  public static void main(String[] args) throws Exception {
  Scanner sc = new Scanner(System.in);
  String s = sc.nextLine();

  isOddString(s.substring(0, s.length() - 1));
  }

  public static void isOddString(String s) {
  if (s.length() % 2 != 0) {
    isOddString(s.substring(0, s.length() - 1));
  }
  if (s.substring(0, s.length() / 2).equals(s.substring(s.length() / 2, s.length()))) {
    System.out.println(s.length());
    System.exit(0);
  } else {
    isOddString(s.substring(0, s.length() - 1));
  }
  }
}


Measured memory_bytes: 23252
s=str(input())
s=s[::-1]
t=''
#print(s)
i=0
while i<len(s):
    if s[i:i+5]=='maerd':
        t+='maerd'
        i+=5
    elif s[i:i+5]=='esare':
        t+='esare'
        i+=5
    elif s[i:i+6]=='resare':
        t+='resare'
        i+=6
    elif s[i:i+7]=='remaerd':
        t+='remaerd'
        i+=7
    else:
        break
if s==t:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include<string.h>
using namespace std;
char a[110][11];
int n;
int ok(char s[11])
{
    int count=0;  int f;
    for(int i=1;i<=n;i++)
    {
          string b=a[i];
          string c=s;
          if(b==c)
            count++;
     }
    if(count>=2)
        return 0;
    else
        return 1;
}
int main()
{
    int f=1;
    scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
       scanf("%s",a[i]);
       if(i==1)
        continue;
       if(ok(a[i])&&a[i][0]==a[i-1][strlen(a[i-1])-1])
        continue;
       else
       {
           f=0;
       }
   }
   if(f)
    printf("Yes\n");
   else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 20000000
#define K 10000
void CS(int *,int *,int,int);
void show(int *,int);
int main(){
  int n,i,*num,*ans,*p,max=0;
  
  scanf("%d",&n);
  num=(int *)malloc(n*sizeof(int));
  ans=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
  scanf("%d",&num[i]);
  if(max<num[i])
    max=num[i];
}
  max++;
 
   CS(num,ans,n,max);
  show(ans,n);
  return 0;
}
  void CS(int num[],int ans[],int n,int max){
  int i,*C;
  C=(int *)malloc(max*sizeof(int));
  for(i=0;i<max;i++)
    C[i]=0;
  for(i=0;i<n;i++)
    C[num[i]]++;
  for(i=1;i<max;i++)
    C[i]+=C[i-1];

  for(i=n-1;i>=0;i--){

  ans[C[num[i]]-1]=num[i];
  C[num[i]]--;
}
}
  void show(int ans[],int n){

  int i;
  for(i=0;i<n;i++){
  if(i!=0)
    printf(" ");
  printf("%d",ans[i]);
      }
  printf("\n");
}



Measured memory_bytes: 17420
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{
    int p, l, r;
}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];
int H[MAX];

void calcDepth(int u, int p){
    D[u] = p;
    if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
    if(T[u].r!=NIL) calcDepth(T[u].r,p+1);
}

int calcHeight(int a,int h){
    int h1=0,h2=0;
    if(T[a].l!=NIL)h1=calcHeight(T[a].l,h)+1;
    if(T[a].r!=NIL)h2=calcHeight(T[a].r,h)+1;
    return H[a]=(h1>h2?h1:h2);
}

int getSibling(int u){
    if(T[u].p==NIL)return NIL;
    if(T[T[u].p].l!=u && T[T[u].p].l!=NIL)return T[T[u].p].l;
    if(T[T[u].p].r!=u && T[T[u].p].r!=NIL)return T[T[u].p].r;
    return NIL;
}

void print(int u){
    int i, c;
    int deg=0;
    if(T[u].l!=NIL)deg++;
    if(T[u].r!=NIL)deg++;
    printf("node %d: parent = %d, ",u,T[u].p);
    printf("sibling = %d, degree = %d, ",getSibling(u),deg);
    printf("depth = %d, height = %d, ",D[u],H[u]);
    
    if(T[u].p==NIL) printf("root\n");
    else if(T[u].l==NIL && T[u].r==NIL) printf("leaf\n");
    else printf("internal node\n");
    
}

int main(){
    int i, j, k;
    int n;
    int id, sib, child1,child2;
    int temp;
    int root = NIL;
    scanf("%d", &n);
    for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
    
    for(i=0; i<n; i++){
        scanf("%d",&id);
        scanf("%d %d",&child1,&child2);
        T[id].l=child1;
        T[id].r=child2;
        if(child1!=NIL)T[child1].p=id;
        if(child2!=NIL)T[child2].p=id;
    }
    //根を求める (find the root)
    for(i=0; i<n; i++){
        if(T[i].p == -1) root = i;
    }
    
    //それぞれのノードの深さを求める (find depth of each node)
    calcDepth(root, 0);
    calcHeight(root,0);
    
    //出力 (output)
    for(i=0; i<n; i++) print(i);
    
    return 0;
}



Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
constexpr ll INF = 1LL << 60;
template<class T> inline void chmin(T& a, T b) { if (a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }

void cinv(lls& llVec, ll n, bool to_0_origin = false) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		if (to_0_origin) val--;
		llVec.push_back(val);
	}
}


int main()
{
	std::string S;
	ll K;
	cin >> S >> K;

	ll i;
	for (i = 1; i < S.length(); i++) {
		if (S[0] != S[i]) break;
	}
	ll s = i; //先頭から一致した数

	for (i = S.length() - 1; i >= 0; i--) {
		if (S[0] != S[i]) break;
	}
	ll e = S.length() - 1 - i;

	//全文字一致の時
	if (s == S.length()) {
		ll allLen = S.length() * K;
		cout << allLen / 2 << '\n';
		return 0;
	}


	std::string midS;

	
	if (e == 0) {//前と後ろが異なるとき
		midS = S;
		s = 0;
		e = 0;
	}
	else {
		midS = S.substr(s, S.length() - s - e);
	}

	ll chgCount = 0;
	ll count = 0;
	for (i = 1; i < midS.length(); i++) {
		if (midS[i - 1] == midS[i]) {
			count++;
		}
		else {
			chgCount += ((count+1) / 2);
			count = 0;
		}
	}
	chgCount += ((count + 1) / 2);
	ll chgNumMid = chgCount;

	cout << s / 2 + ((s + e) / 2) * (K - 1) + e/2 + chgNumMid*K << '\n';

	return 0;
}



Measured memory_bytes: 256
import sys
A = int(input())
B = int(input())
C = int(input())
X = int(input())

if not (0 <= A <= 50 and 0 <= B <= 50 and 0 <= C <= 50):
    sys.exit()
if not ( 1 <= A + B + C ):
    sys.exit()
if not ( 50 <= X <= 20000 ):
    sys.exit()
if X % 50 != 0:
    sys.exit()

count = 0
for I in range(A+1):
    for J in range(B+1):
        for K in range(C+1):
            if I * 500 + J * 100 + K * 50 == X:
                count += 1
print(count)

Measured memory_bytes: 9148
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int h, w;
		cin >> h >> w;

		if ( !( h | w ) )
		{
			break;
		}

		VI hs( h ), ws( w );
		FOR( a, hs )
		{
			cin >> a;
		}
		FOR( a, ws )
		{
			cin >> a;
		}

		VI widths;
		{
			VI csum( 1, 0 );
			partial_sum( ALL( ws ), back_inserter( csum ) );

			REP( i, 0, w )
			{
				REP( j, i + 1, w + 1 )
				{
					widths.PB( csum[j] - csum[i] ); 
				}
			}
		}
		sort( ALL( widths ) );

		VI csum( 1, 0 );
		partial_sum( ALL( hs ), back_inserter( csum ) );

		int res = 0;
		REP( i, 0, h )
		{
			REP( j, i + 1, h + 1 )
			{
				auto pos = equal_range( ALL( widths ), csum[j] - csum[i] );
				res += distance( pos.fst, pos.snd );
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 17556
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] x = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = sc.nextInt();
		}
		if (n >= m) {
			System.out.println(0);
			System.exit(0);
		}
		Arrays.sort(x);
		int[] sa = new int[m - 1];
		for (int i = 0; i < m - 1; i++) {
			sa[i] = x[i + 1] - x[i];
		}
		Arrays.sort(sa);
		long len = x[m - 1] - x[0];
		for (int i = 0; i < n - 1; i++) {
			len -= sa[m - 2 - i];
		}
		System.out.println(len);
	}
}

Measured memory_bytes: 49728
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

string s;

#define DEBUG 1

int dp[505][505];


bool iscat(int left, int right) {

	if (left > right) return true;
	if (s[left] != 'm' || s[right] != 'w') {
		return dp[left][right] = false;
	}
	if (dp[left][right] != -1) {
		return dp[left][right];
	}

	for (int i = left; i + 1 <= right; i++) {
		if (iscat(left + 1, i - 1) && s[i] == 'e' && iscat(i + 1, right - 1)) {
			return dp[left][right] = true;
		}
	}
	return dp[left][right] = false;
}


int main() {

	cin >> s;
	memset(dp, -1, sizeof(dp));
	if (iscat(0, s.size() - 1)) {
		cout << "Cat" << endl;
	}
	else
	{
		cout << "Rabbit" << endl;
	}
		
	return 0;

}



Measured memory_bytes: 4212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long DP[200001];
int C[200001];
void Calc(){
	int N = rei();
	for(int i=0;i<=200000;i++){
		C[i] = -1;
	}
	DP[0] = 1;
	for(int i=0;i<N;i++){
		int c = rei();
		if(C[c] == -1 || C[c] == i-1){
			DP[i+1] = DP[i]; 
		}
		else{
			DP[i+1] = (DP[C[c]+1] + DP[i]) % mod;
		}
		C[c] = i;
	}
	cout << DP[N] << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

mod = 10**9 + 7
fac = [1] * (h+w+1)
inv = [1] * (h+w+1)
for i in range(1,h+w):
    fac[i] = (fac[i-1] * i)%mod
    inv[i] = pow(fac[i], mod-2, mod)

def cmb(n,r):
    return fac[n] * inv[r] * inv[n-r] % mod
    
for x in range(b,w):
    c = x + (h - a - 1)
    d = (w - x - 1) + (a - 1)
    e = cmb(c, x) * cmb(d, a - 1)
    ans = (ans+e)%mod

print(ans)

Measured memory_bytes: 44140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(long long *)a-*(long long *)b;
}

int dp[1000000];
int dp_o[1000000];
int tetra[200];
int tetra_o[200];

int main(void){
	int n,t,i,j;
	t=0;
	rep(i,200){
		tetra[i]=i*(i+1)*(i+2)/6;
		if(tetra[i]%2){
			tetra_o[t++]=tetra[i];
		}
	}
	rep(i,1000000){
		dp[i]=dp_o[i]=inf;
	}
	dp[0]=dp_o[0]=0;
	rep(i,200){
		for(j=tetra[i];j<1000000;j++){
			dp[j]=min(dp[j],dp[j-tetra[i]]+1);
		}
	}
	rep(i,t){
		for(j=tetra_o[i];j<1000000;j++){
			dp_o[j]=min(dp_o[j],dp_o[j-tetra_o[i]]+1);
		}
	}
	while(1){
		scanf("%d",&n);
		if(!n) break;
		printf("%d %d\n",dp[n],dp_o[n]);
	}
	return 0;
}

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

using namespace std;

struct Dsu {
    int n;
    vector<int> p;
    vector<int> r;
    
    Dsu(int _n) { n = _n; p.resize(n); r.resize(n); init(); }
    inline void init() {
        for (int i = 0; i < n; i++) {
            p[i] = i;
            r[i] = 1;
        }
    }
    inline int find(int x) {
        return p[x] == x ? x: p[x] = find(p[x]);
    }
    inline bool join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (r[x] < r[y]) swap(x, y);
        p[y] = x; r[x] += r[y];
        return true;
    }
    inline bool check(int x, int y) {
        return find(x) == find(y);
    }
};

void solve() {
    int n, m, q;
    cin >> n >> m >> q;
    Dsu road(n), rail(n);
    for (int _ = 0; _ < m; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        road.join(x,y);
    }
    for (int _ = 0; _ < q; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        //if (road.check(x,y))
        //    rail.join(x,y);
        rail.join(x,y);
    }
    map<pair<int, int>, int> mp;
    for (int i = 0; i < n; i++) {
        mp[{road.find(i), rail.find(i)}]++;
    }
    for (int i = 0; i < n; i++) {
        cout << mp[{road.find(i), rail.find(i)}] << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;//最下位ビットが立っているときにx^(2^i)をかける
        x = x * x % mod; //xを順次二乗していく
        n >>= 1;
    }
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << mod_pow(n, m, MOD) << endl;
}


Measured memory_bytes: 3216
n = int(input())
a = list(map(int, input().split()))

ans = 0
current = 1

if n == 1 and a[0] == 1:
    print('0')
else:
    for i in range(n):
        if current != a[i]:
            ans += 1
        elif current-1 == a[i]:
            ans += 1
        else:
            current += 1

    if current != 1:
        print(ans)
    else:
        print('-1')


Measured memory_bytes: 26268
s = input()

if s == 'SUN':
    print('7')
elif s == 'MON':
    print('6')
elif s == 'TUE':
    print('5')
elif s == 'WED':
    print('4')
elif s == 'THU':
    print('3')
elif s == 'FRI':
    print('2')
else:
    print('1')


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const int MOD = 1e9 + 7;
int sum(int a, int b) { return (a + b) % MOD; }
int prod(int a, int b) { return a * 1ll * b % MOD; }

int mpow(int b, int e) {
    if (e == 0) return 1;
    if (e&1) return prod(b, mpow(b, e-1));
    return mpow(prod(b, b), e/2);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;

    int nf = 1;
    for (int i = 2; i <= N; i++)
        nf = prod(nf, i);

    vi inv(N + 1);
    for (int i = 1; i <= N; i++) {
        inv[i] = prod(nf, mpow(i, MOD-2));
    }

    vi pref(N + 1);
    for (int i = 2; i <= N; i++) {
        pref[i] = sum(pref[i-1], inv[i]);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int ct = nf;
        ct = sum(ct, pref[i + 1]);
        ct = sum(ct, pref[N - i]);

        int val;
        cin >> val;
        ans = sum(ans, prod(ct, val));
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
char s[1000003],p[2000002],*q;main(i,n,m){for(;scanf("%d%*d%s",&n,s+2)*n;printf("%d\n",m)){for(i=0;i<n*2+1;i++)sprintf(p+i,i&1?"O":"I");m=0;for(q=s;q=strstr(q+2,p);m++);}}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 1608
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M, X, Y = LI()
    x = LI()
    y = LI()

    x.sort()
    y.sort()

    has_war = True
    for Z in range(X, Y+1):
        if X < Z <= Y and x[-1] < Z <= y[0]:
            has_war = False

    if has_war:
        print('War')
    else:
        print('No War')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10040
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

ll A, B, C, D;
ll f(ll x) {
    return x / lcm(C, D);
}

ll g(ll x) {
    return x / C;
}

ll h(ll x) {
    return x / D;
}

ll i(ll x) {
    return g(x) + h(x) - f(x);
}

void solve(){
    // ll A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << B - A + 1 - (i(B) - i(A-1)) << endl;

    return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int main(){
  int N;
  cin >> N;
  int h[N];
  rep(i,N){
    cin >> h[i];
  }
  int ans = 0;
  int M = 0;
  int pre = h[0];
  for(int i = 1; i < N; i++){
    if(h[i] <= pre){
      ans++;
      pre = h[i];
    }
    else{
      ans = 0;
      pre = h[i];
    }
    M = max(M,ans);
    //cout << ans << endl;
  }
  cout << M << endl;
}




Measured memory_bytes: 640
#include <cstdio>
#include <cstdint>
#include <string>

int main() {
  int Q;
  scanf("%d", &Q);

  uintmax_t sign = 0x80000000uLL;

  for (int i = 0; i < Q; ++i) {
    uintmax_t n;
    scanf("%jx", &n);

    bool neg = false;
    if (n & sign) {
      n ^= sign;
      neg = true;
    }
    intmax_t ipart = n >> 7;
    intmax_t fpart = n & 127;

    if (neg) printf("-");
    if (fpart == 0) {
      printf("%jd.0\n", ipart);
    } else {
      char buf[1024];
      snprintf(buf, sizeof buf, "%.12f", n/128.0);
      std::string res(buf);
      while (res.back() == '0') res.pop_back();
      printf("%s\n", res.c_str());
    }
  }
}



Measured memory_bytes: 2824