akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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 int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll s;
    cin >> s;
    const ll st = 1000000000;
    ll x1=st,x2=1,x3=0,y1,y2,y3=0;
    ll l = (s+st-1)/st;
    y1 = l*st-s;
    y2 = l;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
G = {i:[] for i in range(1, n+1)}

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

ans = [-1 for _ in range(n+1)]
ans[0]=1
ans[1]=1
check_list = [1]

while check_list:
  n = check_list.pop(0)
  for g_i in G[n]:
    if ans[g_i]==-1:
      ans[g_i]=n
      check_list.append(g_i)

flg = 'Yes'
if -1 in ans:
  flg = 'No'

if flg=='Yes':
  print('Yes')
  for ans_i in ans[2:]:
    print(ans_i)
else:
  print('No')

Measured memory_bytes: 42168
package main

import "fmt"

func main() {
	var line string
	_, _ = fmt.Scan(&line)
	count := 0
	stack := []string{string(line[0])}
	line = line[1:]
	for _, s := range line {
		str := string(s)
		if len(stack) > 0 {
			ss := string(stack[len(stack) - 1])
			if ss != str {
				stack = stack[:len(stack) - 1]
				count++
			} else {
				stack = append(stack, str)
			}
		} else {
			stack = append(stack, str)
		}
	}
	fmt.Println(count * 2)
}


Measured memory_bytes: 8832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		FastReader fr = new FastReader();

		int N = fr.nextInt();
		int W = fr.nextInt(); // upto 10^5
		int[] w = new int[N];
		int[] v = new int[N]; 
		int sumVals = 0;
		
		for(int i = 0; i < N; i++) {
			w[i] = fr.nextInt();
			v[i] = fr.nextInt();
			sumVals += v[i];
		}

		
		long[] dp = new long[sumVals+1];
		
		Arrays.fill(dp, (int)1e12);
		dp[0] = 0;
		
		for(int i = 0; i < N; i++) {
			for(int val = sumVals - v[i]; val >= 0; val--) {
				dp[val+v[i]] = Math.min(dp[val+v[i]], dp[val]+w[i]);
			}
		}
		
		int ans = -1;
		
		for(int i = 0; i <= sumVals; i++) {
			if(dp[i] <= W) ans = Math.max(ans, i);
		}
		
		System.out.println(ans);
	}

}


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

using namespace std;
using ll = long long;

const int mod = 998244353;

void add (int &x, int y)
{
    x += y;
    if (x >= mod)
        x -= mod;
}
void sub (int &x, int y)
{
    x -= y;
    if (x < 0)
        x += mod;
}
int mult (int x, int y)
{
    return x * 1LL * y % mod;
}
int mult (int a, int b, int c)
{
    return mult(mult(a, b), c);
}
int mult (int a, int b, int c, int d)
{
    return mult(mult(a, b), mult(c, d));
}

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
    auto solve_test = [&] ()
    {
        int n;
        if (!(cin >> n))
            return false;

        string s;
        cin >> s;
        assert(int(s.size()) == 3 * n);

        vector<int> only(3), without(3);

        int ans = 1;
        for (char ch : s)
        {
            const int cur = (ch == 'R' ? 0 : (ch == 'G' ? 1 : (ch == 'B' ? 2 : -1)));
            assert(cur != -1);

            if (without[cur] > 0)
            {
                ans = mult(ans, without[cur]);
                without[cur]--;
            }
            else
            {
                bool ok = false;
                for (int i = 0; !ok && i < 3; i++)
                if (i != cur)
                {
                    if (only[i] > 0)
                    {
                        ans = mult(ans, only[i]);
                        only[i]--;
                        without[i ^ cur ^ 3]++;
                        ok = true;
                    }
                }

                if (!ok)
                    only[cur]++;
            }
        }

        for (int i = 1; i <= n; i++)
            ans = mult(ans, i);

        cout << ans << endl;
        return true;
    };

    while (solve_test());
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("input.txt");

	solve(fin);

	cout << "clock: " << setprecision(4) << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}

