akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 10000011
int main(){
    int n,ans=0;
    in>>n;
	Fur(i,1,n){
        int t=i,k=0;
        while(t)t/=10,k++;
        if(k&1)ans++;
    }
    out<<ans<<ln;
}


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

using namespace std;

void visit(const vector<vector<int>> &g, vector<int> &order, vector<bool> &mark, int pos){
	for(auto next : g[pos]){
		if(mark[next]) continue;
		visit(g, order, mark, next);
	}
	mark[pos] = true;
	order.push_back(pos);
}

vector<int> topologicalSort(const vector<vector<int>> &g){
	vector<int> res;
	vector<bool> mark(g.size(), false);
	for(int i=0;i<g.size();i++){
		if(mark[i]) continue;
		visit(g, res, mark, i);
	}
	reverse(res.begin(), res.end());
	return res;
}

vector<int> ts(const vector<vector<int>>& g){
    vector<int> deg(g.size(), 0);
    for(auto& v : g){
        for(auto& t : v) ++deg[t];
    }
    vector<int> res;
    for(int i=0;i<g.size();i++) if(!deg[i]) res.push_back(i);
    for(int i=0;i<g.size();i++){
        for(auto& t : g[res[i]]){
            --deg[t];
            if(!deg[t]) res.push_back(t);
        }
    }
    return res;
}

int main(){
    int V, E;
    cin >> V >> E;
    vector<vector<int>> g(V);
    for(int i=0;i<E;i++){
        int s, t; cin >> s >> t;
        g[s].push_back(t);
    }
    auto res = topologicalSort(g);
    for(auto& t : res) cout << t << endl;
}


Measured memory_bytes: 3656
import sys
from bisect import bisect_left
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def core(dic1, dic2):
    ans = INF
    for j in dic1.keys():
        if j not in dic2:
            continue
        dic1[j].sort()
        dic2[j].sort()
        v1 = dic1[j]
        v2 = dic2[j]
        for x in v1:
            i = bisect_left(v2, x)
            if i == len(v2):
                continue
            if ans > (v2[i] - x) * 10:
                ans = (v2[i] - x) * 10

    return ans


def main():
    N = int(readline())
    M = 200000
    U, R, D, L = [], [], [], []
    for _ in range(N):
        x, y, u = readline().split()
        x, y = int(x), int(y)
        if u == 'U':
            U.append((x, y))
        elif u == 'R':
            R.append((x, y))
        elif u == 'D':
            D.append((x, y))
        else:
            L.append((x, y))

    ans = INF

    dic1 = defaultdict(list)
    dic2 = defaultdict(list)
    for x, y in U:
        dic1[x].append(y)
    for x, y in D:
        dic2[x].append(y)

    for j in dic1.keys():
        if j not in dic2:
            continue
        dic1[j].sort()
        dic2[j].sort()
        v1 = dic1[j]
        v2 = dic2[j]
        for yu in v1:
            i = bisect_left(v2, yu)
            if i == len(v2):
                continue
            if ans > (v2[i] - yu) * 10 // 2:
                ans = (v2[i] - yu) * 10 // 2

    dic1 = defaultdict(list)
    dic2 = defaultdict(list)
    for x, y in R:
        dic1[y].append(x)
    for x, y in L:
        dic2[y].append(x)

    for j in dic1.keys():
        if j not in dic2:
            continue
        dic1[j].sort()
        dic2[j].sort()
        v1 = dic1[j]
        v2 = dic2[j]
        for xr in v1:
            i = bisect_left(v2, xr)
            if i == len(v2):
                continue
            if ans > (v2[i] - xr) * 10 // 2:
                ans = (v2[i] - xr) * 10 // 2

    dic1 = defaultdict(list)
    dic2 = defaultdict(list)
    for x, y in R:
        dic1[y - x].append(x)
    for x, y in D:
        dic2[y - x].append(x)

    ans = min(ans, core(dic1, dic2))

    dic1 = defaultdict(list)
    dic2 = defaultdict(list)
    for x, y in U:
        dic1[y - x].append(x)
    for x, y in L:
        dic2[y - x].append(x)

    ans = min(ans, core(dic1, dic2))

    dic1 = defaultdict(list)
    dic2 = defaultdict(list)
    for x, y in R:
        dic1[y + x].append(x)
    for x, y in U:
        dic2[y + x].append(x)

    ans = min(ans, core(dic1, dic2))

    dic1 = defaultdict(list)
    dic2 = defaultdict(list)
    for x, y in D:
        dic1[y + x].append(x)
    for x, y in L:
        dic2[y + x].append(x)

    ans = min(ans, core(dic1, dic2))

    if ans == INF:
        print('SAFE')
    else:
        print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 176212
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,x,mxv=0;
	ll ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		mxv=max(mxv,x);
		ans+=mxv-x;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3688
