akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
pair<double,double> relv(pair<double,double> a,pair<double,double> b)
{
  return make_pair(a.first-b.first,a.second-b.second);
}
double dot(pair<double,double> va,pair<double,double> vb)
{
  return va.first*vb.first+va.second*vb.second;
}
double cross(pair<double,double> va,pair<double,double> vb)
{
  return va.first*vb.second-va.second*vb.first;
}
double norm(pair<double,double> va){
  return sqrt(va.first*va.first+va.second*va.second);
}
double dpseg(pair<double,double> p,pair<double,double> a,pair<double,double> b)
{
  if(dot(relv(p,a),relv(b,a))>0 && dot(relv(p,b),relv(a,b))>0)
    return abs(cross(relv(p,a),relv(b,a))/norm(relv(b,a)));
  else return min(norm(relv(p,a)),norm(relv(p,b)));
}
double dvec(pair<double,double> v,pair<double,double> a,pair<double,double> b)
{
  return v.first*(a.first-b.first)-v.second*(a.second-b.second);
}
double dsegseg(pair<double,double> a,pair<double,double> b,pair<double,double> c,pair<double,double> d)
{
  double answer=1e+9;
  if(cross(relv(a,b),relv(a,c))*cross(relv(a,b),relv(a,d)) < 0 &&
     cross(relv(c,d),relv(c,a))*cross(relv(c,d),relv(c,b)) < 0) return 0.0;
  //cout << c.first << ' ' << c.second << ' ' << d.first << ' ' << d.second << endl;
  answer=min(answer,dpseg(a,c,d));
  answer=min(answer,dpseg(b,c,d));
  answer=min(answer,dpseg(c,a,b));
  answer=min(answer,dpseg(d,a,b));
  //cout << answer << endl;
  return answer;
}
double calr(double h,double d)
{
  double r;
  if(h>=d) r=d;
  else r=(h*h+d*d)/h/2;
  //cout << h << ' ' << d << ' ' << r << endl;
  return r;
}
int main(void)
{
  cout << fixed << setprecision(10) << endl;
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sx,sy,ex,ey;
    cin >> sx >> sy >> ex >> ey;
    pair<double,double> s,e;
    s=make_pair(sx,sy),e=make_pair(ex,ey);
    double answer=1e+9;
    REP(i,n){
      int l,u,r,b,h;
      cin >> l >> u >> r >> b >> h;
      if(l<=sx&&sx<=r&&u<=sy&&sy<=b) answer=0.0;
      answer=min(answer,calr(h,dsegseg(s,e,make_pair(l,u),make_pair(r,u))));
      answer=min(answer,calr(h,dsegseg(s,e,make_pair(l,b),make_pair(r,b))));
      answer=min(answer,calr(h,dsegseg(s,e,make_pair(l,u),make_pair(l,b))));
      answer=min(answer,calr(h,dsegseg(s,e,make_pair(r,u),make_pair(r,b))));

      
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 3288
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b,c;
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
if (a<b) {
    int z;
z=b;
b=a;
a=z;
}
if(b<c){
    int z;
    z=c;
    c=b;
    b=z;
}
if(a<b){
int z;
z=b;
b=a;
a=z;
}
System.out.println(c+" "+b+" "+a);

sc.close();
    }
}


