akhauriyash/Code-Regression huggingface dataset:
n = int(input())

points = [None] * n
for i in range(0, n):
    points[i] = list(map(int, input().split()))

f = [[0, 0, 0] for i in range(0, n)]

f[0] = points[0]
for i in range(1, n):
    for j in range(0, 3):
        for k in range(0, 3):
            if j == k: continue
            f[i][j] = max(f[i][j], f[i - 1][k] + points[i][j])

print(max(f[n - 1]))

Measured memory_bytes: 70872
def main():
  import sys
  input=sys.stdin.readline
  h,w,k=map(int,input().split())
  sx,sy,tx,ty=map(int,input().split())
  b=[[-1]*(w+2)]
  for i in range(h):
    s=input()
    bb=[-1]
    for j in s:
      if j==".":bb.append(0)
      else:bb.append(-1)
    bb.append(-1)
    b.append(bb)
  b.append([-1]*(w+2))
  d=[]
  d.append((sx,sy))
  for ss in d:
    x,y=ss
    if x==tx and y==ty:
      exit(print(b[x][y]))
    for i in range(1,k+1):
      if b[x+i][y]<=b[x][y] and b[x+i][y]!=0:break
      if b[x+i][y]==0:d.append((x+i,y))
      b[x+i][y]=b[x][y]+1
    for i in range(1,k+1):
      if b[x-i][y]<=b[x][y] and b[x-i][y]!=0:break
      if b[x-i][y]==0:d.append((x-i,y))
      b[x-i][y]=b[x][y]+1
    for j in range(1,k+1):
      if b[x][y+j]<=b[x][y] and b[x][y+j]!=0:break
      if b[x][y+j]==0:d.append((x,y+j))
      b[x][y+j]=b[x][y]+1
    for j in range(1,k+1):
      if b[x][y-j]<=b[x][y] and b[x][y-j]!=0:break
      if b[x][y-j]==0:d.append((x,y-j))
      b[x][y-j]=b[x][y]+1
  print(-1)
if __name__ == "__main__":
  main()


Measured memory_bytes: 136180
N=int(input())
List = list(map(int, input().split()))
sumS = 0
for i in range(N):
  sumS +=List[i]
trial = sumS // N
mid = 0
res = 10000000
for i in range(N):
  trial += i
  mid = 0 
  for j in range(N):
    mid += (trial - List[j])**2
  res = min(res, mid)
print(res)

Measured memory_bytes: 9132
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

template<class T, int SIZE> class BIT {

   public:
      T bit[SIZE];
      void init(T a) {
         for (int i = 0; i < SIZE; i++) {
            bit[i] = a;
         }
      }
      // 1-indexed 
      void add(int a, int w) {
         for (int x = a; x <= SIZE; x += x & -x) bit[x] += w;
      }
      
      // [1, a], 1-indexed
      T sum(int a) {
         T ret = 0;
         for (int x = a; x > 0; x -= x & -x) ret += bit[x];
         return ret;
      }

      // [a, b), 1-indexed
      T sum(int a, int b) {
         return sum(b) - sum(a - 1);
      }

      // get k-th number with binary search, k: 0-indexed
      int getk(T k) {
         k++;
         T ret = 0;
         int N = 1;
         while (N < SIZE) N *= 2;
         for (int i = N / 2; i > 0; i /= 2) {
            if (ret + i < SIZE && bit[ret + i] < k) {
               k = k - bit[ret + i];
               ret = ret + i;
            }
         }
         return ret + 1;
      }

};

const int NMAX = 100000;
int main() {
   int N, Q;
   cin >> N >> Q;
   BIT<int, NMAX> bit;
   bit.init(0);
   for (int q = 0; q < Q; q++) {
      int c, x, y;
      cin >> c >> x >> y;
      if (c == 0) {
         bit.add(x, y);
      }
      else {
         int ans = bit.sum(x, y);
         cout << ans << endl;
      }
   }
   return 0;
}



Measured memory_bytes: 3492
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
Shining through the city with a little funk and soul
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      static final long MOD = 1000000007L;
      static final int LEN = 667;
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int S = Integer.parseInt(st.nextToken());
         long[][] dp = new long[LEN][S+1];
         dp[0][0] = 1L;
         for(int i=1; i < LEN; i++)
         {
            long[] psums = new long[S+1];
            psums[0] = dp[i-1][0];
            for(int a=1; a <= S; a++)
               psums[a] = (psums[a-1]+dp[i-1][a])%MOD;
            for(int v=3; v <= S; v++)
               dp[i][v] = psums[v-3];
         }
         long res = 0L;
         for(int len=1; len < LEN; len++)
            res = (res+dp[len][S])%MOD;
         System.out.println(res);
      }
   }

