akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

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

const int MAXN = 0;
vector <long long> v;
int N;
void dfs(int x) {
	if(x == v.size()) {
		N--;
		if(N == 0) {
			REP(i,v.size()) cout << v[i];
			cout << endl;
			exit(0);
		}
		return;
	}
	if(v.empty())
		for(int i=1; i<=9; i++) {
			v.push_back(i);
			dfs(x);
			v.pop_back();
		}
	else
		for(int i=v.back()-1; i<=v.back()+1; i++) {
			if(i<0 || i>9) continue;
			v.push_back(i);
			dfs(x);
			v.pop_back();
		}
}

int main(void) {
	cin >> N;
	for(int i=1; ; i++)
		dfs(i);
	return 0;
}




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

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
print(num2alpha(n).lower())

Measured memory_bytes: 9056
program prob4
    implicit none
    integer(8) :: n
    integer(8), allocatable :: a(:)
    integer(8) :: p(10)
    integer(8) :: s(10)
    integer(8) :: i, j
    integer(8) :: ans
    integer(8) :: cnt
    character(10) :: tmp
    integer(8) :: inttmp

    read(*,*) n
    allocate(a(n))

    p(1) = 1
    do i = 2, 10
        p(i) = p(i-1) * 26
    end do
    do i = 1, n
        read(*,*) tmp
        do j = 1, 10
            s(j) = ichar(tmp(j:j)) - ichar('a')
        end do
        call msort(s)
        a(i) = 0
        do j = 1, 10
            a(i) = a(i) + s(j) * p(j)
        end do
    end do

    call msort(a)

    cnt = 1
    inttmp = a(1)
    ans = 0
    do i = 2, n
        if(a(i) == inttmp)then
            cnt = cnt + 1
        else
            ans = ans + cnt * (cnt - 1) / 2
            inttmp = a(i)
            cnt = 1
        end if
    end do
    ans = ans + cnt * (cnt - 1) / 2

    write(*,*) ans



    deallocate(a)

    stop
contains


  !
  ! swap two arguments
  !
subroutine swap(a, b)
    implicit none
    integer(8), intent(inout) :: a, b

    integer(8) :: c

    c = a
    a = b
    b = c

  end subroutine swap

  !
  ! merge sort
  !
  recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)

    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if

    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))

    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x

    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do

    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n

    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
end program prob4

Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B + C + D == 21 && A * B * C * D == 252) {
    cout << "YES" << endl;
  }
  
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

mint calc(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    mint res = modpow(mint(2), N) - 1;
    res -= calc(N, A) + calc(N, B);
    cout << res << endl;
}




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