h, w, k = map(int,input().split())
grid = [list(input()) for _ in range(h)]
ans = 0
# 全行、全列のパターンを全探索
for h_red in range(2**h):
    for w_red in range(2**w):
        
        cnt = 0
        # 前段の2つのfor文で、全パターンについて探索するので、
        # この後の2つのfor文で、パターン毎の#の数をカウントする
        for i in range(h):
            for j in range(w):
                
                # この課題で、一番大事なロジックはここである。
                # ビット演算子>>右シフトと論理積&を組み合わせている
                # h_redやw_redは10進数であるが2進数の場合におけるi、jだけ右にシフトさせる
                # このi、jは10進数扱いであることがややこしい
                # i、jが一周するときに、h_red、w_redをなめているところがポイント
                if (h_red>>i)&1 == 0 and (w_red>>j)&1 == 0:
                    if grid[i][j] == '#':
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 9092
import java.util.*;
import java.io.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num1=0,num2=0;
        String s=br.readLine();
        String[] str = s.split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        if(x<y){
            System.out.println("a"+ " < "+"b");
        }else if(x>y){
            System.out.println("a"+ " > "+"b");
        }else if(x==y){
            System.out.println("a"+ " == "+"b");
        }
        
    }
}

Measured memory_bytes: 16888
n, m = map(int, input().split())
a = []
for _ in range(n):
    t = list(map(int, input().split()))
    a.append(t)

b = [int(input()) for i in range(m)] 

for i in a:
    x = 0
    for k in range(m):
        x += i[k]*b[k]
    else:
        print(x)


Measured memory_bytes: 6020
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val idles = readLine.trim.split(' ').map(_.toInt)
  println(
    List(if (m == 1) 0 else (1 until m).map(i ⇒ (idles(i) - idles(i - 1)) / 2).max, idles.head - 1, n - idles.last).max
  )
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz) : data(sz, -1) {}

  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
};


typedef long long int64;


int64 N, M, Q, A[100000];

int64 component(int height)
{
  int sz = height * 7;
  UnionFind tree(sz);
  vector< bool > used(sz, 0);

  for(int i = 0; i < Q; i++) {
    int64 idx = A[i];
    while(idx < sz) {
      used[idx] = true;
      idx += M;
    }
  }

  for(int i = 0; i < height; i++) {
    for(int j = 0; j < 7; j++) {
      int idx = i * 7 + j;
      if(used[idx]) continue;
      if(j + 1 < 7 && !used[idx + 1]) tree.unite(idx, idx + 1);
      if(i + 1 < height && !used[idx + 7]) tree.unite(idx, idx + 7);
    }
  }
  int64 ret = 0;
  for(int i = 0; i < sz; i++) {
    if(!used[i]) ret += tree.find(i) == i;
  }
  return (ret);
}

int main()
{
  cin >> N >> M >> Q;
  for(int i = 0; i < Q; i++) {
    cin >> A[i];
  }

  int MM = M;
  if(MM % 7) MM *= 7;
  auto latte = component(MM / 7);
  auto malta = component(MM * 2 / 7) - latte;


  cout << latte + malta * (N * 7 / MM - 1) << endl;
}

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

