akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m, x;
	cin >> n >> m >> x;
	vi v(n + 1);
	REP(i, m)
	{
		int a; cin >> a;
		v[a]++;
	}
	int ans = 0;
	REP(i, x) ans += v[i];
	cout << min(ans, m - ans) << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<bool> visited(n+1, false);
	f(i, 0, k)
	{
		ll s;
		cin >> s;
		f(j, 0, s)
		{
			ll temp;
			cin >> temp;
			visited[temp] = true;
		}
	}
	ll ans = 0;
	f(i, 1, n + 1)
	{
		if (visited[i] == false)
			ans += 1;
	}
	cout << ans;
	return 0;
}


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

int main()
{
    int x, a;
    cin >> x >> a;
    if (x < a)
        cout << 0 << endl;
    else
        cout << 10 << endl;
    return 0;
}

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

// 数字の各桁の和を返す
int sumDigits (int n) {
    int s;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

// 最大公約数を返す
int gcd (int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main () {
    string S; cin >> S;
    S.erase(unique(S.begin(), S.end()), S.end());

    cout << S.size()-1 << endl;
}

Measured memory_bytes: 512
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)

N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  G[a].append([b,i])

ans=[None]*(N-1)
def dfs(now,color):
  cnt=1
  for to,j in G[now]:
    if cnt==color:
      cnt+=1
    ans[j]=cnt
    dfs(to,cnt)
    cnt+=1

dfs(0,0)
print(max(ans))
print(*ans, sep="\n")

Measured memory_bytes: 71032
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

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

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func init() {
	// read one word/char/int separated by space(s).
	sc.Split(bufio.ScanWords)

	// read one line.
	// sc.Split(bufio.ScanLines)
}

func main() {
	N := nextInt()
	M := nextInt()
	h := make(heap, 0, 100)
	m := map[int][]int{}
	for i := 0; i < N; i++ {
		A := nextInt()
		B := nextInt()
		m[A] = append(m[A], B)
	}
	ans := int64(0)
	for i := 1; i <= M; i ++ {
		if len(m[i]) > 0 {
			for _, v := range m[i] {
				h.enqueue(v)
			}
		}
		if len(h) > 0 {
			ans += int64(h.dequeue())
		}
	}
	fmt.Printf("%d", ans)
}

type heap []int

func(h *heap) enqueue(n int) {
	*h = append(*h, n)
	h.up(len(*h)-1)
}

func(h *heap) up(cur int) {
	if cur == 0 {
		return
	}
	parent := (cur-1)/2
	if (*h)[parent] < (*h)[cur] {
		(*h)[parent], (*h)[cur] = (*h)[cur], (*h)[parent]
		h.up(parent)
	}
	return
}

func(h *heap) dequeue() int {
	val := (*h)[0]
	(*h)[0] = (*h)[len(*h)-1]
	*h = (*h)[:len(*h)-1]
	h.down(0)
	return val
}

func(h *heap) down(cur int) {
	left := cur*2 + 1
	right := (cur+1) * 2
	if left >= len(*h) {
		return
	}
	if right < len(*h) {
		if (*h)[left] >= (*h)[right] && (*h)[left] > (*h)[cur] {
			(*h)[left], (*h)[cur] = (*h)[cur], (*h)[left]
			h.down(left)
			return
		}
		if (*h)[left] < (*h)[right] && (*h)[right] > (*h)[cur] {
			(*h)[right], (*h)[cur] = (*h)[cur], (*h)[right]
			h.down(right)
			return
		}
	}
	if (*h)[left] > (*h)[cur] {
		(*h)[left], (*h)[cur] = (*h)[cur], (*h)[left]
	}
	return
}

Measured memory_bytes: 11264
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int D,N;
  cin>>D>>N;
  if(N==100) N++;
  ll ans=1;
  for(int i=0;i<D;i++){
    ans*=100;
  }
  cout<<ans*N<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string s;
  cin >> s;
  
  int a = 0;
  for(int i = 0; i< s.size(); i++){
   if(s.at(i) == '1'){
     a++;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] a = scn.nextLine().toCharArray();
		char[] b = scn.nextLine().toCharArray();
		boolean ans = true;
		for(int i = 0;i < 3;i++) {
			ans &= a[i]==b[2-i];
		}
		System.out.println(ans?"YES":"NO");
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin>>n;
	cout<<10-(n/=200)<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
    char s[1200];
    char t[1200];
    int min=10000,i,j,count=0;
    
    scanf("%s",s);
    scanf("%s",t);
    
    int slen = strlen(s);
    int tlen = strlen(t);
    
    for(i = 0; i < slen-tlen+1; i++){
        for(j = 0; j < tlen; j++){
            if(s[i+j] != t[j]){
                count++;
                // printf("%c %c diff\n",s[i],t[j]);
            }
        }
        if(count < min) min = count;
        // printf("%d\n",count);
        count = 0;
    }
    
    printf("%d\n",min);
}


Measured memory_bytes: 1732
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    lli x;
    cin >> x;
    lli a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a, a + N);
    lli sum[N + 1];
    fill(sum, sum + N + 1, 0);
    int cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        sum[i] = sum[i - 1] + a[i - 1];
    }
    for (int i = 0; i <= N; i++)
    {
        if (sum[i] > x)
        {
            cout << i - 1 << endl;
            return 0;
        }
        else if (sum[i] == x)
        {
            cout << i << endl;
            return 0;
        }
        else if (i == N)
        {
            cout << N - 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3596
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<Integer, Integer> map = new HashMap<Integer, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<Integer> cc = new ArrayList<>(N);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	static int INF=1000000007;
	

	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		//int v[]=new int[];for(int i=0;i<;i++)v[i]=sc.nextInt();
		//int a[]=new int[N];for(int i=0;i<N;i++) {a[i]=sc.nextInt();}
		//String S=sc.next();
	
		StringBuffer s = new StringBuffer(sc.next());
		int a=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='?') {
				s.setCharAt(i, 'D');
			}
		}
		p(s.toString());
		
		
		
	}
	static long bi(int i) {
		long t=1;
		for(int a=1;a<=i;a++) {
			t*=a;
			t%=mod;
		}
		return t;
	}
	public static long modPow(long g,long N) {
		long T=1;
		for(int i=0;i<N;i++) {
			T*=g;
			T%=mod;
		}
		return T;
	}
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 40984
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

