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

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll Q,K,P,C,N,X;

    long double A,B,H,M, kh,km,ans;

    string S;

    vector<ll>  aa;

    cin >>A>>B>>H>>M;

    kh=360*(H+M/60)/12;
    km=360*M/60;
    ans=sqrt(pow(A,2)+pow(B,2)-2*A*B*cos((kh-km)*M_PI/180));

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

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

int main() {
	int n, d;
	cin >> n >> d;
	
	double x[15][15];
	
	rep(i, n) {
		rep(j, d) {
			cin >> x[i][j];
		}
	}
	
	int ans = 0;
	
	rep(i, n) {
		for (int j = i + 1; j < n; ++j) {
			double temp = 0;
			rep(k, d) {
				temp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			double dist = sqrt(temp);
			if (floor(dist) == ceil(dist)) {
				ans++;
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int cnt[3] = {};
    REP(i, N) {
        ll a;
        cin >> a;
        if (a % 4 == 0) {
            cnt[0]++;
        } else if (a % 2 == 0) {
            cnt[1]++;
        } else {
            cnt[2]++;
        }
    }
    if (cnt[1] > 0) {
        cnt[2]++;
    }
    if (cnt[0] >= cnt[2] - 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int W,a,b;
  cin>>W>>a>>b;
  if((W+a>=b && a<=b)||(W+b>=a && b<=a)) cout<<0<<endl;
  else cout<<min(abs(W+a-b),abs(W+b-a))<<endl;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll >lis(n);
    vector<vector<ll> > updown(n, vector<ll>(2, 0));
    REP(i, 0, n){cin >> lis[i];}
    ll ans = 0;
    REP(i, 0, n){
        if(i + lis[i] < n)
            updown[i+lis[i]][0]++;
        if(i-lis[i] >= 0)
            updown[i-lis[i]][1]++;
    }
    REP(i, 0, n){
        ans += updown[i][0] * updown[i][1];
    }
    cout << ans << endl;
}

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

int main()
{

	long long A, B;
	cin >> A >> B;
	long long ans = A;

	if (B - A <= 10)
	{
		for (long long i = A + 1; i <= B; i++)
		{
			ans = ans ^ i;
		}
	}
	else
	{
		ans = 0;
		for (long long i = A; i % 4 != 0; i++)
		{
			ans = ans ^ i;
		}
		for (long long i = B; i % 4 != 3; i--)
		{
			ans = ans ^ i;
		}
	}
	cout << ans;

	return 0;

}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = RSt();

            int s1 = int.Parse(s.Substring(0, 2));
            int s2 = int.Parse(s.Substring(2, 2));

            bool b1 = s1 >= 1 && 12 >= s1;
            bool b2 = s2 >= 1 && 12 >= s2;

            if (b1 && b2)
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if (b1)
            {
                Console.WriteLine("MMYY");
            }
            else if (b2)
            {
                Console.WriteLine("YYMM");
            }
            else
            {
                Console.WriteLine("NA");
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


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

int main(){
    int flag=0;

    int ans=0;
    int x,y;
    int xi,yi;
    int n,m;
    int maxX=-101,minY=101;
    cin >> n >> m;
    cin >>x>>y;

    for (int i = 0; i < n; i++){
        cin >>xi;
        maxX=max(maxX,xi);
    }
    for (int i = 0; i < m; i++){
        cin >>yi;
        minY=min(minY,yi);
    }
    
    if(x<y && maxX <minY && !(y<=maxX) && !(minY<=x)){
        flag=0;
    }else{
        flag=1;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag==1)cout << "War" <<endl;
    else cout << "No War" <<endl;
    
    return 0;
}


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

using namespace std;

int main()
{
	int top, bot, r, l, f, b, n, s, t;
	string str;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		top = 1;
		bot = 6;
		r = 3;
		b = 2;
		f = 5;
		l = 4;
		s = 1;
		while(n--){
			cin >> str;
			
			if(str == "North"){
				t = top;
				top = b;
				b = bot;
				bot = f;
				f = t;
			} else if(str == "East"){
				t = top;
				top = l;
				l = bot;
				bot = r;
				r = t;
			} else if(str == "South"){
				t = top;
				top = f;
				f = bot;
				bot = b;
				b = t;
			} else if(str == "West"){
				t = top;
				top = r;
				r = bot;
				bot = l;
				l = t;
			} else if(str == "Right"){
				t = b;
				b = r;
				r = f;
				f = l;
				l = t;
			} else if(str == "Left"){
				t = b;
				b = l;
				l = f;
				f = r;
				r = t;
			}
			s += top;
		}
		
		cout << s << endl;
	}
	
	return 0;
}

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

int main(){
  
  int num,sum=0;
  vector<int> m ={300000,200000,100000};
  for(int i =0; i < 2; i++){
   cin >> num;
   if(num < 4)
     sum += m.at(num-1);    
  }
  
  if(sum == 600000)
    cout << 1000000;
  
  else
    cout << sum;
  
  
}


Measured memory_bytes: 256
import numpy as np
import fractions

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    GCDbefore = {}
    GCDafter = {}
    GCDbefore[-1] = 0
    for i in range(N):
        GCDbefore[i] = fractions.gcd(GCDbefore[i-1], A[i])
    GCDafter[N] = 0
    for i in range(N):
        GCDafter[N-1-i] = fractions.gcd(GCDafter[N-i], A[N-1-i])
    ans = 0
    for i in range (N):
        ans = max(ans, fractions.gcd(GCDbefore[i-1], GCDafter[i+1]))
    print(ans)

Measured memory_bytes: 41844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    string ans ="Yes";

    if(a==b &&a==c && b==c) ans ="No";
    if(a!=b &&a!=c && b!=c) ans = "No";


    cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
bool isprime(int n){
  for(int i = 2; i * i <= n; i++){
    if( n % i == 0) return false;
  }
  return true;
}

int main(){
  int n;
  while(cin>>n && n){
    int ans =0;
    for(int i = n + 1; i <= 2 * n; i++){
      ans += isprime(i);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 868
//
//  main.cpp
//  A
//
//  Created by Sultan.
//  Copyright © 2017 Sultan. All rights reserved.
//
//  CF Handle : 2017_Scayre_TBIL_777
//
//  ARSEN TOKSYN ZVER UUUU!!!!
//

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define ll long long
#define ull unsigned ll
#define ioi exit(0);

#define f first
#define s second

#define inf 1e9 + 7;

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)

#define pb(x) push_back(x)
#define ppb(x) pop_back(x)

#define endl "\n"

#define in(x) insert(x)

#define rep(x,y,z) for(int x=y;x<=z;x++)
#define per(x,y,z) for(int x=y;x>=z;x--)

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

using namespace std;

string s;

int main(){
    
    NFS
    
    cin >> s;
    
    for(int i=0;i<s.size()-8;i++){
        cout << s[i];
    }
    
    ioi
}


Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main() {
 
 
	double d, t, s;
 
 
	cin >> d >> t >> s;
 
	d /= s;
 
	if (d <= t) {
 
		cout << "Yes";
 
	}
	else {
 
		cout << "No";
 
	}
 
 
 
	return 0;
}
 

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

lst = list(map(int, input().split()))
lst = sorted(lst, reverse=True)
class Queue:
  def __init__(self):
    self.queue_lst = []
    self.first_flag = True
    self.count = 0
    self.index = 0
  
  def add(self, friend_val):
    if self.first_flag:
      self.queue_lst.append(friend_val)
      self.first_flag = False
    else:
      self.queue_lst.append(friend_val)
      self.queue_lst.append(friend_val)
      self.count += self.queue_lst[self.index]
      self.index += 1
  
queue = Queue()

for i in lst:
  queue.add(i)



print(queue.count)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end(), greater<int>());
  int sum = 0;
  for (int i = 0; i < k; i++)
    sum += l[i];
  cout << sum << endl;
}

Measured memory_bytes: 256
// ===== 2018/06/02 20:42:56 =====

// ../../../lib/template/includes.hpp

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>

// ../../../lib/template/const_value.hpp

template <typename T> constexpr T inf();
template <> constexpr int inf<int>() { return 1e9; }
template <> constexpr long long inf<long long>() { return 1e18; }
template <> constexpr long double inf<long double>() { return 1e30; }

template <typename T>
constexpr typename std::enable_if<std::is_arithmetic<T>::value, T>::type
zero() {
  return T(0);
}

const long double pi = acos(-1.0);

// ../../../lib/template/initialize.cpp

struct yes_no : std::numpunct<char> {
  string_type do_truename() const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

struct Initialize {
  Initialize() {
    std::locale loc(std::locale(), new yes_no);
    std::cout << std::boolalpha << std::setprecision(11) << std::fixed;
    std::cout.imbue(loc);
  }
};

const Initialize init;

// ../../../lib/template/macros.hpp

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

// ../../../lib/template/misc.hpp

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

// ../../../lib/template/range.hpp

class range {
  class index_type {
    int x;

  public:
    index_type(int x_) : x(x_) {}
    int operator*() const { return x; }
    bool operator!=(index_type &r) { return x < r.x; }
    void operator++() { ++x; }
  };
  index_type i, n;

public:
  range(int n_) : i(0), n(n_) {}
  range(int i_, int n_) : i(i_), n(n_) {}
  index_type &begin() { return i; }
  index_type &end() { return n; }
};

// ../../../lib/template/typedef.hpp

using ll = long long;
using ld = long double;
using Point = std::complex<ld>;

// ../../../lib/template/template.cpp

using namespace std;

// D.cpp

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

void solve(ll N, vector<ll> A) {
  ll sum = 0, r = 0, res = 0;
  for (int l = 0; l < N; ++l) {
    while (r < N && sum + A[r] == (sum ^ A[r])) { sum += A[r]; ++r; }
    res += r - l;
    sum -= A[l];
  }
  cout << res << endl;
}

int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	}
	solve(N, A);
	return 0;
}
// ===== 2018/06/02 20:42:56 =====



Measured memory_bytes: 3328
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn = 200005;
int n, fa[maxn], sg[maxn], pos = 1, tot, maxi = -1, mini = 0x3f3f3f3f;
bool vis[maxn], bucket[maxn];
vector<int> e[maxn];

void dfs(int u) {
	for (auto v : e[u])
		if (!vis[v]) dfs(v);
	for (auto v : e[u])
		if (!vis[v]) bucket[sg[v]] = true;
	while (bucket[sg[u]]) ++sg[u];
	for (auto v : e[u])
		if (!vis[v]) bucket[sg[v]] = false;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)cin >> fa[i], e[fa[i]].push_back(i);
	while (!vis[pos]) vis[pos] = true, pos = fa[pos];
	memset(vis, 0, sizeof vis);
	while (!vis[pos]) vis[pos] = true, pos = fa[pos], ++tot;
	if (tot & 1) for (int i = 1; i <= n; ++i)
		if (vis[i]) dfs(i), maxi = max(maxi, sg[i]), mini = min(mini, sg[i]);
	puts(tot & 1 && maxi == mini ? "IMPOSSIBLE" : "POSSIBLE");

	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int mpow(int a, int b) {
	int res = 1;
	for (int cur = a; b; b >>= 1) {
		if (b & 1) res = (int64_t) res * cur % 1000000007;
		cur = (int64_t) cur * cur % 1000000007;
	}
	return res;
}

int main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	int cnt1 = 0;
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '1') { // cancel
			res = (res + (int64_t) mpow(2, cnt1) * mpow(3, n - i - 1)) % 1000000007;
			// 3 ^ cnt1 * 2 & (n - i - 1)
			cnt1++;
		}
	}
	// all
	res = (res + mpow(2, cnt1)) % 1000000007;
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 512
#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;
  }
  if (a+b == c+d){
    cout << "Balanced" << endl;
  }
  if (a+b < c+d){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int n;
    cin >> n;
    Vec<int> v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (v[v[i]] == i) {
            count++;
        }
    }
    cout << count / 2 << endl;
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    cin>>k;
    long long res=0;
    for(a=1;a<=k;a++){
        for(b=1;b<=k;b++){
            for(c=1;c<=k;c++) res+=__gcd(__gcd(a,b),c);
        }
    }
    cout<<res;
    return 0;
}

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