Measured memory_bytes: 720
from math import sqrt, sin, cos, pi
import time

def main():
    N,L = map(int, input().split())
    t = [int(input()) for i in range(N)]
    #N,L = 3000, 3000
    #t = [int(i) for i in range(N)]

    comb = N * (N-1) * (N-2) / 6
    ans_X, ans_Y = 0, 0
    for i in range(N-1):
        for j in range(i+1,N):
            theta = pi * (t[j] + t[i]) / L

            I_X = cos(theta) * (N - 2*(j-i))
            I_Y = sin(theta) * (N - 2*(j-i))
            ans_X += I_X / comb
            ans_Y += I_Y / comb
            #print(ans_X, ans_Y)
    
    print(ans_X, ans_Y)


if __name__ == "__main__":
    #start = time.time()
    main()
    #elapsed_time = time.time() - start
    #rint ("elapsed_time:{0}".format(elapsed_time) + "[sec]")

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

using namespace std;

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

void solve() {

}

int main() {
	fast;

	int n;
	cin >> n;
	cout << (1000 - (n % 1000)) % 1000;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X;
    cin>>N>>X;
    vector<int>L(N);
    for(int i=0;i<N;i++){
        cin>>L[i];
    }
    int count=0;
    int now=0;
    if(0<=X){count++;}
    for(int i=0;i<N;i++){
        now+=L[i];
        if(now<=X){count++;}
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	string s;
	cin >> s;
	for (int i = s.size() - 1; i >= 0; i--) {
		cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 3136
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=1e5+5;
ll a[N][3];
ll n;
ll dp[N][3];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		cin>>n;
		ll i,j;
		rep(i,0,n)
		{
			rep(j,0,3){
			cin>>a[i][j];
				dp[i][j]=-1;
			}
		}
		dp[0][0]=a[0][0];
		dp[0][1]=a[0][1];
		dp[0][2]=a[0][2];
		rep(i,1,n)
		{
			dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
			dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
			dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
		}
		ll ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int d,g;
  cin >> d >> g;
  int k[d];
  int c[d];
  rep(i,d)cin >> k[i] >> c[i];
  int o=(1<<d);
  int ans=100000000;
  rep(i,o){
    //cout << 0 << i << endl;
    //cout << ans << endl;
    int cnt=0;
    int an=0;
    rep(j,d){
      if(i&(1<<j)){
        an+=c[j]+(j+1)*100*k[j];
        cnt+=k[j];
      }
    }
    if(an>=g){
      ans=min(ans,cnt);
      //if(cnt==54)cout << i << endl;
    }
    else{
      int y=d-1;
      while(i&(1<<y)){
        y--;
      }
      int cn=0;
      if((g-an-1)/(100*(y+1))+1>k[y]-1)continue;
      else ans=min(ans,cnt+(g-an-1)/(100*(y+1))+1);
      //if(cnt+(g-an-1)/(100*(y+1))+1==54)cout << i << endl;
    }
  }
  cout << ans << endl;
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
void fin(int n){
  cout<<n<<endl;
  exit(0);
}
//main
signed main(){
  int M,D;cin>>M>>D;int ans=0;
  for(int m=1;m<=M;m++){
    for(int d=1;d<=D;d++){
      if(d%10<=1)continue;
      if(d/10<=1)continue;
      if(d%10*(d/10)==m)ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#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() {
  ll x;
  cin >> x;
  ll ans = x / 11 * 2;
  x %= 11;
  if (x > 0) ++ans;
  x -= 6;
  if (x > 0) ++ans;
  cout << ans << endl;
  return 0;
}

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

int main(void){
    ll n;
    cin >> n;
    string s;
    while (true) {
        s += 'a' + ((n-1) % 26);
        if (n <= 26) break;
        n = (n-1)/26;
    }
    reverse(all(s));
    cout << s << endl;
    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
        cout<<"hon";
    else if(n%10!=3)
        cout<<"pon";
    else cout<<"bon";
}

Measured memory_bytes: 3572
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vector<vector<int>> k(10,vector<int> (10,0));
    

    REP(i,n+1){
        if(i==0) continue;
        int fst, lst;
        lst = i % 10;
        fst = i;
        REP(k,6){
            if(fst >= 10){
                fst = fst / 10;
            } else {
                break;
            }
        }

      
        k[fst][lst]++;
    }
    int sum = 0;
    REP(i,n+1){
        if(i==0) continue;
        int fst, lst;
        lst = i % 10;
        fst = i;
        REP(k,6){
            if(fst >= 10){
                fst = fst / 10;
            } else {
                break;
            }
        }


        sum += k[lst][fst];
    }
    cout<<sum<<endl;

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
double v,t,y;
int main(){
  while(cin>>v){
    t=v/9.8;
    y=4.9*t*t;
    N=2;
    while((5*N-5)<y)N++;
    cout<<N<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int n,A[50];

int solve(int,int);

int main(){
  int i,q,m;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int j,int l){
  int ans;
  if(l==0) return 1;
  if(j>=n) return 0;
  ans = solve(j+1,l)||solve(j+1,l-A[j]);
  return ans;
}
  

Measured memory_bytes: 580
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
const ll MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;

	if (S == U){
		cout << A-1 << " " << B << "\n";
	} else {
		cout << A << " " << B-1 << "\n";		
	}

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint T;
llint n;
llint a[205];
string s;

void GaussianElimination(llint a[], int n)
{
	llint r = 0;
	for(int i = 59; i >= 0 && r < n; i--){ //上位ビットから見ていく
		if((a[r]&(1LL<<i)) == 0){
			int p = -1;
			for(int j = r+1; j < n; j++){
				if(a[j] & (1LL<<i)){
					p = j;
					break;
				}
			}
			if(p == -1) goto end;
			swap(a[r], a[p]);
		}
		for(int j = 0; j < n; j++){
			if(j == r) continue;
			if(a[j]&(1LL<<i)) a[j] ^= a[r];
		}
		r++;
		end:;
	}
}

llint b[205];

llint get(llint x)
{
	llint ret = 0;
	for(int i = 0; i < 60; i++){
		if(x & (1LL<<i)) ret++;
	}
	return ret % 2;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> T;
	for(int t = 1; t <= T; t++){
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> a[i];
		cin >> s;
		s = "#" + s;
		
		llint sum, pos;
		for(int i = 1; i <= n; i++){
			if(s[i] == '0') continue;
			llint p = 0;
			for(int j = i+1; j <= n; j++){
				if(s[j] == '0'){
					b[p] = a[j];
					p++;
				}
			}
			if(p == 0){
				cout << 1 << endl;
				goto end;
			}
			GaussianElimination(b, p);
			
			/*for(int j = 0; j < p; j++){
				cout << j << " " << b[j] << endl;
			}
			cout << endl;*/
			
			sum = pos = 0;
			for(int j = 59; j >= 0; j--){
				if((sum^a[i]) & (1LL<<j)){
					for(; pos<p; pos++){
						if(b[pos] & (1LL<<j)) break;
					}
					sum ^= b[pos];
				}
			}
			if(sum != a[i]){
				cout << 1 << endl;
				goto end;
			}
		}
		cout << 0 << endl;
		end:;
	}
	
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();

			if(n == 0){
				break;
			}

			char value[] = new char[n];
			int depth[] = new int[n];

			for(int i = 0; i < n; i++){
				String tmpStr = sc.next();
				value[i] = tmpStr.charAt(tmpStr.length() - 1);
				depth[i] = tmpStr.length() - 1;

//				System.out.println(value[i] + " " + depth[i]);
			}

			System.out.println(solve(value, depth, 0, OP_SUM, 0));
		}
	}

	static final int OP_SUM = 0;
	static final int OP_PROD = 1;
	static int solve(char value[], int depth[], int targetDepth, int opMode, int beginIndex){
		int result = 0;
		if(opMode == OP_PROD){
			result = 1;
		}

		for(int i = beginIndex; i < value.length; i++){
			if(depth[i] < targetDepth ){
				break;
			}
			else if(depth[i] > targetDepth){
				continue;
			}

			int tmpRes;
			if(value[i] == '*'){
				tmpRes = solve(value, depth, targetDepth + 1, OP_PROD, i + 1);
			}
			else if(value[i] == '+'){
				tmpRes = solve(value, depth, targetDepth + 1, OP_SUM, i + 1);
			}
			else {
				tmpRes = value[i] - '0';
			}

			if(opMode == OP_SUM){
				result += tmpRes;
			}
			else {
				result *= tmpRes;
			}
		}

		return result;
	}

}



Measured memory_bytes: 30388
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//solve

// int D
void solve(void)
{
  int N,M;
  cin>>N>>M;
  int prev = 1;
  int count = 1;
  vector<int> vec (N,1);
  vector<int> hope(N,0);
  hope[0] = 1;
  for (int i = 0; i < M; i++)
  {
    int X,Y;cin>>X>>Y;
    vec[X-1]--;
    vec[Y-1]++;
    if(hope[X-1] == 1 && hope[Y-1] == 0)
    {
      hope[Y-1] = 1;
    }
    if(vec[X-1] == 0 && hope[X-1] == 1)
    {
      count--;
      hope[X-1] = 0;
    }
  }
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    ANS += hope[i];
  }
  
  cout<<ANS<<endl;

  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
const int Day = 24, Sxd = 60; // Sexagesimal number

int main() {
	int S, hour, min, sec;
	cin >> S;

	if(S >= 0 && S < Day*(Sxd*Sxd) ) {
		hour = S/(Sxd*Sxd);
		min = (S-hour*(Sxd*Sxd)) / Sxd;
		sec = (S-hour*(Sxd*Sxd)) - (min*Sxd);

		cout << hour << ":" << min << ":" << sec << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
struct song{
	string name;
	int time;
};
song a[55];
int main(){
	int n,i,j,sum=0;
	string s;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i].name>>a[i].time;
	}
	cin>>s;
	for(i=n;i>=1;i--){
		if(s==a[i].name){
			cout<<sum;
			break;
		}
		sum+=a[i].time;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void dijkstra(void);
int G[100][100];
int n;
int main() {
	
	int i,j,a,b,c,cc;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			G[i][j] = 1000000;
			}
			}
			for(i=0;i<n;i++) {
				scanf("%d%d",&a,&b);
				
				for(j=0;j<b;j++) {
					scanf("%d%d",&c,&cc);
					
					G[a][c]=cc;
					}
					}
					dijkstra();
					
					return 0;
					}
					
					void dijkstra(void) {
						int i,d[100],c[100],u,m;
						
						for(i=0;i<n;i++) {
							d[i]=1000000;
							c[i]=0;
						}
						d[0]=0;
						c[0]=2;
						
						while(1) {
							m=1000000;
							u=-1;
							for(i=0;i<n;i++) {
							
							if(m>d[i] && c[i]!=1) {
								u=i;
								m=d[i];
							}
							}
							if(u==-1) break;
							c[u]=1;
							
							for(i=0;i<n;i++) {
								if(c[i]!=1 && G[u][i]!=1000000) {
									if(d[i]>(d[u]+G[u][i])) {
										d[i] =d[u]+ G[u][i];
										c[i]=2;
									}
								}
							}
						}
						for(i=0;i<n;i++) {
							printf("%d ",i);
							if(d[i]==1000000) printf("-1\n");
							else printf("%d\n",d[i]);
						}
					}
						
						
						
							
					
					
					
					


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(long i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  long x;
  cin >> x;
  REP(a,0,3001){
    REP(b,-3000,1){
      if(a*a*a*a*a - b*b*b*b*b == x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  REP(b,0,2000){
    REP(a,b+1,2000){
      if(a*a*a*a*a - b*b*b*b*b == x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int a[M], b[M];
  int num[100] = {0};
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
    num[a[i]]++;
    num[b[i]]++;
  }
  for(int i = 1; i <= N; i++){
    cout << num[i] << endl;
  }
}

Measured memory_bytes: 256
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
N, M, X = gets_i_list
a_list = gets_i_list

z_cost = 0
n_cost = 0

a_list.each do |a|
  if X < a
    n_cost += 1
  else
    z_cost += 1
  end
end

puts [z_cost, n_cost].min

Measured memory_bytes: 2172
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    while(scanf("%d%d",&n,&m),n){
        char t[128][16];
        int g[128];
        int sum=0;
        for(int i=0;i<n;i++)
            scanf("%s%d",t[i],&g[i]);

        for(int i=0;i<m;i++){
            char str[16];
            scanf("%s",str);
            for(int j=0;j<n;j++){
                bool flag=true;
                for(int k=0;k<8;k++){
                    if(t[j][k]=='*')continue;
                    flag&=(str[k]==t[j][k]);
                }
                if(flag)sum+=g[j];
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<P> vec;

int main(void){
    scanf("%d",&n);
    if(n%2==0){
        for(int i=1;i<=n/2;i++){
            for(int j=i+1;j<=n/2;j++){
                if(i==j)continue;
                vec.push_back(P(i,j));
                vec.push_back(P(i,(n+1)-j));
                vec.push_back(P(n+1-i,j));
                vec.push_back(P(n+1-i,(n+1)-j));
            }
        }
    }else{
        for(int i=1;i<=n/2;i++){
            for(int j=i+1;j<=n/2;j++){
                if(i==j)continue;
                vec.push_back(P(i,j));
                vec.push_back(P(i,(n)-j));
                vec.push_back(P(n-i,j));
                vec.push_back(P(n-i,(n)-j));
            }
        }
        for(int i=1;i<=n-1;i++){
            vec.push_back(P(i,n));
        }
    }
    printf("%d\n",(int)vec.size());
    for(int i=0;i<vec.size();i++){
        printf("%d %d\n",vec[i].first,vec[i].second);
    }
    return 0;
}




Measured memory_bytes: 384
def main():
  n,q=map(int,input().split())
  s=input()
  t = [0] * (n + 1)
  for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
  for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

if __name__=='__main__':
  main()

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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N, T;
	cin >> N >> T;

	vector<int> t;
	inputVector(t, N);

	int ret = T;
	rep(i, N - 1) {
		ret += min(T, t[i + 1] - t[i]);
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final int MAX_NUM = 100000;
        Scanner sc = new Scanner(System.in);

        long[] backet = new long[MAX_NUM + 1];
        long cnt = 0;

        int numberOfIns = sc.nextInt();
        long numberOfArrLength = sc.nextLong();

        for (int i = 0; i < numberOfIns; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            backet[a] += b;
        }

        for (int i = 0; i <= backet.length; i++) {
            cnt += backet[i];

            if (numberOfArrLength <= cnt) {
                System.out.println(i);
                break;
            }
        }
        sc.close();
    }

}


Measured memory_bytes: 65076
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define po          pop_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define ms          map<string,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define pqb         priority_queue<int>
#define pqs         priority_queue<int,vi,greater<int> >
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define debug(x,y)  cout<<x<<" "<<y<<"\n";
#define w(x)        ll x

using namespace std;
bool isPrime(int n) 
{
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}
void solve()
{
     int n,k;
     cin>>n>>k;
     int a[n+1];
     rep(i,1,n+1){
         cin>>a[i];
     }
     int dp[n+1];
     dp[1]=0;
     dp[2]=abs(a[2]-a[1]);
     rep(i,3,n+1){
         int ans=INT_MAX;
         for(int j=i-1;j>=1&&(i-j)<=k;j--){
             ans=min(ans,dp[j]+abs(a[i]-a[j]));
         }
         dp[i]=ans;
     }
     cout<<dp[n];
     
}
int main()
{
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 1024
//import java.io.*;
import java.util.*;
//import java.math.*;
public class Main {
 
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	System.out.println(gcd(scan.nextInt(),scan.nextInt()));
        }
    }
    public static int gcd(int a,int b){
    	if(b==0)return a;
    	return gcd(b,a%b);
    }
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> X;
    for(int i = 0; i < N; i++){
        int x;
        scanf("%d", &x);
        X.push_back(x);
    }
    vector<int> s(X.size());
   copy(X.begin(), X.end(), s.begin());

   sort(s.begin(), s.end());

   int right = s[s.size()/2];
   int left = s[s.size()/2 -1];

   for(int i = 0; i < N; i++){
       if(X[i] >= right)cout << left << endl;
       else cout << right << endl;
   }
    
}

Measured memory_bytes: 3828
// 2011/07/21 Tazoe

#include <iostream>
#include <climits>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

		char C[100];
		for(int i=0; i<n; i++)
			C[i] = '#';

		for(int i=0; i<m; i++){
			char a;
			cin >> a;

			bool flg;
			switch(a){
				case 'A':
					for(int j=0; j<n; j++)
						if(C[j]=='#'){
							C[j] = a;
							break;
						}
					break;
				case 'B':
					flg = false;
					for(int j=n-1; j>=0; j--)
						if(C[j]=='#'&&(j==0||C[j-1]!='A')&&(j==n-1||C[j+1]!='A')){
							C[j] = a;
							flg = true;
							break;
						}
					if(!flg)
						for(int j=0; j<n; j++)
							if(C[j]=='#'){
								C[j] = a;
								break;
							}
					break;
				case 'C':
					if(i==0){
						C[n/2] = a;
						break;
					}
					for(int j=0; j<n; j++)
						if(C[j]!='#'&&j!=n-1&&C[j+1]=='#'){
							C[j+1] = a;
							break;
						}
						else if(C[j]!='#'&&j!=0&&C[j-1]=='#'){
							C[j-1] = a;
							break;
						}
					break;
				case 'D':
					if(i==0){
						C[0] = a;
						break;
					}
					int D[100];
					for(int j=0; j<n; j++){
						if(C[j]!='#'){
							D[j] = 0;
							continue;
						}
						int d = 0;
						flg = false;
						for(int k=j; k<n; k++, d++)
							if(C[k]!='#'){
								flg = true;
								break;
							}
						if(flg)
							D[j] = d;
						else
							D[j] = INT_MAX;
						d = 0;
						flg = false;
						for(int k=j; k>=0; k--, d++)
							if(C[k]!='#'){
								flg = true;
								break;
							}
						if(flg&&d<D[j])
							D[j] = d;
					}
					int maxD = -1;
					int maxI = -1;
					for(int j=0; j<n; j++)
						if(maxD<D[j]){
							maxD = D[j];
							maxI = j;
						}
					C[maxI] = a;				
					break;
			}
		}

		for(int i=0; i<n; i++)
			cout << C[i];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int n,m,i,j,max,r,a[10000],t;
  while(scanf("%d %d",&n,&m),n||m){
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    for(i=j=r=max=0;i<m;i++){
      scanf("%d",&t);
      for(;a[j]<t&&j<n;j++){
	if(a[j]-r>max)max=a[j]-r;
	r=a[j];
      }
      if(t-r>max)max=t-r;
      r=t;
    }
    for(;j<n;j++){
	if(a[j]-r>max)max=a[j]-r;
	r=a[j];
    }      
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001
#define MAX_X 2002
#define MAX_Y 2002
typedef long long ll;
typedef pair<int, int> P;

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

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

int main()
{
    int N, C;
    cin >> N >> C;

    int s, t, c;
    vector<vector<int>> imos(C + 1, vector<int>(2 * 100005, 0));
    for (int i = 0; i < N; i++)
    {
        cin >> s >> t >> c;
        if (imos[c][2 * s] == -1)
        {
            imos[c][2 * s]++;
        }
        else
        {
            imos[c][2 * s - 1]++;
        }
        imos[c][2 * t]--;
    }

    for (int i = 0; i < imos.size(); i++)
    {
        for (int j = 1; j < imos[i].size(); j++)
        {
            imos[i][j] += imos[i][j - 1];
        }
    }
    for (int i = 0; i < imos.size(); i++)
    {
        for (int j = 1; j < imos[i].size(); j++)
        {
            imos[i][j] = min(imos[i][j], 1);
        }
    }

    int ans = 0;
    for (int i = 0; i < 2 * 100005; i++)
    {
        int tmp = 0;
        for (int j = 0; j < imos.size(); j++)
        {
            tmp += imos[j][i];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    // for (int i = 1; i < imos.size(); i++)
    // {
    //     imos[i][0] += imos[i - 1][0];
    // }
    // for (int i = 1; i < imos.size(); i++)
    // {
    //     for (int j = 1; j < imos[i].size(); j++)
    //     {
    //         imos[i][j] += imos[i - 1][j] + imos[i][j - 1] - imos[i - 1][j - 1];
    //     }
    // }

    // int ans = 0;
    // for (int s : imos.back())
    // {
    //     ans = max(ans, s);
    // }
    // assert(imos.back().back() == 0);
    // cout << ans << endl;
}


Measured memory_bytes: 25344
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

const double pi=3.1415;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
}
int main()
{
    ll a,b,c,N;
    string s,t;
    cin>>N;
    vector<int>ans(N,0);
    rep(i,N-1){
    	cin>>a;
    	a--;
    	ans[a]++;
    }
    rep(i,N){
    	cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 4052
#include<stdio.h>
#define N 100


int bubblesort(int A[], int n,int *c){
  int i,j,s;

  for(i=0;i<n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	s=A[j];
	A[j]=A[j-1];
	A[j-1]=s;
	(*c)++;
	
      }
    }
   
  }
}




int main(){

  int A[N],n,i,c=0;

  scanf("%d",&n);

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

  bubblesort(A,n,&c);

  for(i=0;i<n;i++){
    if((i+1)==n)
      printf("%d",A[i]);
    else
    printf("%d ",A[i]);
  }
 putchar('\n');
 printf("%d",c);
 putchar('\n');
  return 0;

}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll n, a[200005], b[200005], c[200005], i, dpa[200005], dpb[200005], dpc[200005];
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        {cin>>a[i]>>b[i]>>c[i];
    dpa[0]=0;dpb[0]=0;dpc[0]=0;}

    for(i=1;i<=n;i++){
        dpa[i]=max(dpb[i-1]+a[i],dpc[i-1]+a[i]);
         dpb[i]=max(dpa[i-1]+b[i],dpc[i-1]+b[i]);
          dpc[i]=max(dpb[i-1]+c[i],dpa[i-1]+c[i]);
    }

    cout<<max(dpa[n],max(dpb[n],dpc[n]));
    return 0;
}


Measured memory_bytes: 8192
N,A = map(int,input().split())
x = list(map(int,input().split()))

temp = x + [A]

X = max(temp)

m = N * X

dp = [[[0 for s in range(m+1)] for k in range(N+1)] for j in range(N+1)]

dp[0][0][0] = 1

res = 0

for j in range(N):
    for k in range(N):
        for s in range(m):
            if dp[j][k][s]:
                dp[j+1][k][s] += dp[j][k][s]
                dp[j+1][k+1][s+x[j]] += dp[j][k][s]

for k in range(1,N+1):
    res += dp[N][k][k*A]

print(res)


Measured memory_bytes: 65392
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
int n;

void dfs(string s,int k){
  if(s.size()==n){
    cout<<s<<endl;
    return;
  }
  else{
    rep(i,k){
      string t=s;
      t+='a'+i;
      dfs(t,k);
    }
    string t=s;
    t+='a'+k;
    dfs(t,k+1);
  }
  
  return;
}

signed main(){
  cin>>n;
  dfs("",0);
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,t;
  cin >> n >> t;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  ll nowmax = 0;
  vector<ll> benefit(n);
  map<ll,ll> count;
  for(int i = n - 1;i >= 0;i--){
    nowmax = max(a[i],nowmax);
    benefit[i] = nowmax - a[i];
    count[benefit[i]]++;
  }
  sort(benefit.rbegin(),benefit.rend());
  ll res = 0;
  res = count[benefit[0]];
  cout << res << endl;
}

Measured memory_bytes: 11152
import random
import math
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("Yes")
no = lambda: print("No")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
t = II()
temp = 100
i = 0
while True:
	i+=1
	temp*=1.01
	temp = int(temp)
	if temp>=t:
		print(i)
		break


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

using namespace std;

int main()
{
	string str;
	int i;

	getline(cin, str);

	for (i = 0; i < str.length(); i++)
	{
		if (islower(str[i]))
			str[i] = toupper(str[i]);
		else if (isupper(str[i]))
			str[i] = tolower(str[i]);

	}
	cout << str << endl;

	return 0;
}

Measured memory_bytes: 1180
import std.stdio;
import std.conv;
import std.array;
import std.algorithm;

void main()
{
    int N = readln.split[0].to!int;
    int[] A = readln.split.to!(int[]);

    sort(A);

    int ans = A[1];
    while (ans >= 2){
        int cnt = 0;
        foreach (a; A){
            if (a % ans > 0) cnt++;
            if (cnt >= 2) break;
        }

        if (cnt <= 1) break;
        else ans--;
    }

    writeln(ans);
}



Measured memory_bytes: 4296
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var INF = 1e15;

console.log(main());
function main(){
  var n = o.a();
  var x = o.a();
  var h = [0].concat(o.l());
  var dp = xArray(INF,2,2);
  dp[0][0] = h[1];
  dp[1][1] = 0;
  for(var i = 1; i < n; i++){
    var mn = Math.min(i,x)+1;
    var dp2 = xArray(INF,mn+1,mn+1);
    for(var j = 0; j < mn; j++){
      for(var k = j; k < mn; k++){
        var t = Math.max(0,h[i+1] - h[i-j]);
        if(dp[k][j]+t < dp2[k][0])
          dp2[k][0] = dp[k][j]+t;
      }
      if(j < x)for(var k = j; k < mn; k++){
        if(dp[k][j] < dp2[k+1][j+1])
          dp2[k+1][j+1] = dp[k][j];
      }
    }
    dp = dp2;
  }
  var ans = INF;
  for(var i = 0; i <= x; i++){
    if(dp[x][i] < ans)ans = dp[x][i];
  }
  return ans;
}

Measured memory_bytes: 39800
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    string s;
    cin>>s;
    bool a=false;
    rep(i,3){
        if(s.at(i)=='7'){
            cout<<"Yes"<<endl;
            a=true;
            break;
        }
    }
    if(!a){
        cout<<"No"<<endl;
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int N = 1e5 + 5;
ll dp[N];

int main()
{
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); // no scientific output
    int n, w; cin>>n>>w;
    rep(i, n)
    {
        ll weight, value;
        cin>>weight>>value;
        REPR(j, w-weight, 0)
        {
            dp[j+weight] = max(dp[j+weight], dp[j]+value);
        }
    }
    ll mx = 0;
    rep(i, w+1)
    {
        mx = max(mx, dp[i]);
    }
    cout<<mx;
}



/*before sub
loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
*/

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  vector<ll> ans(100100);
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n-k+1){
    ans[i]=a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1]));
  }
  ll mn=1e17;
  rep(i,n-k+1){
    chmin(mn,ans[i]);
  }
  cout << mn << endl;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N 1000001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
vector<int>adj[100005];
int indeg[100005],lpath[100005];
main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
  cin>>n>>m;
  for(i=0;i<m;i++)
  {
    cin>>u>>v;
    adj[u].push_back(v);
    indeg[v]++;
  }

queue<int>q1;

for(i=1;i<=n;i++)
{
    if(indeg[i]==0)
    {
        q1.push(i);
    }
}
int ans=0;
while(!q1.empty())
{
    int x=q1.front();
    q1.pop();
    for(auto y:adj[x])
    {
        indeg[y]--;
        if(indeg[y]==0)
            q1.push(y);
        lpath[y]=max(lpath[y],1+lpath[x]);
        ans=max(ans,lpath[y]);
    }

}

cout<<ans;

}

}


Measured memory_bytes: 10588