Measured memory_bytes: 60172
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<algorithm>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define ll long long 
using namespace std;

// struct Point{
//     int x, y, z, idx;
// };

// bool comparePoints(Point p1, Point p2){
//     if(p1.x != p2.x)return p1.x < p2.x;
//     else {
//         if(p1.y != p2.y)return p1.y < p2.y;
//         else return p1.z < p2.z;
//     }
    
// } 

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    _cin;

    int x;
    cin>>x;
    for(int i=1;i<=180;i++){
        if( (360*i)%x == 0){
            cout<<(360*i)/x<<endl;
            break;
        }
    }

}

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


// http://www.cse.ust.hk/~golin/COMP572/Notes/Matching.pdf

vector<int> min_cost_match(vector< vector<int> > a) {
	int n=a.size(),m=a[0].size();
	vector<int> left(n,-1), right(m,-1);
	vector<int> ofsleft(n,0), ofsright(m,0);
	auto cost=[&](int i,int j){ return a[i][j]+ofsleft[i]+ofsright[j];};

	rep(r,n){
		vector<bool> s(n,false),t(m,false);
		vector<int> trace(m,-1), edge(m,r);
		s[r]=true;

		int b=-1;
		while(1){
			int d=numeric_limits<int>::max();
			rep(j,m) if(!t[j]) d=min(d,cost(edge[j],j));
			rep(i,n) if(s[i]) ofsleft[i]-=d;
			rep(j,m) if(t[j]) ofsright[j]+=d;

			rep(j,m) if(!t[j]&&cost(edge[j],j)==0) b=j;
			trace[b]=edge[b];
			int c=right[b];
			if(c<0) break;
			s[c]=t[b]=true;
			rep(j,m) if(cost(c,j)<cost(edge[j],j)) edge[j]=c;
		}
		while(b>=0){
			int a=trace[b],nb=left[a];
			right[b]=a,left[a]=b,b=nb;
		}
	}
	return left;
}

int n;

int w[110][110],e[110][110];
string s[110];
bool op[110][110];

int row[110],col[110];

void output(int i,int j,int type){
	cout << i+1 << " " << j+1 << " ";
	if(type)
		cout << "write" << endl;
	else
		cout << "erase" << endl;
	return;
}

int main(void){
	cin >> n;
	rep(i,n)rep(j,n) cin >> w[i][j];
	rep(i,n)rep(j,n) cin >> e[i][j];
	rep(i,n) cin >> s[i];

	rep(i,n){
		row[i]=0,col[i]=0;
		rep(j,n) if(s[i][j]=='o') row[i]+=e[i][j];
		rep(j,n) if(s[j][i]=='o') col[i]+=e[j][i];
	}

	vector<vector<int>> cost(n,vector<int>(n,0));
	rep(i,n)rep(j,n){
		if(s[i][j]=='o')
			cost[i][j]=row[i]+col[j]-2*e[i][j];
		else
			cost[i][j]=row[i]+col[j]+2*w[i][j];
	}

	vector<int> match=min_cost_match(cost);
	rep(i,n) op[i][match[i]]=true;

	int mincost=0,cnt=0;
	rep(i,n)rep(j,n){
		if(s[i][j]=='.'&&op[i][j]==true) mincost+=w[i][j],cnt++;
		if(s[i][j]=='o'&&op[i][j]==false) mincost+=e[i][j],cnt++;
	}
	cout << mincost << endl;
	cout << cnt << endl;
	rep(i,n)rep(j,n){
		if(s[i][j]=='.'&&op[i][j]==true) output(i,j,1);
		if(s[i][j]=='o'&&op[i][j]==false) output(i,j,0);
	}
	return 0;
}

Measured memory_bytes: 1448
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    s = ["0"]*N
    for i in range(N):
        s[i] = input()
    ac = str(s.count("AC"))
    wa = str(s.count("WA"))
    tle = str(s.count("TLE"))
    re = str(s.count("RE"))


    
    print("AC x "+ac)
    print("WA x "+wa)
    print("TLE x "+tle)
    print("RE x "+re)

if __name__ == "__main__":
	main()