int main(void)
{
  set<int> A;
  int N;
  cin >> N;
  int temp;
  for (int i = 0; i < N; i++)
  {
    cin >> temp;
    A.insert(temp);
  }

  if (A.size() == N)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 9600
s, t, c, x, y = list(map(int, input().split()))
a = [s, x]
b = [t, y]
if x > y:
    large = a
    least = b
else:
    large = b
    least = a
ans = 0
if s + t >= c * 2:
    ans += c * 2 * least[1]
    if large[0] > c * 2:
        ans += c * 2 * (large[1] - least[1])
    else:
        ans += large[0] * (large[1] - least[1])
else:
    ans += s * x + t * y
print(ans)


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

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

void Empty(int *, int *);
void swap(int *, int *);
int Cal();
int DFS(int, int, int, int, int);

int main(){
  int i, j, l;
  int x, y, a;

for(i=0;i<4;i++)
  for(i = 0 ; i < 4 ; i++){
    for(j = 0 ; j < 4 ; j++){
      scanf("%d",&Puzzle[i][j]);
    }
  }

  Empty(&x,&y);

  for(l = 0 ; l < 100 ; l++){
    for(i = 0 ; i < 4 ; i++){
      for(j = 0 ; j < 4 ; j++){
 tmp[i][j] = Puzzle[i][j];
      }
    }

    a = DFS(x, y, -1, 0, l);
    if(a != -1){
      printf("%d\n",a);
      break;
    }

    for(i = 0 ; i < 4 ; i++){
      for(j = 0 ; j < 4 ; j++){
 Puzzle[i][j] = tmp[i][j];
      }
    }

    a = -1;
    if(l == 99) printf("%d\n",a);
  }

  return 0;
}

void Empty(int *x, int *y){
  int i, j;

  for(i = 0 ; i < 4 ; i++){
    for(j = 0 ; j < 4 ; j++){
      if(!Puzzle[i][j]){
 *x = j;
 *y = i;
 return;
      }
    }
  }
}

void swap(int *a, int *b){
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}


int Cal(){
  int i, a;
  int sum = 0;

  for(i = 0 ; i < 16 ; i++){
    a = Puzzle[i/4][i%4];
    if(a){
      a--;
      sum += abs(i/4 - a/4)  + abs(i%4 - a%4);
    }
  }

  return sum;
}

int DFS(int x, int y, int p, int dep, int limit){
  int i, h, nx, ny, res;

  h = Cal();

  if(h == 0) return dep;
  if(dep + h > limit) return -1;

  for(i = 0 ; i < 4 ; i++){
    nx = x + dx[i];
    ny = y + dy[i];

    if(~p && i == (p+2)%4) continue;
    if(!(0 <= nx && nx < 4 && 0 <= ny && ny < 4)) continue;

    swap(&Puzzle[y][x], &Puzzle[ny][nx]);
    res = DFS(nx, ny, i, dep+1, limit);
    if(~res) return res;

    swap(&Puzzle[y][x], &Puzzle[ny][nx]);
  }

  return -1;
}



Measured memory_bytes: 2112
from itertools import *

n, m, q = map(int, input().split())
abcd = []
for i in range(q):
    abcd.append(list(map(int, input().split())))
    abcd[i][0] -= 1
    abcd[i][1] -= 1

numbers = []
for i in range(1, m + 1):
    numbers.append(i)
    
cwr = list(combinations_with_replacement(numbers, n))

ans = 0
for c in cwr:
    cnt = 0
    for i in range(q):
        if c[abcd[i][1]] - c[abcd[i][0]] == abcd[i][2]:
            cnt += abcd[i][3]
    
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 21468
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
ans = [[10 ** 10] * 3 for i in range(n+1)]
ans[0] = [0,0,0]
for i in range(1,n+1):
    ans[i][0] = max(ans[i-1][1],ans[i-1][2])+lis[i-1][0]
    ans[i][1] = max(ans[i-1][2],ans[i-1][0])+lis[i-1][1]
    ans[i][2] = max(ans[i-1][0],ans[i-1][1])+lis[i-1][2]
print(max(ans[n]))

Measured memory_bytes: 47336
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;



int main() {
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    double  x1,y1,x2,y2,d,x,y;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    x=pow((x1-x2),2);
    y=pow((y1-y2),2);
    d=sqrt(x+y);
    printf("%.8lf\n",d);
    return 0;
}



Measured memory_bytes: 2064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<sstream>
#include<bitset>
using namespace std;
#define pii pair<int,int>
#define pdd pair<double,double>
#define mp make_pair
#define pb push_back
#define ALL(x)	x.begin(),x.end()
#define fst first
#define sec second
#define PQ priority_queue
typedef long long ll;
const double eps = 1e-6;
const int maxn=1e6+10;;
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const double pi=acos(-1.0);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} 
ll n,A,B;
ll a[maxn];
int check(ll m)
{
   ll tem=m*B;
   ll dif=A-B;
   ll sum=0;
   for(int i=n-1;i>=0;i--)
   {
     if(a[i]>tem)
     {
       if((a[i]-tem)%dif) sum+=(a[i]-tem)/dif+1;
       else sum+=(a[i]-tem)/dif;
     }
   
   }
   if(sum<=m) return 1;
   else return 0; 
}
int main()
{
   cin>>n>>A>>B;
   ll MAX=0;
  for(int i=0;i<n;++i)
    {cin>>a[i];MAX=max(a[i],MAX);}
    sort(a,a+n);
  int l,r,mid=0;
  l=1;
  r=inf;
  mid=(l+r)/2;
  while(l<r)
  {
    mid=(l+r)/2;
    if(check(mid)) r=mid;
    else l=mid+1;
  }
  //cout<<mid<<endl;
  cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
int a[maxn],b[maxn];
int fac[32];

int main()
{
    int N,K;
    scanf("%d%d",&N,&K);
    ll res=0;
    for(int i=0;i<N;i++){
        scanf("%d%d",&a[i],&b[i]);
        if((a[i]|K)==K) res+=b[i];
    }
    for(int i=0;i<=30;i++)
        fac[i]=1<<i;
    for(int i=1;i<=30;i++){
        if(K&fac[i]){
            ll cnt=0;
            int tmp=(K^fac[i])|(fac[i]-1);
            for(int j=0;j<N;j++)
                if((a[j]|tmp)==tmp) cnt+=b[j];
            res=max(res,cnt);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int INF = 0x3f3f3f3f;
int main(){
	//IOS;
	ll h,sum=0,a,n;
	cin>>h>>n;
	for(int i=0;i<n;i++)
	cin>>a,sum+=a;
	if(sum>=h)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
import           Control.Monad.ST            (runST)
import qualified Data.Sequence               as S
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  k <- readLn
  print $ solve k

solve :: Int -> Int
solve k = runST $ do
  vs <- VM.replicate k False
  whileLeft (S.singleton (1, 1)) $ \q -> do
    let (n, d) S.:< q' = S.viewl q
    v <- VM.read vs n
    if | n == 0    -> return $ Right d
       | v         -> return $ Left q'
       | otherwise -> do
           VM.write vs n True
           return $ Left $ (((n * 10) `mod` k, d) S.<| q') S.|> ((n + 1) `mod` k, d + 1)

whileLeft :: Monad m => a -> (a -> m (Either a b)) -> m b
whileLeft x f = f x >>= \case
  Left l  -> whileLeft l f
  Right r -> return r


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int SZ = 1 << 18;
const int INF = TEN(9);

struct segtree {
	vector<pii> dat;

	const pii inf = mp(INF, INF);

	void init() {
		dat.resize(SZ * 2);
		rep(i, SZ * 2) dat[i] = inf;
	}

	void update(int pos, int x) {
		dat[pos + SZ - 1] = mp(x, pos);
		pos += SZ - 1;

		while (pos > 0) {
			pos = (pos - 1) / 2;
			dat[pos] = min(dat[pos * 2 + 1], dat[pos * 2 + 2]);
		}
	}

	pii get(int a, int b, int k = 0, int l = 0, int r = SZ) {
		if (b <= l || r <= a) return inf;
		if (a <= l && r <= b) return dat[k];
		return min(get(a, b, k * 2 + 1, l, (l + r) / 2), get(a, b, k * 2 + 2, (l + r) / 2, r));
	}
} seg[2];

int main() {
	seg[0].init();
	seg[1].init();

	int N; cin >> N;
	V<int> p(N);

	rep(i, N) {
		cin >> p[i];
		seg[i % 2].update(i, p[i]);
	}

	using Data = pair<pii, pii>;
	priority_queue<Data, vector<Data>, greater<Data>> que;

	auto add = [&](int l, int r) {
		auto p = seg[l%2].get(l, r);
		if (l >= r || p.fi == INF) return ;
		que.push(mp(seg[l%2].get(l, r), mp(l, r)));
	};

	add(0, N);
	V<int> ans;

	while (!que.empty()) {
		auto p = que.top(); que.pop();
		int val = p.fi.fi, pos = p.fi.se; 
		int l = p.se.fi, r = p.se.se;

		auto nx = seg[1-l%2].get(pos + 1, r);

		ans.pb(val);
		ans.pb(nx.fi);
		add(l, pos);
		add(pos + 1, nx.se);
		add(nx.se + 1, r);
	}

	rep(i, N) printf("%d%c", ans[i], i == N - 1 ? '\n' : ' ');
 
	return 0;
}

Measured memory_bytes: 12020
s=input()
if(s=='SAT'):
    print(1)
if(s=='FRI'):
    print(2)
if(s=='THU'):
    print(3)
if(s=='WED'):
    print(4)
if(s=='TUE'):
    print(5)
if(s=='MON'):
    print(6)
if(s=='SUN'):
    print(7)

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
std::vector<std::string> split(const std::string &str, const char delemiter) {std::vector<std::string> res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int L,R,D; cin >> L >> R >> D;
    int ans = 0;
    for(int i = L; i <= R; ++i) {
        if(i%D==0) ans++;
    }
    cout << ans << endl;
    
    return 0;
}


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

// 解説を読んだ
int main(){
    int n;
    cin >> n;
    char mat[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> mat[i][j];
        }
    }
    int ans = 0;
    for(int d = 0; d < n; d++){
        bool ok = true;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                ok &= mat[(i+d)%n][j] == mat[(j+d)%n][i];
                // printf("(%d,%d) -> (%d,%d)\n", (i+d)%n, j, (j+d)%n, i);
            }
        }
        ans += n * ok;
    }
    cout << ans << endl;
    return 0;
}

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

const long long MAXN = 1e5 + 10, inf = 1e18 + 10;

long long n, m;
long long l, r, c;
long long d[MAXN];
set <pair <long long, long long> > st;
vector <pair <long long, long long> > adj[MAXN];

void dijk() {
	for (int i = 2; i <= n; i++)
		d[i] = inf;
    d[1] = 0;
    
	st.insert({0, 1});

	while (st.size()) {
		int x = st.begin() -> second;
		st.erase(st.begin());
		for (auto y: adj[x])
			if (d[y.first] > d[x] + y.second) {
				st.erase({d[y.first], y.first});
				d[y.first] = d[x] + y.second;
				st.insert({d[y.first], y.first});
			}
	}
}

int main() {
    cin >> n >> m;
    for (int i = n; i > 1; i--)
        adj[i].push_back({i - 1, 0});
   
    for (int i = 0; i < m; i++) {
        cin >> l >> r >> c;
        adj[l].push_back({r, c});
    }
    dijk();
    if (d[n] == inf)
        cout << -1 << '\n';
    else
        cout << d[n] << '\n';
    return 0;
}

Measured memory_bytes: 10752
import java.io.*;
import java.util.*;
 
 
public class Main{
static int mod = (int)(Math.pow(10, 9) + 7);
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int n = sc.nextInt();
      String s = sc.next();
      if (s.length() <= n) out.println(s);
      else{
        for (int i=  0; i < n; i++){
          out.print(s.charAt(i));
        }
        out.print("...");
        out.println();
      }

      out.close();
   }
   
   static long pow(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a;
	   else {
		   long R = pow(a,N/2);
		   if (N % 2 == 0) {
			   return R*R;
		   }
		   else {
			   return R*R*a;
		   }
	   }
   }
   
   static long powMod(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a % mod;
	   else {
		   long R = powMod(a,N/2) % mod;
		   R *= R % mod;
		   if (N % 2 == 0) {
			   R *= a % mod;
		   }
			   return R % mod;
	   }
   }
static void mergeSort(int[] A){ // low to hi sort, single array only
      int n = A.length;
      if (n < 2) return;
      int[] l = new int[n/2];
      int[] r = new int[n - n/2];
 
      for (int i = 0; i < n/2; i++){
        l[i] = A[i];
      }
 
      for (int j = n/2; j < n; j++){
        r[j-n/2] = A[j];
      }
 
      mergeSort(l);
      mergeSort(r);
      merge(l, r, A);
    }
 
    static void merge(int[] l, int[] r, int[] a){
      int i = 0, j = 0, k = 0;
      while (i < l.length && j < r.length && k < a.length){
        if (l[i] < r[j]){
          a[k] = l[i];
          i++;
        }
        else{
          a[k] = r[j];
          j++;
        }
        k++;
      }
      while (i < l.length){
        a[k] = l[i];
        i++;
        k++;
      }
 
      while (j < r.length){
        a[k] = r[j];
        j++;
        k++;
      }
    }

   

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
   //--------------------------------------------------------
}







Measured memory_bytes: 32772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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 (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll H, W, K;
ll ans[305][305];
int main() {
    init();
    cin >> H >> W >> K;
    vc<string> S(H);
    rep(i, H) cin >> S[i];
    
    vc<ll> border = {0};
    bool hass = false;
    rep(i, H) {
        bool isexist = false;
        rep(j,W){
            if(S[i][j]=='#'){
                isexist = true;
                break;
            }
        }
        if(hass&&isexist){
            border.eb(i);
        }
        else if(isexist){
            hass = true;
        }
    }
    border.eb(H);

    ll ansi = 1; //色
    rep(i,border.size()-1){
        ll u = border[i], d = border[i + 1];
        queue<ll> qst;
        repe(h,u,d)rep(w, W) if (S[h][w] == '#') qst.emplace(w);
        qst.emplace(W);

        repe(h, u, d) rep(w, qst.front()) ans[h][w] = ansi;
        while(qst.front()<W){
            ll now_w = qst.front();
            qst.pop();
            repe(h,u,d)repe(w, now_w, qst.front()){
                ans[h][w] = ansi;
            }
            ansi++;
        }
    }

    rep(i,H){
        rep(j, W) cout << ans[i][j] << " ";
        cout << "\n";
    }
    // rep(i, border.size()) cout << border[i] << " ";
    // cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll res=0;
    rep(i,n) res+=a[i]-1;
    cout<<res<<endl;
    return 0;
}

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

int main(){
        using namespace std;

        stack<int> st;
        int n;
        while ( cin >> n ){
                if(n != 0){
                        st.push(n);
                }else if(n == 0){
                        cout << st.top() << endl;
                        st.pop();
                }
        }
        return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (a == b && a == c) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        int tmpa, tmpb, tmpc;
        tmpa = a; tmpb = b; tmpc = c;
        a = tmpb/2 + tmpc/2;
        b = tmpa/2 + tmpc/2;
        c = tmpa/2 + tmpb/2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s;
string a, b;

int main() { 

  cin >> s;

  for (int i = 0; i < sz(s); i++) {
    if (i % 2 == 0) {
      a.append(1, '0');
      b.append(1, '1');
    } else {
      a.append(1, '1');
      b.append(1, '0');
    }
  }

  int diffA = 0, diffB = 0;
  for (int i = 0; i < sz(s); i++) {
    if (s[i] != a[i]) {
      diffA++;
    }
    if (s[i] != b[i]) {
      diffB++;
    }
  }

  cout << min(diffA, diffB) << endl;

  return 0;
}


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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

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

/*
class Node {
public:
  int num;
  int index;
  bool operator<(const Node& b) const {
    if(num < b.num) return (num < b.num);
    else return index > b.index;
  }

  Node(){
    num=0; index=0;
  }
  Node(int n, int i) : num(n), index(i){
  }
};
*/

int main(){
  int n;
  cin >> n;
  vector<int> num(n + 1);
  REP(i,1, n + 1) cin >> num[i];


  int ret = 0;
  rep(i,n){
    if(num[num[i]] == i)  ret++;
  }

cout << (ret / 2) <<endl;
  return 0;
}


Measured memory_bytes: 640
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
Acum = list(accumulate(A))

ans = 10 ** 20

for a in Acum[:-1]:
    snuke = a
    arai = Acum[-1] - a
    ans = min(ans, abs(snuke - arai))
print(ans)

Measured memory_bytes: 24168
using System;

namespace B___Comparison
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine();
            var B = Console.ReadLine();

            if (A.Length != B.Length)
                Console.WriteLine(A.Length > B.Length ? "GREATER" : "LESS");
            else
            {
                for (int i = 0; i < A.Length; i++)
                {
                    if (A[i] != B[i])
                    {
                        Console.WriteLine(A[i] > B[i] ? "GREATER" : "LESS");
                        return;
                    }
                }
                Console.WriteLine("EQUAL");
            }
        }
    }
}


Measured memory_bytes: 13140
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    cnt=1
    for i in l:
        if i%2==1:
            cnt*=1
        else:
            cnt*=2
    print(3**n-cnt)
resolve()


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

void spiral0(int p[128][128], int y , int x);
void spiral1(int p[128][128], int y, int x);
void spiral2(int p[128][128], int, int);
void spiral3(int p[128][128], int, int);

void spiral0(int p[128][128], int y, int x){
  if(p[y-1][x] + p[y+1][x] + p[y][x-1] + p[y][x+1] <= 1) p[y][x] = 1;
  if(p[y][x - 1] == 0 && p[y][x - 2] == 0) spiral0(p, y, x - 1);
  else if(p[y - 1][x] == 0 && p[y - 2][x] == 0) spiral1(p, y - 1, x);
  else if(p[y][x + 1] == 0 && p[y][x + 2] == 0) spiral2(p, y, x + 1);
  else if(p[y + 1][x] == 0 && p[y + 2][x] == 0) spiral3(p, y + 1, x);
  else return;
}

void spiral1(int p[128][128], int y, int x){
  if(p[y-1][x] + p[y+1][x] + p[y][x-1] + p[y][x+1] <= 1) p[y][x] = 1;
  if(p[y - 1][x] == 0 && p[y - 2][x] == 0) spiral1(p, y - 1, x);
  else if(p[y][x + 1] == 0 && p[y][x + 2] == 0) spiral2(p, y, x + 1);
  else if(p[y + 1][x] == 0 && p[y + 2][x] == 0) spiral3(p, y + 1, x);
  else if(p[y][x - 1] == 0 && p[y][x - 2] == 0) spiral0(p, y, x - 1);
  else return;
}

void spiral2(int p[128][128], int y, int x){
  if(p[y-1][x] + p[y+1][x] + p[y][x-1] + p[y][x+1] <= 1)p[y][x] = 1;
  if(p[y][x + 1] == 0 && p[y][x + 2] == 0) spiral2(p, y, x + 1);
  else if(p[y + 1][x] == 0 && p[y + 2][x] == 0) spiral3(p, y + 1, x);
  else if(p[y][x - 1] == 0 && p[y][x - 2] == 0)spiral0(p, y, x - 1);
  else if(p[y - 1][x] == 0 && p[y - 2][x] == 0) spiral1(p, y - 1, x);
  else return;
}

void spiral3(int p[128][128], int y, int x){
  if(p[y-1][x] + p[y+1][x] + p[y][x-1] + p[y][x+1] <= 1)p[y][x] = 1;
  if(p[y + 1][x] == 0 && p[y + 2][x] == 0) spiral3(p, y + 1, x);
  else if(p[y][x - 1] == 0 && p[y][x - 2] == 0)spiral0(p, y, x - 1);
  else if(p[y - 1][x] == 0 && p[y - 2][x] == 0) spiral1(p, y - 1, x);
  else if(p[y][x + 1] == 0 && p[y][x + 2] == 0) spiral2(p, y, x + 1);
  else return;
}

int main(){
  int p[128][128];
  int d, n, i, j, f = 0;
  scanf("%d", &d);
  while(d--){
    memset(p, 0, sizeof(p));
    scanf("%d", &n);
    for(i = 0; i < n + 4; ++i){
      p[i][0] = 1;
      p[0][i] = 1;
      p[i][n + 3] = 1;
      p[n + 3][i] = 1;
    }
    spiral1(p, n + 1, 2);
    if(f) puts("");
    for(i = 2; i < n + 2; ++i){
      for(j = 2; j < n + 2; ++j) putchar(p[i][j] != 0 ? '#' : ' ');
      puts("");
    }
    f = 1;
  }
  return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

ll g[2001][2001];

int main(){
    ll n,x,y;
    cin >> n >> x >> y;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j){
                g[i][j]=0;
            }else{
                g[i][j]=labs(i-j);
            }
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) continue;
            ll now;
            now=min(g[i][x]+g[y][j]+1,g[i][y]+g[x][j]+1);
            g[i][j]=min(g[i][j],now);
        }
    }
    
    vector<ll> ans(n,0);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            ans[g[i][j]]++;
        }
    }
    
    for(int i=1;i<n;i++){
        cout << ans[i]/2 << endl;
    }
    
    
    return 0;
}











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

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    ll n, k;
    cin >> n >> k;
    int maxidx = max(n + 1, 2 * k + 1);
    vector<double> dp(maxidx, 0.0);
    for (int i = k; i < maxidx; ++i) {
        dp[i] = 1.0;
    }
    for (int i = k - 1; i >= 1; --i) {
        dp[i] = 0.5 * dp[i * 2];
    }
    double ret = 0;
    for (int i = 1; i <= n; ++i) {
        ret += dp[i];
    }
    cout << fixed << setprecision(12) << ret / n << endl;

    return 0;
}