Measured memory_bytes: 26112
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define _ <<" "<<
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    Fast_IO();
    int n;
    cin >> n ;
    vector <ll> a ( n + 1  , 0 ) ;
    vector<ll> b ( n  , 0 ) ;
    for ( ll &x  :  a )
        cin >> x ;
    for  ( ll &x : b )
        cin >> x ;
    ll cnt = 0 ;
    for ( int i = 0 ; i < n ; ++ i )
    {
        if ( a[i] <= b[i] ) {
            cnt += a[i] ;
            b[i] -= a[i] ;
            if ( b[i] > 0 ){
                cnt += min ( a[i + 1 ] , b[i]) ;
                a[ i + 1 ] = max ( 0ll , a[ i + 1] - b[ i ]) ;

            }
        }
        else
            cnt +=  b[i] ;

    }
    cout << cnt ;

    return 0 ;
}










Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
int main(){
double a,b,c,d,e,f,x,y;
while(std::cin>>a>>b>>c>>d>>e>>f){
x=(b*f-c*e)/(b*d-a*e);
y=(f*a-d*c)/(a*e-b*d);
printf("%.3f %.3f\n",x==-0?0:x, y==-0?0:y);
}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

ll n;

// maximum x (C(x) == true)
bool C(ll mid){
    return mid * mid <= n;
}

ll BinarySearchMax(ll lb, ll ub){
    // 返り値の範囲：[lb, ub)
    // 条件：
    //   [lb, ub)で検証できること
    //   C(lb)==true, C(ub)==false
    while(ub - lb > 1){
        ll mid = ((lb + ub) >> 1);
        if(C(mid)){
            // [mid, ub)
            lb = mid;
        }else{
            // [lb, mid)
            ub = mid;
        }
    }
    return lb;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll Q;
    cin >> Q;
    rep(q, Q){
        ll a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        n = a * b;
        ll sqn = BinarySearchMax(0, 1000000001);
        dump(sqn);
        ll ans = (a-1)*2;
        if(a + 1 == b){
            
        }else if(a == b){
            
        }else if(sqn*sqn==n){
            ans += (sqn-a)*2-1;
        }else if(sqn*(sqn+1)>=n){
            ans += (sqn-a)*2;
        }else{
            ans += (sqn-a)*2+1;
        }
        cout << ans << endl;
    }
    return 0;
}

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

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

  x %= 7;

  switch(x){
  case 1:
    cout << "fri" << endl;
    break;
  case 2:
    cout << "sat" << endl;

    break;
  case 3:
    cout << "sun" << endl;

    break;
  case 4:
    cout << "mon" << endl;

    break;
  case 5:
    cout << "tue" << endl;

    break;
  case 6:
    cout << "wed" << endl;

    break;
  case 0:
    cout << "thu" << endl;

    break;
  }
  
  return 0;
}



Measured memory_bytes: 3096
using namespace std;
#include <bits/stdc++.h>
int main(){
	int n,count=0;
	cin>>n;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<n;i++){
	for(int j=i+1;j<n;j++){
		for(int k=j+1;k<n;k++){
			if(a[i]!=a[j] && a[j]!=a[k]){
				if(a[i]+a[j]>a[k]){
					count++;
				}
			}
		}
	}
}
cout<<count<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    string S;
    cin >> S;
    vector<vector<int>> Q(m, vector<int>(2, 0));
    for (auto& q: Q)
        cin >> q[0] >> q[1];

    vector<int> csum;
    csum.push_back(0);
    csum.push_back(0);

    for (int i = 1; i < n; i++){
        if (S[i - 1] == 'A' and S[i] == 'C')
            csum.push_back(csum[i] + 1);
        else
            csum.push_back(csum[i]);
    }

    for (const auto& q: Q)
        cout << csum[q[1]] - csum[q[0]] << endl;
}