Measured memory_bytes: 15860
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int N;
  ll L;
  cin >> N >> L;
  vector<ll> A;
  rep(i,N){
    ll a;
    cin >> a;
    A.push_back(a);
  }
  int x = -1;
  rep(i,N-1){
    if(A[i]+A[i+1]>=L){
      x = i;
    }
  }
  if(x < 0){
    cout << "Impossible" << endl;
  }else{
    cout << "Possible" << endl;
    for(int i=N-1; i>x+1; i--) cout << i << endl;
    for(int i=1; i<x+1; i++) cout << i << endl;
    cout << x+1 << endl;
  }
  return 0;
}



Measured memory_bytes: 1908
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long a, b, m;
long acost[100005], bcost[100005];
long amin = LINF, bmin = LINF;

int main(){
    scanf("%ld%ld%ld", &a, &b, &m);
    for(int i = 0; i < a; i++){
        scanf("%ld", acost+i);
        amin = std::min(amin, acost[i]);
    }
    for(int i = 0; i < b; i++){
        scanf("%ld", bcost+i);
        bmin = std::min(bmin, bcost[i]);
    }
    long ans = amin+bmin;
    //printf("  %ld\n", ans);
    for(int i = 0; i < m; i++){
        long x, y, c;
        scanf("%ld%ld%ld", &x, &y, &c);
        ans = std::min(ans, acost[x-1] + bcost[y-1] - c);
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <map>
#include <set> 
#include <math.h> 

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;


typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;


int main()
{
    long double a,b,c;
    cin >> a >> b >> c;
    string res;

    //if(pow(a,0.5) + pow(b,0.5) < pow(c,0.5))
    if(sqrtl(a * b) < (c-a-b) / (2.0))
    //if(sqrt(a) + sqrt(b) < sqrt(c))
    {
        res = "Yes";
    }
    else res = "No";

    //cout << pow(a,0.5) << endl;

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
a = list(map(int, input().split()))
a.sort()
#print(a)
if N > M:
    ans = 0
else:
    distance = [abs(a[i+1] - a[i]) for i in range(M-1)]
    #print(distance)
    distance.sort()
    #print(distance)
    del distance[M-N:]
    ans = 0 
    for j in distance:
        ans += j
print(ans)

Measured memory_bytes: 13968
#include<stdio.h>

int main(void){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);

	if(a <= c){
		if(b <= d && b <= c) printf("%d\n", 0);
		if(b <= d && b > c) printf("%d\n", b - c);
		if(b > d) printf("%d\n", d - c);
	}else{
		if(b <= d) printf("%d\n", b - a);
		if(b > d && a >= d) printf("%d\n", 0);
		if(b > d && a < d) printf("%d\n", d - a);
	}

	return 0;
}


Measured memory_bytes: 128
/*input
5 3
10 30 40 50 20
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

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

#define ll long long
#define N 300005
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() 
{
    off;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll dp[n];
    for(ll i=0;i<n;i++)
        dp[i]=INT_MAX;
    dp[0]=0;
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<=k;j++)
        {
            if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
while 1:
 n, x = map(int, input().split())
 counter = 0
 if n == 0 and x == 0:
  break
 # y + (y-1) + (y-2) = x 
 y = (x+3) // 3
 for a in range(y, n+1):
  for b in range(2, a):
   if (x-a-b) > 0 and (x-a-b) < b:
    counter += 1
 print(counter)
  

Measured memory_bytes: 7656
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N;
    int[] A;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      A = new int[N];
      for(int i = 0; i < N; i++) {
        A[i] = sc.nextInt();
      }
    }
    List<MyNumber> vlist = new ArrayList<MyNumber>();
    for(int i = 0; i < N; i++) {
      vlist.add(new MyNumber(i, A[i]));
    }
    Collections.sort(vlist);
    for(int i = 0; i < N; i++) {
      int v = -1;
      for(int j = N-1; j > -1; j--) {
        MyNumber num = vlist.get(j);
        if ( num.hasIndex(i) == false ) {
          v = num.getValue();
          break;
        }
      }
      System.out.println(v);
    }
  }
  
  private static class MyNumber 
    		implements Comparable<MyNumber> 
  {
    private final int index;
    private final int value;
    
    public MyNumber(int index, int value) {
      this.index = index;
      this.value = value;
    }
    
    @Override
    public int compareTo(MyNumber o) {
      if ( o == null ) {
        return 1;
      }
      if ( value > o.value ) {
        return 1;
      }
      else if ( value < o.value ) {
        return -1;
      }
      return 0;
    }
    
    public boolean hasIndex(int index) {
      return index == this.index;
    }
    
    public int getValue() {
      return value;
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

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

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

// can be applied to string type
#define Unique(v) v.resize(unique(All(v)) - v.begin())

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

#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T>
void Debug(const T &val) { cerr << val << End; }
template<typename T, typename... Args>
void Debug(const T &val, Args... args) {
    cerr << val << ' ';
	Debug(std::forward<Args>(args)...);
}

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

// can be applied to string type
#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
// array sorters
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define a first
#define b second
#define lb std::lower_bound
#define ub std::upper_bound

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

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

#define LOCAL 0

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

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

    string s;

	cin >> s;

	int ans = 0;
	int c = 0;

	int i, len = s.size();

	rep(i, len) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			c++;
		} else {
			Max(ans, c);

			c = 0;
		}
	}

	Max(ans, c);

	Out(ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<long long>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  long long ans=1;
  bool judge_0=false;
  vector<int>cnt(n);
  for(int i=0;i<n;i++){
    if(a.at(i)==0){
      judge_0=true;
      ans=0;
    }
  }
  bool judge=false;
  vector<long long>copy(n);
  for(int i=0;i<n;i++){
    copy.at(i)=a.at(i);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<20;j++){
      copy.at(i)/=10;
      if(copy.at(i)>0){
        cnt.at(i)++;
      }
      else{
        break;
      }
    }
  }
      
  for(int i=0;i<n;i++){
    if(judge){
      break;
    }
    long long copy_a=ans;
    int cnt_a=0;
    for(int j=0;j<50;j++){
      copy_a/=10;
      if(copy_a>0){
        cnt_a++;
      }
      else{
        break;
      }
    }
    if(cnt_a+cnt.at(i)>18){
      judge=true;
      break;
    }
    ans*=a.at(i);
    if(ans>1000000000000000000){
      judge=true;
    }
    if(ans==0){
      judge=true;
    }
  }
  if(judge_0){
    cout << ans << endl;
  }
  else if(judge){
    cout << "-1" << endl;
  }
  else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 5368
#include <iostream>
using namespace std;
int main(void){
   int a,b,c;
   cin >> a >> b >> c;
   if(a==1&&b==1&&c==0){
       cout << "Open" << endl;
   }
else if(a==0&&b==0&&c==1){
    cout << "Open" << endl;
}
else cout << "Close" << endl;
}



Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>


int main() {
	std::string a, b, c;
	std::cin >> a >> b >> c;
	if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}
}

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

const long mod = 1e9+7;

long modpow(long a, long b)
{
	long res = 1;
	while (b > 0)
	{
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b /= 2;
	}
	return res;
}

long comb(long a, long b)
{
	long res = 1;
	for (long i = a; i > a - b; i--)
	{
		res = res * i % mod;
	}
	for (long i = 1; i <= b; i++)
	{
		res = (res * modpow(i, mod - 2)) % mod;
	}
	return res;
}

int main()
{
	long N, A, B;
	cin >> N >> A >> B;
	long ans = modpow(2, N);
	ans--;
	ans -= comb(N, A);
	ans -= comb(N, B);
	while (ans < 0) ans += mod;
	cout << ans << "\n";
}

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

ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
  ll a,b,c,d;cin>>a>>b>>c>>d;
  
  ll p = (c/euclidean_gcd(c,d))*d;
  
  cout<<b - (b/c + b/d - b/p) - (a-1 - ((a-1)/c + (a-1)/d - (a-1)/p))<<endl;
    
}

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


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

	for(int j=0;j<N;j++){
		cout << A[j];
		if(j != N-1)cout << " ";
	}cout << endl;

	for(int i=1;i<=N-1;i++){
		int v = A[i];
		int j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		for(int j=0;j<N;j++){
			cout << A[j];
			if(j != N-1)cout << " ";
		}cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < int, int >
#define INF (int)1e9
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

int n, w;
vector < pii > arr;
ll cache[110][100010];

ll dpSol(int i, int wgt)
{
    if(i == n)
        return 0;
        
    ll &res = cache[i][wgt];
    
    if(res != -1)
        return res;
    
    ll ans = 0;
    if(arr[i].first + wgt <= w)
        ans = arr[i].second + dpSol(i + 1, arr[i].first + wgt);
    ans = max(ans, dpSol(i + 1, wgt));
    return res = ans;
}

int main()
{
    fastIO
    
    cin >> n >> w;
    arr.resize(n);
    
    memset(cache, -1, sizeof(cache));
    
    for(int i = 0; i < n; ++i)
        cin >> arr[i].first >> arr[i].second;
        
    cout << dpSol(0, 0);

    return 0;
}

Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int a,cnt=1;
	while(cin>>a)
	{
		if(a==0)break;
		cout<<"Case "<<cnt<<": "<<a<<endl;
		cnt++;
	}
	return 0;	
}


Measured memory_bytes: 3008
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut a:usize = read!();
    let mut v = HashMap::new();
    for i in 0..a {
        let y:usize = read!();
        let z: &usize = v.get(&y).unwrap_or(&0);
        if z!=&0 {
            println!("NO");
            exit(0);
        }
        v.insert(y,1);
    }
    println!("YES");
}

Measured memory_bytes: 8720
def main(n,lst):
    #dp[N][V]:N日目にVを選択する場合の幸福度の最大値
    dp = [[0]*3 for _ in range(n+1)]
    for i in range(n):
        #i+1日目にA
        a = lst[i][0]
        dp[i+1][0] = max(dp[i][1]+a, dp[i][2]+a)
        #i+1日目にB
        b = lst[i][1]
        dp[i+1][1] = max(dp[i][0]+b, dp[i][2]+b)
        #i+1日目にC
        c = lst[i][2]
        dp[i+1][2] = max(dp[i][0]+c, dp[i][1]+c)
    #dp[n]の最大値
    return max(dp[n])

n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]
print(main(n,lst))

Measured memory_bytes: 47368
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n, vector<pair<int,int>>& S) {
        vector<int> d(n, -1);

        for (auto& p : S) {
            int x = p.first;
            int v = p.second;
            if (d[x] != -1) {
                if (d[x] != v) {
                    return -1;
                }
            }
            d[x] = v;
        }

        if (d[0] == 0 && n > 1) {
            return -1;
        }
        if (d[0] == -1) {
            if (n == 1) {
                d[0] = 0;
            } else {
                d[0] = 1;
            }
        }

        for (int i = 1; i < n; ++i) {
            if (d[i] == -1) {
                d[i] = 0;
            }
        }

        int res = 0;
        for (int i = 0; i < n; ++i) {
            res = res * 10 + d[i];
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> S(m);
    for (int i = 0; i < m; ++i) {
        int s, d;
        cin >> s >> d;
        S[i] = make_pair(s - 1, d);
    }
    Solution sol;
    cout << sol.solve(n, S) << "\n";

    return 0;
}

Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))
M=L[::-1]
for i in range(N-1):
    if M[i]+1<M[i+1]:
        print('No')
        break
    elif M[i]+1==M[i+1]:
        M[i+1]=M[i]
else:print('Yes')

Measured memory_bytes: 20696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#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>
LL facctorialMethod(int k);
int main(){
    string s,s1,s2;
    LL s_len,count;
    cin >> s;
    s_len = s.size();
//    cout << s_len << endl;
    s1 = s.substr(0,s_len/2);
    s2 = s.substr(s_len-s_len/2,s_len/2);

//    s2 = reverse(s2.begin(), s2.end());
    reverse(s2.begin(), s2.end());

    count = 0;
    for(int i = 0; i < s_len/2; i++) {
//        cout << "s1.substr(i,1) :" << s1.substr(i,1) << endl;
        if(s1.substr(i,1) != s2.substr(i,1)) {
            count++;
        }
    }
    cout << count << endl;
    
    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3620
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>
#include <iomanip>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
ll A[200005] = {};
ll B[200005] = {};
ll C[200005] = {};
bool f, ff;
string S[200000];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}



ll minn, maxx;
double ansa;


int main() {

	cin >> N;
	b = 0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		b += a % 2;
	}

	if (b % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}



	return 0;

}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi p(n);
    vcin(p);
    sort(p);
    int sum=0;
    rp(i,n-1){
        sum += p[i];
    }
    cout << sum+p[n-1]/2 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var b = Console.ReadLine();

            if(b == "A")
            {
                Console.WriteLine("T");
            }
            else if (b == "T")
            {
                Console.WriteLine("A");
            }
            else if (b == "C")
            {
                Console.WriteLine("G");
            }
            else if (b == "G")
            {
                Console.WriteLine("C");
            }
        }
    }
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    ll n, q;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    map<ll, ll> mp;
    rep(i, n) {
        if (mp.count(a[i]) == 0) {
            mp[a[i]] = 1;
        } else {
            mp[a[i]] += 1;
        }
    }

    ll sum = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        sum += itr->first * itr->second;
    }

    cin >> q;

    vll s(q, 0);
    rep(i, q) {
        ll b, c;
        cin >> b >> c;

        if (mp.count(b) != 0) {
            sum = sum + (c - b) * mp[b];

            mp[c] += mp[b];
            mp[b] = 0;
        }

        s[i] = sum;
    }

    rep(i,q){
        cout << s[i] << endl;
    }
}

Measured memory_bytes: 10044
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

bool field[51][51];
int w, h, cnt;
int dx[] = { 1, 0, 0, -1, 1, -1, -1, 1}, dy[] = {0, 1, -1, 0, 1, 1, -1, -1};



void rec(int x, int y)
{
	if( x >= 0 && x < w && y >= 0 && y < h && field[y][x] == 1)
	{
		field[y][x] = 0;
	
		FOR(i, 0, 8)
			rec(x+dx[i], y+dy[i]);
	}
	return;
}



int main()
{
	while( cin >> w >> h, (w||h))
	{
		cnt = 0;
		
		FOR(j, 0, h)
			FOR(i, 0, w)
				cin >> field[j][i];
		
		FOR(j, 0, h)
			FOR(i, 0, w)
			{
				if( field[j][i] == 1)
					cnt++;
					rec(i, j);
			}
		
		
		cout << cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
int A;
int B;
cin>>A;
cin>>B;
if(A<=13 && B<=13 && A!=1 && B!=1){
  if(A>B){
    cout<<"Alice";
  }
 else if(B>A){
     cout<<"Bob";
  }
  else if(A==B){
     cout<<"Draw";
  }

}
else if(A<=13 && A!=1 && B==1){
 cout<<"Bob";

}
else if(B<=13 && B!=1 && A==1){
 cout<<"Alice";
}
else{
 cout<<"Draw";
}
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Apr  4 21:00:24 JST 2020
 **/

template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}

const Int INF = 1e9;
Int offset = 2000000;
signed main() {
    Int n, K, C;
    std::cin >> n >> K >> C;
    std::string s;
    std::cin >> s;

    std::vector<Int> l(n + 1, -INF), r(n + 1, -INF), ok(n + 10 + offset * 2);
    l[0] = r[n] = 0;
    REP(i, n) {
        l[i + 1] = l[i];
        if (s[i] == 'x') continue;
        if (i - C >= 0)
            chmax(l[i + 1], l[i - C] + 1);
        else
            chmax(l[i + 1], 1LL);
    }
    for (int i = n - 1; i >= 0; i--) {
        r[i] = r[i + 1];
        if (s[i] == 'x') continue;
        if (i + 1 + C <= n)
            chmax(r[i], r[i + 1 + C] + 1);
        else
            chmax(r[i], 1LL);
    }
    dump(l, r);

    if (C == 0) {
        REP(i, n) {
            if (l[i] + r[i + 1] < K) {
                std::cout << i + 1 << "\n";
            }
        }
        return 0;
    }
    REP(i, -1 - C, n) {
        Int x = i + 1 < 0 ? 0 : l[i + 1];
        Int y = i + C + 1 > n ? 0 : r[i + C + 1];
        dump(i, x, y);
        if (x + y >= K) {
            ok[i + 1 + offset]++;
            ok[i + C + 1 + offset]--;
        }
    }
    REP(i, ok.size() - 1) {
        if (1 <= i + 1 - offset && i + 1 - offset <= n && ok[i] == 0) {
            dump(i, ok[i]);
            std::cout << i + 1 - offset << "\n";
        }
        ok[i + 1] += ok[i];
    }
}


Measured memory_bytes: 37780
#include <bits/stdc++.h>
using namespace std;
# define LL long long


int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int h[n+1],con[n+1];
    for (int i=1;i<=n;i++) {
        scanf("%d",&h[i]);
        con[i]=1;
    }
    for (int i=0;i<m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        if (h[u]<h[v]) con[u]=0;
        else if (h[u]>h[v]) con[v]=0;
        else {
            con[u]=0;
            con[v]=0;
        }
    }
    int ans=0;
    for (int i=1;i<=n;i++){ 
        // cout<<con[i]<<" ";
        if (con[i]==1) ans+=1;
    }
    // cout<<"\n";
    printf("%d",ans);
    
    
}

