akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>      
using namespace std;            

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    int x;
        cin>>x;
     cout<<(x^1LL);
}

Measured memory_bytes: 3612
#!/usr/bin/env python3
# coding=utf-8

import sys

def digit_sum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

n, a, b = sys.stdin.readline().split(" ")
n = int(n)
a = int(a)
b = int(b)
ans = 0
for i in range(1, n + 1):
    if a <= digit_sum(i) <= b:
        ans += i
print(ans)

Measured memory_bytes: 3064
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#############################################

N,K=map(int,input().split())
N=N%K
print(min(N,abs(N-K)))







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

int main(){
    int a,b,c,d;
    cin >> a  >> b >> c >> d;
    if(a+b>c+d){
        cout << "Left" << endl;
    }
    else if(a+b<c+d){
        cout << "Right" << endl;
    }
    else{
        cout << "Balanced" << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int w,h,n;
	cin>>w>>h>>n;
	int minx=0,maxx=w,miny=0,maxy=h;
	int a,b,c;
	while(n--){
		cin>>a>>b>>c;
		if(c==1)
			minx=max(minx,a);
		else if(c==2)
			maxx=min(maxx,a);
		else if(c==3)
			miny=max(miny,b);
		else
			maxy=min(maxy,b);
	}
	cout<<max(maxx-minx,0)*max(maxy-miny,0);
}

Measured memory_bytes: 256
N, M = [int(x) for x in input().split(' ')]
H =  [int(x) for x in input().split(' ')]

C = set(range(1,N+1))
for _ in range(M):
  a, b = set(int(x) for x in input().split(' '))
  if H[a-1] >= H[b-1] and b in C:
    C.remove(b)
  if H[b-1] >= H[a-1] and a in C:
    C.remove(a)
    
print(len(C))
         

Measured memory_bytes: 22384
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(void) {
    ll n;
    cin>>n;
    vector<ll> v;
    rep(i,0,n){
        ll a;
        cin>>a;
        a-=i+1;
        v.pb(a);
    }
    sort(all(v));
    ll b = v[n/2];
    ll sum = 0;
    rep(i,0,n){
        sum += abs(v[i]-b);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2548
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
			//↓

            var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];

            Console.WriteLine(Math.Max(a + b, Math.Max(a - b, a * b)));


			//↑
        }
	}
}

Measured memory_bytes: 13396
#include<iostream>

using namespace std;

int main(void) {
	int n;
	char s[101];
	bool flag = false;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> s[i];
	}

	for (int i = 1; i <= n; i++) {
		if (s[i] == 'Y') {
			flag = true;
		}
	}

	if (flag) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
T = [[0] * (2 * K + 5) for i in range(2 * K + 5)]
for i in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'W':
        y += K
    T[x % (2 * K) + 1][y % (2 * K) + 1] += 1

for i in range(1, 2 * K + 1):
    for j in range(1, 2 * K + 1):
        T[i][j] += T[i][j - 1]


for j in range(1, 2 * K + 1):
    for i in range(1, 2 * K + 1):
        T[i][j] += T[i - 1][j]


num = 0
for i in range(K + 1):
    for j in range(K + 1):
        d = T[i][j]
        d += T[i + K][j + K] - T[i][j + K] - T[i + K][j] + T[i][j]
        d += T[2 * K][j] - T[i + K][j]
        d += T[i][2 * K] - T[i][j + K]
        d += T[2 * K][2 * K] - T[2 * K][j + K] - T[i + K][2 * K] + T[i + K][j + K]
        num = max(num, d)
        num = max(num, N - d)

print(num)

Measured memory_bytes: 78888
#include<cstdio>
#define NUM 10
using namespace std;
bool solve(int data[NUM], int id, int l, int r){
  if(id == NUM)
    return true;
  else if(data[id] > l && data[id] > r)
    return solve(data,id+1,data[id],r) || solve(data,id+1,l,data[id]);
  else if(data[id] < l){
    if(data[id] < r)
      return false;
    else
      return solve(data,id+1,l,data[id]);
  }
  return solve(data,id+1,data[id],r);
}
int main(){
  int N;
  scanf("%d",&N);
  int data[NUM];
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < NUM ; j++)
      scanf("%d",&data[j]);
    if(solve(data,0,0,0))
      printf("YES\n");
    else
      printf("NO\n");
  }
}