int main(void){
    int r, D;
    int x;
    
    cin >> r >> D >> x;
    
    rep(i, 10){
        x = r*x-D;
        cout << x << endl;
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairInt;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int q;
  array<int, 2> p1, p2, p, v1, v2;

  scanf("%d%d%d%d%d", &p1[0], &p1[1], &p2[0], &p2[1], &q);
  v1[0] = p2[0] - p1[0];
  v1[1] = p2[1] - p1[1];

  FOR(i, q) {
    scanf("%d%d", &p[0], &p[1]);
    v2[0] = p[0] - p1[0];
    v2[1] = p[1] - p1[1];

    int ip1 = inner_product(v1.begin(), v1.end(), v1.begin(), 0);
    int ip2 = inner_product(v2.begin(), v2.end(), v1.begin(), 0);
    array<double, 2> x = {
      p1[0] + (double)ip2 / ip1 * (p2[0] - p1[0]),
      p1[1] + (double)ip2 / ip1 * (p2[1] - p1[1])
    };

    printf("%.10lf %.10lf\n", 2 * x[0] - p[0], 2 * x[1] - p[1]);
  }

  return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int r;
  cin>>r;
  cout<<r*r<<endl;
  return(0);
}


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

int main(){
	double v;
	while( scanf("%lf",&v)!=EOF){
		v=ceil((v*v/19.6+5)/5);
		printf("%d\n",(int)v);
	}
			
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main() {
    int m[100][100], a[10000];
    int n, h, w;

    cin >> h >> w >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }

    int x = 0, y = 0, add = 1;
    for (int i=0; i<n; i++) {
        for (int j=0; j<a[i]; j++) {
            //cout << x << " " << y << endl;
            m[y][x] = i+1;
            
            if (add == 1 && x+1 >= w) {
                y++;
                add = -1;
            }
            else if (add == -1 && x-1 < 0){
                y++;
                add = 1;
            }
            else {
                x = x+add;
            }
        }
    }

    cout << endl;
    
    for (int i=0; i<h; i++) {
        for (int j=0; j<w-1; j++) {
            cout << m[i][j] << ' ';
        }
        cout << m[i][w-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#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 srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int n;
  std::cin >> n;

  std::vector<ull> L(n);
  rep(i, n) {
    cin >> L[i];
  }

  int ans {};

  for(auto i=0;i<n;++i) {
    for (auto j = i+1;j < n;++j) {
      for (auto k = j+1;k < n;++k) {
        if (L[i]==L[j]||L[i]==L[k]||L[j]==L[k]) continue;
        int max_l = max(L[i], max(L[j], L[k]));
        if (max_l+max_l < L[i]+L[j]+L[k]) {
          ++ans;
        }
      }
    }
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 3636
// Problem : B - Distance
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define all(a) a.begin(),a.end()
#define x first
#define y second
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
    // your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d;
    cin >> n >> d;
    int t = 0;
    for(int i = 0;i<n;i++){
    	double u,v;
    	cin >> u >> v;
    	u = sqrt(u*u+v*v);
    	if(u<=d)t++;
    }
    cout << t << "\n";
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a;
		cin >> b;
		cout << a + b << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
    int count = 0;
    string str_w, str = "CODEFESTIVAL2016";
    cin >> str_w;

    for (int i = 0; i < 16; i++)
    {
        if (str_w[i] != str[i])
        {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>
#include <fstream>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll a;
    string s;
	cin >>a>>s;
    
	//出力
	if (a>=3200) printf("%s\n", s.c_str());
	else printf("red\n");
}


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

int main()
{
	int k, x; cin >> k >> x;
	set <int> s;
	for (int i = 0; i < k; i++)
	{
		s.insert(x-i);
		s.insert(x+i);
	}
	for (auto it : s)
	{
		if (it > 1000000 || it + 1000000 < 0) continue;
		else cout << it << ' ';
	}
}

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

int main(){
	int n, k;
  	cin >> n >> k;
	
  	int count = 0;
	while(n > 0){
    	n /= k;
      	count++;
    }
  	cout << count << endl;
}

Measured memory_bytes: 256
N,M,K = list(map(int,input().split()))
MOD = 998244353

fac = [1] * (N+1)
inv = [1] * (N+1)
ifac = [1] * (N+1)
for i in range(2,N+1):
    fac[i]=(fac[i-1]*i)%MOD
    inv[i]= -(inv[MOD%i]*(MOD//i))%MOD
    ifac[i]=(ifac[i-1]*inv[i])%MOD

cmbarr = [1] * N
for r in range(N-1):
    cmbarr[r+1] = cmbarr[r] * (N - 1 - r) * inv[r + 1] % MOD

A = [M*pow(M-1,N-1-i,MOD)*cmbarr[i] % MOD for i in range(K+1)]
print(sum(A) % MOD)

Measured memory_bytes: 48568
//By : BebekJK
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 1000000007
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

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

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
int N , M , X;
int C[15] , P[15][15] ;
int L[15];
int main(){
//	BOOST();
	
	cin>>N>>M>>X;
	for(int i=1;i<=N;i++){
		cin>>C[i];
		for(int j=1;j<=M;j++)cin>>P[i][j];
	}
	int ans = MOD;
	for(int i=0;i<(1<<N);i++){
		int price = 0;
		
		memset(L , 0 , sizeof L);
		for(int j=0;j<N;j++){
			if((i>>j)&1){
				price+=C[j+1];
				for(int k=1;k<=M;k++)L[k]+=P[j+1][k];
			}
		}
		bool check = true;
		for(int j=1;j<=M;j++){
			if(L[j]<X)check = false;
		}
		if(check)ans=min(ans , price);
	}
	if(ans==MOD)cout<<"-1"<<endl;
	else cout<<ans<<endl;
}







Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            if (i!=sc.nextInt()) cnt += 1;
        }
        System.out.println(cnt<= 2? "YES": "NO");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
// until dimension reduction.

using namespace std;
typedef long long LL;

const int N = 81; 
const int delt = 6400; 
int n, m, a[N][N], b[N][N];
bool dp[N][N][N*N * 4]; 
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      cin >> a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      cin >> b[i][j]; 
  
  dp[1][1][a[1][1] - b[1][1] + delt] = 1;
  dp[1][1][b[1][1] - a[1][1] + delt] = 1; 

  for (int i = 1; i<= n; i++)
    for (int j = 1; j <= m; j++) {
      if (i == 1 && j == 1) continue;
      for (int now_sum = -6400; now_sum <= 6400; now_sum++) {
        int del = a[i][j] - b[i][j], de = -del;
        if (now_sum - del >= -6400 && now_sum - del <= 6400)
          dp[i][j][now_sum + delt] |= (dp[i][j - 1][now_sum - del + delt] | dp[i - 1][j][now_sum - del + delt]);
        if (now_sum - de >= -6400 && now_sum - de <= 6400)
          dp[i][j][now_sum + delt] |= (dp[i][j - 1][now_sum - de + delt] | dp[i - 1][j][now_sum - de + delt]);
      }
    }
  
  int ans = 0x3f3f3f3f; 
  for (int now_sum = -6400; now_sum <= 6400; now_sum++)
    if (dp[n][m][now_sum + delt]) ans = min(ans, abs(now_sum));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 166272
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	res := 1 << 30
	for _, val := range a {
		tmp := 0
		for val % 2 == 0 {
			val /= 2
			tmp++
		}
		if tmp < res {
			res = tmp
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 512
#include<stdio.h>

int main( void ) 
{
	int dice[7];
	int tdice[7];
	char ins[101];
	int i,j;

	for( i=0; i<6; i++ ) {
    	scanf( "%d", &dice[i] );
    	tdice[i]=dice[i];
    }
   	scanf( "%s", ins );
   
	for( i=0; '\0'!=ins[i]; i++ ) {
		if( 'E' == ins[i] ) {
			tdice[3-1]=dice[1-1];
			tdice[4-1]=dice[6-1];
			tdice[6-1]=dice[3-1];
			tdice[1-1]=dice[4-1];
		} else if( 'W' == ins[i] ) {
			tdice[4-1]=dice[1-1];
			tdice[3-1]=dice[6-1];
			tdice[1-1]=dice[3-1];
			tdice[6-1]=dice[4-1];
		} else if( 'N' == ins[i] ) {
			tdice[5-1]=dice[1-1];
			tdice[2-1]=dice[6-1];
			tdice[1-1]=dice[2-1];
			tdice[6-1]=dice[5-1];
		} else if( 'S' == ins[i] ) {
			tdice[2-1]=dice[1-1];
			tdice[5-1]=dice[6-1];
			tdice[6-1]=dice[2-1];
			tdice[1-1]=dice[5-1];
		}
		for( j=0; j<6; j++ ) {
			dice[j]=tdice[j];
		}
    }
   	printf( "%d\n", dice[1-1] );
   	
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	/*char s[5];
	scanf("%s", s);
	if ((s[0] == s[1] && s[2] == s[3]) ||
		(s[0] == s[2] && s[1] == s[3]) ||
		(s[0] == s[3] && s[1] == s[2])) {
		if (s[0] == s[1] && s[0] == s[2] && s[0] == s[3]) {
			printf("No\n");
		}
		else {
			printf("Yes\n");
		}
		
	}
	else {
		printf("No\n");
	}*/

	int n;
	int p[21];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	int count = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
			(p[i + 1] < p[i] && p[i] < p[i - 1])) {
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const ll inf = (ll)1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	int n;	cin >> n;
	map<int, int> mp;
	rep(i, n) {
		int a;	cin >> a;
		mp[a]++;
	}
	ll ret = 0;
	for (auto it : mp) {
		if (it.second < it.first)	ret += it.second;
		else	ret += it.second - it.first;
	}
	cout << ret << endl;
}

Measured memory_bytes: 4736
#include <iostream>
using namespace std;
int main() 
{
	int i, j;
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
        			cout << i << 'x' << j << '=' << i * j << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W,K; cin >> H >> W >> K;
    vector<string> S(H);
    rep(i,H) cin >> S[i];

    int sy,sx;
    rep(i,H) {
        rep(j,W) {
            if (S[i][j] == 'S') {
                sy = i;
                sx = j;
            }
        }
    }
    const int dy[4] = {-1,0,0,1};
    const int dx[4] = {0,-1,1,0};
    vector<vector<int>> dist(H, vector<int>(W,1e9));
    auto dist2 = dist;
    dist[sy][sx] = dist2[sy][sx] = 0;
    queue<pii> que1,que2;
    que1.emplace(sy,sx);
    que2.emplace(sy,sx);
    while (!que1.empty()) {
        int y,x;
        tie(y,x) = que1.front(); que1.pop();
        rep(i,4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
            if (S[ny][nx] == '#') continue;
            if (dist[ny][nx] != 1e9) continue;
            dist[ny][nx] = dist[y][x]+1;
            que1.emplace(ny,nx);
            if (dist[ny][nx] <= K) {
                que2.emplace(ny,nx);
                dist2[ny][nx] = 0;
            }
        }
    }

    while (!que2.empty()) {
        int y,x;
        tie(y,x) = que2.front(); que2.pop();
        rep(i,4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
            if (dist2[ny][nx] != 1e9) continue;
            dist2[ny][nx] = dist2[y][x]+1;
            que2.emplace(ny,nx);
        }
    }

    int ans = 1e9;
    rep(i,H) {
        rep(j,W) {
            if (i != 0 && i != H-1 && j != 0 && j != W-1) continue;
            chmin(ans, (dist2[i][j]+K-1) / K + 1);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,a,b; cin>>n>>a>>b;
    long long h[n]; rep(i,n) cin>>h[i];
    long long ng=0,ok=INF;
    while(abs(ok-ng)>1){
        long long turn=(ok+ng)/2;
        long long cnt=0;
        rep(i,n){
            long long hp=h[i];
            hp-=b*turn;
            if(hp>0){
                cnt+=(hp+a-b-1)/(a-b);
            }
        }
        if(cnt<=turn){
            ok=turn;
        }else{
            ng=turn;
        }
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  string S;
  cin >> S;
  int N = S.size();
  int p_num = 0;
  rep(i, N) {
    if (S[i] == 'p') p_num++;
  }
  int answer = N / 2 - p_num;
  cout << answer << endl;
  return 0;
}


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

int calc(int n) {
  for (int i = 1; ; i++) {
    if (i * (i + 1) > n * 2) return i - 1;
  }
}

vector<pair<ll, int>> prime_factorize(ll n) {
  vector<pair<ll, int>> vp;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      vp.push_back({i, cnt});
    }
  }
  if (n != 1) vp.push_back({n, 1});
  return vp;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> vp = prime_factorize(n);
  int ans = 0;
  for (int i = 0; i < vp.size(); i++) ans += calc(vp[i].second);
  cout << ans << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include<cmath>
using namespace std;
#define ll (long long)
#define PI (acos(-1))

int main()
{
int K,X;
cin >> K >> X;

if(500*K >= X){
  cout << "Yes";
}else{
  cout << "No";
}

}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
#define ll long long
#define Rep(i,l,r) for(int (i)=(l);(i)<=(r);(i)++)
using namespace std;
map<int,ll>::iterator it;
map<int,ll> mp;
multiset<ll> values;
int n,m,l,r;
int main(){
	cin>>n>>m;
	Rep(i,1,m){mp[i]=0;values.insert(0);}
	Rep(i,1,n){
		cin>>l>>r;
		if(r!=m){
			it=mp.upper_bound(r+1);
			if(it!=mp.begin()){
				it--;
				if(it->first!=r+1){
					ll v=it->second+(r+1-it->first);
					mp[r+1]=v;values.insert(v);
				}
			}
		}
		it=mp.lower_bound(l);
		while(it!=mp.end()&&it->first<=r){
			values.erase(values.find(it->second));
			it=mp.erase(it);
		}
		cout<<((values.size())?(i+(*values.begin())):(-1))<<endl;
	}
	return 0;
}

Measured memory_bytes: 25364
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    string S;
    cin>>S;
    if(S=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int R;
    cin >> R;
    cout << 2*3.14*R << endl;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int fibonacci(int n){
    double phi = (1 + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}
signed main(){

#ifndef ONLINE_JUDGE
    //freopen("input.txt","r", stdin);
#endif

    fastIO
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    for(int i = 0; i < b; i++) cout << a;
    

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int i, j, x, tmp;
  int *A, r, n;

  
  scanf("%d", &n);

  A = malloc(sizeof(int) * n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  x = A[n-1];
  i = -1;

  
  for(j = 0; j < n-1; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }

  i++;
  tmp = A[n-1];
  A[n-1] = A[i];
  A[i] = tmp;


  for(j = 0; j < n; j++){
    if(j == i) printf("[");
    printf("%d", A[j]);
    if(j == i) printf("]");
    if(j != n-1) printf(" ");
    else printf("\n");
  }

  
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <fstream>
#include <string.h>
#include <math.h>
#include <ctype.h>

using namespace std;

int main(){
  string n1,n2;
  cin >> n1;
  cin >> n2;
  if(n1.length() == n2.length()){
    if(n1 > n2) cout << "GREATER" << endl;
    else if(n1 < n2) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
  }
  else if(n1.length() > n2.length()){
    cout << "GREATER" << endl;
  }
  else{
    cout << "LESS" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
h, w = gets.chomp.split.map(&:to_i)
s = []

h.times do
  s << gets.chomp.chars
end

ans = 0

h.times do |i|
  w.times do |j|
    next if s[i][j] == '#'
    queue = []
    visited = Array.new(h).map { Array.new(w, 0)}
    queue << [i, j, 0]
    visited[i][j] = 1
    # スコアを保持
    # scores = Array.new(h).map { Array.new(w, 0)}

    until queue.empty?
      x, y, cnt = queue.shift
      # p "現在のx,y: #{[x , y]}"



      [[x, y + 1], [x, y - 1 ], [x + 1, y], [x - 1 , y]].each do |dx, dy|
        next if (dx < 0) || (dy < 0) || (dx + 1 > h) || (dy + 1 > w)
        next if s[dx][dy] == '#' || visited[dx][dy] == 1

        visited[dx][dy] = 1
        queue << [dx, dy, cnt + 1]
        ans = [ans, cnt + 1].max
      end
    end

    # スコア表示
    # p scores
  end
end

p ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int ans = 0;
    rep(i,n){
        int l,r; cin>>l>>r;
        ans += (r-l)+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

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

func getInputAsInt(in string) (int, int) {
	inArr := strings.Split(in, " ")
	// Atoi(s string) (i int, err error) のerrは捨てる
	val1, _ := strconv.Atoi(inArr[0])
	val2, _ := strconv.Atoi(inArr[1])
	return val1, val2
}

func euclidean(val1, val2 int) (int) {
	surp := 1
	for  {
		surp = val1 % val2
		if surp != 0 {
			val1 = val2
			val2 = surp
		} else {
			break
		}
	}
	return val2
}

func calcLCM(val1, val2, gcd int) (int) {
	return val1/gcd*val2
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	
	for scanner.Scan() {
		val1, val2 := getInputAsInt(scanner.Text())
		gcd := euclidean(val1, val2)
		lcm := calcLCM(val1, val2, gcd)
		fmt.Println(gcd, lcm)
	}
}


Measured memory_bytes: 1048
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int p[n];
  for(int i=0;i<n;i++) cin>>p[i];
  for(int i=0;i<n;i++) p[i]--;
  int ans=0;
  for(int i=0;i<n;i++){
    if(i!=p[i]) continue;
    swap(p[i],p[i+1]);
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int N, l, r, cnt=0;
  cin >> N;
 
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    for (int j = l; j <= r; j++) {
      cnt++;
    }
  }
 
  cout << cnt << endl;
}

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


ll mod_pow(ll x, ll p, ll M = MOD) {
  ll a = 1;
  while (p) {
    if (p % 2)
      a = a*x%M;
    x = x*x%M;
    p /= 2;
  }
  return a;
}


signed main() {
  int n, k;
  cin >> n >> k;

  map<int, ll> dp;
  for (ll x = 1; x * x <= n; x++) {
    if (n % x == 0) {
      dp[x] = 0;
      dp[n / x] = 0;
    }
  }

  for (auto itr = dp.begin(); itr != dp.end(); itr++) {
    int i = itr->first;
    int zi = (i + 1) / 2;
    dp[i] = mod_pow(k, zi);
    //DEBUG(dp[i]);
    for (auto itr2 = dp.begin(); itr2->first < i; itr2++) {
      int j = itr2->first;
      if (i % j != 0) continue;
      (dp[i] -= itr2->second) %= MOD;
    }
    //DEBUG(pll(i, dp[i]));
  }

  ll ans = 0;
  for (auto itr = dp.begin(); itr != dp.end(); itr++) {
    int i = itr->first;
    if (i % 2 == 1) {
      ans = (ans + itr->second * i % MOD) % MOD;
    }
    else {
      ans = (ans + itr->second * (i / 2) % MOD) % MOD;
    }
  }
  ans = (ans + MOD) % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 384
n = int(input())
w = []
flag = True
num = 0
for i in range(n):
  s = input()
  if num == 0:
    w.append(s)
    num += 1
  else:
    if s in w:
      flag = False
      break
    if s[0] != w[-1][-1]:
      flag = False
      break
    w.append(s)
if flag == True:
  print("Yes")
else:
  print("No")

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 500100, MAXK = 25;
const ll MOD = 1e9+7;

vi adj[MAXN];
int cnt[MAXN], ans[MAXN];

void dfs (int v, int p, int c) {
    ans[v] = cnt[v]+c;
    for (int u : adj[v]) {
        if (u == p) continue;
        dfs(u, v, ans[v]);
    }
}

int main()
{
    FAST_IO;

    int n, q; cin >> n >> q;

    REP(n-1) {
        int a, b; cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    REP(q) {
        int p, x; cin >> p >> x;
        cnt[p] += x;
    }

    dfs(1, -1, 0);

    FOR(i, 1, n) cout << ans[i] << " ";

    return 0;
}


Measured memory_bytes: 32384
#include<cstdio>
#include<algorithm>
using namespace std;

int a[100001];
int main(){
	int n,s=0,z=0,t;scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=n,m=0;i;i--){
		m=max(m,a[i]);
		if(m-a[i]>z)z=m-a[i],s=1;
		else if(z==m-a[i])s++;
	}
	printf("%d",s);
}

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

unsigned long long f(unsigned long long n, unsigned long long k)
{
    if (n > k)
    {
        unsigned long long diff = n - k;
        n -= (diff / k) * k;
        if (n > k)
        {
            n = min(n, n - k);
        }
    }
    else if (n == k)
    {
        n = 0;
    }
    else
    {
        n = k - n;
    }
    return n;
}

int main()
{
    unsigned long long N, K;
    cin >> N >> K;
    unsigned long long ans = N;
    for (int i = 0; i < 2; i++)
    {
        N = f(N, K);
        ans = min(ans, N);
    }
    cout << ans << endl;
}


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

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

  for (ll h = 1; h <= 3500; h++) {
    for (ll n = 1; n <= 3500; n++) {
      if (4 * h * n - N * (h + n) <= 0) continue;
      ll w = (N * h * n) / (4 * h * n - N * (h + n));
      if (4 * h * n * w == N * (h * n + n * w + w * h)) {
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
import sys
n, W = map(int, sys.stdin.readline().split())
dp = [[0 for _ in range(W+1)] for _ in range(n)]
for i in range(n):
    w, v =map(int, sys.stdin.readline().split())
    for j in range(W+1):
        dp[i][j] = max(dp[i-1][j], dp[i][j])
        if dp[i-1][j] !=0 and j+w<=W:
            dp[i][j+w] = max(dp[i-1][j+w], v+ dp[i-1][j])
            #print(dp, i)
        
    dp[i][w] = max(dp[i-1][w], v)
    
#print(dp)  
print(max(dp[-1]))

Measured memory_bytes: 171528
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    for0(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long int
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
	
    ll n;
    cin>>n;
    for(int i=-120;i<120;i++){
        for(int j=-120;j<120;j++){
            if(pow(i,5)-pow(j,5)==n){
                cout<<i<<" "<<j;
                End;
            }
        }
    }
    
End;
}


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

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double dist = sqrt(pow(x1-x2 , 2) + pow(y1-y2, 2));
    printf("%lf", dist);

    return 0;
}


Measured memory_bytes: 3216
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#s[i] is linked with t[len(s)-i-1]
def main():
	a,b,c,d = map(int,input().split())
	i = 1 if a/2 == float(c)  and b/2 == float(d) else 0
	print('{} {}'.format(a*b/2,i))


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

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

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

#define mp make_pair
#define pb push_back
#define put(x) { cout << #x << " = "; cout << (x) << endl; }

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef double db;

const int M = 1e6 + 15;
const int Q = 1e9 + 7;

int cnt[26];
string s[M];
int mi[26];

int main() {
    srand(time(NULL));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(0);


	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int j =0; j < 26; j++) mi[j] = 1e9;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 26; j++) cnt[j] = 0;
		for (int j = 0; j < (int)s[i].size(); j++) cnt[s[i][j] - 'a']++;
		for (int j = 0; j < 26; j++) mi[j] = min(mi[j], cnt[j]);
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < mi[i]; j++)
			cout << char('a' + i);
   }
    return 0;
}   

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#define all(c) c.begin(),c.end()
#include<algorithm>
using namespace std;
int main(){
	int n,s;
	while(cin>>n>>s,n||s){
		vector<int> v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		sort(all(v));
		int ans=0;
		vector<int>::iterator ite=v.begin();
		for(int i=0;i<n;i++){
			int x=upper_bound(all(v),s-v[i])-v.begin();
			//cout<<n-x<<endl;
			ans+=(n-x);
			if(v[i]*2>s)
			ans--;
		}
		cout<<ans/2<<endl;
	}
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  int ans = -1;
  for (int i = 1; i <= 1250; i++)
  {
    if (floor(i * 0.08) == a && floor(i * 0.1) == b)
    {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();

        int h = scan.nextInt();
        int w = scan.nextInt();

        int ans = H * W - (h * W) - (w * H) + h * w;

        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define INF 1234567890123456789
#define mod 1000000007
typedef long long ll;
using namespace std;
ll a[100010];
int main(){
	int n;
	ll x;
	cin>>n>>x;
	ll ans=0;
	lol(i,n){
		cin>>a[i];
		if(a[i]>x){
			ans+=a[i]-x;
			a[i]=x;
		}
	}
	lol(i,n-1){
		ll tmp=a[i]+a[i+1]-x;
		if(tmp>0){
			a[i+1]-=tmp;
			ans+=tmp;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
iH,iW,iA,iB = [int(x) for x in input().split()]
iD = 10**9+7 #法

iLBoxW=iB-1
iLBoxH=iH-iA-1
iRBoxW=iW-iB-1
iRBoxH=iH-1
#iMax = iH+iW-2
iMax = max(iLBoxW+iLBoxH,iRBoxW+iRBoxH)

#nCr = n!/r!(n-r)!

#二分累乗法 iDを法として
def fBiPow(iX,iN,iD):
    iY = 1
    while iN > 0:
        if iN % 2 == 0:
            iX = iX * iX % iD
            iN = iN // 2
        else:
            iY = iX * iY % iD
            iN = iN - 1
    return iY

#階乗(iDを法とした)の配列
aM = [1]*(iMax+1)
for i in range(1,iMax+1):
    aM[i]=aM[i-1]*i %iD
#各階乗のiDを法とした逆元の配列
aInvM = [1]*(iMax+1)
aInvM[iMax] = fBiPow(aM[iMax],iD-2,iD)
for i in range(iMax,0,-1):
    aInvM[i-1]=aInvM[i]*i % iD

iRet = 0
for iL in range(0,iLBoxH+1):
    iRet += (aM[iL+iLBoxW]*aInvM[iL]*aInvM[iLBoxW]) % iD * (aM[iRBoxW+iRBoxH-iL]*aInvM[iRBoxW]*aInvM[iRBoxH-iL])%iD
    iRet %= iD
iRet %= iD
print(iRet)


Measured memory_bytes: 18676
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;
    int max_cnt = -1, cnt = 0, prev; cin >> prev;
    for (int i = 1; i < N; i++) {
        int h; cin >> h;
        if (h <= prev) {
            cnt++;
        } else {
            max_cnt = max(max_cnt, cnt);
            cnt = 0;
        }
        prev = h;
    }

    cout << max(max_cnt, cnt) << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, m;
ll fac[N];

int main() {
    cin >> n >> m;
    fac[1] = 1;
    for (int i = 2; i < N; ++i) {
        fac[i] = fac[i - 1] * i % mod;
    }
    if (abs(n - m) > 1) {
        cout << 0 << endl;
    } else {
        ll ans = fac[m] * fac[n] % mod;
        if (n == m)
            ans = ans * 2 % mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4432
#include <stdio.h>

int main(){

  int i,j,n,k,v,u;
   int a[100][100];
  
  scanf("%d",&n);

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      a[i][j]=0;
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      a[u-1][v-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
      if(j<n-1) printf(" ");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 636