Measured memory_bytes: 4520
#include "atcoder/dsu"
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,q;
    cin >> n >> q;
    atcoder::dsu uf(n);
    while(q--){
        ll t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            uf.merge(u,v);
        }else{
            if(uf.same(u,v)){
                print(1);
            }else{
                print(0);
            }
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3852
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
#[fastout]
fn main() {
    input!(m: usize, b: [usize; m]);
    let mut ans = vec![0usize; m + 1];

    for (i, v) in b.iter().enumerate().rev() {
        let mut a = 0;

        for j in 2..m + 1 {
            if (i + 1) * j > m {
                break;
            }
            a += ans[(i + 1) * j];
        }

        if a % 2 != *v {
            ans[(i + 1)] = 1;
        }
    }
    let aaans: Vec<usize> = ans
        .iter()
        .enumerate()
        .filter(|x| *x.1 == 1)
        .map(|(x, _v)| x)
        .collect();
    if aaans.len() == 0 {
        println!("0");
    } else {
        println!("{}", aaans.len());
        for i in aaans {
            print!("{} ", i);
        }
    }
}


Measured memory_bytes: 6444
void main()
{
    long n, t;
    rdVals(n, t);
    long[] a = rdRow;

    long[] amax = new long[n+1];
    foreach_reverse (i, x; a)
    {
        amax[i] = max(amax[i+1], x);
    }

    long key, cnt;
    foreach (i, x; a)
    {
        long diff = max(0, amax[i]-x);
        if (key < diff)
        {
            key = diff;
            cnt = 1;
        }
        else if (key == diff) ++cnt;
    }

    cnt.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 7080
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
ll dp[101][1005];
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, t;
	cin >> n >> t;
	int a[n];
	rep(i, n) cin >> a[i];
	map<int, int> m;
	int M = a[n - 1];
	for (int i = n - 1; i >= 0; i--) {
		m[M - a[i]]++;
		M = max(M, a[i]);
	}
	cout << m.rbegin()->second << endl;
	return 0;
}

Measured memory_bytes: 5376
/*
    ( ´-ω･)︻┻┳══━一一一一一一一				(× _ ×)
	
	Stay Low. Go Fast
	Kill First. Die Last
	One Shot. One Kill
	No Luck. Pure Skill 
*/

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

/*************************** MACROS **************************/
#define ld long double
#define ll long long  
#define ull unsigned long long
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x;i>=y;i--)
#define vll vector<ll>
#define pb push_back
#define S second
#define F first
#define B begin()
#define E end()
#define W(x) while(x--)
#define pll pair< ll,ll >
#define vpll vector< pll >
#define qll queue<ll>
#define dqll deque<ll>
#define qpll queue<pll>
#define dqpll deque<pll>
#define pqll priority_queue<ll>
#define pqpll priority_queue<pll>
#define Line cout<<"\n**************************\n\n";