Measured memory_bytes: 2612
#include <stdio.h>
#include <math.h>
void three_sort(int *a, int *b, int *c){
  int x;
    if(*a > *c){
	x = *c;
	*c = *a;
	*a = x;
    }
    if(*b > *c){
	x = *b;
	*b = *c;
	*c = x;
      }
}
int main(){
  int a, b, c;
  int cnt, i;

  scanf("%d", &cnt);

  for(i = 0; i < cnt; i++){
    scanf(" %d %d %d", &a, &b, &c);
    three_sort(&a, &b, &c);
    if(pow(c, 2) == pow(a, 2) + pow(b, 2)){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=2005;
int n,sz[N],dp[N],ans=1<<30;
char str[N];vector<int>E[N];
void dfs(int u,int f){
	sz[u]=str[u]-'0';dp[u]=0;
	for(int v:E[u])
		if(v!=f){
			dfs(v,u);sz[u]+=sz[v];
			dp[u]+=dp[v]+sz[v];
		}
}
int calc(int u,int f){
	int son=0;
	for(int v:E[u])
		if(v!=f&&dp[v]+sz[v]>dp[son]+sz[son])
			son=v;
	if(!son)return 0;
	int val=calc(son,u)+sz[son];
	if(dp[u]-dp[son]-sz[son]>=val)
		return dp[u]&1;
	else
		return val-(dp[u]-dp[son]-sz[son]);
}
int main(){
	scanf("%d%s",&n,str+1);
	for(int i=1,x,y;i<n;++i){
		scanf("%d%d",&x,&y);
		E[x].push_back(y);E[y].push_back(x);
	}
	for(int i=1;i<=n;++i){
		dfs(i,0);
		if(!calc(i,0))ans=min(ans,dp[i]>>1);
	}
	printf("%d\n",ans==1<<30?-1:ans);
	return 0;
}


Measured memory_bytes: 512
N = int(input())
d = dict()

for i in range(N):
    a = str(input())
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

ans = 0
for v in d.values():
    if (v & 1) == 1:
        ans += 1

print(ans)



Measured memory_bytes: 17880
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,p[10],i,max=0,ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    ans+=p[i];
    if(p[i]>max)max=p[i];
  }
  printf("%d",ans-max/2);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int N, ans=0;
    double mean = 0;
    cin >> N;
    int X[N];
    REP(i, N){
        cin >> X[i];
        mean += X[i];
    }
    mean = (double)round((double)mean/N);
    REP(i, N){
        ans += (X[i]-mean)*(X[i]-mean);
    }
    cout << ans << endl;
    // cout << mean << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;

    int x;
    int ans = 0;
    rep(i, n) {
        cin >> x;
        ans += x - 1;
    }
 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3588
/* be name khoda */

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define forifrom(i, s, n) for (ll i = (s); i < (n); ++i)
#define fori(i, n) forifrom(i, 0, n)
#define forirto(i, n, e) for (ll i = (n - 1); i >= (e); --i)
#define forir(i, n) forirto(i, n, 0)

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define S second
#define F first

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const ll maxn = 100010;

ll n, m;
vi out[maxn], in[maxn];
ll col[maxn];
ll cnt[3];
bool good;

ll dfs(ll x) {
    ++cnt[col[x]];
    ll c1 = (col[x] + 1) % 3;
    ll c2 = (col[x] + 2) % 3;
    ll e = 0;
    for (auto y : out[x]) {
        if (col[y] == -1) {
            col[y] = c1;
            e += dfs(y);
        } else if (col[y] != c1) {
            good = false;
        }
    }
    for (auto y : in[x]) {
        if (col[y] == -1) {
            col[y] = c2;
            e += dfs(y);
        } else if (col[y] != c2) {
            good = false;
        }
    }
    return e + ((ll) out[x].size());
}

int main() {

    cin >> n >> m;
    fori (i, m) {
        ll a, b; cin >> a >> b; --a, --b;
        out[a].pb(b);
        in[b].pb(a);
    }
    memset(col, -1, sizeof col);
    ll ans = 0;
    fori (i, n) {
        if (col[i] == -1) {
            cnt[0] = cnt[1] = cnt[2] = 0;
            good = true;
            col[i] = 0;
            ll e = dfs(i);
            if (good) {
                if (cnt[0] && cnt[1] && cnt[2]) {
                    ans += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0];
                } else {
                    ans += e;
                }
            } else {
                ll c = cnt[0] + cnt[1] + cnt[2];
                ans += c * c;
            }
        }
    }
    cout << ans << '\n';

}

/*
10 4
1 2
3 2
3 4
5 4
1 4

2 2
1 1
1 2
*/


Measured memory_bytes: 18176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final FastIn in = new FastIn();
	private static final PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		Solver sol = new Solver();
		sol.solve();
		out.close();
	}
	private static final class Solver {
		public void solve() {
			int a = in.nextInt();
			out.println(a * (a + 1) / 2);
		}
	}
	private static final class FastIn {
		private BufferedReader br;
		private StringTokenizer st;
		public FastIn() {
			br = new BufferedReader(new InputStreamReader(System.in), 1 << 20);
			st = null;
		}
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


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


int main()
{
    int n,W;

    cin >>n>>W;
     int wei[n+1],va[n+1];
    int dp[n+1][W+1];
    for(int i=0;i<n;i++)cin >> va[i]>>wei[i];

   for (int w=0;w<=W;++w) dp[0][w]=0;


   for (int i=0;i<n;++i){
        for(int w=0;w<=W;++w){
            if(w>=wei[i]) dp[i+1][w]=max(dp[i][w-wei[i]]+va[i],dp[i][w]);
            else  dp[i+1][w]=dp[i][w];

            }
        }

    cout << dp[n][W]<< endl;
}




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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> A(M,0);
  for(int i=0; i<M; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());
  
  vector<int> B(M-1,0);
  for(int i=0; i<M-1; i++) {
    B[i] = A[i+1]- A[i];
  }
  
  sort(B.begin(), B.end(), greater<int>());
  
  long long sum = 0;
  for(int i=N-1; i<M-1; i++) {
    sum += B[i];
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 1024
n=int(input())
p=list(map(int,input().split()))

a=0
for i in range(n-2):
    if (p[i]<p[i+1] and p[i+1]<p[i+2]) or (p[i]>p[i+1] and p[i+1]>p[i+2]):
        a+=1
print(a)

Measured memory_bytes: 3060
S = input()
T = input()
stot = dict()
sset = set()
tset = set()
for s, t in zip(S, T):
    if s in sset:
        dt = stot[s]
        if t != dt:
            print('No')
            break
    else:
        if not t in tset:
            stot[s] = t
            sset.add(s)
            tset.add(t)
        else:
            print('No')
            break
else:
    print('Yes')


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

using namespace std;

const int N = 2e5 + 7;
int n;
int m;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    if(b > a and c > b) {
        cout << "Yes\n";
        exit(0);
    }
    for(int i = 1 ; i <= k ; ++i) {
        if(a >= b) {
            b *= 2LL;
            continue;
        }
        if(b >= c) {
            c *= 2LL;
            continue;
        }
    }
   // cout << a << " " << b << " " << c << endl;
    if(b > a and c > b) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  double l;
  cin >> l;
  printf("%.8lf",l*l*l/27);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int tt;
int head[N],a[N],to[N*2],nxt[N*2],in[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') ch=getchar(),o=-1;
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void dfs(int x,int fa) {
    if(in[x]==1) return;
    int Mx=0;
    long long sum=0;
    for(int i=head[x];i;i=nxt[i]) {
	int y=to[i];
	if(y!=fa) {
	    dfs(y,x),sum+=a[y];
	    Mx=max(Mx,a[y]);
	}
    }
    if(sum<a[x]||sum>a[x]*2||Mx>a[x])
	puts("NO"),exit(0);
    a[x]-=sum-a[x];
}
int main() {
    int n,rt=1;
    cin>>n;
    if(n==2) return puts(gi()==gi()?"YES":"NO"),0;
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=1;i<n;i++) {
	int x=gi(),y=gi();
	++in[x],++in[y];
	to[++tt]=y,nxt[tt]=head[x],head[x]=tt;
	to[++tt]=x,nxt[tt]=head[y],head[y]=tt;
    }
    for(int i=1;i<=n;i++) if(in[i]>1) rt=i;
    dfs(rt,0);
    puts(a[rt]?"NO":"YES");
    return 0;
}

Measured memory_bytes: 6272
#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <stack>
#include <random>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;

#define X first
#define Y second

int n, a, ans = 1, pr = -1, dl = 0;
bool vo;

int main()
{
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("brackets.in", "r", stdin);
	//freopen("brackets.out", "w", stdout);
#endif

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (pr != -1)
		{
			if (a == pr)
			{
				continue;
			}
			else
			{
				if (dl == 1)
				{
					dl++;
					vo = a > pr;
					pr = a;
				}
				else
				{
					if ((vo && a > pr) || (!vo && a < pr))
					{
						pr = a;
						dl++;
					}
					else
					{
						pr = a;
						dl = 1;
						ans++;
					}
				}
			}
		}
		else
		{
			pr = a;
			dl = 1;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int X = ri();

		Console.WriteLine(10 - X / 200);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


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

int main() {
	long long n, k;
	char d[15];
	cin >> n >> k;
	for (int i = 0; i < k; i++) cin >> d[i];

	for (long long i = n; ; i++) {
		string s = to_string(i);
		bool flag = false;
		for (int j = 0; j < s.size(); j++) {
			for (int l = 0; l < k; l++) {
				if (s[j] == d[l]) {
					flag = true;
					break;
				}
			}
        }
      	if (!flag) {
			cout << s << endl;	
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
 ll a,b,c,k,s=0;
 cin>>a>>b>>c>>k;
 if(k<=a){
     cout<<k<<"\n";
     return 0;
 }
 else{
     s+=a;
     k-=a;
     if(k>b){
         s-=(k-b);
         cout<<s<<"\n";
         return 0;
     }
     else{
         cout<<s<<"\n";
         return 0;
     }
 }
    return 0;
}


Measured memory_bytes: 3624
<?php
fscanf(STDIN, "%d", $n);
$h = array_map('intval', explode(' ', trim(fgets(STDIN))));
$pre = -1;
for ($i = 0; $i < $n; $i++) {
    if ($pre < $h[$i]) {
        $pre = $h[$i] - 1;
    } elseif ($pre === $h[$i]) {
    	$pre = $h[$i];
    } elseif ($pre > $h[$i]) {
        exit ('No'.PHP_EOL);
    }
}
echo 'Yes'.PHP_EOL;

Measured memory_bytes: 16884
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
 
using namespace std;
int sum(string n){
    int sum=0;
    for (int i=0; i<n.length(); ++i) {
        sum+=n[i]-'0';
    }
    return sum;
}
 
int main(){
    string n;
    cin>>n; 
     
    int maxx = 0;
    for (int i = n.length()-1; i>=0; --i) {
        string nn = n;
        if(i-1>=0 && n[i-1]!='0'){
            for (int j = n.length()-1; j>=i; j--)
                nn[j]='9';
            nn[i-1]=(char)(nn[i-1]-1);
        }
        int s = sum(nn);
        maxx = maxx < s ? s : maxx;
    }
    cout<<maxx<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N = 405;
int n;
LL ans = 0, A[N];
LL dp[N][N];

LL solve(int l, int r) {
    if(l == r) return 0;
    if(dp[l][r]>0) return dp[l][r];
    LL res = 0, tmp=1e18;
    for(int i=l; i<=r; i++) res += A[i];
    for(int i=l; i<r; i++) {
        chmin(tmp, solve(l, i) + solve(i+1, r)); 
    }
    return dp[l][r]=tmp+res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n;
    REP(i, n) cin >> A[i];
    cout << solve(0, n-1) << endl;

    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  string a;cin>>a;
  res=1;
  ll n=a.size();  
  vector<ll> b(26);
  for(i=0;i<n;i++){
    b[a[i]-'a']++;
  }
  for(i=0;i<25;i++){
    //cout<<res<<endl;
    for(j=i+1;j<26;j++){
      res+=b[i]*b[j];
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll a,b,c,k;

int main(){
  cin>>a>>b>>c>>k;

  if(k%2){
    cout<<b-a<<endl;
  }
  else{
    cout<<a-b<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a,b,c;
	
	cin >> a >> b >> c;
	
	if ((a<b)&&(b<c)) {
		cout << "Yes" << endl;
 	} else {
 		cout << "No" << endl;
	 }
	
	return 0;
}


Measured memory_bytes: 3100
a, b = map(int, input().split())
mod = (b-a) % 4

if a % 2 == 0:
    if mod == 0:
        c = b
    elif mod == 1:
        c = 1
    elif mod == 2:
        c = 1 ^ b
    else:
        c = 0

else:
    if mod == 0:
        c = a
    elif mod == 1:
        c = a ^ b
    elif mod == 2:
        c = a ^ 1
    else:
        c = a ^ b ^ 1

print(c)


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

int main(){
    int n;
    int a,b;
    int biggest , smallest;
    cin >> n >> a >> b;
    biggest = min(a,b);
    
    smallest =  (a+b)-n;
    if(smallest < 0){
        smallest = 0;
    }
    cout << biggest << " " << smallest <<endl;
}

    

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

int main(){
	string str;
    cin>>str;
    while(str[0]!='0'){
        int i,sum=0;
        for(i=0;i<str.size();i++){
            sum+=str[i]-'0';
        }
        cout<<sum<<endl;
        cin>>str;
    }
    return 0;
}


Measured memory_bytes: 3172
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define all(x) begin(x), end(x)
#define lowbit(x) ((x) & -(x))
#define EB emplace_back
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define maxn 1005
using namespace std;

struct DSU {
    vector<int> s, p;
    DSU(int sz) : s(sz + 1, 1), p(sz + 1, -1) {}
    int find(int x) {
        return (p[x] == -1) ? x : (p[x] = find(p[x]));
    }
    bool join(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(s[x] < s[y]) swap(x, y);
        s[x] += s[y]; p[y] = x;
        return true;
    }
    int cnt() {
        int ret = 0;
        for(int i = 1; i < SZ(p); i++) {
            if(p[i] == -1) ret++;
        }
        return ret;
    }
};

int mx[4] = {0, 0, -1, 1};
int my[4] = {-1, 1, 0, 0};
char mp[maxn][maxn];
int id[maxn][maxn];
int n, m;

bool cool(int i, int j) {
    if(i < 0 || i >= n) return false;
    if(j < 0 || j >= m) return false;
    return mp[i][j] == '#';
}

int solve() {
    int R = 0, C = 0;
    for(int i = 0; i < n; i++) {
        int cnt = 0;
        if(mp[i][0] == '#') cnt++;
        if(mp[i][m - 1] == '#') cnt++;
        for(int j = 1; j < m; j++) {
            if(mp[i][j - 1] != mp[i][j]) cnt++;
        }
        if(cnt > 2) return -1;
        if(cnt) R++;
    }
    for(int j = 0; j < m; j++) {
        int cnt = 0;
        if(mp[0][j] == '#') cnt++;
        if(mp[n - 1][j] == '#') cnt++;
        for(int i = 1; i < n; i++) {
            if(mp[i - 1][j] != mp[i][j]) cnt++;
        }
        if(cnt > 2) return -1;
        if(cnt) C++;
    }
    if((R + C) > 0 && (R != n || C != m)) return -1;
    DSU loli(n * m);
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(mp[i][j] == '.') cnt++;
            else {
                for(int k = 0; k < 4; k++) {
                    int ii = i + mx[k];
                    int jj = j + my[k];
                    if(cool(ii, jj)) {
                        loli.join(id[i][j], id[ii][jj]);
                    }
                }
            }
        }
    }
    return loli.cnt() - cnt;
}


int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    /*cin >> n >> m; int tot = 0;
    for(int i = 0; i < n; i++) {
        cin >> mp[i];
        for(int j = 0; j < m; j++)
            id[i][j] = ++tot;
    }
    cout << solve() << '\n';*/
    int n, m, l, r;
    cin >> n >> m;
    l = 1; r = n;
    for(int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        l = max(l, x); r = min(r, y);
    }
    cout << max(0, r - l + 1) << '\n';
    return 0;
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int absl(int a){
  if(a<0)
    return -a;
  else
    return a;
}

signed main()
{
    int a,b;
    cin>>a>>b;
    if(a%b==0)
      cout<<0<<endl;
    else
    {
       a=a%b;
       int m = a;

       if(m>b-a)
        m=b-a;
        cout<<m<<endl;  
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
	int i = 0, fc = 0, ff = 0;
	string s;

	cin >> s;

	while(s[i] != '\0'){
		if (s[i] == 'C') {
			fc = 1;
		}
		else if (s[i] == 'F' && fc == 1) {
			ff = 1;
		}
		i++;
	}

	if (ff == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		a[i] = getInt() - (i + 1)
		sum += a[i]
	}

	sort.Ints(a)

	b := a[N/2]
	//	out(a, b)
	if N%2 == 0 {
		b += a[N/2-1]
		b /= 2
	}
	ans := 0
	for i := 0; i < N; i++ {
		ans += asub(a[i], b)
	}
	out(ans)
}


Measured memory_bytes: 5120
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<BigInteger> list = new ArrayList<>();
        BigInteger zero = new BigInteger("0");
        for (int i = 0; i < n; i++) {
            BigInteger bi = sc.nextBigInteger();
            if (bi.equals(zero)) {
                System.out.println(0);
                return;
            }
            list.add(bi);
        }

        BigInteger a, b, c;
        a = new BigInteger("1");
        c = new BigInteger("1000000000000000000");

        for (int i = 0; i < n; i++) {
            b = list.get(i);
            a = a.multiply(b);
            if (a.compareTo(c) > 0) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(a);
    }
}


Measured memory_bytes: 68428
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fs first
#define sc second
#define mk make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9+1;
const ll LINF = 1e17;
const int MAKS = 300100;
string s, t;
int cnt;
int main(){
	cin >> s;
	cin >> t;
	int n = s.length();
	for (int i = 0; i < n; i++) if (s[i]==t[i]) cnt++;
	cout << cnt;
}

Measured memory_bytes: 256
S = str(input())

odd = []
Even = []

for i in range(len(S)):
    if i % 2 == 0:
        odd.append(S[i])
    else:
        Even.append(S[i])

ans = 'Yes'
for s in odd:
    if s == 'L':
        ans = 'No'
for s in Even:
    if s == 'R':
        ans = 'No'
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y); 
        if(x==0&&y==0){
            break;
        }else if(y>x){
            printf("%d %d\n",x,y);
        }else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}

Measured memory_bytes: 1680
#include <iostream>
#include <stdio.h>
#include <queue>
#include <string>
using namespace std;
  
class Task {
public:
  void input() {
    scanf("%s %d\n", name, &time);
  }
  char name[10];
  int time;
};
  
int main() {
  int n, q;
  queue<Task> tasks;
  
  cin >> n >> q;
  for (int i=0; i<n; i++) {
    auto task = Task();
    task.input();
    tasks.push(task);
  }
  
  int time = 0;
  
  while (!tasks.empty()) {
    auto current = tasks.front(); tasks.pop();
    if (current.time > q) {
      time += q;
      current.time -= q;
      tasks.push(current);
    } else {
      time += current.time;
      cout << current.name << ' ' << time << endl;
    }
  }
}

Measured memory_bytes: 3772
n=int(input())
l=[0]*10
for i in range(n):
  x=input()
  y=x[0]
  if y=='M':
    l[0]+=1
  elif y=='A':
    l[1]+=1
  elif y=='R':
    l[2]+=1
  elif y=='C':
    l[3]+=1
  elif y=='H':
    l[4]+=1
ans=0
for i in range(3):
  for j in range(i+1,i+4):
    for k in range(j+1,j+4):
      ans+=l[i]*l[j]*l[k]
print(ans)

Measured memory_bytes: 3064
#include<cstdio>

int main(){

	int count[26];
	for(int i = 0;i < 26;i++) {
		count[i] = 0;
	}
	char s[1300];
	while(fgets(s,1300,stdin) != NULL) {
        for(int i = 0;s[i] != '\0';i++) {
            if(s[i] >= 'A' && s[i] <= 'Z') {
                count[s[i] - 'A']++;
            }
            if(s[i] >= 'a' && s[i] <= 'z') {
                count[s[i] - 'a']++;
            }
        }
	}

	for(int i = 0;i < 26;i++) {
		printf("%c : %d\n",'a' + i,count[i]);
	}
	return 0;
}


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

int bubbleSort(int a[],int n){
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=n-1;j>=i+1;j--){
			if(a[j]<a[j-1]){
				swap(a[j],a[j-1]);
				flag=1;
				sw++;
			}
		}
	}
	return sw;
}

int main(){
	int n,a[100],sw;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sw=bubbleSort(a,n);
	for(int i=0;i<n;i++){
		if(i) cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	cout<<sw<<endl;
	return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if(op.equals("?"))break;
            int num = 0;
            switch(op){
                case "+":
                    num = a + b;
                    break;
                case "-":
                    num = a - b;
                    break;
                case "*":
                    num = a * b;
                    break;
                case "/":
                    num = a / b;
                    break;
            }
            System.out.println(num);
        }
    }
}



Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string str = "MARCH";
  vector<int> C(str.size(), 0);
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    for (int j = 0; j < str.size(); j++){
      if (S[0] == str[j]){
        C[j]++;
      }
    }
  }
 long long count = 0;
  for (int i = 0; i < (1 << str.size()); i++){
    if (__builtin_popcount(i) != 3){
      continue;
    }
    long long ans = 1;
    for (int j = 0; j < str.size(); j++){
      if ((i >> j) & 1){
        ans *= C[j];
      }
    }
    count += ans;
  }
  cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <cmath>
#include <math.h>

typedef long long ll;
using namespace std;

int main(void){
    int R;
    cin >> R;
    printf("%.13f\n",2*M_PI*R);
}



Measured memory_bytes: 3760
#include <bits/stdc++.h>
//#include "lib/bigint2.h"

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ if(a>b) a=b;}


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >>n;
	
	map<string, int> mp;
	rep(i, n){
		cin >>s;
		sort(all(s));
		mp[s]++;
	}
	ll ans =0;
	for(auto x: mp){
		ans += (ll)x.second * (x.second-1) / 2;
	}
	
	cout <<ans <<"\n";
	return 0;
}


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

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

#define pow CHANGETHENAMESTUPID

using namespace std;

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

const int MAXN = 2010;

int n;

vector<int> graf[MAXN];

void load() {
	scanf("%d", &n);
	int x, y;
	scanf("%d%d", &x, &y); x--; y--;
	graf[x].push_back(y);
	graf[y].push_back(x);
	FOR(i, (n-1)) {
		graf[i].push_back(i+1);
		graf[i+1].push_back(i);
	}
}

int sol[MAXN];

void bfs(int x) {
	int dist[n];
	FOR(i, n) dist[i] = -1;
	dist[x] = 0;
	queue<int> Q;
	Q.push(x);
	while (!Q.empty()) {
		int p = Q.front(); Q.pop();
		for (int sus : graf[p]) {
			if (dist[sus] != -1) continue;
			dist[sus] = dist[p] + 1;
			Q.push(sus);
		}
	}
	FOR(i, n) {
		if (i != x) sol[dist[i]]++;
	}
}

void solve() {
	FOR(i, n) bfs(i);
	for (int i = 1; i < n; i++) {
		printf("%d\n", sol[i] / 2);
	}
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	ll g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}

void solve()
{

	ll n,k;
	cin>>n>>k;
	ll mod = pow(2,31) - 1ll ;
	ll ans=0 ;
	// k * (k-1)^n
	ans = (fast_power(k-1,n-1,mod)*k)%mod ;
	cout<<ans<<endl;
	 //if(ans)
  //{
  //cout<<"Yes"<<endl; 
  //}
  //else
   //{
  //cout<<"No"<<endl;
  //}
 
	
    //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
return ;
}


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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int nanzyo(long long a){

  int i = 0;

  while((a/=10)!=0) i++;

  return i;
}

int main(void){

  int N;
  long long A[100000];
  long long x = 1;

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  for(int i=0; i<N; i++){
    if(nanzyo(A[i])+nanzyo(x)<18 || A[i]*x==1000000000000000000){
      x*=A[i];
      if(i==N-1 && x<=1000000000000000000) cout << x << endl;
      else if(i==N-1) cout << -1 << endl;
    } else{
      cout << -1 << endl;
      return 0;
    }
  }
  // 

  return 0;
}


Measured memory_bytes: 4420
using System;
using System.Collections.Generic;
using System.Linq;

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

            int max = (int)Math.Sqrt(N);
            var searchList = Enumerable.Range(2, max).ToList();

            var pList = new List<int>();
            while (searchList.Count > 0)
            {
                int cand = searchList.First();

                pList.Add(cand);

                searchList.RemoveAll(x => x % cand == 0);
            }

            var ansList = new List<int>();
            for (int i = 0; i < pList.Count;)
            {
                if (N % pList[i] == 0)
                {
                    ansList.Add(pList[i]);
                    N /= pList[i];
                }
                else i++;
            }
            if (ansList.Count == 0 || N != 1) ansList.Add(N);

            Console.Write("{0}: ", n);
            Console.WriteLine(string.Join(" ", ansList));
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



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

using namespace std;

int main() {
    double d;
    cin >> d;
    int d1 = d*1000;
    double ans = sqrt(2)*d;
    if (d1%1000==0) {
        ans = max(ans, d+1);
    }
    ans = max(ans, ceil(d));
    for (int i = 0; i < d; i++) {
        ans = max(ans, i+(sqrt(d*d-i*i)));
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int A, B;
    cin >> A >> B;
    int ans = -1;
    for (int i = 1; i < A; ++i) {
        int N = B + i;
        if ((N / A) + (N % A) < N / B + (N % B) / A + (N % B % A)) {
            ans = N;
            break;
        }
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3232
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let n = stdin.lock().gets().parse::<usize>().unwrap();
    let hotels = stdin.lock().gets().split(' ').take(n)
        .map(|x| x.parse().unwrap()).collect::<Vec<u32>>();
    let ell = stdin.lock().gets().parse::<u32>().unwrap();
    let q = stdin.lock().gets().parse::<usize>().unwrap();
    let mut queries = Vec::with_capacity(q);
    for line in stdin.lock().lines().take(q).map(|x| x.unwrap()) {
        let (a, b): (usize, usize) = line.split(' ').values();
        queries.push(if a < b { (a - 1, b - 1) } else { (b - 1, a - 1) });
    }

    let mut next = vec![0; n];
    for i in 0..n {
        match hotels[i + 1..].binary_search(&(hotels[i] + ell + 1)) {
            Ok(pos) | Err(pos) => next[i] = i + 1 + pos - 1,
        }
    }
    // Exponential jump table.
    let mut jt = vec![Vec::new(); n];
    for i in (0..n).rev() {
        let mut lv = 0;
        let mut p = next[i];
        jt[i].push(p);
        while p < n - 1 && lv < jt[p].len() {
            p = jt[p][lv];
            jt[i].push(p);
            lv += 1;
        }
    }
    for (a, b) in queries {
        let mut x = a;
        let mut days = 0;
        while x < b {
            match jt[x].iter().enumerate().rev().find(|&(_, &to)| to <= b) {
                Some((i, &to)) => {
                    x = to;
                    days += 1 << i;
                },
                None => {
                    days += 1;	// can go beyond "b" in one day.
                    break;
                },
            }
        }
        println!("{}", days);
    }
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }

trait Values<T> { fn values(&mut self) -> T; }
impl<'a, I, T1, T2> Values<(T1, T2)> for I
    where I: Iterator<Item=&'a str>,
          T1: std::str::FromStr, T1::Err: std::fmt::Debug,
          T2: std::str::FromStr, T2::Err: std::fmt::Debug {
    fn values(&mut self) -> (T1, T2) {
        (self.next().unwrap().parse().unwrap(),
         self.next().unwrap().parse().unwrap())
    }
}


Measured memory_bytes: 29436
if __name__ == '__main__':
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    X.sort()
    del_X = [0]*M
    for i in range(1, M):
        del_X[i] = abs(X[i] - X[i-1])
    
    del_X.sort()
    
    if N == 1:
        pass
    
    for n in range(N-1):
        if len(del_X) > 0:
            del_X.pop()
    
    print(sum(del_X))

Measured memory_bytes: 13968