struct pq1{
    bool operator()(const pair<int,int> &p1,const pair<int,int> &p2) {
        return p1.second > p2.second;
    }
};

struct pq2{
    bool operator()(const pair<int,int> &p1,const pair<int,int> &p2) {
        if (p1.first == p2.first) {
            return p1.second < p2.second;
        } else {
            return p1.first < p2.first;
        }
    }
};

int main(void)
{
    IOS
    int n,m;
    cin >> n >> m;
    priority_queue<pair<int,int>,vector<pair<int,int>>,pq1> v1;
    priority_queue<pair<int,int>,vector<pair<int,int>>,pq2> v2;
    REP(i,n) {
        int a,b;
        cin >> a >> b;
        v1.push(make_pair(b,a));
    }

    int ans = 0;
    FOR(i,1,m+1) {
        while(!v1.empty() && v1.top().second <= i) {
            v2.push(v1.top());
            v1.pop();
        }
        if (!v2.empty()) {
            ans += v2.top().first;
            v2.pop();
        }

    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 2548
#include<iostream>
using namespace std;
int main (void){

    int a, b, c, aa, bb ,cc;

    cin >> a >> b;

    aa = a + b;

    bb = a - b;

    cc = a * b;

    if(aa < bb)
        c = bb;
    else 
        c = aa;

    if(c < cc)
        c = cc;
       
        
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; string S; cin >> N >> M >> S;
    vector<vector<int>> G(N);
    rep(i,M){
        int a,b; cin >> a >> b; --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<vector<int>> cnt(N,vector<int>(2,0));
    queue<int> que;
    set<int> erased;
    rep(v,N){
        for (auto nv:G[v]){
            if (S[nv]=='A') ++cnt[v][0];
            else ++cnt[v][1];
        }
        if (!cnt[v][0]||!cnt[v][1]) que.push(v),erased.insert(v);
    }
    while(!que.empty()){
        int v=que.front(); que.pop();
        int i=S[v]=='A'?0:1;
        for (auto nv:G[v]){
            if (erased.count(nv)) continue;
            --cnt[nv][i];
            if (cnt[nv][i]==0) que.push(nv),erased.insert(nv);
        }
    }
    if (erased.size()==N) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 29520
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
int n;
int a[maxn], l[maxn], r[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

void solve() {
  vector<int> st;
  for (int i = 0; i < n; i++) {
    while (!st.empty() && a[st.back()] > a[i]) {
      st.pop_back();
    }
    l[i] = (st.empty()? 0 : st.back() + 1);
    st.push_back(i);
  }
  st.clear();
  for (int i = n - 1; i >= 0; i--) {
    while (!st.empty() && a[st.back()] > a[i]) {
      st.pop_back();
    }
    r[i] = (st.empty()? n : st.back());
    st.push_back(i);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (long long)(i - l[i] + 1) * (r[i] - i) * a[i];
  }
  printf("%lld\n", ans);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> AA(N, -1);
  REP(i, N){
    int a; cin >> a;
    auto itr = lower_bound(AA.begin(), AA.end(), a);
    itr--;
    *itr = a;
  }
  int ans = AA.end() - upper_bound(AA.begin(), AA.end(), -1);
  cout << ans << endl;
}

Measured memory_bytes: 640
/*input
1
11 26
26 24 26 17 13 10 2 3 8 21 20

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 100001

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(ll a, ll b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(ll a, ll b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(ll a, ll b) {return (a * 1ll * b) % mod;}
inline int pwr(ll x, ll y) {
    int ans = 1 % mod;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        x = mul(x, x);
        y >>= 1;
    }
    return ans;
}
inline int inv(int a) {return pwr(a, mod - 2);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, m;
    cin >> n >> m;
    ll a, b;
    vector <PLL> vec;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        vec.pb({a, b});
    }
    sort(all(vec));
    ll ans = 0;
    int ind = 0;
    while (m) {
        ans += min(m, vec[ind++].second) * vec[ind - 1].first;
        m -= min(m, vec[ind - 1].second);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
# dpD - Knapsack 1
import sys
input = sys.stdin.readline

def main():
    n, w = tuple(map(int, input().rstrip().split()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    dp = [[0] * (w + 1) for i in range(n)]
    for i in range(n):
        for j in range(w + 1):
            if j < A[i][0]:
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - A[i][0]] + A[i][1])
    print(max(dp[-1]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 118256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 1000;
int N, K;
ll a[MAX_N+1];
ll sum[MAX_N+1];
bool used[MAX_N*(MAX_N+1)/2];

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

  cin >> N >> K;
  for (int i = 1; i <= N; ++i) cin >> a[i];

  for (int i = 1; i <= N; ++i) sum[i] = sum[i-1] + a[i];

  vector<ll> vec;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < i; ++j) {
      vec.push_back(sum[i]-sum[j]);
    }
  }

  sort(all(vec));
  reverse(all(vec));

  ll ma = vec[0], ans = 0;
  int bitsize = 0;
  while ((1ll<<bitsize) <= ma) ++bitsize;
  memset(used, true, sizeof(used));

  for (int i = bitsize-1; i >= 0; --i) {
    int k = 0;
    vector<int> unused;
    for (int j = 0; j < vec.size(); ++j) {
      if (used[j] && (vec[j]>>i) & 1) {
        ++k;
      } else {
        if (used[j]) unused.push_back(j);
      }
    }

    if (K <= k) {
      ans += (1ll<<i);
      for (int j = 0; j < unused.size(); ++j) used[unused[j]] = false;
    }

  }


  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 8940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005


void solve()
{
    ll h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
      int x;
      int i;
      for(i=1;;i++)
      {
            scanf("%d",&x);
            if(x==0)
            {
                  break;
            }
            printf("Case %d: %d\n",i,x);
      }
      return 0;
}

Measured memory_bytes: 1028
#include <cstdio>
#include <queue>
using namespace std;

struct Process {
    char name[10];
    int t;
};

void simulate(queue<Process> &que, int q) {
    int elaps = 0;
    while (!que.empty()) {
        if (que.front().t <= q) {
            elaps += que.front().t;
            printf("%s %d\n", que.front().name, elaps);
            que.pop();           
        } else {
            elaps += q;
            que.front().t -= q;
            que.push(que.front());
            que.pop();
        }
    }
}

int main() {
    int n, q;
    scanf("%d %d", &n, &q);

    queue<Process> que;
    Process p;
    for (int i = 0; i < n; i++) {
        scanf("%s %d", p.name, &p.t);
        que.push(p);
    }
    
    simulate(que, q);
    return 0;
}


Measured memory_bytes: 3244
#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;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; 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);}
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 N,K; cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    sort(ALL(A));
    cout << accumulate(A.begin(),A.begin()+K,0) << endl;
     
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 2001
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int INF = 1e9;
#define B 100
ll solve1(int, int);

ll n, a[MAX], dp[MAX][MAX];
int con(int k){
	if(k > n)k = 1;
	if(k == 0)k = n;
	return k;
}

ll solve2(int l, int r){
	l = con(l);r = con(r);
	if(l == r)return 0;
	if(a[l] < a[r]){
		r = con(r-1);
	}else if(a[r] < a[l]){
		l = con(l+1);
	}
	return solve1(l, r);
}

ll solve1(int l, int r){
	l = con(l);r = con(r);
	if(l == r)return a[l];
	if(dp[l][r] != 0)return dp[l][r];
	ll vr = solve2(l, r-1);
	ll vl = solve2(l+1, r);
	ll v = max(vl+a[l], vr+a[r]);
	dp[l][r] = max(dp[l][r], v);
	return dp[l][r];
}

int main(){
	ll ans = 0;
	scanf("%d", &n);
	rrep(i,n)scanf("%d", &a[i]);
	for(int i = 1;i <= n;i++){
		ans = max(ans, solve1(i+1, i));
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int N,K ;
  string S;
  cin >>N>>K>>S ;
  if(S.at(K-1) == 'A'){
    S.at(K-1) = 'a'; 
  }
  if(S.at(K-1)=='B'){
    S.at(K-1)='b';
  }
   if(S.at(K-1)=='C'){
    S.at(K-1)='c';
  }
  cout << S<< endl;
}

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

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

}

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

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

	cout << bitset<32>(n) << endl;
	cout << bitset<32>(~n) << endl;
	cout << bitset<32>(n<<1) << endl;
	cout << bitset<32>(n>>1) << endl;


	return 0;
}



Measured memory_bytes: 3144
n = int(input())
b = list(map(int, input().split()))

a = [0 for i in range(n)]

a[0] = b[0]
for i in range(1,n):
    if i!=len(b):
        a[i] = min(b[i-1],b[i])
    else:
        a[i] = b[i-1]
print(sum(a))

Measured memory_bytes: 3060
#include <iostream>
    #include <array>
    #include <algorithm>
     
    using namespace std;
     
    using ll = long long int;
     
    const ll INF = 0x3FFFFFFFFFFFFFFFLL;
     
    ll cost[2000][2000];
     
    int main(){
        
        ll N, M;
        cin >> N >> M;
        for(ll i = 0; i < N; ++i){
            for(ll j = 0; j < i; ++j){
                cost[i][j] = INF;
            }
            cost[i][i] = 0;
            for(ll j = i + 1; j < N; ++j){
                cost[i][j] = INF;
            }
        }
        for(ll i = 0; i < M; ++i){
            ll A, B, C;
            cin >> A >> B >> C;
            cost[A - 1][B - 1] = -C;
        }
        for(ll k = 0; k < N; ++k){
            for(ll i = 0; i < N; ++i){
                for(ll j = 0; j < N; ++j){
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                }
            }
        }
        for(ll i = 0; i < N; ++i){
            if(cost[0][i] < INF / 2 && cost[i][N - 1] < INF / 2 && cost[i][i] < 0){
                cout  << "inf" << endl;
                return 0;
            }
        }
        cout << -cost[0][N - 1] << endl;
        return 0;
    }

Measured memory_bytes: 16256
#include<stdio.h>

main(){
	int w, h;
	int x, y, r;

	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	if(((x - r) >= 0 && (x + r) <= w) && ((y - r) >= 0 && (y + r) <= h)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}



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

using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
    }

    bool same (int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size (int x) {
        return -par[root(x)];
    }
};

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

    UnionFind uf(n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}

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

typedef long long ll;

int main(){
    int n, l;
    cin >> n >> l;
    vector<pair<int,int>> vp;
    for(int i = 0; i < n; i++){
        int p, d;
        cin >> p >> d;
        vp.push_back({p, d});
    }
    sort(vp.begin(), vp.end());
    vector<ll> dpl(n), dpr(n);
    for(int i = 0; i < n; i++){
        dpl[i] = (i==0 ? 0 : dpl[i-1]) + (vp[i].second==0 ? 1 : -1)*(vp[i].first-i-1);
    }
    for(int i = n-1; i >= 0; i--){
        dpr[i] = (i==n-1 ? 0 : dpr[i+1]) + (vp[i].second==1 ? 1 : -1)*(l-(n-1-i)-vp[i].first);
    }
    ll ans = max(dpl.back(), dpr[0]);
    for(int i = 0; i+1 < n; i++){
        ans = max(ans, dpl[i]+dpr[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5396
#include <bits/stdc++.h> 
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef long long ll;
#define MOD 1000000007;

int main() 
{ 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
    	if(s[i]!=t[i]){
    		ans++;
    	}
    }
    cout << ans << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t a;
    cin >> a;
    string s;
    cin >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

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

using namespace std;

typedef long long int lli;

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

  vector< vector<lli> > abcs(n, vector<lli>(3, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> abcs[i][j];
    }
  }

  vector< vector<lli> > memo(n, vector<lli>(3, 0));
  memo[0][0] = abcs[0][0];
  memo[0][1] = abcs[0][1];
  memo[0][2] = abcs[0][2];

  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      vector<lli> tmp;
      for (int k = -1; k <= 1; k+=2) {
        int prevAction = (j + 3 + k) % 3;
        tmp.push_back(memo[i-1][prevAction]);
      }
      memo[i][j] = *max_element(tmp.begin(), tmp.end()) + abcs[i][j];
    }
  }

  cout << *max_element(memo[n-1].begin(), memo[n-1].end()) << endl;
  return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
using namespace std;
const char nc[20] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'};
string ans;
int main()
{
	int m, n, k, t, s;
cin >> m;
if(m==0)
printf("0\n");
	ans = "";
	s = m;
	while(m != 0){
	k = m % (-2);
	t = m / (-2);
	if(k < 0){
	k -= (-2);
	t++;
	}
	m = t;
	ans.push_back(nc[k]);
}
	for(int i = ans.length() - 1; i >= 0; i--){
	cout << ans[i];
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	string S;
  	cin >> S;
  	bool tap = true;
	for(int i = 0; i < S.size(); i++){
    	if(i%2){
        	if((S[i] == 'L' || S[i] == 'U' || S[i] == 'D') && tap == true)
              tap = true;
          	else {
              tap = false;
              break;
            }
        } else {
        	if((S[i] == 'R' || S[i] == 'U' || S[i] == 'D') && tap == true)
              tap = true;
          	else {
              tap = false; 
              break;
            }
        }
    }
  	if(tap == true) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    long long n,k;
    cin>>n>>k;
    long long ans=0;
    ans=(n*3+k)/2;
    cout<<ans<<endl;
    

}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto s = readln.chomp.to!(wchar[]);
    auto K = readln.chomp.to!int;

    wchar[][] ss;
    foreach (int i; 0..s.length.to!int) {
        foreach (j; 1..6) {
            j = min(i + j, s.length);
            ss ~= s[i..j];
        }
    }
    ss = ss.sort.uniq.array;
    writeln(ss[K-1]);
}

Measured memory_bytes: 1144
import math

def is_prime(n):
    if n == 1:
        return False

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

    # 素数判定を5で割ったら1余るものだけ返すように変更
    if n % 5 == 1:
        return True
    else:
        return False

def main():
    N = int(input())
    num_list = []
    for i in range(1, 55556):
        if is_prime(i):
            num_list.append(i)
            if len(num_list) == N:
                print(*num_list)
                exit()

main()

Measured memory_bytes: 40048
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using tiii = tuple<int, int, int>;
const int MAX_D = 100000000;
string mass[50];


int h, w;
int dis[50][50];
void dfs()
{
    rep(i, 0, h)
    rep(j, 0, w)
        dis[i][j] = (mass[i][j] == '.')? MAX_D : -1;

    queue<tiii> que;
    que.push(make_tuple(0, 0, 0));
    while (que.size() > 0)
    {
        int x, y, d;
        tie(x, y, d) = que.front();
        que.pop();
        // cout << x << ' ' << y << ' ' << d << ' ' << (w) << endl;

        if (x < 0 or x >= h or y < 0 or y >= w) continue;
        if (dis[x][y] == -1 or dis[x][y] <= d) continue;

        dis[x][y] = d;
        que.push(make_tuple(x - 1, y, d + 1));
        que.push(make_tuple(x, y - 1, d + 1));
        que.push(make_tuple(x, y + 1, d + 1));
        que.push(make_tuple(x + 1, y, d + 1));
    }
}

int main()
{
    cin >> h >> w;
    rep(i, 0, h)
        cin >> mass[i];
    
    dfs();

    if (dis[h - 1][w - 1] == MAX_D)
        cout << - 1 << endl;
    else
    {
        int ans = 0;
        rep(x, 0, h)
        rep(y, 0, w)
            ans += int(mass[x][y] == '.');
        ans -= dis[h - 1][w - 1] + 1;
        // cout << dis[h - 1][w - 1] << endl;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,hour,min,sec;
    cin >>a;
    hour = a / 3600;
    min= a / 60 - hour*60;
    sec= a -(hour*60+min)*60 ;
    cout << hour << ":" << min <<":" << sec << endl;
}



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

int c[100001];
int sc[100001];
int f(int n) {
    if (n == 1)
        return 0;
    for (int i = 2; i*i <= n; i++)
        if (n % i == 0)
            return 0;
    return 1;
}

int main() {

    int q;
    scanf("%d", &q);
    
    c[1] = 0;
    sc[1] = 0;
    
    for (int i = 2; i <= 100001; i++) {
        if (f(i) && f((i+1)/2))
            c[i] = 1;
    }
    
    for (int i = 2; i <= 100001; i++) {
        sc[i] = sc[i-1]+c[i];
    }
    
    for (int i = 0; i < q; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        printf("%d\n", sc[b] - sc[a-1]);
    }
    
}


Measured memory_bytes: 1408
#include<stdio.h>

int main()
{
	long long A,B,C,D;
	scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
	if(A*B >= C*D)
		printf("%lld\n",A*B);
	else
		printf("%lld\n",C*D);
	
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
	int H[300],W[300],Count=0,i,hi,wi;
	
	while(1){
		scanf("%d %d",&H[Count],&W[Count]);
		if(H[Count]==0&&W[Count]==0){
			break;
		}
		Count++;
	}
	for(i=0;i<Count;i++){
		for(hi=0;hi<H[i];hi++){
			if(hi%2==0){
				for(wi=0;wi<W[i];wi++){
					if(wi%2==0)printf("#");
					if(wi%2==1)printf(".");
				}
			}
			if(hi%2==1){
				for(wi=0;wi<W[i];wi++){
					if(wi%2==1)printf("#");
					if(wi%2==0)printf(".");
				}
			}
			
			printf("\n");
		}
		printf("\n");
	}
  return 0;
}

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

//Prison
int main(){
	int n,m;
	cin >> n >> m;
	int min_card=0,max_card=n+1;
	for(int i = 1; i <= m;i++){
		int l_i,r_i;
		cin >> l_i >> r_i;
		if(min_card < l_i) min_card = l_i;
		if(max_card > r_i) max_card = r_i;
	}
	int card_num = max_card - min_card + 1;
	if(card_num < 0) card_num = 0;
	cout << card_num << endl;

	return 0;
}


Measured memory_bytes: 256
/* Coached by Dukkha */
#include <stdio.h>

#define N 100000

int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a < b ? a : b; }

int main() {
	static int aa[N];
	int n, t, i, a, d, k;

	scanf("%d%d", &n, &t);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	a = aa[0];
	d = 0;
	for (i = 1; i < n; i++) {
		d = max(d, aa[i] - a);
		a = min(a, aa[i]);
	}
	a = aa[0];
	k = 0;
	for (i = 1; i < n; i++) {
		if (aa[i] - a == d)
			k++;
		a = min(a, aa[i]);
	}
	printf("%d\n", k);
	return 0;
}


Measured memory_bytes: 512
require 'prime'

N = gets.to_i
MOD = 10 ** 9 + 7

P = Hash.new{|h, k| h[k] = 0}
(1..N).each{|n|
  Prime.prime_division(n).each{|k, v|
    P[k] += v
  }
}
ans = 1
P.each{|k, v|
  ans = (ans * (v+1)) % MOD
}

puts ans % MOD


Measured memory_bytes: 2300
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  int q=n/15,r=n%15;
  li s=0;
  rep(i,q){
    s+=60+120*i;
  }
  if(df)print(q,r);
  rep(i,r+1){
    if(i%3==0 or i%5==0) continue;
    s+=i+15*q;
  }
  print(s);
}


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

using namespace std;
typedef long long ll;

int n, m;
int cw[10010], ce[10010];
string s[110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s[i];
  }
  for (int j = 0; j < n; j++) {
    int cntw = 0, cnte = 0;
    for (int i = 0; i < m; i++) {
      cntw += s[i][j] == 'W';
      cnte += s[i][j] == 'E';
    }
    cw[j + 1] = cntw;
    ce[j + 1] = cnte;
  }
  for (int j = n + 1; j > 0; j--) {
    cw[j - 1] += cw[j];
  }
  for (int j = 0; j < n + 1; j++) {
    ce[j + 1] += ce[j];
  }

  int d = 1 << 30, ans = -1;
  for (int i = 0; i <= n; i++) {
    int nd = cw[i + 1] + ce[i];
    if (nd < d) {
      ans = i;
      d = nd;
    }
  }
  cout << ans << " " << ans + 1 << endl;

  return 0;
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int par[100001], rnk[100001];

int fnd(int a) {
    if (par[a] == a) {
        return a;
    }

    par[a] = fnd(par[a]);
    return par[a];
}

void un(int a, int b) {
    if (fnd(a) == fnd(b)) {
        return;
    }

    par[fnd(a)] = fnd(b);
}



int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    memset(rnk, 0, sizeof rnk);
    for (int i = 1; i <= n; i++) {
        par[i] = i;
    }

    unordered_set<int> just;
    int x, y, z;
    while (m--) {
        cin >> x >> y >> z;
        un(x, y);
    }

    for (int i = 1; i <= n; i++) {
        just.insert(fnd(i));
    }

    cout << just.size();


}


Measured memory_bytes: 5156
n = int(input())
s = []
for _ in range(n):
    tmp_s = sorted(input())
    s.append("".join(tmp_s))

s.sort(key=len)
ans = ''

for i in range(len(s[0])):
    count = 0
    for j in range(len(s) - 1):
        if s[0][i] in s[j+1]:
            s[j+1] = s[j+1].replace(s[0][i], "", 1)
            count += 1

    if count == len(s) - 1:
        ans += s[0][i]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int a,b,count=0,five,four,three,two,one;
    cin>>a>>b;
    for (int i=a;i<=b;i++) {
        five=i/10000;
        four=(i-10000*five)/1000;
        three=(i-10000*five-1000*four)/100;
        two=(i-10000*five-1000*four-100*three)/10;
        one=(i-10000*five-1000*four-100*three-10*two);
        if (five==one&&four==two) {
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define dup(x) x.erase(unique(x.begin(), x.end()),x.end())
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

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

    bool isNone[200];
    memset(isNone, 0, sizeof(isNone));
    ll ans = 0;
    ll mn = 1e9+7;
    ll x,n;
    cin >> x >> n;
    vector<ll> v(n);
    for(int i = 0;i<n;i++){\
        cin >> v[i];
        isNone[v[i]] = true;
    }
    if(n == 0) ans = x;
    else{
        for(int i = 0;i<=101;i++){
            if(abs(x-i) < mn && !isNone[i]){
                mn = abs(x-i);
                ans = i;
            }
        }
    }
    cout << ans;

	return 0;
} 

Measured memory_bytes: 3644
S=200002
N,C=gets.split.map &:to_i
H=Hash.new{|h,k|h[k]=[]}
N.times{
	s,t,c=gets.split.map &:to_i
	H[c]<<[s,t]
}
A=[0]*S
H.each{|k,v|
	v.sort!
	(v.size-2).downto(0){|i|
		if v[i][1]==v[i+1][0]
			v[i][1]=v[i+1][1]
			v.delete_at(i+1)
		end
	}
	v.each{|a,b|
		A[a*2-1]+=1
		A[b*2]-=1
	}
}
(1...S).each{|i|A[i]+=A[i-1]}
p A.max

Measured memory_bytes: 12024
#include <iostream>
using namespace std;      
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a==5 && b==5 && c==7)||(a==5 && b==7 && c==5)||(a==7 && b==5 && c==5)){                    
    cout << "YES" << "\n";
  }
  else{
    cout << "NO" << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	char S[11];
	int i, count = 0, ans = 0;
	scanf("%s", &S);
	for (i = 0; i < 11; ++i) {
		switch (S[i]) {
		case'A':
		case'G':
		case'C':
		case'T':
			++count;
			break;

		default:
			if (count > ans) {
				ans = count;
				count = 0;
			}
			else {
				ans = ans;
				count = 0;
			}
			break;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
<?php
fscanf(STDIN, "%d", $n);
$a1 = explode(' ', trim(fgets(STDIN)));
$a2 = explode(' ', trim(fgets(STDIN)));

$c1 = $a1[0];
$c2 = array_sum($a2);
$x = $c1 + $c2;
for ($i = 1; $i < $n; $i++) {
	$c1 += $a1[$i];
	$c2 -= $a2[$i-1];
	if ($c1 + $c2 > $x) $x = $c1 + $c2;
}
echo $x;

Measured memory_bytes: 4604
fn solve() {
    let n: usize = read();
    let mut a: Vec<usize> = (0..n).map(|_| read::<usize>()).collect();
    let r = n;
    let l = 0;
    let p = r - 1;
    let e = a[p];
    a.swap(p, r - 1);
    let mut b = l;
    for i in l..r - 1 {
        if a[i] <= e {
            a.swap(i, b);
            b += 1;
        }
    }
    a.swap(b, r - 1);
    for i in 0..n {
        if i == b {
            print!("[{}] ", a[i]);
        } else if i != n - 1 {
            print!("{} ", a[i]);
        } else {
            println!("{}", a[i]);
        }
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

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

// =========



Measured memory_bytes: 9076
f :: Int -> Int
f n
  | even n    = n `div` 2
  | otherwise = 3 * n + 1

solve :: [Int] -> Int
solve list
  | next `elem` list = length list + 1
  | otherwise        = solve (list ++ [next])
  where next = f $ last list


main :: IO ()
main = do
  s <- readLn
  print $ solve [s]

Measured memory_bytes: 892
#include<stdio.h>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
#include<stack>
#include<math.h>
#include<set>
using namespace std;

int n,k,w[100005];
typedef long long int ll;
int check(ll p){
	int j=0;
	for(int i=0;i<k;i++){
		ll s=0;
		while(s+w[j]<=p){
			s+=w[j];
			j++;
			if(j==n)
				return 1;
		}
	}
	return 0;
}
ll ef(){
	ll i=0,j=100000*10000,m;
	while(j-i>1){
		m=(i+j)/2;
		if(check(m))j=m;
		else i=m;
	}
	return j;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		scanf("%d",&w[i]);
	int ans=ef();
	cout<<ans<<endl;
}


Measured memory_bytes: 3536