/*************************** CONST ******************************/

const ll MOD = 1000000007;
const ll MOD1 = 998244353;
const ll MIN_LL = -1e18;
const ll MAX_LL = 1e18;
const int MAX_INT = 1e9;
const int MIN_INT = -1e9;
const ld pie = 3.1415926535;
 
/************************** POW UTIL *****************************/
 
ll fpow(ll n,ll p){;ll m=1;while(p){if(p%2)m*=n;p>>=1;n*=n;}return m;}
ll mfpow(ll n,ll p,ll M){ll m=1;n%=M;while(p){if(p%2)m=(m*n)%M;n=(n*n)%M;p>>=1;}return m%M;}
 
/************************* PRINT UTIL *****************************/

template<class T> inline ostream& operator<<(ostream& o,vector<T> v){for(auto i:v)o<<i<<" ";return o;};
template<class T> inline ostream& operator<<(ostream& o,set<T> s){for(auto i:s)o<<i<<" ";return o;}
template<class T> inline ostream& operator<<(ostream& o,multiset<T> s){for(auto i:s)cout<<i<<" ";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,pair<T1,T2> p){o<<p.F<<" "<<p.S<<"\n";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,map<T1,T2> m){for(auto p:m)o<<p.F<<" "<<p.S<<"\n";return o;}