Measured memory_bytes: 1792
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, t; cin >> n >> t;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int mi = INF;
    map<int, int> mp;
    rep(i, n) {
        if(i > 0) mp[a[i] - mi] ++;
        chmin(mi, a[i]);
    }
    cout << (*mp.rbegin()).sc << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 10316
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    cin >> n;
    ll ans=1;
    rep(i,n){
        ans=ans*(i+1)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string A;
    cin >>A;
    int N=0,W=0,S=0,E=0;
    for(int i=0;i<A.size();i++){
    if(A.at(i)=='N'){
        N++;
    }
    else if (A.at(i)=='W'){
        W++;
    }
    else if (A.at(i)=='S'){
        S++;
    }
    else if (A.at(i)=='E'){
        E++;
    }
    }
  if(S>=1&&N>=1){
      if(E==0&&W==0){
         cout <<"Yes"<<endl;
         return 0;
    }
    if(E>=1&&W>=1){
     cout <<"Yes"<<endl;
     return 0;
    }
    }
 else  if(E>=1&&W>=1){
    if(S==0&&N==0){
      cout <<"Yes"<<endl;
     return 0;
    } 
     if(S>=1&&N>=1){
      cout <<"Yes"<<endl;
     return 0;
    }      
    }
 else  if(S==0&&N==0){
     if(W>=1&&E>=1){
      cout <<"Yes"<<endl;
     return 0;
    }
     if(E==0&&W==0){
      cout <<"Yes"<<endl;
     return 0;
    } 
    }   
else  if(E==0&&W==0){
     if(S>=1&&N>=1){
      cout <<"Yes"<<endl;
     return 0;
    }
    if(N==0&&S==0){
      cout <<"Yes"<<endl;
     return 0;
    }     
 }
 cout <<"No"<<endl;    
 
}
 

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoder.ABC.ABC120
{
    class A
    {


        public static void Solve()
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);

            var ans = 0;
            var maxnum = b / a;
            ans = Math.Min(c, maxnum);
            Console.WriteLine(ans);


            //var result = Solve(Convert(input));
            //Console.WriteLine(result);
        }

        static void Main(string[] args)
        {
            Solve();
        }
    }
}

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