Measured memory_bytes: 6904
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n; cin >> n;
	unordered_map<int, int> cnt;
	vi a(n); rep(i, n) {
		cin >> a[i];
		++cnt[a[i]], ++cnt[a[i] + 1], ++cnt[a[i] - 1];
	}

	int ans = 0;
	for (auto itr : cnt) {
		ans = max(ans, itr.second);
	}
	cout << ans << endl;

}


Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int black;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	string s[10];
	for (int i = 0; i < h; i++)
		cin >> s[i];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (s[i][j] == '#') black++;

	long ans = 0;
	for (int i = 0; i < (1 << h); i++) {
		int cnt = 0;
		vector<int> bit;
		for (int l = 0; l < h; l++) {
			if (i & (1 << l)) {
				for (int m = 0; m < w; m++)
					if (s[l][m] == '#') cnt++;
				bit.push_back(l);
			}
		}
		for (int j = 0; j < (1 << w); j++) {
			int cnt_ = cnt;
			for (int l = 0; l < w; l++) {
				if (j & (1 << l)) {
					for (int m = 0; m < h; m++)
						if (s[m][l] == '#') cnt_++;
					for (auto m : bit)
						if (s[m][l] == '#') cnt_--;
				}
			}
			if (black - cnt_ == k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
// #define int long long 

using namespace std;

int32_t main()
{
	fio;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	bool turn=true;
	while(a>0 and c>0)
	{
		if(turn)
		{
			c-=b;
		}
		else
		{
			a-=d;
		}

		turn=!turn;
	}

	if(a<=0)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<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;
typedef long long ll;
typedef pair<ll,double> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

ll a[200010],sum[200010];

int main() {
    int n;cin>>n;
    rep(i,n) cin>>a[i];
    rep(i,n) sum[i+1] = sum[i] + a[i];
    ll ans = 1LL<<60;
    rep(i,n+1) {
        int l = 0,r=i;
        while(r - l > 1) {
            int mid = (r+l)/2;
            if(sum[mid] >= sum[i] - sum[mid]) r = mid;
            else l = mid;
        }
        long long P = sum[l], Q = sum[i] - sum[l];
        long long P2 = sum[r], Q2 = sum[i] - sum[r];
        long long left_min = min(P, Q), left_max = max(P, Q);
        if (abs(P2-Q2) < abs(P-Q)) left_min = min(P2, Q2), left_max = max(P2, Q2);

        l = i, r = n;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (sum[mid] - sum[i] >= sum[n] - sum[mid]) r = mid;
            else l = mid;
        }
        long long R = sum[l] - sum[i], S = sum[n] - sum[l];
        long long R2 = sum[r] - sum[i], S2 = sum[n] - sum[r];
        long long right_min = min(R, S), right_max = max(R, S);
        if (abs(R2-S2) < abs(R-S)) right_min = min(R2, S2), right_max = max(R2, S2);

        ll tmp = max(left_max,right_max) - min(left_min,right_min);
        ans = min(ans,tmp);

    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  if(n==m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i].first;
    A[i].second = i + 1;
  }
  sort(begin(A), end(A));
  for (auto& v : A)
    cout << v.second << " ";
  cout << endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n),c(n);
    for(int i=0;i<n;++i)cin>>v[i];
    for(int i=0;i<n;++i)cin>>c[i];
    int ans = 0;
    for(int i=0;i<n;++i)
        if(v[i]-c[i] > 0)
            ans += v[i]-c[i];
    cout<<ans<<endl;
}

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

int main() {
  int daikin, ichien, amari;
  cin >> daikin >> ichien;
  
  amari = daikin % 500;
  
  if (amari <= ichien) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }

}

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

int main() {
  int n, m;
  cin >> n >> m;
  int counter = 0;
  for(int i = 1; i < n; i++) {
    counter += i;
  }
  for(int i = 1; i < m; i++) {
    counter += i;
  }
  cout << counter;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, a[100], count, a_reverse[100];

	scanf("%d", &n);

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

	for (count = 0; count < n; count++)
	{
		a_reverse[(n - 1) - count] = a[count];
	}

	for (count = 0; count < (n - 1); count++)
	{
		printf("%d ", a_reverse[count]);
	}

	printf("%d", a_reverse[n - 1]);

	printf("\n");

	return 0;
}


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

int main(){
  long long X,K,D,t,ans;
  cin >> X >> K >> D;
  
  t = abs(X) / D;
  
  if (t >= K){
    if (X>0)
      ans = X - D*K;
    else
      ans = X + D*K;
  }
  else {
    K -= t;
    K %= 2;
    //cout << D << " " << K << endl;
    if (X>0)
      ans = min(abs(X - D*(t-K)),abs(X-D*(t+K)));
    else
      ans = min(abs(X + D*(t-K)),abs(X+D*(t+K)));
  }
  
  cout << abs(ans) << endl;
  
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cond(char *s){
  if(s[0]!='A') return 0;
  int n=0;
  while(s[n]!='\0') n++;
  int i;
  for(i=3-1;i<n-1;i++){
    if(s[i]=='C') break;
  }
  if(i>=n-1) return 0;
  int j;
  for(j=1;j<n;j++){
    if(j==i) continue;
    if(s[j]>='A' && s[j]<='Z') return 0;
  }
  return 1;
}

void run(void){
  char s[11];
  scanf("%s",s);
  printf("%s\n",cond(s)?"AC":"WA");
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL x, k, d;

int main() {
  cin >> x >> k >> d;
  int fg = x < 0 ? -1 : 1;
  LL c = abs(x) / d;
  if (k <= c) {
    x = fg * (abs(x) - k * d);
  } else {
    k -= c;
    x = fg * (abs(x) % d);
    if (k & 1) x = x < 0 ? x + d : x - d;
  }
  cout << abs(x) << endl;
  return 0;
}

Measured memory_bytes: 3628
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	int n, m;
	cin >> n >> m;

	vector<pii> v(n);

	for(int i = 0; i < n; ++i)
		cin >> v[i].x >> v[i].y;

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

	reverse(v.begin(), v.end());

	multiset<int> ms;

	int j = n-1;

	int ans = 0;

	for(int i = m-1; i >= 0; i--)
	{
		while(j >= 0 and i+v[j].x <= m)
		{
			ms.insert(v[j].y);
			j--;
		}
		// cerr << i << ' ' << j << '\n';
		if(ms.size())
		{
			auto it = ms.end();
			it--;
			ans += *it;
			ms.erase(it);
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int a,b;
    cin >> a >> b;
    if(a*b%2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	unsigned long R;
	std::cin >> R;

	if ( R < 1200 )
	{
		std::cout << "ABC" << std::endl;
	}
	else if ( R < 2800 )
	{
		std::cout << "ARC" << std::endl;
	}
	else
	{
		std::cout << "AGC" << std::endl;
	}

	return ( 0 );
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
int a[MAX_N];

int main2() {
  int N = nextInt();
  int T = nextInt();
  REP(i, N) a[i] = nextInt();
  const int INF = 1001001001;

  int min_val = INF;

  int stride = 0;
  int count = 0;
  REP(i, N) {
    if (min_val > a[i]) {
      min_val = a[i];
    } else {
      int d = a[i] - min_val;
      if (stride < d) {
        stride = d;
        count = 1;
      } else if (stride == d) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 100000



int main(){
	int b,c;
	int a;
	int n;
	bool ans;
	cin>>n;
	while(n--){
		ans=true;
		b=c=0;
		for(int i=0;i<10;i++){
			cin>>a;
			if(a>b){
				b=a;
			}else if(a>c){
				c=a;
			}else{
				ans=false;
			}
		}
		if(ans){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

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

int main()
{


	int n;
	string s;
	cin >> n >> s;

	for(size_t i=0;i<s.size();i++){
		int c = s[i];
		c = ((c+n)%('Z'+1));
		if(c < 'A'){ c+='A'; }
		s[i] = c;
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
int a,b,len;
string st;
int main()
{
	cin>>a>>b>>st;
	len=st.length();
	for(int i=0;i<len;i++)
	if(st[i]<'0'&&i!=a||st[i]>'9'&&i!=a){cout<<"No";return 0;}
	if(st[a]!='-')cout<<"No";
	else cout<<"Yes";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

ll a[200000];
signed main() {
	int n; scanf("%d", &n);
	ll cnt = 0;
	rep(i, n) {
		scanf("%lld", &a[i]);
		cnt += a[i];
	}
	ll Min = LLONG_MAX;
	ll cnt2 = 0;
	rep(i, n - 1) {
		cnt2 += a[i];
		cnt -= a[i];
		Min = min(Min, abs(cnt - cnt2));
	}
	printf("%lld\n", Min);
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
//const ll INFL = 1LL << 60;//10^18 = 2^60
const ll INFL = 1LL << 60;
const int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const ll N_ = (1 << 18);
ll seg[2*N_-1];
//Range Minimum Query
void update(ll k, ll x){
  k += N_-1;
  seg[k] = x;
  while(k > 0){
    k = (k-1)/2;
    seg[k] = min(seg[2*k+1], seg[2*k+2]);
  }
}

ll query(ll x, ll y, ll k, ll left, ll right){
  if(right <= x || y <= left) return INFL;
  if(x <= left && right <= y) return seg[k];
  ll mid = (left + right) / 2;
  ll l = query(x, y, 2*k+1, left, mid);
  ll r = query(x, y, 2*k+2, mid, right);
  return min(l, r);
}

void init_seg(){
  rep(i, 2*N_-1) seg[i] = INFL;
}

int main(void){
  init_seg();
  ll N, x; cin >> N >> x;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  rep(i, N) update(i, A[i]);
  ll ans = INFL;
  for(int i = 0; i < N; i++){
    ll res = x * i;
    for(int j = 0; j < N; j++){
      if(j >= i){
        res += query(j-i, j+1, 0, 0, N_);
      }else{
        res += min(query(0, j+1, 0, 0, N_), query(N+j-i, N, 0, 0, N_));
      }
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6400
#include <stdio.h>

int main(){
  
  int n,a,i;
  long min=0,max=0,sum=0;
  scanf("%d",&n);

  for(i=0;i<n;++i){
    scanf("%d",&a);
    if(i==0){
      min=a;
      max=a;
    }
    if(min>a) min=a;
    if(max<a) max=a;
    sum+=a;
  }
  printf("%ld %ld %ld\n",min,max,sum);


  return 0;
}



Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
int a[2005];
int main()
{
	int n,i,j,k,x,y,b,c,d;
	scanf("%d %d %d",&n,&x,&y);
	a[n-1]=0;
	for(i=1;i<=n;i++)
	{
	for(j=i+1;j<=n;j++)
		{
			if(j<x&&i<x)
			{
				a[j-i]++;
			}
			else if(i<=x&&j>=y)
			{
				a[j-i-(y-x)+1]++;
			}
			else if(i>x&&j<=y&&i<y)
			{
				c = min(j-i,y-j+i-x+1);
				a[c]++;
			}
			else if(i>=x&&j>y&&i<y)
			{
				c=min(j-i,j-y+i-x+1);
				a[c]++;
			}
			else if(i<=x&&j<y)
			{
				c=min(j-i,y-j+1+x-i);
				a[c]++;
			}
			else if(i>=y)
			{
				a[j-i]++;
			}
	}
	}
	for(i=1;i<n;i++)
		printf("%d\n",a[i]);
}

Measured memory_bytes: 256
n,m,c=list(map(int,input().split(" ")))
bl=list(map(int,input().split(" ")))
al=[[0 for i in range(m)] for j in range(n)]
for i in range(n):
    al[i]=list(map(int,input().split(" ")))
ans=0
for i in range(n):
    inp=0
    for j in range(m):
        inp+=al[i][j]*bl[j]
    if inp>-c:
        ans+=1
print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

from collections import deque

N = int(input())
A = deque(map(int, input().split()))

ind = 1
cnt = 0
while A:
  x = A.popleft()
  if x != ind:
    cnt += 1
  else:
    ind += 1
print(cnt if cnt != N else -1)  

Measured memory_bytes: 25244
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    vector< vi > a(n+5);
    int i, j;
    FOR(i, 1, n+1)
    {
        FOR(j, 1, n)
        {
            int temp;
            cin>>temp;
            a[i].push_back(temp);
        }
        reverse(a[i].begin(), a[i].end());
    }
    set <int> cur;
    FOR(i, 1, n+1)
    {
        cur.insert(i);
    }
    set <int >::iterator it, it2;
    int ans = 0;
    while(cur.size())
    {
        it = cur.begin();
        while(it != cur.end())
        {
            int u = *it;
            int v = a[u].back();
            it2 = it;
            it2++;
            if(u != a[v].back())
                cur.erase(it);
            else 
                cur.insert(v);
            it = it2;
        }
        ans++;
        it = cur.begin();
        while(it != cur.end())
        {
            int u = *it;
            it2 = it;
            it2++;
            a[u].pop_back();
            if(!a[u].size())
                cur.erase(it);
            it = it2;
        }
    }
    bool is = true;
    FOR(i, 1, n+1)
    {
        if(a[i].size())
        {
            is = false;
            break;
        }
    }
    if(is)
    {
        cout<<ans<<endl;
    }
    else 
        cout<<-1<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
  int n,i,m,jp = 0;
  double bi = 0.0;
  
  scanf("%d",&n);
  
  double x;
  char u[4];
  
  for(i = 0;i < n;i++){
    scanf("%lf %s",&x,u);
    if(u[0] == 'J'){
    jp = jp + x;
   }else{
    bi = bi + x;
   }
  }
  
  printf("%f\n",(jp + (bi * 380000.0)));
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var k = long.Parse(inputs[0]);
            var x = long.Parse(inputs[1]);

            var list = new int[k * 2 - 1];
            var a = x - k - 1;
            for (var i = -(k - 1); i <= k - 1; i++)
            {
                Console.WriteLine(x + i);
            }
        }
    }
}


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

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

	int A[N], B[N], C[N-1];
	for(int i=0; i<N && cin>>l; i++) A[i] = l;
	for(int i=0; i<N && cin>>l; i++) B[i] = l;
	for(int i=0; i<N-1 && cin>>l; i++) C[i] = l;

	int sum = 0;

	for(int i=0; i<N; i++)
	{
		sum += B[A[i]-1];
		if( i == N-1 ) break;
		if( A[i+1] - A[i] == 1 ) sum += C[A[i]-1];
	}

	cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main()
{
    int  a=0,b=0,a1=0,b1=0,i=0,n=0,j=0;
    for(i=1;;i++){
        cin >> n;
        if(n==0)break;
        for(j=0;j<n;j++){
            cin >> a >> b;
            if(a>b){
                a1+=a+b;
            }
            if(a<b){
                b1+=a+b;
            }
            if(a==b){
                a1+=a;
                b1+=b;
            }

        }
        cout << a1 << ' ' << b1 <<endl;
        a1=b1=0;
    }
    //cout << b;
}

Measured memory_bytes: 1156
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


class DGraph:
    def __init__(self, n, edges):
        self._vertice = [{} for _ in range(n)]
        for e in edges:
            self._vertice[e[0]][e[1]] = e[2] if len(e) == 3 else 1

    def __len__(self):
        return len(self._vertice)

    def edges(self, n=None):
        srcs = range(len(self)) if n is None else [n]
        return sum([[(s, d, c) for d, c in self._vertice[s].items()] for s in srcs], [])

    def transpose(self):
        tedges = [(t, f, c) for f, t, c in self.edges()]
        return DGraph(len(self), tedges)

    def cost(self, src, dst):
        return self._vertice[src].get(dst, float('inf'))


def topological_sort(g):
    result = []
    status = [0] * len(g)

    def _dfs(v):
        st = [v]
        while 0 < len(st):
            cv = st[-1]
            if status[cv] == 0:
                status[cv] = 1
                for _, d, _ in g.edges(cv):
                    if status[d] == 1:
                        raise ValueError('has cyclic')
                    st.append(d)
            elif status[cv] == 1:
                status[cv] = 2
                result.append(cv)
            if status[cv] == 2:
                st.pop()

    for v in range(len(g)):
        _dfs(v)
    return list(reversed(result))


def solve(N: int, M: int, x: "List[int]", y: "List[int]"):
    es = [(xx-1, yy-1, 0) for xx, yy in zip(x,y)]
    g = DGraph(N, es)

    order = topological_sort(g)
    dp = [0] * N
    for i in order:
        for _, j, _ in g.edges(i):
            dp[j] = max(dp[j], dp[i] + 1)
    return max(dp)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (M)  # type: "List[int]" 
    y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    result = solve(N, M, x, y)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62420
import sys
def f(a,b,c):
    return a if a!="s"and a==b==c else 0
for s in sys.stdin:
    for i in range(3):
        c=f(*s[i:9:3])
        if c: break
        j=i*3
        c=f(*s[j:j+3])
        if c: break
    else:
        a=s[4]
        c=a if f(*s[0:9:4])or f(*s[2:7:2]) else "d"
    print c

Measured memory_bytes: 4216
#include <iostream>
#include <vector>
using ll = long long;
constexpr ll MOD = 1e9 + 7;
int main()
{
    int N;
    ll K;
    std::cin >> N >> K;
    using Mat = std::vector<std::vector<ll>>;
    Mat a(N, std::vector<ll>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) { std::cin >> a[i][j]; }
    }
    auto mul = [N](const Mat& m1, const Mat& m2) {
        Mat ans(N, std::vector<ll>(N, 0));
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int k = 0; k < N; k++) { (ans[i][j] += m1[i][k] * m2[k][j] % MOD) %= MOD; }
            }
        }
        return ans;
    };
    auto unit = [N]() {
        Mat ans(N, std::vector<ll>(N, 0));
        for (int i = 0; i < N; i++) { ans[i][i] = 1; }
        return ans;
    };
    auto pow = [&](auto&& self, const Mat& m, const ll n) -> Mat { return n == 0 ? unit() : n % 2 == 1 ? mul(self(self, m, n - 1), m) : self(self, mul(m, m), n / 2); };
    const auto p = pow(pow, a, K);
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) { (ans += p[i][j]) %= MOD; }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int f[100];
int n, m, tot(0);
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int k;
		cin >> k;
		for (int j = 1; j <= k; j++)
		{
			int t;
			cin >> t;
			f[t]++;
		}
	}
	for (int i = 1; i <= m; i++)
		if (f[i] == n)
			tot++;
	cout << tot << endl;

	return 0;
}

Measured memory_bytes: 256
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
ans = 0
bus = 0
pk = t[0] + k

for i in range(n):
    if bus == c or t[i] > pk:
        ans += 1
        bus = 1
        pk = t[i] + k
    else: 
        bus += 1
print(ans + 1)

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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  int x;
  cin >> x;
  int mi = x;
  int mx = x;
  for (int i = 0; i < 4; i++) {
    cin >> x;
    mi = min(mi, x);
    mx = max(mx, x);
  }
  int k;
  cin >> k;
  cout << ((mx - mi) <= k ? "Yay!" : ":(");
  return 0;
}




Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

vector<int> R;
vector<int> G;
vector<int> B;

Int get_num(int x,int diff, char s) {
    Int ans = 0;
    if(s == 'R') {
        ans = (R.end()-lower_bound(R.begin(),R.end(),x));
        auto d = lower_bound(R.begin(),R.end(),x+diff);
        
        if(d != R.end() && *d == x+diff)
            ans--;
    } else if(s == 'G') {
        ans = (G.end()-lower_bound(G.begin(),G.end(),x));
        auto d = lower_bound(G.begin(),G.end(),x+diff);
        if(d != G.end() && *d == x+diff)
            ans--;
    } else {
        ans = (B.end() - lower_bound(B.begin(),B.end(),x));
        auto d = lower_bound(B.begin(),B.end(),x+diff);
        if(d != B.end() && *d == x+diff)
            ans--;
    }

    return ans < 0 ? 0 : ans;
}
int main(void) {
    int N;
    cin>>N;
    string S;
    cin>>S;

    for(int i = 0;i < N;i++) {
        if(S[i] == 'R')
            R.push_back(i);
        else if(S[i] == 'G')
            G.push_back(i);
        else
            B.push_back(i);
    }

    Int sum = 0;
    for(int i = 0;i < N-2;i++) {
        char s1 = S[i];
        for(int j = i+1;j < N-1;j++) {
            char s2 = S[j];
            if(s1 != s2) { //condition1
                if(s1 == 'R' && s2 == 'G') { 
                    sum += get_num(j, j-i, 'B');

                } else if(s1 == 'R' && s2 == 'B') {
                    sum += get_num(j, j-i, 'G');

                } else if(s1 == 'G' && s2 == 'R') {
                    sum += get_num(j, j-i, 'B');

                } else if(s1 == 'G' && s2 == 'B') {
                    sum += get_num(j, j-i, 'R');
 
                } else if(s1 == 'B' && s2 == 'R') {
                    sum += get_num(j, j-i, 'G');
 
                } else if(s1 == 'B' && s2 == 'G') {
                    sum += get_num(j, j-i, 'R');
 
                }
            }
        }
    }

    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 3200
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }

template<class T>
class Tree {
public:
	class Node {
	public:
		int parent;
		vector<int> children;
		int depth;
		T value;
	};

	vector<Node> data;
	int root = -1;
	int _size = 1;

	Tree() {
		data.resize(1);
	}
	
	void resize(int size) {
		if (size > _size) {
			while (_size < size) {
				_size *= 2;
			}
			data.resize(_size);
		}
	}
	
	void addNode(int id, vector<int>& children, T value) {
		resize(id + 1);

		if (root == -1) {
			root = id;
			data[id].parent = -1;
		}

		data[id].children = children;
		for (int i = 0; i < children.size(); ++i) {
			resize(children[i] + 1);
			if (root == children[i]) {
				root = id; 
				data[id].parent = -1;
			}
			data[children[i]].parent = id;
		}
		data[id].value = value;
	}

	void calcDepth() {
		if (root == -1) {
			return;
		}

		int depth = 0;
		queue<int> que;
		que.push(root);
		while (!que.empty()) {
			for (int i = 0, n = que.size(); i < n; ++i) {
				int parent = que.front();
				que.pop();

				data[parent].depth = depth;

				for (int j = 0; j < data[parent].children.size(); ++j) {
					que.push(data[parent].children[j]);
				}
			}
			depth++;
		}
	}
};

int main() {
	Tree<int> tree;

	int n, id, k;
	vector<int> v;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> id >> k;
		v.resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> v[j];
		}
		tree.addNode(id, v, 0);
	}

	string s;
	tree.calcDepth();
	for (int i = 0; i < n; ++i) {
		if (tree.data[i].parent == -1) {
			s = "root";
		}
		else if (tree.data[i].children.size() == 0) {
			s = "leaf";
		}
		else {
			s = "internal node";
		}
		printf("node %d: parent = %d, depth = %d, %s, [", i, tree.data[i].parent, tree.data[i].depth, s.c_str());
		for (int j = 0, k = tree.data[i].children.size(); j < k; ++j) {
			printf("%d", tree.data[i].children[j]);
			if (j < k - 1)
				printf(", ");
		}
		printf("]\n");
	}

	return 0;
}

Measured memory_bytes: 11392
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Read();
		int n = int.Parse(input[0]);
		int nMax = 10000;
		int[] cnt = new int[nMax+1];
		int test1Max = 100;
		int test3Max = 1000000;
		for(int i=0; i<test3Max; i++)
		{
			int x = (i % test1Max) + 1;
			int y = ((i / test1Max) % test1Max) + 1;
			int z = (i / test1Max / test1Max) + 1;
			int result = Func(x,y,z,nMax);
			if(result != 0) cnt[result]++;
		}
		for(int i=1; i<=n; i++) Write(cnt[i]);
	}

	static int Func(int x, int y, int z, int nMax)
	{
		int ans = x*x + y*y + z*z + x*y + y*z + z*x;
		if(ans > nMax) ans = 0;
		return ans;
	}

	static string[] Read()
	{
		return Console.ReadLine().Split(' ');
	}

	static void Write(object o)
	{
		Console.WriteLine(o.ToString());
	}
}



Measured memory_bytes: 27696
#include<stdio.h>
#include<string.h>
int main(){
  int b=0,i,j=0,k=0;
  char w[1000],a[1000],c[12]="END_OF_TEXT";
  scanf("%s",w);
  while(w[j]!='\0'){
    j++;
  }
  while(strcmp(a,c)!=0){
    scanf("%s",a);
    while(a[k]!='\0'){
      k++;
    }
    if(j==k){
      for(i=0;i<j;i++){
    if(w[i]>='a'&&w[i]<='z'){
      if(a[i]>='A'&&a[i]<='Z'){
        a[i]+=32;
      }
      if(a[i]!=w[i]){
        break;
      }
    }
    else if(w[i]>='A'&&w[i]<='Z'){
      if(a[i]>='a'&&a[i]<='z'){
        a[i]-=32;
      }
      if(a[i]!=w[i]){
        break;
      }
    }
    if(i==j-1){
      b++;
    }
      }
    }
    k=0;
  }
  printf("%d\n",b);
  return(0);
}

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(N);
  for(int i=0;i<N;i++)
    cin >> A[i];
  for(int i=0;i<N;i++)
    cin >> B[i];    
  for(int i=0;i<N-1;i++)
    cin >> C[i];

  int ans = 0;
  for(int i=0;i<N;i++)
    {
      ans += B[A[i]-1];
      //      cout << B[A[i]-1] << endl;
      if( i>0 && A[i]-A[i-1]==1)
	{
	  //	  cout << C[A[i-1]-1] << endl;
	  ans += C[A[i-1]-1];
	}
      
    }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc157/abc157_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  cout << ((N % 2 == 0) ? (N / 2) : (N / 2 + 1))<< endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int n;  cin >> n;
  vi h(n);
  rep(i,n){
    cin >> h[i];
  }
  int ans = 0;
  rep(i,n){
    bool flag = true;
    rep(j,i){
      if(h[i] < h[j]){
        flag = false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll d;   cin >> d;
    vector<ll> c(26), days(26, 0);
    REP(i, 26) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26, 0));
    REP(i, d) REP(j, 26) cin >> s[i][j];
    REP(q, d){
        ll obj=-1, tmp=-LINF;
        REP(i, 26){
            if(tmp<days[i]*c[i]+s[q][i]){
                if(0<=obj) days[obj] += 1;
                obj = i;
                tmp = days[i]*c[i]+s[q][i];
            }else days[i] += 1;
        }
        days[obj] = 0;
        cout << obj+1 << endl;
    }
}


Measured memory_bytes: 3688
#include <stdio.h>

int main(){
   char s[100002];
   int i,l,r,n,c[100002],q;

   scanf("%d %d",&n,&q);
   scanf("%s",&s[1]);
   c[n]=c[n+1]=0;
   for (i=n-1;i>0;i--)
      if (s[i]=='A' && s[i+1]=='C') c[i]=c[i+1]+1;
      else                          c[i]=c[i+1];
   for (i=0;i<q;i++) {
      scanf("%d %d",&l,&r);
      printf("%d\n",c[l]-c[r]);
   }
   return 0;
}


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

typedef long long ll;

ll n, a, b, c, d, e;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> a >> b >> c >> d >> e;
    b = min(a, b);
    c = min(b, c);
    d = min(c, d);
    e = min(d, e);
    ll res = (n + e - 1) / e + 4;
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 3616