/*************************** VARIABLES **************************/

const vll days={31,28,31,30,31,30,31,31,30,31,30,31};
 
bool br,br1,br2; 
char ch,ch1,ch2;
 

ll n,m,k,x,y,z,mini,maxi,l,r,sum,t,w;
pll p,p1,p2;

string s,s1,s2;

set<ll> st,st1,st2;
multiset<ll> mst; 

map<ll,ll> mp;

/**************************** FXNS ****************************/

bool vis[(int)1e6+100];

void solve()
{

	cin>>n;

	ll a[n];

	loop(i,0,n)cin>>x,mp[x]++;

	x = 0;

	for(auto i:mp){

		if(!vis[i.F])
		{
			if(i.S == 1)
			{
				// cout<<"@ "<<i.F<<endl;
				x++;
			}
			for(ll j=i.F;j<1e6+100;j+=i.F)vis[j] = true;
		}
	
	}
		

	cout<<x<<endl;

}
 
/*************************** MAIN ****************************/
 
int main(){
 
 
	// #ifndef ONLINE_JUDGE
	        // freopen("input.txt", "rt", stdin);
	        // freopen("output.txt", "wt", stdout);
	// #endif
 
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);

	solve();
 
	return 0;
}


Measured memory_bytes: 17052
h,w,k = map(int,input().split())
S = [list(input()) for _ in range(h)]