#define F first
#define S second
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


int main(){
  ll n,cnt=0,max=0;cin>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
    if(a[i]<0){
      a[i]=a[i]*(-1);
      cnt++;
    }
  }
  sort(a.begin(),a.end());
  rep(i,n){max+=a[i];}
  if(cnt%2==0)cout<<max<<endl;
  else cout<<max-a[0]*2<<endl;
return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

use std::cmp::{max, min};

fn main() {

  let n: i64 = read();
  let mut prev = 0;
  let mut cnt = 0;
  let mut max_cnt = 0;
  for _ in 0..n {
    let h: i64 = read();
    if prev < h {
        cnt = 0;
    } else {
        cnt += 1;
    }
    max_cnt = max(max_cnt, cnt);
    prev = h
  }

  println!("{}", max_cnt);
  
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <random>

#define ll long long

using namespace std;

int main() {
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    int n;
    scanf("%d", &n);
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    vector<int> dp(n + 1);
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; i++)
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    printf("%d", dp[n]);
    return 0;
}


Measured memory_bytes: 1024
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = sorted(list(map(int, input().split())), reverse=True)[:k]
b = sorted(list(map(int, input().split())), reverse=True)[:k]
c = sorted(list(map(int, input().split())), reverse=True)[:k]
def f(a, b):
    return [i + j for i in a for j in b]