int main(void) {
    int H, N;
    cin >> H >> N;
    vector< int > A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A[i];
    }
    if (sum >= H) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


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

using namespace std;

typedef pair<long, long> ii;
vector<ii> g[111111];
ii a[111111];
void f(int u, ii &b) {
	if (a[u].second < 0)
		b.second = min(b.second, a[u].first);
	else
		b.first = max(b.first, -a[u].first);
	if (b.second - b.first < 2)
		return;
	for (auto t : g[u]) {
		ii c = { t.second - a[u].first,-a[u].second };
		if (!a[t.first].second) {
			a[t.first] = c;
			f(t.first, b);
			if (b.second - b.first < 2)
				return;
			continue;
		}
		if (a[t.first].second == c.second) {
			if (a[t.first].first == c.first)
				continue;
			b.second = b.first;
			return;
		}
		auto i = (a[t.first].first - c.first)*c.second;
		if (i % 2 || i / 2 <= b.first || i / 2 >= b.second) {
			b.second = b.first;
			return;
		}
		b.first = i / 2 - 1;
		b.second = b.first + 2;
	}
}
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int u, v, s;
		scanf("%d%d%d", &u, &v, &s);
		g[u].emplace_back(v, s);
		g[v].emplace_back(u, s);
	}
	a[1].second = 1;
	ii b = { 0,1e18 };
	f(1, b);
	cout << max(0l, b.second - b.first - 1) << endl;
	return 0;
}


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