res = float('inf')
for div in range(2**(h-1)):
    cut = []
    for i in range(h-1):
        if ((div >> i) & 1):
            cut.append(i+1)
    fr = 0
    part = []
    for i in range(len(cut)):
        to = cut[i]
        part.append(S[fr:to])
        fr = to
    else:
        part.append(S[fr:])
    comp_arr = []

    for p in part:
        tmp = [0]*(w)
        for p_ in p:
            for idx in range(len(p_)):
                if p_[idx]=='1':
                    tmp[idx] += 1
        comp_arr.append(tmp)
    
    if not all([all([i <= k for i in b]) for b in comp_arr]):
        continue
    
    cnt = len(cut)
    tank = [0]*len(comp_arr)
    for m in range(w):
        for n in range(len(comp_arr)):
            tank[n] += comp_arr[n][m]
        if any([c>k for c in tank]):
            cnt += 1
            for n in range(len(comp_arr)):
                tank[n] = comp_arr[n][m]
    res = min(res, cnt)
print(res)

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

int main()
{
  int n,w;
  cin>>n;
  cin>>w;
  if(n==0){
  cout<<"0"<<endl;
  return 0;
  }
  vector<vector<unsigned long long>> v(n+1,vector<unsigned long long>(w+1));
  vector<unsigned long long> wt(n);
  vector<unsigned long long> val(n);
  for(int i=0;i<n;i++)
  cin>>wt[i]>>val[i];

  //dp[1]=abs(v[1]-v[0]);
  for(int i=1;i<=n;i++)
  {
      for(int j=1;j<=w;j++)
      {
        if(wt[i-1]<=j)
        v[i][j]=max({v[i-1][j],v[i][j],v[i-1][j-wt[i-1]]+val[i-1]});
        else
        v[i][j]=max(v[i][j],v[i-1][j]);
      }
  }
  cout<<v[n][w]<<endl;
  return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long
typedef pair<int, int>P;
int f[105][12],p[105][12];
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 10; j++)cin >> f[i][j];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 11; j++)cin >> p[i][j];
	int res = -1145141919ll;

	for (int i = 1; i < 1024; i++) {
		vector<int>V;
		for (int j = 0; j < 10; j++) {
			if (i&(1 << j))V.push_back(j);
		}
		
		int ans = 0;
		for (int j = 0; j < n; j++) {
			int c = 0;
			for (int k = 0; k < V.size(); k++) {
				if (f[j][V[k]])c++;
			}
			ans += p[j][c];
		//	cout << i << ' ' << j << ' ' << c << endl;
		}
		res = max(res, ans);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int n, m;
int f[N] ;
int find(int x) {
    return f[x] == x ? f[x] : f[x] = find(f[x]) ;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) f[i] = i;
    for(int i = 1; i <= m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        int fx = find(x), fy = find(y) ;
        if(fx != fy) f[fx] = fy;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) ans += f[i] == i;
    cout << ans ;
    return 0;
}


Measured memory_bytes: 640
n = int(input())
cards = list()
marks = ['S', 'H', 'C', 'D']
for i in range(n):
    a, b = input().split()
    b = int(b)
    if a == 'S':
        cards.append(b)
    elif a == 'H':
        cards.append(b + 13)
    elif a == 'C':
        cards.append(b + 26)
    elif a == 'D':
        cards.append(b + 39)
for i in range(1, 53):
    if not (i in cards):
        print(marks[(i-1)//13], (i-1) % 13 + 1)
        


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;
template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, T;
    cin >> N >> T;
    vec A(N+1);
    A[0] = inf;

    Rep (i, N) {
        cin >> A[i+1];
    }

    ll tmp = inf;
    vec profit(N);
    Rep (i, N) {
        profit[i] = A[i+1] - tmp;
        chmin(tmp, A[i+1]);
    }

    map<ll, ll> check;
    Rep (i, N) {
        check[profit[i]]++;
    }

    auto itr = check.end();
    itr--;

    cout << (*itr).second << "\n";

}

Measured memory_bytes: 8064