ab_results = sorted(f(a, b), reverse=True)
results = sorted(f(c, ab_results[:k]), reverse=True)

print("\n".join(map(str, results[:k])))


Measured memory_bytes: 236044
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define A 500
#define B 100
#define C 50
using namespace std;
int main()
{
	int x, a, b, c, v = 0;
	cin >> a >> b >> c >> x;
	for (int q = 0; q <= a; q++) {
		for (int w = 0; w <= b; w++) {
			for (int e = 0; e <= c; e++) {
				if (A*q + B * w + C * e == x) {
					v++;
				}
			}
		}
	}
	cout << v;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 100000
int main(){
  int n,a[M],i,j,x;

  cin>>n;
  for(i=0;i<n;i++)cin>>a[i];  
  x=a[i-1];
  i=-1;
  for(j=0;j<n-1;j++){
    if(a[j]<=x){
      i++;
      swap(a[j],a[i]);
    }
  }
  swap(a[i+1],a[n-1]);

  for(int k=0;k<=i;k++){
    cout<<a[k]<<" ";
  }
  cout<<"["<<x<<"] ";
  for(int k=i+2;k<n;k++){
    cout<<a[k];
    if(k<n-1)cout<<" ";
    else cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3476
//let's do it
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 100000000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 300005

ll pref[maxn],suff[maxn],arr[maxn];
multiset<ll>s;

int main()
{
	boost1;boost2;
	ll i,j,n,x,y,ans=-inf,sum;
	cin>>n;
	for(i=1;i<=3*n;i++)
	cin>>arr[i];
	sum=0;
	for(i=1;i<=3*n;i++)
	{
		if(i<=n || !s.size())
		{
			s.insert(arr[i]);
			sum+=arr[i];
			pref[i]=sum;
		}
		else
		{
			if(arr[i]>*s.begin())
			{
				sum-=*s.begin();
				s.erase(s.begin());
				sum+=arr[i];
				s.insert(arr[i]);
				pref[i]=sum;
			}
			else
			pref[i]=sum;
		}
	}
	/*for(i=1;i<=3*n;i++)
	cout<<pref[i]<<" ";
	cout<<endl;*/
	sum=0;
	s.clear();
	for(i=3*n;i>=1;i--)
	{
		if(i>2*n || !s.size())
		{
			s.insert(arr[i]);
			sum+=arr[i];
			suff[i]=sum;
		}
		else
		{
			if(arr[i]<*(--s.end()))
			{
				sum-=*(--s.end());
				s.erase(s.find(*(--s.end())));
				sum+=arr[i];
				s.insert(arr[i]);
				suff[i]=sum;
			}
			else
			suff[i]=sum;
		}
	}
	/*for(i=1;i<=3*n;i++)
	cout<<suff[i]<<" ";
	cout<<endl;*/
	//ans=0;
	for(i=n;i<=2*n;i++)
	ans=max(ans,pref[i]-suff[i+1]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 12032
a=input()
#N=list(map(int,input().split()))
b=int(a)
l=len(a)

if l==1:
    s=b

if l==2:
    s=9

if l==3:
    s=9+b-99
if l==4:
    s=909
if l==5:
    s=909+b-9999
if l==6:
    s=90909

print(s)

Measured memory_bytes: 3060
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    ans = 10 ** 5
    ans = min(ans, abs(a - b) + abs(b - c))
    ans = min(ans, abs(a - c) + abs(b - c))
    ans = min(ans, abs(a - c) + abs(a - b))
    
    print(ans)
    

    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
MOD = int(1e9+7)


def main():
    n = int(input())    
    A = list(map(int,input().split()))
    sum_a = 0
    for a in A:
        sum_a = (sum_a + a) % MOD
        
    ans = 0
    for a in A:
        sum_a = (sum_a - a) % MOD
        ans = (ans + ((a*sum_a) % MOD)) % MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 105344
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

	VI ans(n);
	if (n % 2 == 0){
		REP(i,n){
			int j = i/2;
			if (i % 2 == 0){
				cin >> ans[n/2+j];
			}else{
				cin >> ans[n/2-1-j];
			}
		}
	}else{
		REP(i,n){
			int j = i/2;
			if (i % 2 == 0){
				cin >> ans[n/2-j];
			}else{
				cin >> ans[n/2+1+j];
			}
		}
	}
	REP(i,n) printf("%d ", ans[i]);
	cout << endl;
	return 0;
}

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

int main(void) {
  int N, A;
  float T;
  int H;
  float temp, diff;
  float min_diff = 1000000;
  int index = 0;
  
  cin >> N >> T >> A;
  
  cin >> H;
  temp = T - 0.006 * (float)H;
  min_diff = abs(A - temp);
  
  for (int i = 1; i < N; i++) {
    cin >> H;
    temp = T - 0.006 * (float)H;
    diff = abs(A - temp);
    if (diff < min_diff) {
      index = i;
      min_diff = diff;
    }
  }
  
  cout << index+1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
ac,wa,tle,re=0,0,0,0
for i in range(N):
    if(S[i]=='AC'):
        ac+=1
    elif(S[i]=='WA'):
        wa+=1
    elif(S[i]=='TLE'):
        tle+=1
    elif(S[i]=='RE'):
        re+=1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

Measured memory_bytes: 16320
// Marcin Knapik
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
  
const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m, k, q;
	
int tab[30][30];
int dp[5*N][22];

void prep(){
	for(int i = 1; i < (1<<n); i++){
		for(int j = __builtin_popcount(i)-1; j < n; j++){
			ll wyn = 0;
			int pom = i;

			while(pom){
				int l = __builtin_ctz(pom);
				pom -= (1<<l);
				if(tab[l][j]){
					int nowa = i ^ (1<<l);
					if(nowa == 0)
						wyn ++;
					if(j)
						wyn += dp[nowa][j-1];
				}
			}
			if(j)
				dp[i][j] = (wyn + dp[i][j-1])%INF;
			else
				dp[i][j] = wyn;
		}
	}
}

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

    cin >> n;
    FOR(i, n)
    	FOR(j, n)
    		cin >> tab[i][j];
    prep();
    cout << dp[(1<<n)-1][n-1]  << '\n';
}

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

int main()
{
    int x;

    for (int i = 0; i < 5 ; i++)
    {
        cin >> x;
        if (0 == x) 
        {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;

}

Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const int INF = 1e9;
int n,k,q;
vi a;

int solve(int mn) {
	vector<vi> b;
	vi loc;
	for(int i=0; i<n; ++i) {
		if(a[i] >= mn) {
			loc.pb(a[i]);
		} else {
			if(!loc.empty()) {
				b.pb(loc);
				loc.clear();
			}
		}
	}
	if(!loc.empty())
		b.pb(loc);
 
	vi cand;
	for(int i=0; i<(int)b.size(); ++i) {
		sort(all(b[i]));
		int m = sz(b[i]);
		for(int j=0; j<m-k+1; ++j) {
			cand.pb(b[i][j]);
		}
	}
	if(sz(cand) < q) {
		return INF;
	}
	sort(all(cand));
	return cand[q-1]-cand[0];
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> k >> q;
	a.resize(n);
	set<int> s;
	rep(i,0,n) {
		cin >> a[i];
		s.insert(a[i]);
	}
	int ret = INF;
	for(auto mn : s) {
		ret = min(ret, solve(mn));
	}
	cout << ret << '\n';
	return 0;
}


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

ll go(int a,int b,int c)
{
	if(a==b&&b==c)return 1;
	if(a==b||b==c)return 3;
	return 6;
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int k;
	ll ans = 0;
	cin>>k;
	for(int i=1;i<=k;i++)
		for(int j=i;j<=k;j++)
			for(int z=j;z<=k;z++)
				ans += go(i,j,z)*__gcd(i,__gcd(j,z));
	cout<<ans;
}


Measured memory_bytes: 3648
n = int(input())
info = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        x -= 1
        info[i].append((x, y))

ans = 0
for bit_state in range(1 << n):
    flag = True
    for i in range(n):
        # i番目は正直者
        if (bit_state >> i) & 1:
            for x, y in info[i]:
                if (bit_state >> x) & 1 != y:
                    flag = False
    if flag:
        ans = max(bin(bit_state).count("1"), ans)
print(ans)

Measured memory_bytes: 42604
def main():
    N, M, Q = map(int, input().split())
    cs = [[0 for _ in range(N + 1)] for _ in range((N + 1))]
    for _ in range(M):
        L, R = map(int, input().split())
        cs[L][R] += 1
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            cs[i][j] += cs[i - 1][j]
            cs[i][j] += cs[i][j - 1]
            cs[i][j] -= cs[i - 1][j - 1]
    ans = []
    for _ in range(Q):
        p, q = map(int, input().split())
        ans.append(cs[q][q] - cs[q][p - 1] - cs[p - 1][q] + cs[p - 1][p - 1])
    for a in ans:
        print(a)


main()


Measured memory_bytes: 17708
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  cout << ((n%k==0)? 0:1) << "\n";
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char S[110];
char T[110];
int main(){
	int a;scanf("%d",&a);scanf("%s%s",S,T);
	for(int i=0;i<a;i++)printf("%c%c",S[i],T[i]);printf("\n");
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

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

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll n, k;

	cin >> n >> k;

	ll ans = 0;

	ll i;

	if (n == 1) {
		Out(k);
	} else {
		ans = k;

		repi(i, n, 1) ans *= (k - 1);

		Out(ans);
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	char last=' ';
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		char c;
		cin>>c;	
		if(c!=last)
		{
			last=c;
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

#define int long long
#define nl "\n"
#define sp " "

const int mod = 1e9 + 7;

signed main(){
	int n; cin >> n; vector<int> v(n), c(n);
	for (int i = 0; i < n; i++){
		cin >> v[i]; c[i] = v[i];
	}
	int sum = 0, ans = 0; unordered_map<int, int> mp;
	for (int i = c.size() - 1; i > 0; i--){
		sum += c[i];
		mp.insert(make_pair(i, sum));
	}
	for (int i = 0; i < v.size() - 1; i++){
		ans += ((v[i] % mod) * (mp[i+1] % mod));
		ans = ans % mod;
	}
	cout << ans;
}


Measured memory_bytes: 14596
#include <stdio.h>

int main() {
	int a, b, c, d;

	scanf("%d%d%d%d", &a, &b, &c, &d);
	printf(a + b > c + d ? "Left\n" : a + b == c + d ? "Balanced\n" : "Right\n");
	return 0;
}


Measured memory_bytes: 128
import math

class segtree:
    def __init__(self,size):
        n = 1
        while n < size:
            n *= 2
        self.node = [0]*(2*n-1)
        self.begin = n

    def update(self,dex,value):
        dex += self.begin-1
        self.node[dex] = value
        while dex > 0:
            dex = (dex-1)//2
            self.node[dex] = self.node[dex*2+1] | self.node[dex*2+2]

    def segment(self,l,r):
        l += self.begin-1
        r += self.begin-1
        ans = 0
        while l <= r:
            if l==0:
                ans = self.node[0]
                break
            if l%2 == 0:
                ans |= self.node[l]
            l//=2
            if r%2 == 1:
                ans |= self.node[r]
            r = r//2 -1
        return ans

    def view(self):
        return  self.node

N = int(input())
seg = segtree(N)
S = input()
for i in range(N):
    seg.update(i,2**(ord(S[i])-ord("a")))
Q = int(input())
anses = []
for i in range(Q):
    a,b,c = input().split()
    if a=="1":
        seg.update(int(b)-1,2**(ord(c)-ord("a")))
    elif a=="2":
        ans = seg.segment(int(b)-1,int(c)-1)
        count = 0
        while ans:
            if ans & 1:
                count += 1
            ans >>= 1
        anses.append(count)
for i in anses:
    print(i)

Measured memory_bytes: 76744
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <map>
#include <set>
#define LL long long
#define mp make_pair
#define x first
#define y second

using namespace std;

const int maxn=200010;
const int oo=1000000000;
const int modulo=1000000007;

string s;
int suf[maxn][26];
int f[maxn];
vector<char> a;

void input(){
    cin >> s;
}

void init(){
    s = ' ' + s;
    for (int i = 0; i < 26; i++) suf[s.size() - 1][i] = s.size();
    for (int i = s.size() - 2; i >= 0; i--)
        for (int j = 0; j < 26; j++)
            if (s[i + 1] - 'a' == j) suf[i][j] = i+1; else suf[i][j] = suf[i+1][j];
}

void solve(){
    f[s.size()] = 0;
    for (int i = 0; i < s.size(); i++) f[i] = oo;
    for (int i = s.size() - 1; i >= 0; i--)
        for (int j = 0; j < 26; j++)
            f[i] = min(f[i], f[suf[i][j]] + 1);
    int j = 0;
    while (j < s.size()){
        int i = 0;
        while (f[suf[j][i]] >= f[j]) i++;
        a.push_back('a' + i);
        j = suf[j][i];
    }
}

void output(){
    for (int i = 0; i < a.size(); i++) cout << a[i];
}

int main(){
//	freopen("test.inp", "r", stdin);
//	freopen("test.out", "w", stdout);
	std::ios::sync_with_stdio(false);
	input();
	init();
	solve();
	output();

	return(0);
}


Measured memory_bytes: 21712
import sys
input = sys.stdin.readline


N = int(input())
s = [ int(input()) for _ in range(N)]
s= sorted(s)
sums = sum(s)
if sums %10 !=0:
    print(sums)
    exit()
else:
    for i in range(N):
        ans = sums - s[i]
        if ans % 10 != 0:
            print(ans)
            exit()
print(0)


Measured memory_bytes: 9176
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const n: number = tmp[0].split(" ").map(int => parseInt(int))[0];
    return `${(n + (n % 2)) / 2}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

using namespace std;

int main(){
    int n;
    while(cin >> n){
        vector<int> a(n);
        for(auto& t : a) cin >> t;
        sort(a.begin(), a.end());
        int best = a[0];
        int score = min(a[0], a.back() - a[0]);
        for(int i=1;i<n-1;i++){
            int cur = min(a[i], a.back() - a[i]);
            if(cur > score){
                best = a[i];
                score = cur;
            }
        }
        cout << a.back() << " " << best << endl;
    }
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
int main(){
	ll a,b;
	cin >> a >> b;

	ll b_xor;
	ll a_xor;
	if(b % 2 == 0){
	   b_xor = ((b / 2) % 2) ^ b;
	}
	else{
		b_xor = ((b + 1) / 2) % 2;
	}

	if(a == 0){
		cout << b_xor << endl;
		return 0;
	}

	if((a - 1) % 2 == 0){
		a_xor = (((a-1) / 2) % 2) ^ (a - 1);
	}
	else{
		a_xor = (a / 2) % 2;
	}
	cout << (b_xor ^ a_xor) << endl;;
}


Measured memory_bytes: 3616
n, y = map(int, input().split())
flg = True
a, b, c = -1, -1, -1
for i in range(n+1):
 if 10000*i>y: break
 for j in range(n+1-i):
  if 10000*i+5000*j>y: break
  if y-10000*i-5000*j == 1000*(n-i-j):
   a, b, c = i, j, n-i-j
   flg = False
   break
 if not flg: break
print(a, b, c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int a,b;
cin >> a >> b;
if(a + b >= 10) cout << "error" << endl;
else cout << a + b << endl;

return 0;
}

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

vector<int> adj[200007];
int dist[200007];
bool vis[200007];
int N, M;

void bfs(int pos)
{
    queue<int> q;
    q.push(pos);
    vis[pos] = 1;

    while (!q.empty()) {
        int curnode = q.front();
        q.pop();
        for (auto x : adj[curnode]) {
            if (vis[x]) continue;

            vis[x] = 1;
            dist[x] = dist[curnode] + 1;
            q.push(x);
        }
    }
}

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

    int u, v;
    for (int i = 1; i <= M; i++) {
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    bfs(1);

    if (dist[N] == 2) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
}


Measured memory_bytes: 13424
function F()
  N = parse(Int64,readline())
  c = 0
  f = false
  for i =1:N
    D1,D2 = parse.(Int64,split(readline()))
    if D1 == D2
      c += 1
      if c==3
        f = true
        break
      end
    else
      if c != 0
        c = 0
      end
    end
  end
  if f == true
    println("Yes")
  else
    println("No")
  end
  
end
F()

Measured memory_bytes: 170528
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N, K;
  cin >> N >> K;
  i64 ans = 0;
  while(N != 0) {
    N /= K;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256