using namespace std;


int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
    int x;
    string s;
    cin >> x >> s;
    if(x < 3200){
        cout << "red\n";
    }else{
        cout << s << endl;
    }
    return 0;
}


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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    ll n,m;
    ll a[1000008];
    ll sum = 0;

    cin>>n>>m;
    FOR(i,0,m)
    {
        cin>>a[i];
        sum+=a[i];
    }

    if (sum > n)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<n-sum<<endl;
    }
}


Measured memory_bytes: 3660
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
	    ll n;
	    cin>>n;
	    ll ans=0;
	    rep(i,1,n+1){
	    	ll nm=i;
	    	ll c=0;
	    	while(nm>0){
	    	nm/=10;
	    	c++;
	    	}
	    	if(c%2==1)
	    	ans++;
	    }
	    cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,k;
	cin >> n >> k;
	long long int ans = pow(n/k,3);
	if (k%2 == 0&& k/2 <= n) {
		
		int x = (n - k/2)/k;
		x += 1;
		ans += pow(x,3);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int n,m,q;
    cin>>n>>m>>q;
    vector<int> l(m),r(m),p1(q),p2(q);
    vector< vector<int>> score(n,vector<int> (n,0));
    map<pair<int,int>,int> p;
    rep(i,m){
        cin>>l[i]>>r[i];
        l[i]--,r[i]--;
        p[{l[i],r[i]}]++;
    }
    for(auto c:p){
        int start = c.first.first;
        int goal = c.first.second;
        int point = c.second;
        for(int i=start;i>=0;i--){
            for(int j=goal;j<n;j++){
                score[i][j] += point;
            }
        }
    }
    rep(i,q){
        cin>>p1[i]>>p2[i];
        p1[i]--,p2[i]--;
        cout<<score[p1[i]][p2[i]]<<endl;
    }
}

Measured memory_bytes: 12756